@@ -298,6 +298,50 @@ In converting to a GOTO program this structure is changed in several ways:
298
298
instruction. Each goto_programt should have precisely one such
299
299
instruction.
300
300
301
+ \subsection subsection-goto-function-example Example goto-program
302
+
303
+ The following C program, in a file named ` mult.c ` :
304
+
305
+ ```
306
+ unsigned mult(unsigned a, unsigned b)
307
+ {
308
+ int acc = 0, i;
309
+ for (i = 0; i < b; i++)
310
+ acc += a;
311
+ return acc;
312
+ }
313
+ ```
314
+
315
+ is translated by ` cbmc --show-goto-functions mult.c ` into:
316
+
317
+ ```
318
+ mult /* mult */
319
+ // 0 file third.c line 2 function mult
320
+ signed int acc;
321
+ // 1 file third.c line 2 function mult
322
+ acc = 0;
323
+ // 2 file third.c line 2 function mult
324
+ signed int i;
325
+ // 3 file third.c line 3 function mult
326
+ i = 0;
327
+ // 4 file third.c line 3 function mult
328
+ 1: IF !((unsigned int)i < b) THEN GOTO 2
329
+ // 5 file third.c line 4 function mult
330
+ acc = (signed int)((unsigned int)acc + a);
331
+ // 6 file third.c line 3 function mult
332
+ i = i + 1;
333
+ // 7 file third.c line 3 function mult
334
+ GOTO 1
335
+ // 8 file third.c line 5 function mult
336
+ 2: mult#return_value = (unsigned int)acc;
337
+ // 9 file third.c line 5 function mult
338
+ dead i;
339
+ // 10 file third.c line 5 function mult
340
+ dead acc;
341
+ // 11 file third.c line 6 function mult
342
+ END_FUNCTION
343
+ ```
344
+
301
345
\section section-goto-transforms Subsequent Transformation
302
346
303
347
It is normal for a program that calls ` goto_convert ` to immediately pass the
@@ -524,6 +568,7 @@ then it performs 'linking' of the temporary into a passed destination
524
568
Details about linking of ` ::goto_modelt ` instances can be found
525
569
[ here] (\ref section-linking-goto-models).
526
570
571
+ (The above result was produced using ` cbmc version 5.11 ` )
527
572
528
573
\section section-linking-goto-models Linking Goto Models
529
574
0 commit comments