Esempio n. 1
0
int main(void)
{
  int __retres;
  struct Zero zero;
  __e_acsl_memory_init((int *)0,(char ***)0,(size_t)8);
  __e_acsl_globals_init();
  __e_acsl_store_block((void *)(& zero),(size_t)0);
  /*@ assert \block_length(&ZERO) ≡ 0; */
  {
    unsigned long __gen_e_acsl_block_length;
    __gen_e_acsl_block_length = __e_acsl_block_length((void *)(& ZERO));
    __e_acsl_assert(__gen_e_acsl_block_length == 0UL,(char *)"Assertion",
                    (char *)"main",(char *)"\\block_length(&ZERO) == 0",15);
  }
  /*@ assert \block_length(&zero) ≡ 0; */
  {
    unsigned long __gen_e_acsl_block_length_2;
    __gen_e_acsl_block_length_2 = __e_acsl_block_length((void *)(& zero));
    __e_acsl_assert(__gen_e_acsl_block_length_2 == 0UL,(char *)"Assertion",
                    (char *)"main",(char *)"\\block_length(&zero) == 0",16);
  }
  PA = (int *)(& A);
  /*@ assert \block_length((int *)A) ≡ sizeof(A); */
  {
    unsigned long __gen_e_acsl_block_length_3;
    __gen_e_acsl_block_length_3 = __e_acsl_block_length((void *)(A));
    __e_acsl_assert(__gen_e_acsl_block_length_3 == 16UL,(char *)"Assertion",
                    (char *)"main",
                    (char *)"\\block_length((int *)A) == sizeof(A)",20);
  }
  /*@ assert \block_length(&A[3]) ≡ sizeof(A); */
  {
    unsigned long __gen_e_acsl_block_length_4;
    __gen_e_acsl_block_length_4 = __e_acsl_block_length((void *)(& A[3]));
    __e_acsl_assert(__gen_e_acsl_block_length_4 == 16UL,(char *)"Assertion",
                    (char *)"main",
                    (char *)"\\block_length(&A[3]) == sizeof(A)",21);
  }
  /*@ assert \block_length(PA) ≡ sizeof(A); */
  {
    unsigned long __gen_e_acsl_block_length_5;
    __gen_e_acsl_block_length_5 = __e_acsl_block_length((void *)PA);
    __e_acsl_assert(__gen_e_acsl_block_length_5 == 16UL,(char *)"Assertion",
                    (char *)"main",(char *)"\\block_length(PA) == sizeof(A)",
                    22);
  }
  PA ++;
  /*@ assert \block_length(PA + 1) ≡ \block_length(&A[1]); */
  {
    unsigned long __gen_e_acsl_block_length_6;
    unsigned long __gen_e_acsl_block_length_7;
    __gen_e_acsl_block_length_6 = __e_acsl_block_length((void *)(PA + 1));
    __gen_e_acsl_block_length_7 = __e_acsl_block_length((void *)(& A[1]));
    __e_acsl_assert(__gen_e_acsl_block_length_6 == __gen_e_acsl_block_length_7,
                    (char *)"Assertion",(char *)"main",
                    (char *)"\\block_length(PA + 1) == \\block_length(&A[1])",
                    24);
  }
  int a[4] = {1, 2, 3, 4};
  __e_acsl_store_block((void *)(a),(size_t)16);
  __e_acsl_full_init((void *)(& a));
  int *pa = (int *)(& a);
  __e_acsl_store_block((void *)(& pa),(size_t)8);
  __e_acsl_full_init((void *)(& pa));
  /*@ assert \block_length((int *)a) ≡ sizeof(a); */
  {
    unsigned long __gen_e_acsl_block_length_8;
    __gen_e_acsl_block_length_8 = __e_acsl_block_length((void *)(a));
    __e_acsl_assert(__gen_e_acsl_block_length_8 == 16UL,(char *)"Assertion",
                    (char *)"main",
                    (char *)"\\block_length((int *)a) == sizeof(a)",29);
  }
  /*@ assert \block_length(&a[3]) ≡ sizeof(a); */
  {
    unsigned long __gen_e_acsl_block_length_9;
    __gen_e_acsl_block_length_9 = __e_acsl_block_length((void *)(& a[3]));
    __e_acsl_assert(__gen_e_acsl_block_length_9 == 16UL,(char *)"Assertion",
                    (char *)"main",
                    (char *)"\\block_length(&a[3]) == sizeof(a)",30);
  }
  /*@ assert \block_length(pa) ≡ sizeof(a); */
  {
    unsigned long __gen_e_acsl_block_length_10;
    __gen_e_acsl_block_length_10 = __e_acsl_block_length((void *)pa);
    __e_acsl_assert(__gen_e_acsl_block_length_10 == 16UL,(char *)"Assertion",
                    (char *)"main",(char *)"\\block_length(pa) == sizeof(a)",
                    31);
  }
  __e_acsl_full_init((void *)(& pa));
  pa ++;
  /*@ assert \block_length(pa + 1) ≡ \block_length(&a[1]); */
  {
    unsigned long __gen_e_acsl_block_length_11;
    unsigned long __gen_e_acsl_block_length_12;
    __gen_e_acsl_block_length_11 = __e_acsl_block_length((void *)(pa + 1));
    __gen_e_acsl_block_length_12 = __e_acsl_block_length((void *)(& a[1]));
    __e_acsl_assert(__gen_e_acsl_block_length_11 == __gen_e_acsl_block_length_12,
                    (char *)"Assertion",(char *)"main",
                    (char *)"\\block_length(pa + 1) == \\block_length(&a[1])",
                    33);
  }
  long l = (long)4;
  __e_acsl_store_block((void *)(& l),(size_t)8);
  __e_acsl_full_init((void *)(& l));
  char *pl = (char *)(& l);
  __e_acsl_store_block((void *)(& pl),(size_t)8);
  __e_acsl_full_init((void *)(& pl));
  /*@ assert \block_length(&l) ≡ sizeof(long); */
  {
    unsigned long __gen_e_acsl_block_length_13;
    __gen_e_acsl_block_length_13 = __e_acsl_block_length((void *)(& l));
    __e_acsl_assert(__gen_e_acsl_block_length_13 == 8UL,(char *)"Assertion",
                    (char *)"main",
                    (char *)"\\block_length(&l) == sizeof(long)",39);
  }
  /*@ assert \block_length(pl) ≡ sizeof(long); */
  {
    unsigned long __gen_e_acsl_block_length_14;
    __gen_e_acsl_block_length_14 = __e_acsl_block_length((void *)pl);
    __e_acsl_assert(__gen_e_acsl_block_length_14 == 8UL,(char *)"Assertion",
                    (char *)"main",
                    (char *)"\\block_length(pl) == sizeof(long)",40);
  }
  /*@ assert \block_length(pl + 7) ≡ sizeof(long); */
  {
    unsigned long __gen_e_acsl_block_length_15;
    __gen_e_acsl_block_length_15 = __e_acsl_block_length((void *)(pl + 7));
    __e_acsl_assert(__gen_e_acsl_block_length_15 == 8UL,(char *)"Assertion",
                    (char *)"main",
                    (char *)"\\block_length(pl + 7) == sizeof(long)",41);
  }
  int *pi = (int *)(& l);
  __e_acsl_store_block((void *)(& pi),(size_t)8);
  __e_acsl_full_init((void *)(& pi));
  /*@ assert \block_length(pi) ≡ \block_length(&l); */
  {
    unsigned long __gen_e_acsl_block_length_16;
    unsigned long __gen_e_acsl_block_length_17;
    __gen_e_acsl_block_length_16 = __e_acsl_block_length((void *)pi);
    __gen_e_acsl_block_length_17 = __e_acsl_block_length((void *)(& l));
    __e_acsl_assert(__gen_e_acsl_block_length_16 == __gen_e_acsl_block_length_17,
                    (char *)"Assertion",(char *)"main",
                    (char *)"\\block_length(pi) == \\block_length(&l)",43);
  }
  __e_acsl_full_init((void *)(& pi));
  pi ++;
  /*@ assert \block_length(pi) ≡ \block_length(&l); */
  {
    unsigned long __gen_e_acsl_block_length_18;
    unsigned long __gen_e_acsl_block_length_19;
    __gen_e_acsl_block_length_18 = __e_acsl_block_length((void *)pi);
    __gen_e_acsl_block_length_19 = __e_acsl_block_length((void *)(& l));
    __e_acsl_assert(__gen_e_acsl_block_length_18 == __gen_e_acsl_block_length_19,
                    (char *)"Assertion",(char *)"main",
                    (char *)"\\block_length(pi) == \\block_length(&l)",45);
  }
  size_t size = (unsigned long)12;
  char *p = malloc(size);
  __e_acsl_store_block((void *)(& p),(size_t)8);
  __e_acsl_full_init((void *)(& p));
  /*@ assert \block_length(p) ≡ size; */
  {
    unsigned long __gen_e_acsl_block_length_20;
    __gen_e_acsl_block_length_20 = __e_acsl_block_length((void *)p);
    __e_acsl_assert(__gen_e_acsl_block_length_20 == size,(char *)"Assertion",
                    (char *)"main",(char *)"\\block_length(p) == size",50);
  }
  /*@ assert \block_length(p + 11) ≡ size; */
  {
    unsigned long __gen_e_acsl_block_length_21;
    __gen_e_acsl_block_length_21 = __e_acsl_block_length((void *)(p + 11));
    __e_acsl_assert(__gen_e_acsl_block_length_21 == size,(char *)"Assertion",
                    (char *)"main",(char *)"\\block_length(p + 11) == size",
                    51);
  }
  __e_acsl_full_init((void *)(& p));
  p += 5;
  /*@ assert \block_length(p + 5) ≡ \block_length(p - 5); */
  {
    unsigned long __gen_e_acsl_block_length_22;
    unsigned long __gen_e_acsl_block_length_23;
    __gen_e_acsl_block_length_22 = __e_acsl_block_length((void *)(p + 5));
    __gen_e_acsl_block_length_23 = __e_acsl_block_length((void *)(p - 5));
    __e_acsl_assert(__gen_e_acsl_block_length_22 == __gen_e_acsl_block_length_23,
                    (char *)"Assertion",(char *)"main",
                    (char *)"\\block_length(p + 5) == \\block_length(p - 5)",
                    53);
  }
  size = (unsigned long)30 * sizeof(long);
  long *q = malloc(size);
  __e_acsl_store_block((void *)(& q),(size_t)8);
  __e_acsl_full_init((void *)(& q));
  /*@ assert \block_length(q) ≡ size; */
  {
    unsigned long __gen_e_acsl_block_length_24;
    __gen_e_acsl_block_length_24 = __e_acsl_block_length((void *)q);
    __e_acsl_assert(__gen_e_acsl_block_length_24 == size,(char *)"Assertion",
                    (char *)"main",(char *)"\\block_length(q) == size",59);
  }
  __e_acsl_full_init((void *)(& q));
  q += 4;
  /*@ assert \block_length(q) ≡ size; */
  {
    unsigned long __gen_e_acsl_block_length_25;
    __gen_e_acsl_block_length_25 = __e_acsl_block_length((void *)q);
    __e_acsl_assert(__gen_e_acsl_block_length_25 == size,(char *)"Assertion",
                    (char *)"main",(char *)"\\block_length(q) == size",61);
  }
  __retres = 0;
  __e_acsl_delete_block((void *)(& ZERO));
  __e_acsl_delete_block((void *)(& PA));
  __e_acsl_delete_block((void *)(A));
  __e_acsl_delete_block((void *)(& q));
  __e_acsl_delete_block((void *)(& p));
  __e_acsl_delete_block((void *)(& pi));
  __e_acsl_delete_block((void *)(& pl));
  __e_acsl_delete_block((void *)(& l));
  __e_acsl_delete_block((void *)(& pa));
  __e_acsl_delete_block((void *)(a));
  __e_acsl_delete_block((void *)(& zero));
  __e_acsl_memory_clean();
  return __retres;
}
Esempio n. 2
0
int __gen_e_acsl_main(int argc, char **argv)
{
  int __retres;
  int i;
  /*@ assert ∀ int k; 0 ≤ k < argc ⇒ \valid(argv + k); */
  {
    int __gen_e_acsl_forall;
    int __gen_e_acsl_k;
    __e_acsl_store_block((void *)(& argv),(size_t)8);
    __gen_e_acsl_forall = 1;
    __gen_e_acsl_k = 0;
    while (1) {
      if (__gen_e_acsl_k < argc) ; else break;
      {
        int __gen_e_acsl_valid;
        __gen_e_acsl_valid = __e_acsl_valid((void *)(argv + __gen_e_acsl_k),
                                            sizeof(char *),(void *)argv,
                                            (void *)(& argv));
        if (__gen_e_acsl_valid) ;
        else {
          __gen_e_acsl_forall = 0;
          goto e_acsl_end_loop1;
        }
      }
      __gen_e_acsl_k ++;
    }
    e_acsl_end_loop1: ;
    __e_acsl_assert(__gen_e_acsl_forall,(char *)"Assertion",(char *)"main",
                    (char *)"\\forall int k; 0 <= k < argc ==> \\valid(argv + k)",
                    12);
  }
  /*@ assert \block_length(argv) ≡ (argc + 1) * sizeof(char *); */
  {
    unsigned long __gen_e_acsl_block_length;
    __e_acsl_mpz_t __gen_e_acsl_block_length_2;
    __e_acsl_mpz_t __gen_e_acsl_;
    int __gen_e_acsl_eq;
    __gen_e_acsl_block_length = __e_acsl_block_length((void *)argv);
    __gmpz_init_set_ui(__gen_e_acsl_block_length_2,__gen_e_acsl_block_length);
    __gmpz_init_set_si(__gen_e_acsl_,(argc + 1L) * 8);
    __gen_e_acsl_eq = __gmpz_cmp((__e_acsl_mpz_struct const *)(__gen_e_acsl_block_length_2),
                                 (__e_acsl_mpz_struct const *)(__gen_e_acsl_));
    __e_acsl_assert(__gen_e_acsl_eq == 0,(char *)"Assertion",(char *)"main",
                    (char *)"\\block_length(argv) == (argc + 1) * sizeof(char *)",
                    13);
    __gmpz_clear(__gen_e_acsl_block_length_2);
    __gmpz_clear(__gen_e_acsl_);
  }
  /*@ assert *(argv + argc) ≡ \null; */
  {
    int __gen_e_acsl_valid_read;
    __gen_e_acsl_valid_read = __e_acsl_valid_read((void *)(argv + argc),
                                                  sizeof(char *),
                                                  (void *)argv,
                                                  (void *)(& argv));
    __e_acsl_assert(__gen_e_acsl_valid_read,(char *)"RTE",(char *)"main",
                    (char *)"mem_access: \\valid_read(argv + argc)",15);
    /*@ assert Eva: mem_access: \valid_read(argv + argc); */
    __e_acsl_assert(*(argv + argc) == (char *)0,(char *)"Assertion",
                    (char *)"main",(char *)"*(argv + argc) == \\null",15);
  }
  /*@ assert ¬\valid(*(argv + argc)); */
  {
    int __gen_e_acsl_initialized;
    int __gen_e_acsl_and;
    __gen_e_acsl_initialized = __e_acsl_initialized((void *)(argv + argc),
                                                    sizeof(char *));
    if (__gen_e_acsl_initialized) {
      int __gen_e_acsl_valid_read_2;
      int __gen_e_acsl_valid_2;
      __gen_e_acsl_valid_read_2 = __e_acsl_valid_read((void *)(argv + argc),
                                                      sizeof(char *),
                                                      (void *)argv,
                                                      (void *)(& argv));
      __e_acsl_assert(__gen_e_acsl_valid_read_2,(char *)"RTE",(char *)"main",
                      (char *)"mem_access: \\valid_read(argv + argc)",16);
      /*@ assert Eva: mem_access: \valid_read(argv + argc); */
      __gen_e_acsl_valid_2 = __e_acsl_valid((void *)*(argv + argc),
                                            sizeof(char),
                                            (void *)*(argv + argc),
                                            (void *)(argv + argc));
      __gen_e_acsl_and = __gen_e_acsl_valid_2;
    }
    else __gen_e_acsl_and = 0;
    __e_acsl_assert(! __gen_e_acsl_and,(char *)"Assertion",(char *)"main",
                    (char *)"!\\valid(*(argv + argc))",16);
  }
  i = 0;
  while (i < argc) {
    {
      size_t tmp;
      tmp = __gen_e_acsl_strlen((char const *)*(argv + i));
      int len = (int)tmp;
      /*@ assert \valid(*(argv + i)); */
      {
        int __gen_e_acsl_initialized_2;
        int __gen_e_acsl_and_2;
        __gen_e_acsl_initialized_2 = __e_acsl_initialized((void *)(argv + i),
                                                          sizeof(char *));
        if (__gen_e_acsl_initialized_2) {
          int __gen_e_acsl_valid_read_3;
          int __gen_e_acsl_valid_3;
          __gen_e_acsl_valid_read_3 = __e_acsl_valid_read((void *)(argv + i),
                                                          sizeof(char *),
                                                          (void *)argv,
                                                          (void *)(& argv));
          __e_acsl_assert(__gen_e_acsl_valid_read_3,(char *)"RTE",
                          (char *)"main",
                          (char *)"mem_access: \\valid_read(argv + i)",19);
          __gen_e_acsl_valid_3 = __e_acsl_valid((void *)*(argv + i),
                                                sizeof(char),
                                                (void *)*(argv + i),
                                                (void *)(argv + i));
          __gen_e_acsl_and_2 = __gen_e_acsl_valid_3;
        }
        else __gen_e_acsl_and_2 = 0;
        __e_acsl_assert(__gen_e_acsl_and_2,(char *)"Assertion",
                        (char *)"main",(char *)"\\valid(*(argv + i))",19);
      }
      /*@ assert ∀ int k; 0 ≤ k ≤ len ⇒ \valid(*(argv + i) + k); */
      {
        int __gen_e_acsl_forall_2;
        long __gen_e_acsl_k_2;
        __gen_e_acsl_forall_2 = 1;
        __gen_e_acsl_k_2 = 0;
        while (1) {
          if (__gen_e_acsl_k_2 <= (long)len) ; else break;
          {
            int __gen_e_acsl_valid_read_4;
            int __gen_e_acsl_valid_4;
            __gen_e_acsl_valid_read_4 = __e_acsl_valid_read((void *)(
                                                            argv + i),
                                                            sizeof(char *),
                                                            (void *)argv,
                                                            (void *)(& argv));
            __e_acsl_assert(__gen_e_acsl_valid_read_4,(char *)"RTE",
                            (char *)"main",
                            (char *)"mem_access: \\valid_read(argv + i)",20);
            __gen_e_acsl_valid_4 = __e_acsl_valid((void *)(*(argv + i) + __gen_e_acsl_k_2),
                                                  sizeof(char),
                                                  (void *)*(argv + i),
                                                  (void *)(argv + i));
            if (__gen_e_acsl_valid_4) ;
            else {
              __gen_e_acsl_forall_2 = 0;
              goto e_acsl_end_loop2;
            }
          }
          __gen_e_acsl_k_2 ++;
        }
        e_acsl_end_loop2: ;
        __e_acsl_assert(__gen_e_acsl_forall_2,(char *)"Assertion",
                        (char *)"main",
                        (char *)"\\forall int k; 0 <= k <= len ==> \\valid(*(argv + i) + k)",
                        20);
      }
    }
    i ++;
  }
  __retres = 0;
  __e_acsl_delete_block((void *)(& argv));
  return __retres;
}