#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 add2op(int, int);
int add3op(int /*<<< orphan*/, int, int);
int add3opnoflag(int /*<<< orphan*/, int, int);
int plus3(int);
int /*<<< orphan*/ printf(char *, ...);
int sub3op(int /*<<< orphan*/, int, int);
main() {
  int i, j, k;
  for (i = 0; i < 5; i++) {
    switch (i) {
    case 0:
      printf("plus3 test\n");
      break;
    case 1:
      printf("\nadd3op test\n");
      break;
    case 2:
      printf("\nadd3onoflag test\n");
      break;
    case 3:
      printf("\nadd2op test\n");
      break;
    case 4:
      printf("\nsub3op test\n");
      break;
    }
    for (j = 1; j < 5; j++)
      for (k = -3; k < 3; k++) {
        switch (i) {
        case 0:
          printf("%d + 3 = %d\n", j, plus3(j));
          break;
        case 1:
          printf("%d + %d = %d\n", j, k, add3op(0, j, k));
          break;
        case 2:
          printf("%d + %d = %d\n", j, k, add3opnoflag(0, j, k));
          break;
        case 3:
          printf("%d + %d = %d\n", j, k, add2op(j, k));
          break;
        case 4:
          printf("%d - %d = %d\n", j, k, sub3op(0, j, k));
        }
        if (!i)
          break;
      }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    137d <main+0x21d>
mov    -0x8(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x4,%rax
ja     11ff <main+0x9f>
mov    -0x18(%rbp),%rax
lea    0xe64(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11ff <main+0x9f>
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11ff <main+0x9f>
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11ff <main+0x9f>
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11ff <main+0x9f>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0xc(%rbp)
cmpl   $0x5,-0xc(%rbp)
jge    136a <main+0x20a>
movl   $0xfffffffd,-0x10(%rbp)
cmpl   $0x3,-0x10(%rbp)
jge    1357 <main+0x1f7>
mov    -0x8(%rbp),%eax
mov    %rax,-0x20(%rbp)
sub    $0x4,%rax
ja     1335 <main+0x1d5>
mov    -0x20(%rbp),%rax
lea    0xdd7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0xc(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0xc(%rbp),%edi
call   1050 <plus3@plt>
mov    -0x24(%rbp),%esi
mov    %eax,%edx
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1335 <main+0x1d5>
mov    -0xc(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
xor    %edi,%edi
call   1080 <add3op@plt>
mov    -0x2c(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    %eax,%ecx
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1335 <main+0x1d5>
mov    -0xc(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
xor    %edi,%edi
call   1070 <add3opnoflag@plt>
mov    -0x34(%rbp),%esi
mov    -0x30(%rbp),%edx
mov    %eax,%ecx
lea    0xdb6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1335 <main+0x1d5>
mov    -0xc(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1060 <add2op@plt>
mov    -0x3c(%rbp),%esi
mov    -0x38(%rbp),%edx
mov    %eax,%ecx
lea    0xd84(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1335 <main+0x1d5>
mov    -0xc(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
xor    %edi,%edi
call   1030 <sub3op@plt>
mov    -0x44(%rbp),%esi
mov    -0x40(%rbp),%edx
mov    %eax,%ecx
lea    0xd5e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    1344 <main+0x1e4>
jmp    1357 <main+0x1f7>
jmp    1349 <main+0x1e9>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1217 <main+0xb7>
jmp    135c <main+0x1fc>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1206 <main+0xa6>
jmp    136f <main+0x20f>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1176 <main+0x16>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe7e(%rip),%r13
lea    0xea8(%rip),%r12
lea    0xeaf(%rip),%r15
xor    %r14d,%r14d
jmp    11ae <main+0x3e>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%r14d
cmp    $0x5,%r14d
je     1280 <main+0x110>
cmp    $0x4,%r14d
ja     11ca <main+0x5a>
mov    %r14d,%eax
lea    0xe52(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
call   1030 <puts@plt>
mov    $0x1,%ebp
jmp    1201 <main+0x91>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1060 <plus3@plt>
lea    0xe36(%rip),%rdi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebp
cmp    $0x5,%ebp
je     11a0 <main+0x30>
test   %r14d,%r14d
je     11e0 <main+0x70>
mov    $0xfffffffd,%ebx
jmp    1231 <main+0xc1>
nopl   (%rax)
mov    %ebp,%edi
mov    %ebx,%esi
call   1070 <add2op@plt>
mov    %r12,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebx
cmp    $0x3,%ebx
je     11f9 <main+0x89>
lea    -0x1(%r14),%eax
cmp    $0x3,%eax
ja     1229 <main+0xb9>
movslq 0x0(%r13,%rax,4),%rax
add    %r13,%rax
jmp    *%rax
xor    %edi,%edi
mov    %ebp,%esi
mov    %ebx,%edx
call   1090 <add3op@plt>
jmp    1219 <main+0xa9>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %edi,%edi
mov    %ebp,%esi
mov    %ebx,%edx
call   1080 <add3opnoflag@plt>
jmp    1219 <main+0xa9>
nopl   (%rax)
xor    %edi,%edi
mov    %ebp,%esi
mov    %ebx,%edx
call   1040 <sub3op@plt>
mov    %r15,%rdi
jmp    121c <main+0xac>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"plus3 test\0A\00"
@.str.1 = [14 x i8] c"\0Aadd3op test\0A\00"
@.str.2 = [19 x i8] c"\0Aadd3onoflag test\0A\00"
@.str.3 = [14 x i8] c"\0Aadd2op test\0A\00"
@.str.4 = [14 x i8] c"\0Asub3op test\0A\00"
@.str.5 = [13 x i8] c"%d + 3 = %d\0A\00"
@.str.6 = [14 x i8] c"%d + %d = %d\0A\00"
@.str.7 = [14 x i8] c"%d - %d = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
br label %5
5: ; preds = %76, %0
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 5
br i1 %7, label %8, label %79
8: ; preds = %5
%9 = load i32, i32* %2
switch i32 %9, label %20 [
i32 0, label %10
i32 1, label %12
i32 2, label %14
i32 3, label %16
i32 4, label %18
]
10: ; preds = %8
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %20
12: ; preds = %8
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %20
14: ; preds = %8
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %20
16: ; preds = %8
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %20
18: ; preds = %8
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
br label %20
20: ; preds = %8, %18, %16, %14, %12, %10
store i32 1, i32* %3
br label %21
21: ; preds = %72, %20
%22 = load i32, i32* %3
%23 = icmp slt i32 %22, 5
br i1 %23, label %24, label %75
24: ; preds = %21
store i32 -3, i32* %4
br label %25
25: ; preds = %68, %24
%26 = load i32, i32* %4
%27 = icmp slt i32 %26, 3
br i1 %27, label %28, label %71
28: ; preds = %25
%29 = load i32, i32* %2
switch i32 %29, label %63 [
i32 0, label %30
i32 1, label %35
i32 2, label %42
i32 3, label %49
i32 4, label %56
]
30: ; preds = %28
%31 = load i32, i32* %3
%32 = load i32, i32* %3
%33 = call i32 @plus3(i32 %32)
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 %31, i32 %33)
br label %63
35: ; preds = %28
%36 = load i32, i32* %3
%37 = load i32, i32* %4
%38 = load i32, i32* %3
%39 = load i32, i32* %4
%40 = call i32 @add3op(i32 0, i32 %38, i32 %39)
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %36, i32 %37, i32 %40)
br label %63
42: ; preds = %28
%43 = load i32, i32* %3
%44 = load i32, i32* %4
%45 = load i32, i32* %3
%46 = load i32, i32* %4
%47 = call i32 @add3opnoflag(i32 0, i32 %45, i32 %46)
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %43, i32 %44, i32 %47)
br label %63
49: ; preds = %28
%50 = load i32, i32* %3
%51 = load i32, i32* %4
%52 = load i32, i32* %3
%53 = load i32, i32* %4
%54 = call i32 @add2op(i32 %52, i32 %53)
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %50, i32 %51, i32 %54)
br label %63
56: ; preds = %28
%57 = load i32, i32* %3
%58 = load i32, i32* %4
%59 = load i32, i32* %3
%60 = load i32, i32* %4
%61 = call i32 @sub3op(i32 0, i32 %59, i32 %60)
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i32 %57, i32 %58, i32 %61)
br label %63
63: ; preds = %56, %28, %49, %42, %35, %30
%64 = load i32, i32* %2
%65 = icmp ne i32 %64, 0
br i1 %65, label %67, label %66
66: ; preds = %63
br label %71
67: ; preds = %63
br label %68
68: ; preds = %67
%69 = load i32, i32* %4
%70 = add nsw i32 %69, 1
store i32 %70, i32* %4
br label %25
71: ; preds = %66, %25
br label %72
72: ; preds = %71
%73 = load i32, i32* %3
%74 = add nsw i32 %73, 1
store i32 %74, i32* %3
br label %21
75: ; preds = %21
br label %76
76: ; preds = %75
%77 = load i32, i32* %2
%78 = add nsw i32 %77, 1
store i32 %78, i32* %2
br label %5
79: ; preds = %5
%80 = load i32, i32* %1
ret i32 %80
}

LLVM IR (-O2):
@.str.5 = [13 x i8] c"%d + 3 = %d\0A\00"
@.str.6 = [14 x i8] c"%d + %d = %d\0A\00"
@.str.7 = [14 x i8] c"%d - %d = %d\0A\00"
@str = [13 x i8] c"\0Asub3op test\00"
@str.8 = [13 x i8] c"\0Aadd2op test\00"
@str.9 = [18 x i8] c"\0Aadd3onoflag test\00"
@str.10 = [13 x i8] c"\0Aadd3op test\00"
@str.11 = [11 x i8] c"plus3 test\00"
@reltable.main = [5 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @str.11 to i64), i64 ptrtoint ([5 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @str.10 to i64), i64 ptrtoint ([5 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @str.9 to i64), i64 ptrtoint ([5 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @str.8 to i64), i64 ptrtoint ([5 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @str to i64), i64 ptrtoint ([5 x i32]* @reltable.main to i64)) to i32)]
define i32 @main() {
br label %1
1: ; preds = %0, %36
%2 = phi i32 [ 0, %0 ], [ %37, %36 ]
%3 = icmp ult i32 %2, 5
br i1 %3, label %4, label %9
4: ; preds = %1
%5 = zext i32 %2 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([5 x i32]* @reltable.main to i8*), i64 %6)
%8 = tail call i32 @puts(i8* dereferenceable(1) %7)
br label %9
9: ; preds = %1, %4
%10 = icmp eq i32 %2, 0
br label %11
11: ; preds = %9, %33
%12 = phi i32 [ 1, %9 ], [ %34, %33 ]
br i1 %10, label %27, label %13
13: ; preds = %11, %30
%14 = phi i32 [ %31, %30 ], [ -3, %11 ]
switch i32 %2, label %30 [
i32 4, label %24
i32 1, label %15
i32 2, label %18
i32 3, label %21
]
15: ; preds = %13
%16 = tail call i32 @add3op(i32 0, i32 %12, i32 %14)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %12, i32 %14, i32 %16)
br label %30
18: ; preds = %13
%19 = tail call i32 @add3opnoflag(i32 0, i32 %12, i32 %14)
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %12, i32 %14, i32 %19)
br label %30
21: ; preds = %13
%22 = tail call i32 @add2op(i32 %12, i32 %14)
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %12, i32 %14, i32 %22)
br label %30
24: ; preds = %13
%25 = tail call i32 @sub3op(i32 0, i32 %12, i32 %14)
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i32 %12, i32 %14, i32 %25)
br label %30
27: ; preds = %11
%28 = tail call i32 @plus3(i32 %12)
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 %12, i32 %28)
br label %33
30: ; preds = %15, %18, %21, %24, %13
%31 = add nsw i32 %14, 1
%32 = icmp eq i32 %31, 3
br i1 %32, label %33, label %13
33: ; preds = %30, %27
%34 = add nuw nsw i32 %12, 1
%35 = icmp eq i32 %34, 5
br i1 %35, label %36, label %11
36: ; preds = %33
%37 = add nuw nsw i32 %2, 1
%38 = icmp eq i32 %37, 5
br i1 %38, label %39, label %1
39: ; preds = %36
ret i32 0
}