#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(int, int);
int /*<<< orphan*/ div(int, int);
int /*<<< orphan*/ mul(int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *, ...);
int /*<<< orphan*/ sub(int, int);
int main() {
  int num1, num2, choice;
  printf("Enter two Numbers\n");
  scanf("%d%d", &num1, &num2);
  printf("____________________MAIN MENU____________________\n");
  printf("1. Add\n");
  printf("2. Subtract\n");
  printf("3. Multiply\n");
  printf("4. Divide\n");
  printf("Enter your choice\n");
  scanf("%d", &choice);
  switch (choice) {
  case 1:
    add(num1, num2);
    break;
  case 2:
    sub(num1, num2);
    break;
  case 3:
    mul(num1, num2);
    break;
  case 4:
    div(num1, num2);
    break;
  default:
    printf("Incorrect choice....please try again\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
call   1040 <printf@plt>
lea    0xea1(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x19(%rbp)
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1060 <scanf@plt>
lea    0xe8d(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb4(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb0(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb1(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb2(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb1(%rip),%rdi
call   1040 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xe3f(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x3,%eax
ja     1258 <main+0xf8>
mov    -0x18(%rbp),%rax
lea    0xdf1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <add@plt>
jmp    1264 <main+0x104>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1080 <sub@plt>
jmp    1264 <main+0x104>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1070 <mul@plt>
jmp    1264 <main+0x104>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <div@plt>
jmp    1264 <main+0x104>
lea    0xe3c(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xeaa(%rip),%rdi
call   1040 <puts@plt>
lea    0xe99(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xe98(%rip),%rdi
call   1040 <puts@plt>
lea    0xebe(%rip),%rdi
call   1040 <puts@plt>
lea    0xeb9(%rip),%rdi
call   1040 <puts@plt>
lea    0xeb9(%rip),%rdi
call   1040 <puts@plt>
lea    0xeb9(%rip),%rdi
call   1040 <puts@plt>
lea    0xeb7(%rip),%rdi
call   1040 <puts@plt>
lea    0xe3b(%rip),%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x14(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     120e <main+0xae>
lea    0xe0a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
call   1030 <add@plt>
jmp    1247 <main+0xe7>
lea    0xe7f(%rip),%rdi
call   1040 <puts@plt>
jmp    1247 <main+0xe7>
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
call   1080 <sub@plt>
jmp    1247 <main+0xe7>
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
call   1070 <mul@plt>
jmp    1247 <main+0xe7>
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
call   1050 <div@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Enter two Numbers\0A\00"
@.str.1 = [5 x i8] c"%d%d\00"
@.str.2 = [51 x i8] c"____________________MAIN MENU____________________\0A\00"
@.str.3 = [8 x i8] c"1. Add\0A\00"
@.str.4 = [13 x i8] c"2. Subtract\0A\00"
@.str.5 = [13 x i8] c"3. Multiply\0A\00"
@.str.6 = [11 x i8] c"4. Divide\0A\00"
@.str.7 = [19 x i8] c"Enter your choice\0A\00"
@.str.8 = [3 x i8] c"%d\00"
@.str.9 = [38 x i8] c"Incorrect choice....please try again\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%7 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
%13 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %4)
%14 = load i32, i32* %4
switch i32 %14, label %31 [
i32 1, label %15
i32 2, label %19
i32 3, label %23
i32 4, label %27
]
15: ; preds = %0
%16 = load i32, i32* %2
%17 = load i32, i32* %3
%18 = call i32 @add(i32 %16, i32 %17)
br label %33
19: ; preds = %0
%20 = load i32, i32* %2
%21 = load i32, i32* %3
%22 = call i32 @sub(i32 %20, i32 %21)
br label %33
23: ; preds = %0
%24 = load i32, i32* %2
%25 = load i32, i32* %3
%26 = call i32 @mul(i32 %24, i32 %25)
br label %33
27: ; preds = %0
%28 = load i32, i32* %2
%29 = load i32, i32* %3
%30 = call i32 @div(i32 %28, i32 %29)
br label %33
31: ; preds = %0
%32 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.9, i64 0, i64 0))
br label %33
33: ; preds = %31, %27, %23, %19, %15
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"%d%d\00"
@.str.8 = [3 x i8] c"%d\00"
@str = [18 x i8] c"Enter two Numbers\00"
@str.10 = [50 x i8] c"____________________MAIN MENU____________________\00"
@str.11 = [7 x i8] c"1. Add\00"
@str.12 = [12 x i8] c"2. Subtract\00"
@str.13 = [12 x i8] c"3. Multiply\00"
@str.14 = [10 x i8] c"4. Divide\00"
@str.15 = [18 x i8] c"Enter your choice\00"
@str.16 = [37 x i8] c"Incorrect choice....please try again\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 ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%8 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.10, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.11, i64 0, i64 0))
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.12, i64 0, i64 0))
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.13, i64 0, i64 0))
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.14, i64 0, i64 0))
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.15, i64 0, i64 0))
%15 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %3)
%16 = load i32, i32* %3
switch i32 %16, label %33 [
i32 1, label %17
i32 2, label %21
i32 3, label %25
i32 4, label %29
]
17: ; preds = %0
%18 = load i32, i32* %1
%19 = load i32, i32* %2
%20 = call i32 @add(i32 %18, i32 %19)
br label %35
21: ; preds = %0
%22 = load i32, i32* %1
%23 = load i32, i32* %2
%24 = call i32 @sub(i32 %22, i32 %23)
br label %35
25: ; preds = %0
%26 = load i32, i32* %1
%27 = load i32, i32* %2
%28 = call i32 @mul(i32 %26, i32 %27)
br label %35
29: ; preds = %0
%30 = load i32, i32* %1
%31 = load i32, i32* %2
%32 = call i32 @div(i32 %30, i32 %31)
br label %35
33: ; preds = %0
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.16, i64 0, i64 0))
br label %35
35: ; preds = %33, %29, %25, %21, %17
ret i32 0
}