-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreadwrite.v
400 lines (390 loc) · 17.4 KB
/
readwrite.v
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
Require Import Clightdefs.
Local Open Scope Z_scope.
Definition ___builtin_fmin : ident := 40%positive.
Definition ___i64_sar : ident := 32%positive.
Definition ___compcert_va_int32 : ident := 16%positive.
Definition ___builtin_fsqrt : ident := 38%positive.
Definition ___builtin_read32_reversed : ident := 46%positive.
Definition _ten : ident := 54%positive.
Definition ___i64_stof : ident := 24%positive.
Definition ___i64_stod : ident := 22%positive.
Definition ___compcert_va_int64 : ident := 17%positive.
Definition ___builtin_memcpy_aligned : ident := 8%positive.
Definition ___builtin_subl : ident := 5%positive.
Definition _temp : ident := 50%positive.
Definition ___builtin_fnmadd : ident := 43%positive.
Definition ___builtin_va_start : ident := 12%positive.
Definition _second_test : ident := 53%positive.
Definition _printf : ident := 47%positive.
Definition ___builtin_annot_intval : ident := 10%positive.
Definition ___builtin_fnmsub : ident := 44%positive.
Definition ___builtin_negl : ident := 3%positive.
Definition ___builtin_write32_reversed : ident := 2%positive.
Definition ___builtin_write16_reversed : ident := 1%positive.
Definition ___builtin_clz : ident := 36%positive.
Definition ___i64_shr : ident := 31%positive.
Definition ___builtin_va_copy : ident := 14%positive.
Definition ___builtin_mull : ident := 6%positive.
Definition ___i64_sdiv : ident := 26%positive.
Definition ___compcert_va_composite : ident := 19%positive.
Definition ___builtin_fmax : ident := 39%positive.
Definition ___builtin_membar : ident := 11%positive.
Definition _i : ident := 49%positive.
Definition ___builtin_ctz : ident := 37%positive.
Definition ___builtin_addl : ident := 4%positive.
Definition ___i64_smod : ident := 28%positive.
Definition ___builtin_fabs : ident := 7%positive.
Definition ___builtin_fmsub : ident := 42%positive.
Definition ___i64_dtou : ident := 21%positive.
Definition ___compcert_va_float64 : ident := 18%positive.
Definition ___builtin_annot : ident := 9%positive.
Definition _j : ident := 52%positive.
Definition ___builtin_read16_reversed : ident := 45%positive.
Definition ___builtin_fmadd : ident := 41%positive.
Definition ___builtin_va_arg : ident := 13%positive.
Definition ___i64_udiv : ident := 27%positive.
Definition ___builtin_bswap : ident := 33%positive.
Definition _main : ident := 56%positive.
Definition ___i64_utof : ident := 25%positive.
Definition ___builtin_va_end : ident := 15%positive.
Definition ___builtin_bswap32 : ident := 34%positive.
Definition ___i64_umod : ident := 29%positive.
Definition ___stringlit_1 : ident := 55%positive.
Definition ___builtin_bswap16 : ident := 35%positive.
Definition ___i64_shl : ident := 30%positive.
Definition ___i64_utod : ident := 23%positive.
Definition _first_test : ident := 51%positive.
Definition _a : ident := 48%positive.
Definition ___i64_dtos : ident := 20%positive.
Definition v___stringlit_1 := {|
gvar_info := (tarray tschar 5);
gvar_init := (Init_int8 (Int.repr 37) :: Init_int8 (Int.repr 100) ::
Init_int8 (Int.repr 32) :: Init_int8 (Int.repr 10) ::
Init_int8 (Int.repr 0) :: nil);
gvar_readonly := true;
gvar_volatile := false
|}.
Definition f_first_test := {|
fn_return := tint;
fn_callconv := cc_default;
fn_params := ((_a, (tptr tint)) :: (_i, tint) :: nil);
fn_vars := nil;
fn_temps := ((_temp, tint) :: nil);
fn_body :=
(Ssequence
(Sassign
(Ederef
(Ebinop Oadd (Etempvar _a (tptr tint)) (Etempvar _i tint) (tptr tint))
tint) (Econst_int (Int.repr 1) tint))
(Ssequence
(Sset _temp
(Ederef
(Ebinop Oadd (Etempvar _a (tptr tint)) (Etempvar _i tint)
(tptr tint)) tint))
(Sreturn (Some (Etempvar _temp tint)))))
|}.
Definition f_second_test := {|
fn_return := tint;
fn_callconv := cc_default;
fn_params := ((_a, (tptr tint)) :: (_i, tint) :: nil);
fn_vars := nil;
fn_temps := ((_j, tint) :: (_temp, tint) :: nil);
fn_body :=
(Ssequence
(Sset _j (Econst_int (Int.repr 0) tint))
(Ssequence
(Swhile
(Ebinop Ole (Etempvar _j tint) (Etempvar _i tint) tint)
(Ssequence
(Sassign
(Ederef
(Ebinop Oadd (Etempvar _a (tptr tint)) (Etempvar _j tint)
(tptr tint)) tint) (Econst_int (Int.repr 1) tint))
(Sset _j
(Ebinop Oadd (Etempvar _j tint) (Econst_int (Int.repr 1) tint)
tint))))
(Ssequence
(Sset _temp
(Ederef
(Ebinop Oadd (Etempvar _a (tptr tint)) (Etempvar _i tint)
(tptr tint)) tint))
(Sreturn (Some (Etempvar _temp tint))))))
|}.
Definition v_ten := {|
gvar_info := (tarray tint 10);
gvar_init := (Init_int32 (Int.repr 1) :: Init_int32 (Int.repr 2) ::
Init_int32 (Int.repr 3) :: Init_int32 (Int.repr 4) ::
Init_int32 (Int.repr 5) :: Init_int32 (Int.repr 6) ::
Init_int32 (Int.repr 7) :: Init_int32 (Int.repr 8) ::
Init_int32 (Int.repr 9) :: Init_int32 (Int.repr 0) :: nil);
gvar_readonly := false;
gvar_volatile := false
|}.
Definition f_main := {|
fn_return := tint;
fn_callconv := cc_default;
fn_params := nil;
fn_vars := nil;
fn_temps := ((58%positive, tint) :: (57%positive, tint) :: nil);
fn_body :=
(Ssequence
(Ssequence
(Scall (Some 57%positive)
(Evar _first_test (Tfunction (Tcons (tptr tint) (Tcons tint Tnil)) tint
cc_default))
((Evar _ten (tarray tint 10)) :: (Econst_int (Int.repr 2) tint) :: nil))
(Scall None
(Evar _printf (Tfunction (Tcons (tptr tschar) Tnil) tint
{|cc_vararg:=true; cc_unproto:=false; cc_structret:=false|}))
((Evar ___stringlit_1 (tarray tschar 5)) ::
(Etempvar 57%positive tint) :: nil)))
(Ssequence
(Ssequence
(Scall (Some 58%positive)
(Evar _second_test (Tfunction (Tcons (tptr tint) (Tcons tint Tnil))
tint cc_default))
((Evar _ten (tarray tint 10)) :: (Econst_int (Int.repr 5) tint) ::
nil))
(Scall None
(Evar _printf (Tfunction (Tcons (tptr tschar) Tnil) tint
{|cc_vararg:=true; cc_unproto:=false; cc_structret:=false|}))
((Evar ___stringlit_1 (tarray tschar 5)) ::
(Etempvar 58%positive tint) :: nil)))
(Sreturn (Some (Econst_int (Int.repr 0) tint)))))
|}.
Definition composites : list composite_definition :=
nil.
Definition prog : Clight.program := {|
prog_defs :=
((___stringlit_1, Gvar v___stringlit_1) ::
(___builtin_fabs,
Gfun(External (EF_builtin ___builtin_fabs
(mksignature (AST.Tfloat :: nil) (Some AST.Tfloat)
cc_default)) (Tcons tdouble Tnil) tdouble cc_default)) ::
(___builtin_memcpy_aligned,
Gfun(External (EF_builtin ___builtin_memcpy_aligned
(mksignature
(AST.Tint :: AST.Tint :: AST.Tint :: AST.Tint :: nil)
None cc_default))
(Tcons (tptr tvoid)
(Tcons (tptr tvoid) (Tcons tuint (Tcons tuint Tnil)))) tvoid
cc_default)) ::
(___builtin_annot,
Gfun(External (EF_builtin ___builtin_annot
(mksignature (AST.Tint :: nil) None
{|cc_vararg:=true; cc_unproto:=false; cc_structret:=false|}))
(Tcons (tptr tschar) Tnil) tvoid
{|cc_vararg:=true; cc_unproto:=false; cc_structret:=false|})) ::
(___builtin_annot_intval,
Gfun(External (EF_builtin ___builtin_annot_intval
(mksignature (AST.Tint :: AST.Tint :: nil) (Some AST.Tint)
cc_default)) (Tcons (tptr tschar) (Tcons tint Tnil))
tint cc_default)) ::
(___builtin_membar,
Gfun(External (EF_builtin ___builtin_membar
(mksignature nil None cc_default)) Tnil tvoid cc_default)) ::
(___builtin_va_start,
Gfun(External (EF_builtin ___builtin_va_start
(mksignature (AST.Tint :: nil) None cc_default))
(Tcons (tptr tvoid) Tnil) tvoid cc_default)) ::
(___builtin_va_arg,
Gfun(External (EF_builtin ___builtin_va_arg
(mksignature (AST.Tint :: AST.Tint :: nil) None
cc_default)) (Tcons (tptr tvoid) (Tcons tuint Tnil))
tvoid cc_default)) ::
(___builtin_va_copy,
Gfun(External (EF_builtin ___builtin_va_copy
(mksignature (AST.Tint :: AST.Tint :: nil) None
cc_default))
(Tcons (tptr tvoid) (Tcons (tptr tvoid) Tnil)) tvoid cc_default)) ::
(___builtin_va_end,
Gfun(External (EF_builtin ___builtin_va_end
(mksignature (AST.Tint :: nil) None cc_default))
(Tcons (tptr tvoid) Tnil) tvoid cc_default)) ::
(___compcert_va_int32,
Gfun(External (EF_external ___compcert_va_int32
(mksignature (AST.Tint :: nil) (Some AST.Tint) cc_default))
(Tcons (tptr tvoid) Tnil) tuint cc_default)) ::
(___compcert_va_int64,
Gfun(External (EF_external ___compcert_va_int64
(mksignature (AST.Tint :: nil) (Some AST.Tlong)
cc_default)) (Tcons (tptr tvoid) Tnil) tulong
cc_default)) ::
(___compcert_va_float64,
Gfun(External (EF_external ___compcert_va_float64
(mksignature (AST.Tint :: nil) (Some AST.Tfloat)
cc_default)) (Tcons (tptr tvoid) Tnil) tdouble
cc_default)) ::
(___compcert_va_composite,
Gfun(External (EF_external ___compcert_va_composite
(mksignature (AST.Tint :: AST.Tint :: nil) (Some AST.Tint)
cc_default)) (Tcons (tptr tvoid) (Tcons tuint Tnil))
(tptr tvoid) cc_default)) ::
(___i64_dtos,
Gfun(External (EF_external ___i64_dtos
(mksignature (AST.Tfloat :: nil) (Some AST.Tlong)
cc_default)) (Tcons tdouble Tnil) tlong cc_default)) ::
(___i64_dtou,
Gfun(External (EF_external ___i64_dtou
(mksignature (AST.Tfloat :: nil) (Some AST.Tlong)
cc_default)) (Tcons tdouble Tnil) tulong cc_default)) ::
(___i64_stod,
Gfun(External (EF_external ___i64_stod
(mksignature (AST.Tlong :: nil) (Some AST.Tfloat)
cc_default)) (Tcons tlong Tnil) tdouble cc_default)) ::
(___i64_utod,
Gfun(External (EF_external ___i64_utod
(mksignature (AST.Tlong :: nil) (Some AST.Tfloat)
cc_default)) (Tcons tulong Tnil) tdouble cc_default)) ::
(___i64_stof,
Gfun(External (EF_external ___i64_stof
(mksignature (AST.Tlong :: nil) (Some AST.Tsingle)
cc_default)) (Tcons tlong Tnil) tfloat cc_default)) ::
(___i64_utof,
Gfun(External (EF_external ___i64_utof
(mksignature (AST.Tlong :: nil) (Some AST.Tsingle)
cc_default)) (Tcons tulong Tnil) tfloat cc_default)) ::
(___i64_sdiv,
Gfun(External (EF_external ___i64_sdiv
(mksignature (AST.Tlong :: AST.Tlong :: nil)
(Some AST.Tlong) cc_default))
(Tcons tlong (Tcons tlong Tnil)) tlong cc_default)) ::
(___i64_udiv,
Gfun(External (EF_external ___i64_udiv
(mksignature (AST.Tlong :: AST.Tlong :: nil)
(Some AST.Tlong) cc_default))
(Tcons tulong (Tcons tulong Tnil)) tulong cc_default)) ::
(___i64_smod,
Gfun(External (EF_external ___i64_smod
(mksignature (AST.Tlong :: AST.Tlong :: nil)
(Some AST.Tlong) cc_default))
(Tcons tlong (Tcons tlong Tnil)) tlong cc_default)) ::
(___i64_umod,
Gfun(External (EF_external ___i64_umod
(mksignature (AST.Tlong :: AST.Tlong :: nil)
(Some AST.Tlong) cc_default))
(Tcons tulong (Tcons tulong Tnil)) tulong cc_default)) ::
(___i64_shl,
Gfun(External (EF_external ___i64_shl
(mksignature (AST.Tlong :: AST.Tint :: nil)
(Some AST.Tlong) cc_default))
(Tcons tlong (Tcons tint Tnil)) tlong cc_default)) ::
(___i64_shr,
Gfun(External (EF_external ___i64_shr
(mksignature (AST.Tlong :: AST.Tint :: nil)
(Some AST.Tlong) cc_default))
(Tcons tulong (Tcons tint Tnil)) tulong cc_default)) ::
(___i64_sar,
Gfun(External (EF_external ___i64_sar
(mksignature (AST.Tlong :: AST.Tint :: nil)
(Some AST.Tlong) cc_default))
(Tcons tlong (Tcons tint Tnil)) tlong cc_default)) ::
(___builtin_bswap,
Gfun(External (EF_builtin ___builtin_bswap
(mksignature (AST.Tint :: nil) (Some AST.Tint) cc_default))
(Tcons tuint Tnil) tuint cc_default)) ::
(___builtin_bswap32,
Gfun(External (EF_builtin ___builtin_bswap32
(mksignature (AST.Tint :: nil) (Some AST.Tint) cc_default))
(Tcons tuint Tnil) tuint cc_default)) ::
(___builtin_bswap16,
Gfun(External (EF_builtin ___builtin_bswap16
(mksignature (AST.Tint :: nil) (Some AST.Tint) cc_default))
(Tcons tushort Tnil) tushort cc_default)) ::
(___builtin_clz,
Gfun(External (EF_builtin ___builtin_clz
(mksignature (AST.Tint :: nil) (Some AST.Tint) cc_default))
(Tcons tuint Tnil) tuint cc_default)) ::
(___builtin_ctz,
Gfun(External (EF_builtin ___builtin_ctz
(mksignature (AST.Tint :: nil) (Some AST.Tint) cc_default))
(Tcons tuint Tnil) tuint cc_default)) ::
(___builtin_fsqrt,
Gfun(External (EF_builtin ___builtin_fsqrt
(mksignature (AST.Tfloat :: nil) (Some AST.Tfloat)
cc_default)) (Tcons tdouble Tnil) tdouble cc_default)) ::
(___builtin_fmax,
Gfun(External (EF_builtin ___builtin_fmax
(mksignature (AST.Tfloat :: AST.Tfloat :: nil)
(Some AST.Tfloat) cc_default))
(Tcons tdouble (Tcons tdouble Tnil)) tdouble cc_default)) ::
(___builtin_fmin,
Gfun(External (EF_builtin ___builtin_fmin
(mksignature (AST.Tfloat :: AST.Tfloat :: nil)
(Some AST.Tfloat) cc_default))
(Tcons tdouble (Tcons tdouble Tnil)) tdouble cc_default)) ::
(___builtin_fmadd,
Gfun(External (EF_builtin ___builtin_fmadd
(mksignature
(AST.Tfloat :: AST.Tfloat :: AST.Tfloat :: nil)
(Some AST.Tfloat) cc_default))
(Tcons tdouble (Tcons tdouble (Tcons tdouble Tnil))) tdouble
cc_default)) ::
(___builtin_fmsub,
Gfun(External (EF_builtin ___builtin_fmsub
(mksignature
(AST.Tfloat :: AST.Tfloat :: AST.Tfloat :: nil)
(Some AST.Tfloat) cc_default))
(Tcons tdouble (Tcons tdouble (Tcons tdouble Tnil))) tdouble
cc_default)) ::
(___builtin_fnmadd,
Gfun(External (EF_builtin ___builtin_fnmadd
(mksignature
(AST.Tfloat :: AST.Tfloat :: AST.Tfloat :: nil)
(Some AST.Tfloat) cc_default))
(Tcons tdouble (Tcons tdouble (Tcons tdouble Tnil))) tdouble
cc_default)) ::
(___builtin_fnmsub,
Gfun(External (EF_builtin ___builtin_fnmsub
(mksignature
(AST.Tfloat :: AST.Tfloat :: AST.Tfloat :: nil)
(Some AST.Tfloat) cc_default))
(Tcons tdouble (Tcons tdouble (Tcons tdouble Tnil))) tdouble
cc_default)) ::
(___builtin_read16_reversed,
Gfun(External (EF_builtin ___builtin_read16_reversed
(mksignature (AST.Tint :: nil) (Some AST.Tint) cc_default))
(Tcons (tptr tushort) Tnil) tushort cc_default)) ::
(___builtin_read32_reversed,
Gfun(External (EF_builtin ___builtin_read32_reversed
(mksignature (AST.Tint :: nil) (Some AST.Tint) cc_default))
(Tcons (tptr tuint) Tnil) tuint cc_default)) ::
(___builtin_write16_reversed,
Gfun(External (EF_builtin ___builtin_write16_reversed
(mksignature (AST.Tint :: AST.Tint :: nil) None
cc_default)) (Tcons (tptr tushort) (Tcons tushort Tnil))
tvoid cc_default)) ::
(___builtin_write32_reversed,
Gfun(External (EF_builtin ___builtin_write32_reversed
(mksignature (AST.Tint :: AST.Tint :: nil) None
cc_default)) (Tcons (tptr tuint) (Tcons tuint Tnil))
tvoid cc_default)) ::
(_printf,
Gfun(External (EF_external _printf
(mksignature (AST.Tint :: nil) (Some AST.Tint)
{|cc_vararg:=true; cc_unproto:=false; cc_structret:=false|}))
(Tcons (tptr tschar) Tnil) tint
{|cc_vararg:=true; cc_unproto:=false; cc_structret:=false|})) ::
(_first_test, Gfun(Internal f_first_test)) ::
(_second_test, Gfun(Internal f_second_test)) :: (_ten, Gvar v_ten) ::
(_main, Gfun(Internal f_main)) :: nil);
prog_public :=
(_main :: _ten :: _second_test :: _first_test :: _printf ::
___builtin_write32_reversed :: ___builtin_write16_reversed ::
___builtin_read32_reversed :: ___builtin_read16_reversed ::
___builtin_fnmsub :: ___builtin_fnmadd :: ___builtin_fmsub ::
___builtin_fmadd :: ___builtin_fmin :: ___builtin_fmax ::
___builtin_fsqrt :: ___builtin_ctz :: ___builtin_clz ::
___builtin_bswap16 :: ___builtin_bswap32 :: ___builtin_bswap ::
___i64_sar :: ___i64_shr :: ___i64_shl :: ___i64_umod :: ___i64_smod ::
___i64_udiv :: ___i64_sdiv :: ___i64_utof :: ___i64_stof :: ___i64_utod ::
___i64_stod :: ___i64_dtou :: ___i64_dtos :: ___compcert_va_composite ::
___compcert_va_float64 :: ___compcert_va_int64 :: ___compcert_va_int32 ::
___builtin_va_end :: ___builtin_va_copy :: ___builtin_va_arg ::
___builtin_va_start :: ___builtin_membar :: ___builtin_annot_intval ::
___builtin_annot :: ___builtin_memcpy_aligned :: ___builtin_fabs :: nil);
prog_main := _main;
prog_types := composites;
prog_comp_env := make_composite_env composites;
prog_comp_env_eq := refl_equal _
|}.