#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 add(int, int);
int divi(int, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int mult(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, ...);
int sub(int, int);
void main(void) {
  int a, b, choice;
  for (;;) {
    printf("\n\nEnter two integer: ");
    scanf("%d%d", &a, &b);
    printf("\nEnter choice: 1 for add and 2 for sub");
    printf("\nEnter choice: 3 for mult and 4 for divi");
    printf("\nEnter 5 for exit the program.");
    scanf("%d", &choice);
    switch (choice) {
    case 1:
      printf("Summation is: %d", add(a, b));
      break;
    case 2:
      printf("Subtraction is: %d", sub(a, b));
      break;
    case 3:
      printf("Multiplication is: %d", mult(a, b));
      break;
    case 4:
      printf("Division is: %d", divi(a, b));
      break;
    case 5:
      exit(0);
    default:
      printf("\n Enter the right choice.");
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xe95(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x19(%rbp)
call   1040 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xe97(%rip),%rdi
lea    -0x4(%rbp),%rsi
lea    -0x8(%rbp),%rdx
call   1070 <scanf@plt>
mov    -0x19(%rbp),%al
lea    0xe85(%rip),%rdi
call   1040 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xe9d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xeb7(%rip),%rdi
call   1040 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xf0e(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x4,%eax
ja     1290 <main+0x120>
mov    -0x18(%rbp),%rax
lea    0xe00(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <add@plt>
mov    %eax,%esi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    129e <main+0x12e>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1090 <sub@plt>
mov    %eax,%esi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    129e <main+0x12e>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1060 <mult@plt>
mov    %eax,%esi
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    129e <main+0x12e>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1050 <divi@plt>
mov    %eax,%esi
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    129e <main+0x12e>
xor    %edi,%edi
call   1080 <exit@plt>
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1178 <main+0x8>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xeaa(%rip),%rbx
lea    0xeca(%rip),%rbp
lea    0xeec(%rip),%r14
lea    0xf4b(%rip),%r15
lea    0x14(%rsp),%r12
lea    0xe5a(%rip),%r13
jmp    11c5 <main+0x55>
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
call   1050 <divi@plt>
lea    0xf1c(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe48(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe50(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   1070 <scanf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0x14(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x4,%eax
ja     125e <main+0xee>
movslq 0x0(%r13,%rax,4),%rax
add    %r13,%rax
jmp    *%rax
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
call   1030 <add@plt>
lea    0xe5e(%rip),%rdi
jmp    11bc <main+0x4c>
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
call   1060 <mult@plt>
lea    0xe69(%rip),%rdi
jmp    11bc <main+0x4c>
lea    0xe83(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11c5 <main+0x55>
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
call   1090 <sub@plt>
lea    0xe2a(%rip),%rdi
jmp    11bc <main+0x4c>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"\0A\0AEnter two integer: \00"
@.str.1 = [5 x i8] c"%d%d\00"
@.str.2 = [39 x i8] c"\0AEnter choice: 1 for add and 2 for sub\00"
@.str.3 = [41 x i8] c"\0AEnter choice: 3 for mult and 4 for divi\00"
@.str.4 = [31 x i8] c"\0AEnter 5 for exit the program.\00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [17 x i8] c"Summation is: %d\00"
@.str.7 = [19 x i8] c"Subtraction is: %d\00"
@.str.8 = [22 x i8] c"Multiplication is: %d\00"
@.str.9 = [16 x i8] c"Division is: %d\00"
@.str.10 = [26 x i8] c"\0A Enter the right choice.\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
br label %4
4: ; preds = %36, %0
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 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* %1, i32* %2)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%10 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %3)
%11 = load i32, i32* %3
switch i32 %11, label %34 [
i32 1, label %12
i32 2, label %17
i32 3, label %22
i32 4, label %27
i32 5, label %32
]
12: ; preds = %4
%13 = load i32, i32* %1
%14 = load i32, i32* %2
%15 = call i32 @add(i32 %13, i32 %14)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i32 %15)
br label %36
17: ; preds = %4
%18 = load i32, i32* %1
%19 = load i32, i32* %2
%20 = call i32 @sub(i32 %18, i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i32 %20)
br label %36
22: ; preds = %4
%23 = load i32, i32* %1
%24 = load i32, i32* %2
%25 = call i32 @mult(i32 %23, i32 %24)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i32 %25)
br label %36
27: ; preds = %4
%28 = load i32, i32* %1
%29 = load i32, i32* %2
%30 = call i32 @divi(i32 %28, i32 %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i32 %30)
br label %36
32: ; preds = %4
%33 = call i32 @exit(i32 0)
unreachable
34: ; preds = %4
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0))
br label %36
36: ; preds = %34, %27, %22, %17, %12
br label %4
}

LLVM IR (-O2):
@.str = [22 x i8] c"\0A\0AEnter two integer: \00"
@.str.1 = [5 x i8] c"%d%d\00"
@.str.2 = [39 x i8] c"\0AEnter choice: 1 for add and 2 for sub\00"
@.str.3 = [41 x i8] c"\0AEnter choice: 3 for mult and 4 for divi\00"
@.str.4 = [31 x i8] c"\0AEnter 5 for exit the program.\00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [17 x i8] c"Summation is: %d\00"
@.str.7 = [19 x i8] c"Subtraction is: %d\00"
@.str.8 = [22 x i8] c"Multiplication is: %d\00"
@.str.9 = [16 x i8] c"Division is: %d\00"
@.str.10 = [26 x i8] c"\0A Enter the right choice.\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*
br label %7
7: ; preds = %39, %0
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %3)
%14 = load i32, i32* %3
switch i32 %14, label %37 [
i32 1, label %15
i32 2, label %20
i32 3, label %25
i32 4, label %30
i32 5, label %35
]
15: ; preds = %7
%16 = load i32, i32* %1
%17 = load i32, i32* %2
%18 = call i32 @add(i32 %16, i32 %17)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i32 %18)
br label %39
20: ; preds = %7
%21 = load i32, i32* %1
%22 = load i32, i32* %2
%23 = call i32 @sub(i32 %21, i32 %22)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i32 %23)
br label %39
25: ; preds = %7
%26 = load i32, i32* %1
%27 = load i32, i32* %2
%28 = call i32 @mult(i32 %26, i32 %27)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i32 %28)
br label %39
30: ; preds = %7
%31 = load i32, i32* %1
%32 = load i32, i32* %2
%33 = call i32 @divi(i32 %31, i32 %32)
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i32 %33)
br label %39
35: ; preds = %7
%36 = call i32 @exit(i32 0)
unreachable
37: ; preds = %7
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0))
br label %39
39: ; preds = %37, %30, %25, %20, %15
br label %7
}