File: recol.c

package info (click to toggle)
frama-c 20161101%2Bsilicon%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 42,324 kB
  • ctags: 35,695
  • sloc: ml: 200,142; ansic: 31,465; makefile: 2,334; sh: 1,643; lisp: 259; python: 85; asm: 26
file content (58 lines) | stat: -rw-r--r-- 1,140 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* run.config*
   OPT: -val @VALUECONFIG@ -slevel 100 -cpp-extra-args="-DPTEST " -journal-disable -no-warn-signed-overflow
   OPT: -val @VALUECONFIG@ -slevel 100 -cpp-extra-args="-DPTEST " -journal-disable -machdep ppc_32 -no-warn-signed-overflow
*/

#ifndef PTEST
#include <stdio.h>
#endif

#define S 100

char s[S];
int c=0;
int s_int;
int *p_int;
char ones[]="11111111"; 
char one23[]="1223";
int col_ones;
int col_123;

int main(void)
{
  char *p = s;

  col_ones = 1 + * (int*) ones;
  col_123 = 1 + * (int*) one23;

  while (p <= s+S-sizeof(int))
    {
      c = 7 * c + 97;
      if (c % 3 == 0)
	*p++ = c;
      else if (c % 3 == 1)
      	{
	  *(short*)p = c;
	  p += sizeof(short);
	}
      else
      	{
	  *(int*)p = c;
	  p += sizeof(int);
	}
    }

  for (p_int = (int*) s; p_int < (int*)(s+S); p_int++)
    {
      s_int = 11 * s_int + *p_int;
    }

#ifndef PTEST
  printf("s_int: %d  col_ones: %d col_123:%d\n", s_int, col_ones, col_123);
#endif
  /* rsultat attendu, avec int 32-bits :
     little endian: s_int = -833811464
     big_endian :  s_int: -1480071902  col_ones: 825307442 col_123:825373236
  */
  return 0;
}