예제 #1
0
void f(void const *s, int c, unsigned long n)
{
  __e_acsl_store_block((void *)(& s),(size_t)8);
  unsigned char const *p = (unsigned char const *)s;
  __e_acsl_store_block((void *)(& p),(size_t)8);
  __e_acsl_full_init((void *)(& p));
  /*@ assert p - (unsigned char const *)s ≡ n - n; */
  {
    __e_acsl_mpz_t __gen_e_acsl_;
    __e_acsl_mpz_t __gen_e_acsl_n;
    __e_acsl_mpz_t __gen_e_acsl_sub;
    int __gen_e_acsl_eq;
    __gmpz_init_set_ui(__gen_e_acsl_,p - (unsigned char const *)s);
    __gmpz_init_set_ui(__gen_e_acsl_n,n);
    __gmpz_init(__gen_e_acsl_sub);
    __gmpz_sub(__gen_e_acsl_sub,
               (__e_acsl_mpz_struct const *)(__gen_e_acsl_n),
               (__e_acsl_mpz_struct const *)(__gen_e_acsl_n));
    __gen_e_acsl_eq = __gmpz_cmp((__e_acsl_mpz_struct const *)(__gen_e_acsl_),
                                 (__e_acsl_mpz_struct const *)(__gen_e_acsl_sub));
    __e_acsl_assert(__gen_e_acsl_eq == 0,(char *)"Assertion",(char *)"f",
                    (char *)"p - (unsigned char const *)s == n - n",16);
    __gmpz_clear(__gen_e_acsl_);
    __gmpz_clear(__gen_e_acsl_n);
    __gmpz_clear(__gen_e_acsl_sub);
  }
  /*@ assert p - (unsigned char const *)s ≡ 0; */
  __e_acsl_assert(p - (unsigned char const *)s == 0UL,(char *)"Assertion",
                  (char *)"f",(char *)"p - (unsigned char const *)s == 0",17);
  __e_acsl_delete_block((void *)(& s));
  __e_acsl_delete_block((void *)(& p));
  return;
}
예제 #2
0
int main(void)
{
  int __retres;
  {
    int i;
    i = 0;
    while (i < 3) {
      T1[i] = i;
      i ++;
    }
  }
  {
    int i_0;
    i_0 = 0;
    while (i_0 < 4) {
      T2[i_0] = 2 * i_0;
      i_0 ++;
    }
  }
  /*@ assert T1[0] ≡ T2[0]; */
  {
    mpz_t __gen_e_acsl_;
    mpz_t __gen_e_acsl__2;
    int __gen_e_acsl_eq;
    __gmpz_init_set_si(__gen_e_acsl_,(long)T1[0UL]);
    __gmpz_init_set_si(__gen_e_acsl__2,(long)T2[0UL]);
    __gen_e_acsl_eq = __gmpz_cmp((__mpz_struct const *)(__gen_e_acsl_),
                                 (__mpz_struct const *)(__gen_e_acsl__2));
    __e_acsl_assert(__gen_e_acsl_eq == 0,(char *)"Assertion",(char *)"main",
                    (char *)"T1[0] == T2[0]",13);
    __gmpz_clear(__gen_e_acsl_);
    __gmpz_clear(__gen_e_acsl__2);
  }
  /*@ assert T1[1] ≢ T2[1]; */
  {
    mpz_t __gen_e_acsl__3;
    mpz_t __gen_e_acsl__4;
    int __gen_e_acsl_ne;
    __gmpz_init_set_si(__gen_e_acsl__3,(long)T1[1UL]);
    __gmpz_init_set_si(__gen_e_acsl__4,(long)T2[1UL]);
    __gen_e_acsl_ne = __gmpz_cmp((__mpz_struct const *)(__gen_e_acsl__3),
                                 (__mpz_struct const *)(__gen_e_acsl__4));
    __e_acsl_assert(__gen_e_acsl_ne != 0,(char *)"Assertion",(char *)"main",
                    (char *)"T1[1] != T2[1]",14);
    __gmpz_clear(__gen_e_acsl__3);
    __gmpz_clear(__gen_e_acsl__4);
  }
  __retres = 0;
  return __retres;
}
/*
 * Class:     GmpUtil
 * Method:    mpz_clear
 * Signature: (J)V
 */
JNIEXPORT void JNICALL Java_GmpUtil_mpz_1clear
  (JNIEnv *x, jclass y, jlong o)
{
  mpz_t* p = (mpz_t*)o;
  __gmpz_clear( *p );
  free( p );
}
예제 #4
0
int main(void)
{
  int __retres;
  int x;
  __e_acsl_memory_init((int *)0,(char ***)0,(size_t)8);
  /*@ assert 0 ≡ 0; */
  {
    __e_acsl_mpz_t __gen_e_acsl_;
    int __gen_e_acsl_eq;
    __gmpz_init_set_si(__gen_e_acsl_,0L);
    __gen_e_acsl_eq = __gmpz_cmp((__e_acsl_mpz_struct const *)(__gen_e_acsl_),
                                 (__e_acsl_mpz_struct const *)(__gen_e_acsl_));
    __e_acsl_assert(__gen_e_acsl_eq == 0,(char *)"Assertion",(char *)"main",
                    (char *)"0 == 0",6);
    __gmpz_clear(__gen_e_acsl_);
  }
  x = 0;
  x ++;
  /*@ assert 0 ≢ 1; */
  {
    __e_acsl_mpz_t __gen_e_acsl__2;
    __e_acsl_mpz_t __gen_e_acsl__3;
    int __gen_e_acsl_ne;
    __gmpz_init_set_si(__gen_e_acsl__2,0L);
    __gmpz_init_set_si(__gen_e_acsl__3,1L);
    __gen_e_acsl_ne = __gmpz_cmp((__e_acsl_mpz_struct const *)(__gen_e_acsl__2),
                                 (__e_acsl_mpz_struct const *)(__gen_e_acsl__3));
    __e_acsl_assert(__gen_e_acsl_ne != 0,(char *)"Assertion",(char *)"main",
                    (char *)"0 != 1",8);
    __gmpz_clear(__gen_e_acsl__2);
    __gmpz_clear(__gen_e_acsl__3);
  }
  /*@ assert 1152921504606846975 ≡ 0xfffffffffffffff; */
  {
    __e_acsl_mpz_t __gen_e_acsl__4;
    int __gen_e_acsl_eq_2;
    __gmpz_init_set_ui(__gen_e_acsl__4,1152921504606846975UL);
    __gen_e_acsl_eq_2 = __gmpz_cmp((__e_acsl_mpz_struct const *)(__gen_e_acsl__4),
                                   (__e_acsl_mpz_struct const *)(__gen_e_acsl__4));
    __e_acsl_assert(__gen_e_acsl_eq_2 == 0,(char *)"Assertion",
                    (char *)"main",
                    (char *)"1152921504606846975 == 0xfffffffffffffff",9);
    __gmpz_clear(__gen_e_acsl__4);
  }
  /*@ assert
      0xffffffffffffffffffffffffffffffff ≡
      0xffffffffffffffffffffffffffffffff;
  */
  {
    __e_acsl_mpz_t __gen_e_acsl__5;
    int __gen_e_acsl_eq_3;
    __gmpz_init_set_str(__gen_e_acsl__5,
                        "340282366920938463463374607431768211455",10);
    __gen_e_acsl_eq_3 = __gmpz_cmp((__e_acsl_mpz_struct const *)(__gen_e_acsl__5),
                                   (__e_acsl_mpz_struct const *)(__gen_e_acsl__5));
    __e_acsl_assert(__gen_e_acsl_eq_3 == 0,(char *)"Assertion",
                    (char *)"main",
                    (char *)"0xffffffffffffffffffffffffffffffff == 0xffffffffffffffffffffffffffffffff",
                    11);
    __gmpz_clear(__gen_e_acsl__5);
  }
  __retres = 0;
  return __retres;
}
예제 #5
0
/* compiler builtin: 
   void *__builtin_alloca(unsigned long);   */
void test_specifier_application(char const *allowed, char const *fmt,
                                int only_negative, char *at)
{
  size_t tmp;
  unsigned long __lengthof_format;
  __e_acsl_store_block((void *)(& __lengthof_format),(size_t)8);
  __e_acsl_store_block((void *)(& tmp),(size_t)8);
  __e_acsl_store_block((void *)(& at),(size_t)8);
  __e_acsl_store_block((void *)(& only_negative),(size_t)4);
  __e_acsl_store_block((void *)(& fmt),(size_t)8);
  __e_acsl_store_block((void *)(& allowed),(size_t)8);
  __e_acsl_full_init((void *)(& tmp));
  tmp = __gen_e_acsl_strlen(fmt);
  int len = (int)tmp;
  __e_acsl_store_block((void *)(& len),(size_t)4);
  __e_acsl_full_init((void *)(& len));
  /*@ assert
      alloca_bounds: 0 < sizeof(char) * (len + 1) ≤ 18446744073709551615;
  */
  {
    int __gen_e_acsl_and;
    if (0L < 1L * (len + 1L)) {
      __e_acsl_mpz_t __gen_e_acsl_;
      __e_acsl_mpz_t __gen_e_acsl__2;
      int __gen_e_acsl_le;
      __gmpz_init_set_si(__gen_e_acsl_,1L * (len + 1L));
      __gmpz_init_set_ui(__gen_e_acsl__2,18446744073709551615UL);
      __gen_e_acsl_le = __gmpz_cmp((__e_acsl_mpz_struct const *)(__gen_e_acsl_),
                                   (__e_acsl_mpz_struct const *)(__gen_e_acsl__2));
      __gen_e_acsl_and = __gen_e_acsl_le <= 0;
      __gmpz_clear(__gen_e_acsl_);
      __gmpz_clear(__gen_e_acsl__2);
    }
    else __gen_e_acsl_and = 0;
    __e_acsl_assert(__gen_e_acsl_and,(char *)"Assertion",
                    (char *)"test_specifier_application",
                    (char *)"alloca_bounds: 0 < sizeof(char) * (len + 1) <= 18446744073709551615",
                    82);
  }
  __e_acsl_full_init((void *)(& __lengthof_format));
  __lengthof_format = (unsigned long)(len + 1);
  char *format = __builtin_alloca(sizeof(char) * __lengthof_format);
  __e_acsl_store_block((void *)format,sizeof(char) * __lengthof_format);
  __e_acsl_store_block((void *)(& format),(size_t)8);
  __e_acsl_full_init((void *)(& format));
  __gen_e_acsl_strcpy(format,fmt);
  {
    int i_0 = 0;
    __e_acsl_store_block((void *)(& i_0),(size_t)4);
    __e_acsl_full_init((void *)(& i_0));
    while (1) {
      size_t tmp_3;
      __e_acsl_store_block((void *)(& tmp_3),(size_t)8);
      __e_acsl_full_init((void *)(& tmp_3));
      tmp_3 = __gen_e_acsl_strlen(valid_specifiers);
      ;
      if (! ((size_t)i_0 < tmp_3)) {
        __e_acsl_delete_block((void *)(& tmp_3));
        break;
      }
      {
        char *tmp_2;
        __e_acsl_store_block((void *)(& tmp_2),(size_t)8);
        int c = (int)*(valid_specifiers + i_0);
        __e_acsl_store_block((void *)(& c),(size_t)4);
        __e_acsl_full_init((void *)(& c));
        __e_acsl_initialize((void *)(format + (len - 1)),sizeof(char));
        *(format + (len - 1)) = (char)c;
        __e_acsl_full_init((void *)(& tmp_2));
        tmp_2 = __gen_e_acsl_strchr(allowed,c);
        if (tmp_2) {
          if (! only_negative) {
            {
              pid_t pid = fork();
              __e_acsl_store_block((void *)(& pid),(size_t)4);
              __e_acsl_full_init((void *)(& pid));
              if (! pid) {
                apply_specifier(format,c);
                __gen_e_acsl_exit(0);
              }
              else {
                int process_status;
                __e_acsl_store_block((void *)(& process_status),(size_t)4);
                waitpid(pid,& process_status,0);
                signal_eval(process_status,0,(char const *)at);
                __e_acsl_delete_block((void *)(& process_status));
              }
              __e_acsl_delete_block((void *)(& pid));
            }
          }
        }
        else {
          {
            pid_t pid_0 = fork();
            __e_acsl_store_block((void *)(& pid_0),(size_t)4);
            __e_acsl_full_init((void *)(& pid_0));
            if (! pid_0) {
              apply_specifier(format,c);
              __gen_e_acsl_exit(0);
            }
            else {
              int process_status_0;
              __e_acsl_store_block((void *)(& process_status_0),(size_t)4);
              waitpid(pid_0,& process_status_0,0);
              signal_eval(process_status_0,1,(char const *)at);
              __e_acsl_delete_block((void *)(& process_status_0));
            }
            __e_acsl_delete_block((void *)(& pid_0));
          }
        }
        __e_acsl_delete_block((void *)(& tmp_2));
        __e_acsl_delete_block((void *)(& c));
      }
      __e_acsl_full_init((void *)(& i_0));
      i_0 ++;
      __e_acsl_delete_block((void *)(& tmp_3));
    }
    __e_acsl_delete_block((void *)(& i_0));
  }
  __e_acsl_delete_block((void *)format);
  __e_acsl_delete_block((void *)(& at));
  __e_acsl_delete_block((void *)(& only_negative));
  __e_acsl_delete_block((void *)(& fmt));
  __e_acsl_delete_block((void *)(& allowed));
  __e_acsl_delete_block((void *)(& __lengthof_format));
  __e_acsl_delete_block((void *)(& format));
  __e_acsl_delete_block((void *)(& tmp));
  __e_acsl_delete_block((void *)(& len));
  return;
}
예제 #6
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;
}