#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*/ Diff(int, int);
int /*<<< orphan*/ DivisionCall(int, int);
int GetInput(char *);
int /*<<< orphan*/ Prod(int, int);
int /*<<< orphan*/ ShowIntResult(int /*<<< orphan*/);
int /*<<< orphan*/ SumOperation();
int /*<<< orphan*/ puts(char *);
void Calculator() {
  int choice =
      GetInput("Select operation: 1- Sum, 2- Diff, 3- Prod, 4- Division\n");
  switch (choice) {
  case 1:
    SumOperation();
    break;
  case 2:
    ShowIntResult(Diff(GetInput("Give input: "), GetInput("Give input: ")));
    break;
  case 3:
    ShowIntResult(Prod(GetInput("Give input: "), GetInput("Give input: ")));
    break;
  case 4:
    DivisionCall(GetInput("Give input: "), GetInput("Give input: "));
    break;
  default:
    puts("The operation is not in the list");
    break;
  }
}


x86 assembly (clang, -O0):
<Calculator>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xe91(%rip),%rdi
call   1040 <GetInput@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x3,%eax
ja     1248 <Calculator+0xd8>
mov    -0x10(%rbp),%rax
lea    0xe59(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1060 <SumOperation@plt>
jmp    1254 <Calculator+0xe4>
lea    0xe86(%rip),%rdi
call   1040 <GetInput@plt>
mov    %eax,-0x14(%rbp)
lea    0xe77(%rip),%rdi
call   1040 <GetInput@plt>
mov    -0x14(%rbp),%edi
mov    %eax,%esi
call   1090 <Diff@plt>
mov    %eax,%edi
call   1030 <ShowIntResult@plt>
jmp    1254 <Calculator+0xe4>
lea    0xe55(%rip),%rdi
call   1040 <GetInput@plt>
mov    %eax,-0x18(%rbp)
lea    0xe46(%rip),%rdi
call   1040 <GetInput@plt>
mov    -0x18(%rbp),%edi
mov    %eax,%esi
call   1070 <Prod@plt>
mov    %eax,%edi
call   1030 <ShowIntResult@plt>
jmp    1254 <Calculator+0xe4>
lea    0xe24(%rip),%rdi
call   1040 <GetInput@plt>
mov    %eax,-0x1c(%rbp)
lea    0xe15(%rip),%rdi
call   1040 <GetInput@plt>
mov    -0x1c(%rbp),%edi
mov    %eax,%esi
call   1080 <DivisionCall@plt>
jmp    1254 <Calculator+0xe4>
lea    0xe07(%rip),%rdi
call   1050 <puts@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Calculator>:
push   %rbp
push   %rbx
push   %rax
lea    0xe96(%rip),%rdi
call   1040 <GetInput@plt>
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     11a4 <Calculator+0x34>
lea    0xe72(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1060 <SumOperation@plt>
lea    0xeab(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <puts@plt>
lea    0xe8c(%rip),%rbx
mov    %rbx,%rdi
call   1040 <GetInput@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <GetInput@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1090 <Diff@plt>
jmp    11fc <Calculator+0x8c>
lea    0xe68(%rip),%rbx
mov    %rbx,%rdi
call   1040 <GetInput@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <GetInput@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1070 <Prod@plt>
mov    %eax,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <ShowIntResult@plt>
lea    0xe39(%rip),%rbx
mov    %rbx,%rdi
call   1040 <GetInput@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <GetInput@plt>
mov    %ebp,%edi
mov    %eax,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1080 <DivisionCall@plt>

LLVM IR (-O0):
@.str = [57 x i8] c"Select operation: 1- Sum, 2- Diff, 3- Prod, 4- Division\0A\00"
@.str.1 = [13 x i8] c"Give input: \00"
@.str.2 = [33 x i8] c"The operation is not in the list\00"
define void @Calculator() {
%1 = alloca i32
%2 = call i32 @GetInput(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
store i32 %2, i32* %1
%3 = load i32, i32* %1
switch i32 %3, label %20 [
i32 1, label %4
i32 2, label %6
i32 3, label %11
i32 4, label %16
]
4: ; preds = %0
%5 = call i32 (...) @SumOperation()
br label %22
6: ; preds = %0
%7 = call i32 @GetInput(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @GetInput(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @Diff(i32 %7, i32 %8)
%10 = call i32 @ShowIntResult(i32 %9)
br label %22
11: ; preds = %0
%12 = call i32 @GetInput(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @GetInput(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @Prod(i32 %12, i32 %13)
%15 = call i32 @ShowIntResult(i32 %14)
br label %22
16: ; preds = %0
%17 = call i32 @GetInput(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 @GetInput(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 @DivisionCall(i32 %17, i32 %18)
br label %22
20: ; preds = %0
%21 = call i32 @puts(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
br label %22
22: ; preds = %20, %16, %11, %6, %4
ret void
}

LLVM IR (-O2):
@.str = [57 x i8] c"Select operation: 1- Sum, 2- Diff, 3- Prod, 4- Division\0A\00"
@.str.1 = [13 x i8] c"Give input: \00"
@.str.2 = [33 x i8] c"The operation is not in the list\00"
define void @Calculator() {
%1 = tail call i32 @GetInput(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
switch i32 %1, label %18 [
i32 1, label %2
i32 2, label %4
i32 3, label %9
i32 4, label %14
]
2: ; preds = %0
%3 = tail call i32 (...) @SumOperation()
br label %20
4: ; preds = %0
%5 = tail call i32 @GetInput(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @GetInput(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @Diff(i32 %5, i32 %6)
%8 = tail call i32 @ShowIntResult(i32 %7)
br label %20
9: ; preds = %0
%10 = tail call i32 @GetInput(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call i32 @GetInput(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%12 = tail call i32 @Prod(i32 %10, i32 %11)
%13 = tail call i32 @ShowIntResult(i32 %12)
br label %20
14: ; preds = %0
%15 = tail call i32 @GetInput(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%16 = tail call i32 @GetInput(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%17 = tail call i32 @DivisionCall(i32 %15, i32 %16)
br label %20
18: ; preds = %0
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
br label %20
20: ; preds = %18, %14, %9, %4, %2
ret void
}