/* Generated by Frama-C */
#include "pthread.h"
#include "sched.h"
#include "signal.h"
#include "stddef.h"
#include "stdint.h"
#include "stdio.h"
#include "stdlib.h"
#include "time.h"
extern  __attribute__((__FC_BUILTIN__)) int __e_acsl_sound_verdict;

/*@ requires \valid(y);
    requires *x >= 0;
    ensures *\old(x) == \old(*x) + 1;
    assigns *x;
    assigns *x \from *x, x;
    
    behavior b1:
      assumes *x == 1;
      ensures *\old(x) < 0;
      assigns \nothing;
    
    behavior b2:
      assumes *x == 0;
      ensures *\old(x) == 1;
    
    complete behaviors b2, b1;
    disjoint behaviors b1, b2;
 */
void __gen_e_acsl_f(int *x, int *y);

void f(int *x, int *y)
{
  long __gen_e_acsl_old_variant;
  {
    {
      int __gen_e_acsl_valid_read;
      __e_acsl_store_block((void *)(& y),8UL);
      __e_acsl_store_block((void *)(& x),8UL);
      __e_acsl_assert_data_t __gen_e_acsl_assert_data =
        {.values = (void *)0};
      __e_acsl_assert_register_int(& __gen_e_acsl_assert_data,"*x",0,*x);
      __e_acsl_assert_data_t __gen_e_acsl_assert_data_2 =
        {.values = (void *)0};
      __e_acsl_assert_register_ptr(& __gen_e_acsl_assert_data_2,"x",
                                   (void *)x);
      __e_acsl_assert_register_ulong(& __gen_e_acsl_assert_data_2,
                                     "sizeof(int)",0,sizeof(int));
      __gen_e_acsl_valid_read = __e_acsl_valid_read((void *)x,sizeof(int),
                                                    (void *)x,(void *)(& x));
      __gen_e_acsl_assert_data_2.blocking = 1;
      __gen_e_acsl_assert_data_2.kind = "RTE";
      __gen_e_acsl_assert_data_2.pred_txt = "\\valid_read(x)";
      __gen_e_acsl_assert_data_2.file = "e-acsl-valid.c";
      __gen_e_acsl_assert_data_2.fct = "f";
      __gen_e_acsl_assert_data_2.line = 27;
      __gen_e_acsl_assert_data_2.name = "mem_access";
      __e_acsl_assert(__gen_e_acsl_valid_read,& __gen_e_acsl_assert_data_2);
      __e_acsl_assert_clean(& __gen_e_acsl_assert_data_2);
      __gen_e_acsl_assert_data.blocking = 1;
      __gen_e_acsl_assert_data.kind = "Precondition";
      __gen_e_acsl_assert_data.pred_txt = "*x >= 0";
      __gen_e_acsl_assert_data.file = "e-acsl-valid.c";
      __gen_e_acsl_assert_data.fct = "f";
      __gen_e_acsl_assert_data.line = 27;
      __e_acsl_assert(*x >= 0,& __gen_e_acsl_assert_data);
      __e_acsl_assert_clean(& __gen_e_acsl_assert_data);
    }
    /*@ requires *x >= 0;
        ensures 2 >= 1;
        assigns *x; */
    {
      __e_acsl_initialize((void *)x,sizeof(int));
      (*x) ++;
    }
    __e_acsl_assert_data_t __gen_e_acsl_assert_data_3 =
      {.values = (void *)0};
    __gen_e_acsl_assert_data_3.blocking = 1;
    __gen_e_acsl_assert_data_3.kind = "Postcondition";
    __gen_e_acsl_assert_data_3.pred_txt = "2 >= 1";
    __gen_e_acsl_assert_data_3.file = "e-acsl-valid.c";
    __gen_e_acsl_assert_data_3.fct = "f";
    __gen_e_acsl_assert_data_3.line = 28;
    __e_acsl_assert(1,& __gen_e_acsl_assert_data_3);
  }
  {
    int i = 0;
    /*@ loop invariant 0 <= i <= 1;
        loop variant 2 - i; */
    while (1) {
      __gen_e_acsl_old_variant = 2L - i;
      if (! (i < 1)) break;
      /*@ assert 1 == 1; */ ;
      /*@ assert \valid(y); */ ;
      i ++;
      {
        __e_acsl_assert_data_t __gen_e_acsl_assert_data_4 =
          {.values = (void *)0};
        __e_acsl_assert_register_long(& __gen_e_acsl_assert_data_4,
                                      "old 2 - i",0,__gen_e_acsl_old_variant);
        __e_acsl_assert_data_t __gen_e_acsl_assert_data_5 =
          {.values = (void *)0};
        __e_acsl_assert_copy_values(& __gen_e_acsl_assert_data_5,
                                    & __gen_e_acsl_assert_data_4);
        __e_acsl_assert_register_long(& __gen_e_acsl_assert_data_5,
                                      "current 2 - i",0,2L - i);
        __gen_e_acsl_assert_data_4.blocking = 1;
        __gen_e_acsl_assert_data_4.kind = "Variant";
        __gen_e_acsl_assert_data_4.pred_txt = "(old 2 - i) >= 0";
        __gen_e_acsl_assert_data_4.file = "e-acsl-valid.c";
        __gen_e_acsl_assert_data_4.fct = "f";
        __gen_e_acsl_assert_data_4.line = 33;
        __e_acsl_assert(__gen_e_acsl_old_variant >= 0L,
                        & __gen_e_acsl_assert_data_4);
        __e_acsl_assert_clean(& __gen_e_acsl_assert_data_4);
        __gen_e_acsl_assert_data_5.blocking = 1;
        __gen_e_acsl_assert_data_5.kind = "Variant";
        __gen_e_acsl_assert_data_5.pred_txt = "(old 2 - i) > 2 - i";
        __gen_e_acsl_assert_data_5.file = "e-acsl-valid.c";
        __gen_e_acsl_assert_data_5.fct = "f";
        __gen_e_acsl_assert_data_5.line = 33;
        __e_acsl_assert(__gen_e_acsl_old_variant > 2L - i,
                        & __gen_e_acsl_assert_data_5);
        __e_acsl_assert_clean(& __gen_e_acsl_assert_data_5);
      }
    }
  }
  __e_acsl_delete_block((void *)(& y));
  __e_acsl_delete_block((void *)(& x));
  return;
}

int main(void)
{
  int __retres;
  __e_acsl_memory_init((int *)0,(char ***)0,8UL);
  int x = 0;
  __e_acsl_store_block((void *)(& x),4UL);
  __e_acsl_full_init((void *)(& x));
  int *y = malloc(sizeof(int));
  __e_acsl_store_block((void *)(& y),8UL);
  __e_acsl_full_init((void *)(& y));
  __gen_e_acsl_f(& x,y);
  __retres = 0;
  __e_acsl_delete_block((void *)(& y));
  __e_acsl_delete_block((void *)(& x));
  __e_acsl_memory_clean();
  return __retres;
}

/*@ requires \valid(y);
    requires *x >= 0;
    ensures *\old(x) == \old(*x) + 1;
    assigns *x;
    assigns *x \from *x, x;
    
    behavior b1:
      assumes *x == 1;
      ensures *\old(x) < 0;
      assigns \nothing;
    
    behavior b2:
      assumes *x == 0;
      ensures *\old(x) == 1;
    
    complete behaviors b2, b1;
    disjoint behaviors b1, b2;
 */
void __gen_e_acsl_f(int *x, int *y)
{
  __e_acsl_contract_t *__gen_e_acsl_contract;
  {
    int __gen_e_acsl_valid;
    int __gen_e_acsl_valid_read;
    int __gen_e_acsl_valid_read_2;
    int __gen_e_acsl_active_bhvrs;
    __e_acsl_store_block((void *)(& y),8UL);
    __e_acsl_store_block((void *)(& x),8UL);
    __gen_e_acsl_contract = __e_acsl_contract_init(2UL);
    __e_acsl_assert_data_t __gen_e_acsl_assert_data = {.values = (void *)0};
    __e_acsl_assert_register_ptr(& __gen_e_acsl_assert_data,"y",(void *)y);
    __e_acsl_assert_register_ulong(& __gen_e_acsl_assert_data,"sizeof(int)",
                                   0,sizeof(int));
    __gen_e_acsl_valid = __e_acsl_valid((void *)y,sizeof(int),(void *)y,
                                        (void *)(& y));
    __e_acsl_assert_register_int(& __gen_e_acsl_assert_data,"\\valid(y)",0,
                                 __gen_e_acsl_valid);
    __gen_e_acsl_assert_data.blocking = 1;
    __gen_e_acsl_assert_data.kind = "Precondition";
    __gen_e_acsl_assert_data.pred_txt = "\\valid(y)";
    __gen_e_acsl_assert_data.file = "e-acsl-valid.c";
    __gen_e_acsl_assert_data.fct = "f";
    __gen_e_acsl_assert_data.line = 12;
    __e_acsl_assert(__gen_e_acsl_valid,& __gen_e_acsl_assert_data);
    __e_acsl_assert_clean(& __gen_e_acsl_assert_data);
    __e_acsl_assert_data_t __gen_e_acsl_assert_data_2 =
      {.values = (void *)0};
    __e_acsl_assert_register_ptr(& __gen_e_acsl_assert_data_2,"x",(void *)x);
    __e_acsl_assert_register_ulong(& __gen_e_acsl_assert_data_2,
                                   "sizeof(int)",0,sizeof(int));
    __gen_e_acsl_valid_read = __e_acsl_valid_read((void *)x,sizeof(int),
                                                  (void *)x,(void *)(& x));
    __gen_e_acsl_assert_data_2.blocking = 1;
    __gen_e_acsl_assert_data_2.kind = "RTE";
    __gen_e_acsl_assert_data_2.pred_txt = "\\valid_read(x)";
    __gen_e_acsl_assert_data_2.file = "e-acsl-valid.c";
    __gen_e_acsl_assert_data_2.fct = "f";
    __gen_e_acsl_assert_data_2.line = 17;
    __gen_e_acsl_assert_data_2.name = "mem_access";
    __e_acsl_assert(__gen_e_acsl_valid_read,& __gen_e_acsl_assert_data_2);
    __e_acsl_assert_clean(& __gen_e_acsl_assert_data_2);
    __e_acsl_contract_set_behavior_assumes(__gen_e_acsl_contract,0UL,*x == 1);
    __e_acsl_assert_data_t __gen_e_acsl_assert_data_3 =
      {.values = (void *)0};
    __e_acsl_assert_register_ptr(& __gen_e_acsl_assert_data_3,"x",(void *)x);
    __e_acsl_assert_register_ulong(& __gen_e_acsl_assert_data_3,
                                   "sizeof(int)",0,sizeof(int));
    __gen_e_acsl_valid_read_2 = __e_acsl_valid_read((void *)x,sizeof(int),
                                                    (void *)x,(void *)(& x));
    __gen_e_acsl_assert_data_3.blocking = 1;
    __gen_e_acsl_assert_data_3.kind = "RTE";
    __gen_e_acsl_assert_data_3.pred_txt = "\\valid_read(x)";
    __gen_e_acsl_assert_data_3.file = "e-acsl-valid.c";
    __gen_e_acsl_assert_data_3.fct = "f";
    __gen_e_acsl_assert_data_3.line = 21;
    __gen_e_acsl_assert_data_3.name = "mem_access";
    __e_acsl_assert(__gen_e_acsl_valid_read_2,& __gen_e_acsl_assert_data_3);
    __e_acsl_assert_clean(& __gen_e_acsl_assert_data_3);
    __e_acsl_contract_set_behavior_assumes(__gen_e_acsl_contract,1UL,*x == 0);
    __gen_e_acsl_active_bhvrs = __e_acsl_contract_partial_count_all_behaviors
    ((__e_acsl_contract_t const *)__gen_e_acsl_contract);
    __e_acsl_assert_data_t __gen_e_acsl_assert_data_4 =
      {.values = (void *)0};
    __e_acsl_assert_register_int(& __gen_e_acsl_assert_data_4,
                                 "number of active behaviors",0,
                                 __gen_e_acsl_active_bhvrs);
    __e_acsl_assert_data_t __gen_e_acsl_assert_data_5 =
      {.values = (void *)0};
    __e_acsl_assert_register_int(& __gen_e_acsl_assert_data_5,
                                 "number of active behaviors",0,
                                 __gen_e_acsl_active_bhvrs);
    __gen_e_acsl_assert_data_4.blocking = 1;
    __gen_e_acsl_assert_data_4.kind = "Precondition";
    __gen_e_acsl_assert_data_4.pred_txt = "all behaviors complete";
    __gen_e_acsl_assert_data_4.file = "e-acsl-valid.c";
    __gen_e_acsl_assert_data_4.fct = "f";
    __gen_e_acsl_assert_data_4.line = 26;
    __e_acsl_assert(__gen_e_acsl_active_bhvrs >= 1,
                    & __gen_e_acsl_assert_data_4);
    __e_acsl_assert_clean(& __gen_e_acsl_assert_data_4);
    __gen_e_acsl_active_bhvrs = __e_acsl_contract_partial_count_all_behaviors
    ((__e_acsl_contract_t const *)__gen_e_acsl_contract);
    __e_acsl_assert_data_t __gen_e_acsl_assert_data_6 =
      {.values = (void *)0};
    __e_acsl_assert_register_int(& __gen_e_acsl_assert_data_6,
                                 "number of active behaviors",0,
                                 __gen_e_acsl_active_bhvrs);
    __e_acsl_assert_data_t __gen_e_acsl_assert_data_7 =
      {.values = (void *)0};
    __e_acsl_assert_register_int(& __gen_e_acsl_assert_data_7,
                                 "number of active behaviors",0,
                                 __gen_e_acsl_active_bhvrs);
    __gen_e_acsl_assert_data_7.blocking = 1;
    __gen_e_acsl_assert_data_7.kind = "Precondition";
    __gen_e_acsl_assert_data_7.pred_txt = "all behaviors disjoint";
    __gen_e_acsl_assert_data_7.file = "e-acsl-valid.c";
    __gen_e_acsl_assert_data_7.fct = "f";
    __gen_e_acsl_assert_data_7.line = 26;
    __e_acsl_assert(__gen_e_acsl_active_bhvrs <= 1,
                    & __gen_e_acsl_assert_data_7);
    __e_acsl_assert_clean(& __gen_e_acsl_assert_data_7);
  }
  f(x,y);
  __e_acsl_contract_clean(__gen_e_acsl_contract);
  __e_acsl_delete_block((void *)(& y));
  __e_acsl_delete_block((void *)(& x));
  return;
}


