#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*/ addition(int, int);
int /*<<< orphan*/ displayDescription();
int /*<<< orphan*/ displayMenu();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int x, y;
  int choice;
  displayDescription();
  printf("Welcome to the Calculator Program!\n\n");
  printf("Please enter a non-negative value: \n");
  scanf("%d", &x);
  printf("Please enter another non-negative value: \n");
  scanf("%d", &y);
  do {
    displayMenu();
    scanf("%d", &choice);
    switch (choice) {
    case 1:
      printf("Value 1 + Value 2 = ", addition(x, y));
      break;
    case 2:
      printf("Value 1 + Value 2 = ", addition(x, y));
      break;
    case 3:
      printf("Value 1 + Value 2 = ", addition(x, y));
      break;
    case 4:
      printf("Value 1 + Value 2 = ", addition(x, y));
      break;
    }
  } while (choice != 5);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <displayDescription@plt>
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xed1(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xeb3(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1070 <scanf@plt>
xor    %eax,%eax
call   1050 <displayMenu@plt>
lea    0xe9c(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x3,%eax
ja     126b <main+0x11b>
mov    -0x18(%rbp),%rax
lea    0xe19(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <addition@plt>
mov    %eax,%esi
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    126b <main+0x11b>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <addition@plt>
mov    %eax,%esi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    126b <main+0x11b>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <addition@plt>
mov    %eax,%esi
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    126b <main+0x11b>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <addition@plt>
mov    %eax,%esi
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1270 <main+0x120>
cmpl   $0x5,-0x10(%rbp)
jne    11b0 <main+0x60>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
xor    %eax,%eax
call   1050 <displayDescription@plt>
lea    0xeaf(%rip),%rdi
call   1040 <puts@plt>
lea    0xec7(%rip),%rdi
call   1040 <puts@plt>
lea    0xe7f(%rip),%r14
lea    0x10(%rsp),%rsi
mov    %r14,%rdi
call   1080 <scanf@plt>
lea    0xecb(%rip),%rdi
call   1040 <puts@plt>
lea    0xc(%rsp),%rsi
mov    %r14,%rdi
call   1080 <scanf@plt>
lea    0x14(%rsp),%r12
lea    0xe3d(%rip),%rbx
lea    0xe49(%rip),%r15
jmp    11d5 <main+0x75>
nopl   0x0(%rax)
cmp    $0x5,%eax
je     121b <main+0xbb>
xor    %eax,%eax
call   1060 <displayMenu@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1080 <scanf@plt>
mov    0x14(%rsp),%eax
lea    -0x1(%rax),%ecx
cmp    $0x3,%ecx
ja     11d0 <main+0x70>
movslq (%rbx,%rcx,4),%rax
add    %rbx,%rax
jmp    *%rax
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
call   1030 <addition@plt>
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x14(%rsp),%eax
jmp    11d0 <main+0x70>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [37 x i8] c"Welcome to the Calculator Program!\0A\0A\00"
@.str.1 = [37 x i8] c"Please enter a non-negative value: \0A\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [43 x i8] c"Please enter another non-negative value: \0A\00"
@.str.4 = [21 x i8] c"Value 1 + Value 2 = \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (...) @displayDescription()
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
br label %11
11: ; preds = %36, %0
%12 = call i32 (...) @displayMenu()
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%14 = load i32, i32* %4
switch i32 %14, label %35 [
i32 1, label %15
i32 2, label %20
i32 3, label %25
i32 4, label %30
]
15: ; preds = %11
%16 = load i32, i32* %2
%17 = load i32, i32* %3
%18 = call i32 @addition(i32 %16, i32 %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %18)
br label %35
20: ; preds = %11
%21 = load i32, i32* %2
%22 = load i32, i32* %3
%23 = call i32 @addition(i32 %21, i32 %22)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %23)
br label %35
25: ; preds = %11
%26 = load i32, i32* %2
%27 = load i32, i32* %3
%28 = call i32 @addition(i32 %26, i32 %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %28)
br label %35
30: ; preds = %11
%31 = load i32, i32* %2
%32 = load i32, i32* %3
%33 = call i32 @addition(i32 %31, i32 %32)
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %33)
br label %35
35: ; preds = %11, %30, %25, %20, %15
br label %36
36: ; preds = %35
%37 = load i32, i32* %4
%38 = icmp ne i32 %37, 5
br i1 %38, label %11, label %39
39: ; preds = %36
%40 = load i32, i32* %1
ret i32 %40
}

LLVM IR (-O2):
@.str.2 = [3 x i8] c"%d\00"
@.str.4 = [21 x i8] c"Value 1 + Value 2 = \00"
@str = [36 x i8] c"Welcome to the Calculator Program!\0A\00"
@str.5 = [36 x i8] c"Please enter a non-negative value: \00"
@str.6 = [42 x i8] c"Please enter another non-negative value: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 (...) @displayDescription()
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.5, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.6, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
br label %13
13: ; preds = %37, %0
%14 = call i32 (...) @displayMenu()
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%16 = load i32, i32* %3
switch i32 %16, label %37 [
i32 1, label %17
i32 2, label %21
i32 3, label %25
i32 4, label %29
]
17: ; preds = %13
%18 = load i32, i32* %1
%19 = load i32, i32* %2
%20 = call i32 @addition(i32 %18, i32 %19)
br label %33
21: ; preds = %13
%22 = load i32, i32* %1
%23 = load i32, i32* %2
%24 = call i32 @addition(i32 %22, i32 %23)
br label %33
25: ; preds = %13
%26 = load i32, i32* %1
%27 = load i32, i32* %2
%28 = call i32 @addition(i32 %26, i32 %27)
br label %33
29: ; preds = %13
%30 = load i32, i32* %1
%31 = load i32, i32* %2
%32 = call i32 @addition(i32 %30, i32 %31)
br label %33
33: ; preds = %29, %25, %21, %17
%34 = phi i32 [ %32, %29 ], [ %28, %25 ], [ %24, %21 ], [ %20, %17 ]
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %3
br label %37
37: ; preds = %33, %13
%38 = phi i32 [ %36, %33 ], [ %16, %13 ]
%39 = icmp eq i32 %38, 5
br i1 %39, label %40, label %13
40: ; preds = %37
ret i32 0
}