/* Generated by Frama-C */
#include "stddef.h"
#include "stdio.h"
#include "stdlib.h"
int LAST;
int *new_inversed(int len, int *v)
{
  int i;
  int *p;
  __e_acsl_store_block((void *)(& p),(size_t)8);
  {
    int __gen_e_acsl_valid;
    int __gen_e_acsl_and;
    __e_acsl_store_block((void *)(& v),(size_t)8);
    __gen_e_acsl_valid = __e_acsl_valid((void *)v,sizeof(int),(void *)v,
                                        (void *)(& v));
    if (__gen_e_acsl_valid) {
      unsigned long __gen_e_acsl_offset;
      __e_acsl_mpz_t __gen_e_acsl_offset_2;
      __e_acsl_mpz_t __gen_e_acsl_;
      __e_acsl_mpz_t __gen_e_acsl_add;
      unsigned long __gen_e_acsl_block_length;
      __e_acsl_mpz_t __gen_e_acsl_block_length_2;
      int __gen_e_acsl_le;
      __gen_e_acsl_offset = __e_acsl_offset((void *)v);
      __gmpz_init_set_ui(__gen_e_acsl_offset_2,__gen_e_acsl_offset);
      __gmpz_init_set_si(__gen_e_acsl_,len * 4L);
      __gmpz_init(__gen_e_acsl_add);
      __gmpz_add(__gen_e_acsl_add,
                 (__e_acsl_mpz_struct const *)(__gen_e_acsl_offset_2),
                 (__e_acsl_mpz_struct const *)(__gen_e_acsl_));
      __gen_e_acsl_block_length = __e_acsl_block_length((void *)v);
      __gmpz_init_set_ui(__gen_e_acsl_block_length_2,
                         __gen_e_acsl_block_length);
      __gen_e_acsl_le = __gmpz_cmp((__e_acsl_mpz_struct const *)(__gen_e_acsl_add),
                                   (__e_acsl_mpz_struct const *)(__gen_e_acsl_block_length_2));
      __gen_e_acsl_and = __gen_e_acsl_le <= 0;
      __gmpz_clear(__gen_e_acsl_offset_2);
      __gmpz_clear(__gen_e_acsl_);
      __gmpz_clear(__gen_e_acsl_add);
      __gmpz_clear(__gen_e_acsl_block_length_2);
    }
    else __gen_e_acsl_and = 0;
    __e_acsl_assert(__gen_e_acsl_and,"Assertion","new_inversed",
                    "\\valid(v) && \\offset(v) + len * sizeof(int) <= \\block_length(v)",
                    "tests/memory/vector.c",11);
  }
  /*@
  assert \valid(v) ∧ \offset(v) + len * sizeof(int) ≤ \block_length(v);
   */
  ;
  __e_acsl_full_init((void *)(& p));
  p = (int *)malloc(sizeof(int) * (unsigned long)len);
  i = 0;
  while (i < len) {
    __e_acsl_initialize((void *)(p + i),sizeof(int));
    *(p + i) = *(v + ((len - i) - 1));
    i ++;
  }
  __e_acsl_delete_block((void *)(& v));
  __e_acsl_delete_block((void *)(& p));
  return p;
}

int main(void)
{
  int __retres;
  int *v2;
  __e_acsl_memory_init((int *)0,(char ***)0,(size_t)8);
  __e_acsl_store_block((void *)(& v2),(size_t)8);
  int x = 3;
  int v1[3] = {1, 2, x};
  __e_acsl_store_block((void *)(v1),(size_t)12);
  __e_acsl_full_init((void *)(& v1));
  {
    int __gen_e_acsl_valid;
    __gen_e_acsl_valid = __e_acsl_valid((void *)(& v1[2]),sizeof(int),
                                        (void *)(& v1[2]),(void *)0);
    __e_acsl_assert(__gen_e_acsl_valid,"Assertion","main","\\valid(&v1[2])",
                    "tests/memory/vector.c",21);
  }
  /*@ assert \valid(&v1[2]); */ ;
  LAST = v1[2];
  {
    int __gen_e_acsl_initialized;
    __gen_e_acsl_initialized = __e_acsl_initialized((void *)(& v1[2]),
                                                    sizeof(int));
    __e_acsl_assert(__gen_e_acsl_initialized,"Assertion","main",
                    "\\initialized(&v1[2])","tests/memory/vector.c",23);
  }
  /*@ assert \initialized(&v1[2]); */ ;
  __e_acsl_full_init((void *)(& v2));
  v2 = new_inversed(3,v1);
  /*@ assert Eva: initialization: \initialized(v2 + 2); */
  LAST = *(v2 + 2);
  {
    int __gen_e_acsl_initialized_2;
    __gen_e_acsl_initialized_2 = __e_acsl_initialized((void *)(v2 + 2),
                                                      sizeof(int));
    __e_acsl_assert(__gen_e_acsl_initialized_2,"Assertion","main",
                    "\\initialized(v2 + 2)","tests/memory/vector.c",26);
  }
  /*@ assert \initialized(v2 + 2); */ ;
  __e_acsl_assert(LAST == 1,"Assertion","main","LAST == 1",
                  "tests/memory/vector.c",27);
  /*@ assert LAST ≡ 1; */ ;
  free((void *)v2);
  __retres = 0;
  __e_acsl_delete_block((void *)(& v2));
  __e_acsl_delete_block((void *)(v1));
  __e_acsl_memory_clean();
  return __retres;
}


