/* 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;

struct list {
   int element ;
   struct list *next ;
};
/*@ behavior B1:
      assumes l == \null;
      ensures \result == \old(l);
    
    behavior B2:
      assumes !\valid(l) || !\valid(l->next);
      ensures \result == \old(l);
 */
struct list *__gen_e_acsl_f(struct list *l);

struct list *f(struct list *l)
{
  struct list *__retres;
  __e_acsl_store_block((void *)(& __retres),8UL);
  __e_acsl_store_block((void *)(& l),8UL);
  if (l == (struct list *)0) {
    __e_acsl_full_init((void *)(& __retres));
    __retres = l;
    goto return_label;
  }
  if (l->next == (struct list *)0) {
    __e_acsl_full_init((void *)(& __retres));
    __retres = l;
    goto return_label;
  }
  __e_acsl_full_init((void *)(& __retres));
  __retres = (struct list *)0;
  return_label:
  __e_acsl_delete_block((void *)(& l));
  __e_acsl_delete_block((void *)(& __retres));
  return __retres;
}

int main(void)
{
  int __retres;
  __e_acsl_memory_init((int *)0,(char ***)0,8UL);
  __gen_e_acsl_f((struct list *)0);
  __retres = 0;
  __e_acsl_memory_clean();
  return __retres;
}

/*@ behavior B1:
      assumes l == \null;
      ensures \result == \old(l);
    
    behavior B2:
      assumes !\valid(l) || !\valid(l->next);
      ensures \result == \old(l);
 */
struct list *__gen_e_acsl_f(struct list *l)
{
  __e_acsl_contract_t *__gen_e_acsl_contract;
  struct list *__gen_e_acsl_at;
  struct list *__retres;
  __e_acsl_store_block((void *)(& __retres),8UL);
  {
    int __gen_e_acsl_valid;
    int __gen_e_acsl_or;
    __e_acsl_store_block((void *)(& l),8UL);
    __gen_e_acsl_at = l;
    __gen_e_acsl_contract = __e_acsl_contract_init(2UL);
    __e_acsl_contract_set_behavior_assumes(__gen_e_acsl_contract,0UL,
                                           l == (struct list *)0);
    __gen_e_acsl_valid = __e_acsl_valid((void *)l,sizeof(struct list),
                                        (void *)l,(void *)(& l));
    if (! __gen_e_acsl_valid) __gen_e_acsl_or = 1;
    else {
      int __gen_e_acsl_initialized;
      int __gen_e_acsl_and;
      __gen_e_acsl_initialized = __e_acsl_initialized((void *)(& l->next),
                                                      sizeof(struct list *));
      if (__gen_e_acsl_initialized) {
        int __gen_e_acsl_valid_read;
        int __gen_e_acsl_valid_2;
        __e_acsl_assert_data_t __gen_e_acsl_assert_data =
          {.values = (void *)0};
        __e_acsl_assert_register_ptr(& __gen_e_acsl_assert_data,"&l->next",
                                     (void *)(& l->next));
        __e_acsl_assert_register_ulong(& __gen_e_acsl_assert_data,
                                       "sizeof(struct list *)",0,
                                       sizeof(struct list *));
        __gen_e_acsl_valid_read = __e_acsl_valid_read((void *)(& l->next),
                                                      sizeof(struct list *),
                                                      (void *)(& l->next),
                                                      (void *)0);
        __gen_e_acsl_assert_data.blocking = 1;
        __gen_e_acsl_assert_data.kind = "RTE";
        __gen_e_acsl_assert_data.pred_txt = "\\valid_read(&l->next)";
        __gen_e_acsl_assert_data.file = "valid_in_contract.c";
        __gen_e_acsl_assert_data.fct = "f";
        __gen_e_acsl_assert_data.line = 17;
        __gen_e_acsl_assert_data.name = "mem_access";
        __e_acsl_assert(__gen_e_acsl_valid_read,& __gen_e_acsl_assert_data);
        __e_acsl_assert_clean(& __gen_e_acsl_assert_data);
        __gen_e_acsl_valid_2 = __e_acsl_valid((void *)l->next,
                                              sizeof(struct list),
                                              (void *)l->next,
                                              (void *)(& l->next));
        __gen_e_acsl_and = __gen_e_acsl_valid_2;
      }
      else __gen_e_acsl_and = 0;
      __gen_e_acsl_or = ! __gen_e_acsl_and;
    }
    __e_acsl_contract_set_behavior_assumes(__gen_e_acsl_contract,1UL,
                                           __gen_e_acsl_or);
  }
  __retres = f(l);
  {
    int __gen_e_acsl_assumes_value;
    __gen_e_acsl_assumes_value = __e_acsl_contract_get_behavior_assumes
    ((__e_acsl_contract_t const *)__gen_e_acsl_contract,0UL);
    if (__gen_e_acsl_assumes_value) {
      __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,"\\result",
                                   (void *)__retres);
      __e_acsl_assert_register_ptr(& __gen_e_acsl_assert_data_2,"\\old(l)",
                                   (void *)__gen_e_acsl_at);
      __gen_e_acsl_assert_data_2.blocking = 1;
      __gen_e_acsl_assert_data_2.kind = "Postcondition";
      __gen_e_acsl_assert_data_2.pred_txt = "\\result == \\old(l)";
      __gen_e_acsl_assert_data_2.file = "valid_in_contract.c";
      __gen_e_acsl_assert_data_2.fct = "f";
      __gen_e_acsl_assert_data_2.line = 15;
      __gen_e_acsl_assert_data_2.name = "B1";
      __e_acsl_assert(__retres == __gen_e_acsl_at,
                      & __gen_e_acsl_assert_data_2);
      __e_acsl_assert_clean(& __gen_e_acsl_assert_data_2);
    }
    __gen_e_acsl_assumes_value = __e_acsl_contract_get_behavior_assumes
    ((__e_acsl_contract_t const *)__gen_e_acsl_contract,1UL);
    if (__gen_e_acsl_assumes_value) {
      __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,"\\result",
                                   (void *)__retres);
      __e_acsl_assert_register_ptr(& __gen_e_acsl_assert_data_3,"\\old(l)",
                                   (void *)__gen_e_acsl_at);
      __gen_e_acsl_assert_data_3.blocking = 1;
      __gen_e_acsl_assert_data_3.kind = "Postcondition";
      __gen_e_acsl_assert_data_3.pred_txt = "\\result == \\old(l)";
      __gen_e_acsl_assert_data_3.file = "valid_in_contract.c";
      __gen_e_acsl_assert_data_3.fct = "f";
      __gen_e_acsl_assert_data_3.line = 18;
      __gen_e_acsl_assert_data_3.name = "B2";
      __e_acsl_assert(__retres == __gen_e_acsl_at,
                      & __gen_e_acsl_assert_data_3);
      __e_acsl_assert_clean(& __gen_e_acsl_assert_data_3);
    }
    __e_acsl_contract_clean(__gen_e_acsl_contract);
    __e_acsl_delete_block((void *)(& l));
    __e_acsl_delete_block((void *)(& __retres));
    return __retres;
  }
}


