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

/*@ requires valid_string_s: valid_read_string(s);
    ensures acsl_c_equiv: \result ≡ strlen(\old(s));
    assigns \result;
    assigns \result \from (indirect: *(s + (0 ..)));
 */
size_t __gen_e_acsl_strlen(char const *s);

/*@ requires \valid(&argc);
    requires \valid(&argv); */
int main(int argc, char **argv);

int __gen_e_acsl_main(int argc, char **argv)
{
  int __retres;
  int i;
  {
    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,"Assertion","main",
                    "\\forall int k; 0 <= k < argc ==> \\valid(argv + k)",
                    "tests/memory/mainargs.c",12);
  }
  /*@ assert ∀ int k; 0 ≤ k < argc ⇒ \valid(argv + k); */ ;
  {
    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,"Assertion","main",
                    "\\block_length(argv) == (argc + 1) * sizeof(char *)",
                    "tests/memory/mainargs.c",13);
    __gmpz_clear(__gen_e_acsl_block_length_2);
    __gmpz_clear(__gen_e_acsl_);
  }
  /*@ assert \block_length(argv) ≡ (argc + 1) * sizeof(char *); */ ;
  {
    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,"RTE","main",
                    "mem_access: \\valid_read(argv + argc)",
                    "tests/memory/mainargs.c",15);
    /*@ assert Eva: mem_access: \valid_read(argv + argc); */
    __e_acsl_assert(*(argv + argc) == (char *)0,"Assertion","main",
                    "*(argv + argc) == \\null","tests/memory/mainargs.c",15);
  }
  /*@ assert *(argv + argc) ≡ \null; */ ;
  {
    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,"RTE","main",
                      "mem_access: \\valid_read(argv + argc)",
                      "tests/memory/mainargs.c",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,"Assertion","main",
                    "!\\valid(*(argv + argc))","tests/memory/mainargs.c",16);
  }
  /*@ assert ¬\valid(*(argv + argc)); */ ;
  i = 0;
  while (i < argc) {
    {
      size_t tmp;
      tmp = __gen_e_acsl_strlen((char const *)*(argv + i));
      int len = (int)tmp;
      {
        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,"RTE","main",
                          "mem_access: \\valid_read(argv + i)",
                          "tests/memory/mainargs.c",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,"Assertion","main",
                        "\\valid(*(argv + i))","tests/memory/mainargs.c",19);
      }
      /*@ assert \valid(*(argv + i)); */ ;
      {
        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,"RTE","main",
                            "mem_access: \\valid_read(argv + i)",
                            "tests/memory/mainargs.c",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,"Assertion","main",
                        "\\forall int k; 0 <= k <= len ==> \\valid(*(argv + i) + k)",
                        "tests/memory/mainargs.c",20);
      }
      /*@ assert ∀ int k; 0 ≤ k ≤ len ⇒ \valid(*(argv + i) + k); */ ;
    }
    i ++;
  }
  __retres = 0;
  __e_acsl_delete_block((void *)(& argv));
  return __retres;
}

/*@ requires \valid(&argc);
    requires \valid(&argv); */
int main(int argc, char **argv)
{
  int __retres;
  __e_acsl_memory_init(& argc,& argv,(size_t)8);
  {
    int __gen_e_acsl_valid;
    int __gen_e_acsl_valid_2;
    __gen_e_acsl_valid = __e_acsl_valid((void *)(& argc),sizeof(int),
                                        (void *)(& argc),(void *)0);
    __e_acsl_assert(__gen_e_acsl_valid,"Precondition","main",
                    "\\valid(&argc)","tests/memory/mainargs.c",7);
    __gen_e_acsl_valid_2 = __e_acsl_valid((void *)(& argv),sizeof(char **),
                                          (void *)(& argv),(void *)0);
    __e_acsl_assert(__gen_e_acsl_valid_2,"Precondition","main",
                    "\\valid(&argv)","tests/memory/mainargs.c",8);
  }
  __retres = __gen_e_acsl_main(argc,argv);
  __e_acsl_delete_block((void *)(& argv));
  __e_acsl_memory_clean();
  return __retres;
}

/*@ requires valid_string_s: valid_read_string(s);
    ensures acsl_c_equiv: \result ≡ strlen(\old(s));
    assigns \result;
    assigns \result \from (indirect: *(s + (0 ..)));
 */
size_t __gen_e_acsl_strlen(char const *s)
{
  size_t __retres;
  __e_acsl_store_block((void *)(& s),(size_t)8);
  __retres = strlen(s);
  __e_acsl_delete_block((void *)(& s));
  return __retres;
}


