@@ -524,6 +524,49 @@ then it performs 'linking' of the temporary into a passed destination
524
524
Details about linking of ` ::goto_modelt ` instances can be found
525
525
[ here] (\ref section-linking-goto-models).
526
526
527
+ \subsection subsection-goto-function-example Example goto-program
528
+
529
+ The following C program, in a file named ` mult.c ` :
530
+
531
+ ```
532
+ unsigned mult(unsigned a, unsigned b)
533
+ {
534
+ int acc, i;
535
+ for (i = 0; i < b; i++)
536
+ acc += a;
537
+ return acc;
538
+ }
539
+ ```
540
+
541
+ is translated by ` cbmc --show-goto-functions mult.c ` into:
542
+
543
+ ```
544
+ mult /* mult */
545
+ // 0 file third.c line 2 function mult
546
+ signed int acc;
547
+ // 1 file third.c line 2 function mult
548
+ signed int i;
549
+ // 2 file third.c line 3 function mult
550
+ i = 0;
551
+ // 3 file third.c line 3 function mult
552
+ 1: IF !((unsigned int)i < b) THEN GOTO 2
553
+ // 4 file third.c line 4 function mult
554
+ acc = (signed int)((unsigned int)acc + a);
555
+ // 5 file third.c line 3 function mult
556
+ i = i + 1;
557
+ // 6 file third.c line 3 function mult
558
+ GOTO 1
559
+ // 7 file third.c line 5 function mult
560
+ 2: mult#return_value = (unsigned int)acc;
561
+ // 8 file third.c line 5 function mult
562
+ dead i;
563
+ // 9 file third.c line 5 function mult
564
+ dead acc;
565
+ // 10 file third.c line 6 function mult
566
+ END_FUNCTION
567
+ ```
568
+
569
+ (The above result was produced using ` cbmc version 5.11 ` )
527
570
528
571
\section section-linking-goto-models Linking Goto Models
529
572
0 commit comments