/* Generated by Frama-C */
#include "stddef.h"
#include "stdio.h"
extern int __e_acsl_sound_verdict;

/*@ behavior yes:
      assumes ∀ int i; 0 < i < n ⇒ *(t + (i - 1)) ≤ *(t + i);
      ensures \result ≡ 1;
 */
int __gen_e_acsl_sorted(int *t, int n);

int sorted(int *t, int n)
{
  int __retres;
  int b = 1;
  if (n <= 1) {
    __retres = 1;
    goto return_label;
  }
  b = 1;
  while (b < n) {
    if (*(t + (b - 1)) > *(t + b)) {
      __retres = 0;
      goto return_label;
    }
    b ++;
  }
  __retres = 1;
  return_label: return __retres;
}

int main(void)
{
  int __retres;
  __e_acsl_memory_init((int *)0,(char ***)0,(size_t)8);
  int t[7] = {1, 4, 4, 5, 5, 5, 7};
  __e_acsl_store_block((void *)(t),(size_t)28);
  __e_acsl_full_init((void *)(& t));
  int n = __gen_e_acsl_sorted(t,7);
  __e_acsl_assert(n == 1,"Assertion","main","n == 1","tests/bts/bts1324.i",
                  23);
  /*@ assert n ≡ 1; */ ;
  __retres = 0;
  __e_acsl_delete_block((void *)(t));
  __e_acsl_memory_clean();
  return __retres;
}

/*@ behavior yes:
      assumes ∀ int i; 0 < i < n ⇒ *(t + (i - 1)) ≤ *(t + i);
      ensures \result ≡ 1;
 */
int __gen_e_acsl_sorted(int *t, int n)
{
  __e_acsl_contract_t *__gen_e_acsl_contract;
  int __retres;
  {
    int __gen_e_acsl_forall;
    int __gen_e_acsl_i;
    __e_acsl_store_block((void *)(& t),(size_t)8);
    __gen_e_acsl_contract = __e_acsl_contract_init((size_t)1);
    __gen_e_acsl_forall = 1;
    __gen_e_acsl_i = 0 + 1;
    while (1) {
      if (__gen_e_acsl_i < n) ; else break;
      {
        int __gen_e_acsl_valid_read;
        int __gen_e_acsl_valid_read_2;
        __gen_e_acsl_valid_read = __e_acsl_valid_read((void *)(t + __gen_e_acsl_i),
                                                      sizeof(int),(void *)t,
                                                      (void *)(& t));
        __e_acsl_assert(__gen_e_acsl_valid_read,"RTE","sorted",
                        "mem_access: \\valid_read(t + __gen_e_acsl_i)",
                        "tests/bts/bts1324.i",6);
        __gen_e_acsl_valid_read_2 = __e_acsl_valid_read((void *)(t + (
                                                                 __gen_e_acsl_i - 1L)),
                                                        sizeof(int),
                                                        (void *)t,
                                                        (void *)(& t));
        __e_acsl_assert(__gen_e_acsl_valid_read_2,"RTE","sorted",
                        "mem_access: \\valid_read(t + (long)(__gen_e_acsl_i - 1))",
                        "tests/bts/bts1324.i",6);
        if (*(t + (__gen_e_acsl_i - 1L)) <= *(t + __gen_e_acsl_i)) ;
        else {
          __gen_e_acsl_forall = 0;
          goto e_acsl_end_loop1;
        }
      }
      __gen_e_acsl_i ++;
    }
    e_acsl_end_loop1: ;
    __e_acsl_contract_set_behavior_assumes(__gen_e_acsl_contract,(size_t)0,
                                           __gen_e_acsl_forall);
  }
  __retres = sorted(t,n);
  {
    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,(size_t)0);
    if (__gen_e_acsl_assumes_value) __e_acsl_assert(__retres == 1,
                                                    "Postcondition","sorted",
                                                    "yes: \\result == 1",
                                                    "tests/bts/bts1324.i",7);
    __e_acsl_contract_clean(__gen_e_acsl_contract);
    __e_acsl_delete_block((void *)(& t));
    return __retres;
  }
}


