#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, ...);
void main() {
  int i, j, k, ch;
  printf("\n\n MENU \n\n");
  printf(" 1.ADDITION\n 2.SUBTRACTION\n 3.DIVISION\n 4.MULTIPLICATION\n");
  printf("\n\n ENTER YOUR CHOICE \n\n");
  scanf("%d", &ch);
  switch (ch) {
  case 1:
    printf("\n\n ENTER TWO NUMBERS \n\n");
    scanf("%d %d", &i, &j);
    k = i + j;
    printf("\n\n Sum = %d", k);
    break;
  case 2:
    printf("\n\n ENTER TWO NUMBERS \n\n");
    scanf("%d %d", &i, &j);
    k = i - j;
    printf("\n\n Difference = %d", k);
    break;
  case 3:
    printf("\n\n ENTER TWO NUMBERS \n\n");
    scanf("%d %d", &i, &j);
    k = i / j;
    printf("\n\n Quotient = %d", k);
    break;
  case 4:
    printf("\n\n ENTER TWO NUMBERS \n\n");
    scanf("%d %d", &i, &j);
    k = i * j;
    printf("\n\n Value after Multiplication = %d", k);
    break;
  default:
    printf("\n\n ---- WRONG CHOICE ---- \n\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xee1(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x19(%rbp)
call   1030 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xed8(%rip),%rdi
call   1030 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xf03(%rip),%rdi
call   1030 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xf46(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x3,%eax
ja     12a1 <main+0x181>
mov    -0x18(%rbp),%rax
lea    0xe76(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedd(%rip),%rdi
lea    -0x4(%rbp),%rsi
lea    -0x8(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12af <main+0x18f>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9a(%rip),%rdi
lea    -0x4(%rbp),%rsi
lea    -0x8(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x4(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12af <main+0x18f>
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe57(%rip),%rdi
lea    -0x4(%rbp),%rsi
lea    -0x8(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12af <main+0x18f>
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe13(%rip),%rdi
lea    -0x4(%rbp),%rsi
lea    -0x8(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x4(%rbp),%eax
imul   -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12af <main+0x18f>
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xf2e(%rip),%rdi
call   1030 <puts@plt>
lea    0xf2c(%rip),%rdi
call   1030 <puts@plt>
lea    0xf59(%rip),%rdi
call   1030 <puts@plt>
lea    0xed3(%rip),%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x14(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     11bf <main+0x8f>
lea    0xe82(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf35(%rip),%rdi
call   1030 <puts@plt>
lea    0xe76(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
add    0x10(%rsp),%esi
lea    0xe5c(%rip),%rdi
jmp    1271 <main+0x141>
lea    0xf14(%rip),%rdi
call   1030 <puts@plt>
add    $0x18,%rsp
ret
lea    0xeec(%rip),%rdi
call   1030 <puts@plt>
lea    0xe2d(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x10(%rsp),%esi
sub    0xc(%rsp),%esi
lea    0xe1f(%rip),%rdi
jmp    1271 <main+0x141>
lea    0xeb7(%rip),%rdi
call   1030 <puts@plt>
lea    0xdf8(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x10(%rsp),%eax
cltd
idivl  0xc(%rsp)
lea    0xdfc(%rip),%rdi
mov    %eax,%esi
jmp    1271 <main+0x141>
lea    0xe7f(%rip),%rdi
call   1030 <puts@plt>
lea    0xdc0(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
imul   0x10(%rsp),%esi
lea    0xdd5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"\0A\0A MENU \0A\0A\00"
@.str.1 = [58 x i8] c" 1.ADDITION\0A 2.SUBTRACTION\0A 3.DIVISION\0A 4.MULTIPLICATION\0A\00"
@.str.2 = [24 x i8] c"\0A\0A ENTER YOUR CHOICE \0A\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [24 x i8] c"\0A\0A ENTER TWO NUMBERS \0A\0A\00"
@.str.5 = [6 x i8] c"%d %d\00"
@.str.6 = [12 x i8] c"\0A\0A Sum = %d\00"
@.str.7 = [19 x i8] c"\0A\0A Difference = %d\00"
@.str.8 = [17 x i8] c"\0A\0A Quotient = %d\00"
@.str.9 = [35 x i8] c"\0A\0A Value after Multiplication = %d\00"
@.str.10 = [29 x i8] c"\0A\0A ---- WRONG CHOICE ---- \0A\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%9 = load i32, i32* %4
switch i32 %9, label %42 [
i32 1, label %10
i32 2, label %18
i32 3, label %26
i32 4, label %34
]
10: ; preds = %0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %1, i32* %2)
%13 = load i32, i32* %1
%14 = load i32, i32* %2
%15 = add nsw i32 %13, %14
store i32 %15, i32* %3
%16 = load i32, i32* %3
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i32 %16)
br label %44
18: ; preds = %0
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%20 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %1, i32* %2)
%21 = load i32, i32* %1
%22 = load i32, i32* %2
%23 = sub nsw i32 %21, %22
store i32 %23, i32* %3
%24 = load i32, i32* %3
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i32 %24)
br label %44
26: ; preds = %0
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%28 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %1, i32* %2)
%29 = load i32, i32* %1
%30 = load i32, i32* %2
%31 = sdiv i32 %29, %30
store i32 %31, i32* %3
%32 = load i32, i32* %3
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i32 %32)
br label %44
34: ; preds = %0
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%36 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %1, i32* %2)
%37 = load i32, i32* %1
%38 = load i32, i32* %2
%39 = mul nsw i32 %37, %38
store i32 %39, i32* %3
%40 = load i32, i32* %3
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0), i32 %40)
br label %44
42: ; preds = %0
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0))
br label %44
44: ; preds = %42, %34, %26, %18, %10
ret void
}

LLVM IR (-O2):
@.str.3 = [3 x i8] c"%d\00"
@.str.5 = [6 x i8] c"%d %d\00"
@.str.6 = [12 x i8] c"\0A\0A Sum = %d\00"
@.str.7 = [19 x i8] c"\0A\0A Difference = %d\00"
@.str.8 = [17 x i8] c"\0A\0A Quotient = %d\00"
@.str.9 = [35 x i8] c"\0A\0A Value after Multiplication = %d\00"
@str = [10 x i8] c"\0A\0A MENU \0A\00"
@str.11 = [57 x i8] c" 1.ADDITION\0A 2.SUBTRACTION\0A 3.DIVISION\0A 4.MULTIPLICATION\00"
@str.12 = [23 x i8] c"\0A\0A ENTER YOUR CHOICE \0A\00"
@str.16 = [23 x i8] c"\0A\0A ENTER TWO NUMBERS \0A\00"
@str.17 = [28 x i8] c"\0A\0A ---- WRONG CHOICE ---- \0A\00"
define void @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 ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.11, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.12, i64 0, i64 0))
%10 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%11 = load i32, i32* %3
switch i32 %11, label %40 [
i32 1, label %12
i32 2, label %19
i32 3, label %26
i32 4, label %33
]
12: ; preds = %0
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.16, i64 0, i64 0))
%14 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %1, i32* %2)
%15 = load i32, i32* %1
%16 = load i32, i32* %2
%17 = add nsw i32 %16, %15
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i32 %17)
br label %42
19: ; preds = %0
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.16, i64 0, i64 0))
%21 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %1, i32* %2)
%22 = load i32, i32* %1
%23 = load i32, i32* %2
%24 = sub nsw i32 %22, %23
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i32 %24)
br label %42
26: ; preds = %0
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.16, i64 0, i64 0))
%28 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %1, i32* %2)
%29 = load i32, i32* %1
%30 = load i32, i32* %2
%31 = sdiv i32 %29, %30
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i32 %31)
br label %42
33: ; preds = %0
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.16, i64 0, i64 0))
%35 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %1, i32* %2)
%36 = load i32, i32* %1
%37 = load i32, i32* %2
%38 = mul nsw i32 %37, %36
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0), i32 %38)
br label %42
40: ; preds = %0
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.17, i64 0, i64 0))
br label %42
42: ; preds = %40, %33, %26, %19, %12
ret void
}