#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*/ Add(float, float);
int /*<<< orphan*/ Division(float, float);
int /*<<< orphan*/ ErrorMessage();
int /*<<< orphan*/ Exit();
int /*<<< orphan*/ Multiplication(float, float);
int /*<<< orphan*/ Subtraction(float, float);
int /*<<< orphan*/ discardUnnecessaryInput();
int getMenuOption();
int /*<<< orphan*/ printf(char *);
int scanf(char *, float *, float *);
void performOperation(int i) {
  if (i == 5) {
    Exit();
  }
  while ((i < 1) || (i > 5)) {
    ErrorMessage();
    i = getMenuOption();
  }
  float num1, num2;
  switch (i) {
  case 1:
    printf("\nPlease enter two numbers for Addition, separated by a space: ");
    break;
  case 2:
    printf(
        "\nPlease enter two numbers for Subtraction, separated by a space: ");
    break;
  case 3:
    printf("\nPlease enter two numbers for Multiplication, separated by a "
           "space: ");
    break;
  case 4:
    printf("\nPlease enter two numbers for Division, separated by a space: ");
    break;
  default:
    break;
  }
  while (2 != scanf("%f %f", &num1, &num2)) {
    printf("\nError reading your numbers, please re-enter both numbers: ");
    discardUnnecessaryInput();
  }
  switch (i) {
  case 1:
    Add(num1, num2);
    break;
  case 2:
    Subtraction(num1, num2);
    break;
  case 3:
    Multiplication(num1, num2);
    break;
  case 4:
    Division(num1, num2);
    break;
  default:
    break;
  }
}


x86 assembly (clang, -O0):
<performOperation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x5,-0x4(%rbp)
jne    11bc <performOperation+0x1c>
mov    $0x0,%al
call   10a0 <Exit@plt>
jmp    11c1 <performOperation+0x21>
mov    $0x1,%al
cmpl   $0x1,-0x4(%rbp)
mov    %al,-0xd(%rbp)
jl     11da <performOperation+0x3a>
cmpl   $0x5,-0x4(%rbp)
setg   %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    11ea <performOperation+0x4a>
jmp    1200 <performOperation+0x60>
mov    $0x0,%al
call   1030 <ErrorMessage@plt>
mov    $0x0,%al
call   1050 <getMenuOption@plt>
mov    %eax,-0x4(%rbp)
jmp    11c1 <performOperation+0x21>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x3,%eax
ja     126d <performOperation+0xcd>
mov    -0x18(%rbp),%rax
lea    0xde0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xdf0(%rip),%rdi
call   1060 <printf@plt>
jmp    1272 <performOperation+0xd2>
lea    0xe1e(%rip),%rdi
call   1060 <printf@plt>
jmp    1272 <performOperation+0xd2>
lea    0xe4f(%rip),%rdi
call   1060 <printf@plt>
jmp    1272 <performOperation+0xd2>
lea    0xe83(%rip),%rdi
call   1060 <printf@plt>
jmp    1272 <performOperation+0xd2>
jmp    1272 <performOperation+0xd2>
jmp    1277 <performOperation+0xd7>
lea    0xea7(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   10b0 <scanf@plt>
mov    %eax,%ecx
mov    $0x2,%eax
cmp    %ecx,%eax
je     12b2 <performOperation+0x112>
lea    0xe8a(%rip),%rdi
call   1060 <printf@plt>
mov    $0x0,%al
call   1070 <discardUnnecessaryInput@plt>
jmp    1277 <performOperation+0xd7>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x3,%eax
ja     132b <performOperation+0x18b>
mov    -0x20(%rbp),%rax
lea    0xd3e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
call   10c0 <Add@plt>
jmp    1330 <performOperation+0x190>
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
call   1080 <Subtraction@plt>
jmp    1330 <performOperation+0x190>
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
call   1090 <Multiplication@plt>
jmp    1330 <performOperation+0x190>
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
call   1040 <Division@plt>
jmp    1330 <performOperation+0x190>
jmp    1330 <performOperation+0x190>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<performOperation>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
cmp    $0x5,%edi
jne    1256 <performOperation+0xb6>
xor    %eax,%eax
call   10a0 <Exit@plt>
mov    $0x5,%r13d
lea    0xf5b(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   10b0 <scanf@plt>
cmp    $0x2,%eax
je     1222 <performOperation+0x82>
lea    0xf46(%rip),%r14
lea    0xf39(%rip),%r15
lea    0xc(%rsp),%r12
lea    0x8(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1060 <printf@plt>
xor    %eax,%eax
call   1070 <discardUnnecessaryInput@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   10b0 <scanf@plt>
cmp    $0x2,%eax
jne    1200 <performOperation+0x60>
add    $0xffffffff,%r13d
cmp    $0x3,%r13d
ja     12e0 <performOperation+0x140>
lea    0xdd9(%rip),%rax
movslq (%rax,%r13,4),%rcx
add    %rax,%rcx
jmp    *%rcx
movss  0xc(%rsp),%xmm0
movss  0x8(%rsp),%xmm1
call   10c0 <Add@plt>
jmp    12e0 <performOperation+0x140>
mov    %edi,%eax
lea    -0x6(%rax),%ecx
cmp    $0xfffffffa,%ecx
ja     1276 <performOperation+0xd6>
xor    %eax,%eax
call   1030 <ErrorMessage@plt>
xor    %eax,%eax
call   1050 <getMenuOption@plt>
lea    -0x6(%rax),%ecx
cmp    $0xfffffffb,%ecx
jb     1260 <performOperation+0xc0>
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     11bd <performOperation+0x1d>
lea    0xd77(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xd87(%rip),%rdi
call   1060 <printf@plt>
mov    $0x1,%r13d
jmp    11c3 <performOperation+0x23>
movss  0xc(%rsp),%xmm0
movss  0x8(%rsp),%xmm1
call   1080 <Subtraction@plt>
jmp    12e0 <performOperation+0x140>
movss  0xc(%rsp),%xmm0
movss  0x8(%rsp),%xmm1
call   1090 <Multiplication@plt>
jmp    12e0 <performOperation+0x140>
movss  0xc(%rsp),%xmm0
movss  0x8(%rsp),%xmm1
call   1040 <Division@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xd6a(%rip),%rdi
call   1060 <printf@plt>
mov    $0x2,%r13d
jmp    11c3 <performOperation+0x23>
lea    0xd95(%rip),%rdi
call   1060 <printf@plt>
mov    $0x3,%r13d
jmp    11c3 <performOperation+0x23>
lea    0xdc3(%rip),%rdi
call   1060 <printf@plt>
mov    $0x4,%r13d
jmp    11c3 <performOperation+0x23>

LLVM IR (-O0):
@.str = [63 x i8] c"\0APlease enter two numbers for Addition, separated by a space: \00"
@.str.1 = [66 x i8] c"\0APlease enter two numbers for Subtraction, separated by a space: \00"
@.str.2 = [69 x i8] c"\0APlease enter two numbers for Multiplication, separated by a space: \00"
@.str.3 = [63 x i8] c"\0APlease enter two numbers for Division, separated by a space: \00"
@.str.4 = [6 x i8] c"%f %f\00"
@.str.5 = [60 x i8] c"\0AError reading your numbers, please re-enter both numbers: \00"
define void @performOperation(i32 %0) {
%2 = alloca i32
%3 = alloca float
%4 = alloca float
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = icmp eq i32 %5, 5
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 (...) @Exit()
br label %9
9: ; preds = %7, %1
br label %10
10: ; preds = %18, %9
%11 = load i32, i32* %2
%12 = icmp slt i32 %11, 1
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = load i32, i32* %2
%15 = icmp sgt i32 %14, 5
br label %16
16: ; preds = %13, %10
%17 = phi i1 [ true, %10 ], [ %15, %13 ]
br i1 %17, label %18, label %21
18: ; preds = %16
%19 = call i32 (...) @ErrorMessage()
%20 = call i32 (...) @getMenuOption()
store i32 %20, i32* %2
br label %10
21: ; preds = %16
%22 = load i32, i32* %2
switch i32 %22, label %31 [
i32 1, label %23
i32 2, label %25
i32 3, label %27
i32 4, label %29
]
23: ; preds = %21
%24 = call i32 @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str, i64 0, i64 0))
br label %32
25: ; preds = %21
%26 = call i32 @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.1, i64 0, i64 0))
br label %32
27: ; preds = %21
%28 = call i32 @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.2, i64 0, i64 0))
br label %32
29: ; preds = %21
%30 = call i32 @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.3, i64 0, i64 0))
br label %32
31: ; preds = %21
br label %32
32: ; preds = %31, %29, %27, %25, %23
br label %33
33: ; preds = %36, %32
%34 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), float* %3, float* %4)
%35 = icmp ne i32 2, %34
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = call i32 @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.5, i64 0, i64 0))
%38 = call i32 (...) @discardUnnecessaryInput()
br label %33
39: ; preds = %33
%40 = load i32, i32* %2
switch i32 %40, label %57 [
i32 1, label %41
i32 2, label %45
i32 3, label %49
i32 4, label %53
]
41: ; preds = %39
%42 = load float, float* %3
%43 = load float, float* %4
%44 = call i32 @Add(float %42, float %43)
br label %58
45: ; preds = %39
%46 = load float, float* %3
%47 = load float, float* %4
%48 = call i32 @Subtraction(float %46, float %47)
br label %58
49: ; preds = %39
%50 = load float, float* %3
%51 = load float, float* %4
%52 = call i32 @Multiplication(float %50, float %51)
br label %58
53: ; preds = %39
%54 = load float, float* %3
%55 = load float, float* %4
%56 = call i32 @Division(float %54, float %55)
br label %58
57: ; preds = %39
br label %58
58: ; preds = %57, %53, %49, %45, %41
ret void
}

LLVM IR (-O2):
@.str = [63 x i8] c"\0APlease enter two numbers for Addition, separated by a space: \00"
@.str.1 = [66 x i8] c"\0APlease enter two numbers for Subtraction, separated by a space: \00"
@.str.2 = [69 x i8] c"\0APlease enter two numbers for Multiplication, separated by a space: \00"
@.str.3 = [63 x i8] c"\0APlease enter two numbers for Division, separated by a space: \00"
@.str.4 = [6 x i8] c"%f %f\00"
@.str.5 = [60 x i8] c"\0AError reading your numbers, please re-enter both numbers: \00"
define void @performOperation(i32 %0) {
%2 = alloca float
%3 = alloca float
%4 = icmp eq i32 %0, 5
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = tail call i32 (...) @Exit()
%7 = bitcast float* %2 to i8*
%8 = bitcast float* %3 to i8*
br label %29
9: ; preds = %1
%10 = add i32 %0, -6
%11 = icmp ult i32 %10, -5
br i1 %11, label %12, label %17
12: ; preds = %9, %12
%13 = tail call i32 (...) @ErrorMessage()
%14 = tail call i32 (...) @getMenuOption()
%15 = add i32 %14, -6
%16 = icmp ult i32 %15, -5
br i1 %16, label %12, label %17
17: ; preds = %12, %9
%18 = phi i32 [ %0, %9 ], [ %14, %12 ]
%19 = bitcast float* %2 to i8*
%20 = bitcast float* %3 to i8*
switch i32 %18, label %29 [
i32 1, label %21
i32 2, label %23
i32 3, label %25
i32 4, label %27
]
21: ; preds = %17
%22 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @.str, i64 0, i64 0))
br label %29
23: ; preds = %17
%24 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @.str.1, i64 0, i64 0))
br label %29
25: ; preds = %17
%26 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str.2, i64 0, i64 0))
br label %29
27: ; preds = %17
%28 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @.str.3, i64 0, i64 0))
br label %29
29: ; preds = %5, %17, %27, %25, %23, %21
%30 = phi i32 [ 5, %5 ], [ 5, %17 ], [ 4, %27 ], [ 3, %25 ], [ 2, %23 ], [ 1, %21 ]
%31 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), float* %2, float* %3)
%32 = icmp eq i32 %31, 2
br i1 %32, label %38, label %33
33: ; preds = %29, %33
%34 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.5, i64 0, i64 0))
%35 = call i32 (...) @discardUnnecessaryInput()
%36 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), float* %2, float* %3)
%37 = icmp eq i32 %36, 2
br i1 %37, label %38, label %33
38: ; preds = %33, %29
switch i32 %30, label %55 [
i32 1, label %39
i32 2, label %43
i32 3, label %47
i32 4, label %51
]
39: ; preds = %38
%40 = load float, float* %2
%41 = load float, float* %3
%42 = call i32 @Add(float %40, float %41)
br label %55
43: ; preds = %38
%44 = load float, float* %2
%45 = load float, float* %3
%46 = call i32 @Subtraction(float %44, float %45)
br label %55
47: ; preds = %38
%48 = load float, float* %2
%49 = load float, float* %3
%50 = call i32 @Multiplication(float %48, float %49)
br label %55
51: ; preds = %38
%52 = load float, float* %2
%53 = load float, float* %3
%54 = call i32 @Division(float %52, float %53)
br label %55
55: ; preds = %38, %51, %47, %43, %39
%56 = bitcast float* %2 to i8*
%57 = bitcast float* %3 to i8*
ret void
}