#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int rec_inc(int, int);
int fun() {
  int i;
  int v1;
  int v2 = 13;
  int v3 = 7;
  int v4 = 5;
  int v5 = 2;
  printf("REC CALL START\n");
  v1 = rec_inc(42, 100);
  printf("REC CALL END\n");
  printf("FOR LOOP START\n");
  for (i = 0; i < 100; i++) {
    v2 = v2 + 1;
  }
  printf("FOR LOOP END\n");
  printf("WHILE LOOP START\n");
  i = 0;
  while (i < 100) {
    v3 = v3 + 1;
    i++;
  }
  printf("WHILE LOOP END\n");
  printf("DO WHILE LOOP START\n");
  i = 0;
  do {
    v4 = v4 + 1;
    i++;
  } while (i < 100);
  printf("DO WHILE LOOP END\n");
  printf("GOTO START\n");
  i = 0;
my_label:
  v5 = v5 + 1;
  i++;
  if (i < 100)
    goto my_label;
  printf("GOTO END\n");
  return v1 + v2 + v3 + v4 + v5;
}


x86 assembly (clang, -O0):
<fun>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0xd,-0xc(%rbp)
movl   $0x7,-0x10(%rbp)
movl   $0x5,-0x14(%rbp)
movl   $0x2,-0x18(%rbp)
lea    0xeb5(%rip),%rdi
call   1030 <printf@plt>
mov    $0x2a,%edi
mov    $0x64,%esi
call   1040 <rec_inc@plt>
mov    %eax,-0x8(%rbp)
lea    0xea7(%rip),%rdi
call   1030 <printf@plt>
lea    0xea9(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x64,-0x4(%rbp)
jge    11a2 <fun+0x82>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1181 <fun+0x61>
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
lea    0xe8a(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x64,-0x4(%rbp)
jge    11e2 <fun+0xc2>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11c1 <fun+0xa1>
lea    0xe6b(%rip),%rdi
call   1030 <printf@plt>
lea    0xe47(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x64,-0x4(%rbp)
jl     1201 <fun+0xe1>
lea    0xe2d(%rip),%rdi
call   1030 <printf@plt>
lea    0xe34(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x64,-0x4(%rbp)
jge    125d <fun+0x13d>
jmp    123c <fun+0x11c>
lea    0xe0c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fun>:
push   %rbx
lea    0xed8(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2a,%edi
mov    $0x64,%esi
call   1040 <rec_inc@plt>
mov    %eax,%ebx
lea    0xeca(%rip),%rdi
call   1030 <puts@plt>
lea    0xecb(%rip),%rdi
call   1030 <puts@plt>
lea    0xece(%rip),%rdi
call   1030 <puts@plt>
lea    0xed2(%rip),%rdi
call   1030 <puts@plt>
lea    0xeda(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb7(%rip),%rdi
call   1030 <puts@plt>
lea    0xebf(%rip),%rdi
call   1030 <puts@plt>
lea    0xec5(%rip),%rdi
call   1030 <puts@plt>
lea    0xec4(%rip),%rdi
call   1030 <puts@plt>
add    $0x1ab,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"REC CALL START\0A\00"
@.str.1 = [14 x i8] c"REC CALL END\0A\00"
@.str.2 = [16 x i8] c"FOR LOOP START\0A\00"
@.str.3 = [14 x i8] c"FOR LOOP END\0A\00"
@.str.4 = [18 x i8] c"WHILE LOOP START\0A\00"
@.str.5 = [16 x i8] c"WHILE LOOP END\0A\00"
@.str.6 = [21 x i8] c"DO WHILE LOOP START\0A\00"
@.str.7 = [19 x i8] c"DO WHILE LOOP END\0A\00"
@.str.8 = [12 x i8] c"GOTO START\0A\00"
@.str.9 = [10 x i8] c"GOTO END\0A\00"
define i32 @fun() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 13, i32* %3
store i32 7, i32* %4
store i32 5, i32* %5
store i32 2, i32* %6
%7 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @rec_inc(i32 42, i32 100)
store i32 %8, i32* %2
%9 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %11
11: ; preds = %17, %0
%12 = load i32, i32* %1
%13 = icmp slt i32 %12, 100
br i1 %13, label %14, label %20
14: ; preds = %11
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 1
store i32 %16, i32* %3
br label %17
17: ; preds = %14
%18 = load i32, i32* %1
%19 = add nsw i32 %18, 1
store i32 %19, i32* %1
br label %11
20: ; preds = %11
%21 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %1
br label %23
23: ; preds = %26, %20
%24 = load i32, i32* %1
%25 = icmp slt i32 %24, 100
br i1 %25, label %26, label %31
26: ; preds = %23
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
%29 = load i32, i32* %1
%30 = add nsw i32 %29, 1
store i32 %30, i32* %1
br label %23
31: ; preds = %23
%32 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%33 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %1
br label %34
34: ; preds = %39, %31
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
store i32 %36, i32* %5
%37 = load i32, i32* %1
%38 = add nsw i32 %37, 1
store i32 %38, i32* %1
br label %39
39: ; preds = %34
%40 = load i32, i32* %1
%41 = icmp slt i32 %40, 100
br i1 %41, label %34, label %42
42: ; preds = %39
%43 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
%44 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0))
store i32 0, i32* %1
br label %45
45: ; preds = %52, %42
%46 = load i32, i32* %6
%47 = add nsw i32 %46, 1
store i32 %47, i32* %6
%48 = load i32, i32* %1
%49 = add nsw i32 %48, 1
store i32 %49, i32* %1
%50 = load i32, i32* %1
%51 = icmp slt i32 %50, 100
br i1 %51, label %52, label %53
52: ; preds = %45
br label %45
53: ; preds = %45
%54 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0))
%55 = load i32, i32* %2
%56 = load i32, i32* %3
%57 = add nsw i32 %55, %56
%58 = load i32, i32* %4
%59 = add nsw i32 %57, %58
%60 = load i32, i32* %5
%61 = add nsw i32 %59, %60
%62 = load i32, i32* %6
%63 = add nsw i32 %61, %62
ret i32 %63
}

LLVM IR (-O2):
@str = [15 x i8] c"REC CALL START\00"
@str.10 = [13 x i8] c"REC CALL END\00"
@str.11 = [15 x i8] c"FOR LOOP START\00"
@str.12 = [13 x i8] c"FOR LOOP END\00"
@str.13 = [17 x i8] c"WHILE LOOP START\00"
@str.14 = [15 x i8] c"WHILE LOOP END\00"
@str.15 = [20 x i8] c"DO WHILE LOOP START\00"
@str.16 = [18 x i8] c"DO WHILE LOOP END\00"
@str.17 = [11 x i8] c"GOTO START\00"
@str.18 = [9 x i8] c"GOTO END\00"
define i32 @fun() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @rec_inc(i32 42, i32 100)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.10, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.11, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.12, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.13, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.14, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.15, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.16, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.17, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.18, i64 0, i64 0))
%12 = add nsw i32 %2, 427
ret i32 %12
}