[kernel] Parsing share/libc/__fc_builtin_for_normalization.i (no preprocessing)
[kernel] Parsing tests/spec/max.c (with preprocessing)
tests/spec/max.c:16:[kernel] warning: parsing obsolete ACSL construct '\valid_range(addr,min,max)'. '\valid(addr+(min..max))' should be used instead.
tests/spec/max.c:46:[kernel] warning: parsing obsolete ACSL construct '\valid_range(addr,min,max)'. '\valid(addr+(min..max))' should be used instead.
/* Generated by Frama-C */
/*@
axiomatic IsMax {
  predicate is_max{L}(ℤ max, int t[], ℤ length) ;
  
  axiom max_gt{L}:
    ∀ int t[], ℤ max, ℤ length, ℤ i;
      is_max{L}(max, t, length) ⇒ 0 ≤ i < length ⇒ t[i] ≤ max;
  
  axiom max_eq{L}:
    ∀ int t[], ℤ max, ℤ length;
      is_max{L}(max, t, length) ⇒ (∃ ℤ i; t[i] ≡ max);
  
  }
 */
/*@ requires \valid(t+(0 .. n-1));
    
    behavior nonempty:
      assumes n > 0;
      ensures
        0 ≤ \result < \old(n) ∧
        (∀ int i; 0 ≤ i < \old(n) ⇒ *(\old(t)+\result) ≥ *(\old(t)+i)) ∧
        is_max(*(\old(t)+\result), (int [])\old(t), \old(n));
    
    behavior empty:
      assumes n ≤ 0;
      ensures \result ≡ -1;
 */
int max(int *t, int n)
{
  int __retres;
  int imax;
  int i;
  /*@ ghost int max_0; */
  imax = 0;
  if (n <= 0) {
    __retres = -1;
    goto return_label;
  }
  /*@ ghost max_0 = *(t + 0); */
  i = 1;
  /*@ loop invariant
        (∀ int j; 0 ≤ j < i ⇒ *(t+imax) ≥ *(t+j)) ∧
        is_max(max_0, (int [])t, i-1);
  */
  while (i < n) {
    if (*(t + i) > *(t + imax)) {
      imax = i;
      /*@ ghost max_0 = *(t + i); */
    }
    i ++;
  }
  __retres = imax;
  return_label: return __retres;
}

int main(void)
{
  int __retres;
  int test[10];
  int x;
  test[0] = 1;
  test[1] = 2;
  test[2] = 3;
  test[3] = 4;
  test[4] = 9;
  test[5] = 8;
  test[6] = 7;
  test[7] = 6;
  test[8] = 5;
  test[9] = 10;
  /*@ assert \valid(&test[0 .. 9]); */ ;
  x = max(test,10);
  /*@ assert test[x] ≥ 10; */ ;
  __retres = 0;
  return __retres;
}


