#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 *);
int main() {
  int NumA = 0;
  int NumB = 0;
  printf("Give NumA : ");
  scanf("%d", &NumA);
  printf("Give NumB : ");
  scanf("%d", &NumB);
  int selection;
  printf("MENU\n");
  printf("1 = +\n");
  printf("2 = -\n");
  printf("3 = *\n");
  printf("4 = /\n");
  printf("0 = Exit\n");
  scanf("%d", &selection);
  switch (selection) {
  case 1: {
    printf("%d+%d=%d\n", NumA, NumB, NumA + NumB);
    break;
  }
  case 2: {
    printf("%d-%d=%d\n", NumA, NumB, NumA - NumB);
    break;
  }
  case 3: {
    printf("%d*%d=%d\n", NumA, NumB, NumA * NumB);
    break;
  }
  case 4: {
    printf("%d/%d=%d\n", NumA, NumB, NumA / NumB);
    break;
  }
  case 0: {
    break;
  }
  default: {
    printf("ERROR ! Not supported !\n");
    break;
  }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xed0(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x21(%rbp)
call   1030 <printf@plt>
lea    0xecc(%rip),%rdi
mov    %rdi,-0x20(%rbp)
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x21(%rbp),%al
lea    0xeb8(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x21(%rbp),%al
lea    0xea9(%rip),%rdi
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xea0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xe88(%rip),%rdi
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x4,%rax
ja     1295 <main+0x175>
mov    -0x18(%rbp),%rax
lea    0xdff(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%ecx
add    -0xc(%rbp),%ecx
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12a3 <main+0x183>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%ecx
sub    -0xc(%rbp),%ecx
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12a3 <main+0x183>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%ecx
imul   -0xc(%rbp),%ecx
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12a3 <main+0x183>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    -0x28(%rbp),%edx
mov    %eax,%ecx
lea    0xdf7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12a3 <main+0x183>
jmp    12a3 <main+0x183>
lea    0xde9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0x8(%rsp)
movl   $0x0,0x4(%rsp)
lea    0xec8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec7(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xeb6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xed0(%rip),%rdi
call   1030 <puts@plt>
lea    0xec9(%rip),%rdi
call   1030 <puts@plt>
lea    0xec3(%rip),%rdi
call   1030 <puts@plt>
lea    0xebd(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb7(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb1(%rip),%rdi
call   1030 <puts@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x4,%rax
ja     1205 <main+0xd5>
lea    0xe18(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x8(%rsp),%esi
mov    0x4(%rsp),%edx
lea    (%rdx,%rsi,1),%ecx
lea    0xe2e(%rip),%rdi
jmp    1256 <main+0x126>
lea    0xe73(%rip),%rdi
call   1030 <puts@plt>
jmp    125d <main+0x12d>
mov    0x8(%rsp),%esi
mov    0x4(%rsp),%edx
mov    %esi,%ecx
sub    %edx,%ecx
lea    0xe15(%rip),%rdi
jmp    1256 <main+0x126>
mov    0x8(%rsp),%esi
mov    0x4(%rsp),%edx
mov    %edx,%ecx
imul   %esi,%ecx
lea    0xe09(%rip),%rdi
jmp    1256 <main+0x126>
mov    0x8(%rsp),%esi
mov    0x4(%rsp),%ecx
mov    %esi,%eax
cltd
idiv   %ecx
lea    0xdfd(%rip),%rdi
mov    %ecx,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Give NumA : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [13 x i8] c"Give NumB : \00"
@.str.3 = [6 x i8] c"MENU\0A\00"
@.str.4 = [7 x i8] c"1 = +\0A\00"
@.str.5 = [7 x i8] c"2 = -\0A\00"
@.str.6 = [7 x i8] c"3 = *\0A\00"
@.str.7 = [7 x i8] c"4 = /\0A\00"
@.str.8 = [10 x i8] c"0 = Exit\0A\00"
@.str.9 = [10 x i8] c"%d+%d=%d\0A\00"
@.str.10 = [10 x i8] c"%d-%d=%d\0A\00"
@.str.11 = [10 x i8] c"%d*%d=%d\0A\00"
@.str.12 = [10 x i8] c"%d/%d=%d\0A\00"
@.str.13 = [25 x i8] c"ERROR ! Not supported !\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%16 = load i32, i32* %4
switch i32 %16, label %46 [
i32 1, label %17
i32 2, label %24
i32 3, label %31
i32 4, label %38
i32 0, label %45
]
17: ; preds = %0
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = load i32, i32* %2
%21 = load i32, i32* %3
%22 = add nsw i32 %20, %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i32 %18, i32 %19, i32 %22)
br label %48
24: ; preds = %0
%25 = load i32, i32* %2
%26 = load i32, i32* %3
%27 = load i32, i32* %2
%28 = load i32, i32* %3
%29 = sub nsw i32 %27, %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i32 %25, i32 %26, i32 %29)
br label %48
31: ; preds = %0
%32 = load i32, i32* %2
%33 = load i32, i32* %3
%34 = load i32, i32* %2
%35 = load i32, i32* %3
%36 = mul nsw i32 %34, %35
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i32 %32, i32 %33, i32 %36)
br label %48
38: ; preds = %0
%39 = load i32, i32* %2
%40 = load i32, i32* %3
%41 = load i32, i32* %2
%42 = load i32, i32* %3
%43 = sdiv i32 %41, %42
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.12, i64 0, i64 0), i32 %39, i32 %40, i32 %43)
br label %48
45: ; preds = %0
br label %48
46: ; preds = %0
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.13, i64 0, i64 0))
br label %48
48: ; preds = %46, %45, %38, %31, %24, %17
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"Give NumA : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [13 x i8] c"Give NumB : \00"
@.str.9 = [10 x i8] c"%d+%d=%d\0A\00"
@.str.10 = [10 x i8] c"%d-%d=%d\0A\00"
@.str.11 = [10 x i8] c"%d*%d=%d\0A\00"
@.str.12 = [10 x i8] c"%d/%d=%d\0A\00"
@str = [5 x i8] c"MENU\00"
@str.14 = [6 x i8] c"1 = +\00"
@str.15 = [6 x i8] c"2 = -\00"
@str.16 = [6 x i8] c"3 = *\00"
@str.17 = [6 x i8] c"4 = /\00"
@str.18 = [9 x i8] c"0 = Exit\00"
@str.19 = [24 x i8] c"ERROR ! Not supported !\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%5 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%10 = bitcast i32* %3 to i8*
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.14, i64 0, i64 0))
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.15, i64 0, i64 0))
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.16, i64 0, i64 0))
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.17, i64 0, i64 0))
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.18, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%18 = load i32, i32* %3
switch i32 %18, label %39 [
i32 1, label %19
i32 2, label %24
i32 3, label %29
i32 4, label %34
i32 0, label %41
]
19: ; preds = %0
%20 = load i32, i32* %1
%21 = load i32, i32* %2
%22 = add nsw i32 %21, %20
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i32 %20, i32 %21, i32 %22)
br label %41
24: ; preds = %0
%25 = load i32, i32* %1
%26 = load i32, i32* %2
%27 = sub nsw i32 %25, %26
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i32 %25, i32 %26, i32 %27)
br label %41
29: ; preds = %0
%30 = load i32, i32* %1
%31 = load i32, i32* %2
%32 = mul nsw i32 %31, %30
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i32 %30, i32 %31, i32 %32)
br label %41
34: ; preds = %0
%35 = load i32, i32* %1
%36 = load i32, i32* %2
%37 = sdiv i32 %35, %36
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.12, i64 0, i64 0), i32 %35, i32 %36, i32 %37)
br label %41
39: ; preds = %0
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.19, i64 0, i64 0))
br label %41
41: ; preds = %0, %39, %34, %29, %24, %19
ret i32 0
}