#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 */
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int choice;
  int firstNumber;
  int secondNumber;
  printf("Hello and welcome to Sapein's Simple Calculator Program!\n");
  while (choice != 5) {
    printf("Please enter one of the below options to get started!\n");
    printf("1.Multiplication\n");
    printf("2.Division\n");
    printf("3.Addition\n");
    printf("4.Subtraction\n");
    printf("5.Exit\n");
    scanf(" %d", &choice);
    printf("\nFirst Number: ");
    if (choice == 5) {
      break;
    }
    scanf(" %d", &firstNumber);
    printf("\nSecond Number:");
    scanf(" %d", &secondNumber);
    if (choice == 1) {
      printf("%d * %d = %d", firstNumber, secondNumber,
             firstNumber * secondNumber);
      char wait = getchar();
    } else if (choice == 2) {
      printf("%d / %d = %d", firstNumber, secondNumber,
             firstNumber / secondNumber);
      char wait = getchar();
    } else if (choice == 3) {
      printf("%d + %d = %d", firstNumber, secondNumber,
             firstNumber + secondNumber);
      char wait = getchar();
    } else if (choice == 4) {
      printf("%d - %d = %d", firstNumber, secondNumber,
             firstNumber - secondNumber);
      char wait = getchar();
    } else {
      printf("Wrong Input");
    }
    char wait = getchar();
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x5,-0x8(%rbp)
je     1308 <main+0x1d8>
lea    0xedc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf05(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf09(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf07(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf05(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf06(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf29(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xef0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x5,-0x8(%rbp)
jne    11d8 <main+0xa8>
jmp    1308 <main+0x1d8>
lea    0xefc(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xede(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jne    123a <main+0x10a>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0xc(%rbp),%ecx
imul   -0x10(%rbp),%ecx
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x11(%rbp)
jmp    12f9 <main+0x1c9>
cmpl   $0x2,-0x8(%rbp)
jne    1276 <main+0x146>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    -0x1c(%rbp),%edx
mov    %eax,%ecx
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x12(%rbp)
jmp    12f4 <main+0x1c4>
cmpl   $0x3,-0x8(%rbp)
jne    12a9 <main+0x179>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0xc(%rbp),%ecx
add    -0x10(%rbp),%ecx
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x13(%rbp)
jmp    12ef <main+0x1bf>
cmpl   $0x4,-0x8(%rbp)
jne    12dc <main+0x1ac>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0xc(%rbp),%ecx
sub    -0x10(%rbp),%ecx
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x14(%rbp)
jmp    12ea <main+0x1ba>
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ef <main+0x1bf>
jmp    12f4 <main+0x1c4>
jmp    12f9 <main+0x1c9>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x15(%rbp)
jmp    114d <main+0x1d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xf1b(%rip),%rdi
call   1030 <puts@plt>
lea    0xfb3(%rip),%rbp
lea    0xed1(%rip),%r14
lea    0x14(%rsp),%r15
lea    0xe9c(%rip),%r12
lea    0xc(%rsp),%r13
lea    0xe80(%rip),%rbx
jmp    11b6 <main+0x76>
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
mov    %edx,%ecx
imul   %esi,%ecx
lea    0xe9a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmpl   $0x5,0x14(%rsp)
je     12b4 <main+0x174>
lea    0xeec(%rip),%rdi
call   1030 <puts@plt>
lea    0xf16(%rip),%rdi
call   1030 <puts@plt>
lea    0xf1b(%rip),%rdi
call   1030 <puts@plt>
lea    0xf1a(%rip),%rdi
call   1030 <puts@plt>
lea    0xf19(%rip),%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x5,0x14(%rsp)
je     12b4 <main+0x174>
mov    %r14,%rdi
lea    0x10(%rsp),%rsi
call   1060 <scanf@plt>
lea    0xdf2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %r13,%rsi
call   1060 <scanf@plt>
mov    0x14(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     1272 <main+0x132>
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
jmp    *%rax
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%ecx
mov    %esi,%eax
cltd
idiv   %ecx
lea    0xdd4(%rip),%rdi
mov    %ecx,%edx
mov    %eax,%ecx
jmp    1196 <main+0x56>
lea    0xdeb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11a4 <main+0x64>
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
lea    (%rdx,%rsi,1),%ecx
lea    0xdb3(%rip),%rdi
jmp    1196 <main+0x56>
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
mov    %esi,%ecx
sub    %edx,%ecx
lea    0xda8(%rip),%rdi
jmp    1196 <main+0x56>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [58 x i8] c"Hello and welcome to Sapein's Simple Calculator Program!\0A\00"
@.str.1 = [55 x i8] c"Please enter one of the below options to get started!\0A\00"
@.str.2 = [18 x i8] c"1.Multiplication\0A\00"
@.str.3 = [12 x i8] c"2.Division\0A\00"
@.str.4 = [12 x i8] c"3.Addition\0A\00"
@.str.5 = [15 x i8] c"4.Subtraction\0A\00"
@.str.6 = [8 x i8] c"5.Exit\0A\00"
@.str.7 = [4 x i8] c" %d\00"
@.str.8 = [16 x i8] c"\0AFirst Number: \00"
@.str.9 = [16 x i8] c"\0ASecond Number:\00"
@.str.10 = [13 x i8] c"%d * %d = %d\00"
@.str.11 = [13 x i8] c"%d / %d = %d\00"
@.str.12 = [13 x i8] c"%d + %d = %d\00"
@.str.13 = [13 x i8] c"%d - %d = %d\00"
@.str.14 = [12 x i8] c"Wrong Input\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
%6 = alloca i8
%7 = alloca i8
%8 = alloca i8
%9 = alloca i8
store i32 0, i32* %1
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %78, %0
%12 = load i32, i32* %2
%13 = icmp ne i32 %12, 5
br i1 %13, label %14, label %80
14: ; preds = %11
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32* %2)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
%23 = load i32, i32* %2
%24 = icmp eq i32 %23, 5
br i1 %24, label %25, label %26
25: ; preds = %14
br label %80
26: ; preds = %14
%27 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32* %3)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
%29 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32* %4)
%30 = load i32, i32* %2
%31 = icmp eq i32 %30, 1
br i1 %31, label %32, label %40
32: ; preds = %26
%33 = load i32, i32* %3
%34 = load i32, i32* %4
%35 = load i32, i32* %3
%36 = load i32, i32* %4
%37 = mul nsw i32 %35, %36
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0), i32 %33, i32 %34, i32 %37)
%39 = call signext i8 (...) @getchar()
store i8 %39, i8* %5
br label %78
40: ; preds = %26
%41 = load i32, i32* %2
%42 = icmp eq i32 %41, 2
br i1 %42, label %43, label %51
43: ; preds = %40
%44 = load i32, i32* %3
%45 = load i32, i32* %4
%46 = load i32, i32* %3
%47 = load i32, i32* %4
%48 = sdiv i32 %46, %47
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0), i32 %44, i32 %45, i32 %48)
%50 = call signext i8 (...) @getchar()
store i8 %50, i8* %6
br label %77
51: ; preds = %40
%52 = load i32, i32* %2
%53 = icmp eq i32 %52, 3
br i1 %53, label %54, label %62
54: ; preds = %51
%55 = load i32, i32* %3
%56 = load i32, i32* %4
%57 = load i32, i32* %3
%58 = load i32, i32* %4
%59 = add nsw i32 %57, %58
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0), i32 %55, i32 %56, i32 %59)
%61 = call signext i8 (...) @getchar()
store i8 %61, i8* %7
br label %76
62: ; preds = %51
%63 = load i32, i32* %2
%64 = icmp eq i32 %63, 4
br i1 %64, label %65, label %73
65: ; preds = %62
%66 = load i32, i32* %3
%67 = load i32, i32* %4
%68 = load i32, i32* %3
%69 = load i32, i32* %4
%70 = sub nsw i32 %68, %69
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0), i32 %66, i32 %67, i32 %70)
%72 = call signext i8 (...) @getchar()
store i8 %72, i8* %8
br label %75
73: ; preds = %62
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0))
br label %75
75: ; preds = %73, %65
br label %76
76: ; preds = %75, %54
br label %77
77: ; preds = %76, %43
br label %78
78: ; preds = %77, %32
%79 = call signext i8 (...) @getchar()
store i8 %79, i8* %9
br label %11
80: ; preds = %25, %11
ret i32 0
}

LLVM IR (-O2):
@.str.7 = [4 x i8] c" %d\00"
@.str.8 = [16 x i8] c"\0AFirst Number: \00"
@.str.9 = [16 x i8] c"\0ASecond Number:\00"
@.str.10 = [13 x i8] c"%d * %d = %d\00"
@.str.11 = [13 x i8] c"%d / %d = %d\00"
@.str.12 = [13 x i8] c"%d + %d = %d\00"
@.str.13 = [13 x i8] c"%d - %d = %d\00"
@.str.14 = [12 x i8] c"Wrong Input\00"
@str = [57 x i8] c"Hello and welcome to Sapein's Simple Calculator Program!\00"
@str.15 = [54 x i8] c"Please enter one of the below options to get started!\00"
@str.16 = [17 x i8] c"1.Multiplication\00"
@str.17 = [11 x i8] c"2.Division\00"
@str.18 = [11 x i8] c"3.Addition\00"
@str.19 = [14 x i8] c"4.Subtraction\00"
@str.20 = [7 x i8] c"5.Exit\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 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str, i64 0, i64 0))
br label %8
8: ; preds = %0, %50
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.15, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.16, i64 0, i64 0))
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.17, i64 0, i64 0))
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.18, i64 0, i64 0))
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.19, i64 0, i64 0))
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.20, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32* %1)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
%17 = load i32, i32* %1
%18 = icmp eq i32 %17, 5
br i1 %18, label %54, label %19
19: ; preds = %8
%20 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32* %2)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
%22 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32* %3)
%23 = load i32, i32* %1
switch i32 %23, label %48 [
i32 1, label %24
i32 2, label %30
i32 3, label %36
i32 4, label %42
]
24: ; preds = %19
%25 = load i32, i32* %2
%26 = load i32, i32* %3
%27 = mul nsw i32 %26, %25
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0), i32 %25, i32 %26, i32 %27)
%29 = call signext i8 (...) @getchar()
br label %50
30: ; preds = %19
%31 = load i32, i32* %2
%32 = load i32, i32* %3
%33 = sdiv i32 %31, %32
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0), i32 %31, i32 %32, i32 %33)
%35 = call signext i8 (...) @getchar()
br label %50
36: ; preds = %19
%37 = load i32, i32* %2
%38 = load i32, i32* %3
%39 = add nsw i32 %38, %37
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0), i32 %37, i32 %38, i32 %39)
%41 = call signext i8 (...) @getchar()
br label %50
42: ; preds = %19
%43 = load i32, i32* %2
%44 = load i32, i32* %3
%45 = sub nsw i32 %43, %44
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0), i32 %43, i32 %44, i32 %45)
%47 = call signext i8 (...) @getchar()
br label %50
48: ; preds = %19
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0))
br label %50
50: ; preds = %30, %42, %48, %36, %24
%51 = call signext i8 (...) @getchar()
%52 = load i32, i32* %1
%53 = icmp eq i32 %52, 5
br i1 %53, label %54, label %8
54: ; preds = %50, %8
ret i32 0
}