#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*/ clrscr();
int /*<<< orphan*/ getch();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, ...);
void main() {
  int a, b, ch;
  float result;
  do {
    clrscr();
    printf("select the operation from list");
    printf("\n 1.ADDITION \n 2.SUBSTRACTION");
    printf("\n 3.MULTIPLICATION \n 4.DIVISION");
    printf("\n Enter your choice:");
    scanf("%d", &ch);
  } while ((ch > 4) || (ch < 1));
  switch (ch) {
  case 1:
    printf("\n enter two numbers:");
    scanf("%d%d", &a, &b);
    result = a + b;
    printf("\n result=%f", result);
    break;
  case 2:
    printf("\n enter two numbers:");
    scanf("%d%d", &a, &b);
    result = a - b;
    printf("\n result=%f", result);
    break;
  case 3:
    printf("\n enter two numbers:");
    scanf("%d%d", &a, &b);
    result = a * b;
    printf("\n result=%f", result);
    break;
  case 4:
    printf("\n enter two numbers:");
    scanf("%d%d", &a, &b);
    result = a / b;
    printf("\n result=%f", result);
  }
  getch();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1030 <clrscr@plt>
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xedb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeed(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf0b(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    $0x1,%al
cmpl   $0x4,-0xc(%rbp)
mov    %al,-0x11(%rbp)
jg     11b2 <main+0x72>
cmpl   $0x1,-0xc(%rbp)
setl   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1148 <main+0x8>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x3,%eax
ja     131f <main+0x1df>
mov    -0x20(%rbp),%rax
lea    0xe23(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe9c(%rip),%rdi
lea    -0x4(%rbp),%rsi
lea    -0x8(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe73(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    131f <main+0x1df>
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe4d(%rip),%rdi
lea    -0x4(%rbp),%rsi
lea    -0x8(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x4(%rbp),%eax
sub    -0x8(%rbp),%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe24(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    131f <main+0x1df>
lea    0xdf7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdfe(%rip),%rdi
lea    -0x4(%rbp),%rsi
lea    -0x8(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x4(%rbp),%eax
imul   -0x8(%rbp),%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdd4(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    131f <main+0x1df>
lea    0xda7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdae(%rip),%rdi
lea    -0x4(%rbp),%rsi
lea    -0x8(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd84(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <getch@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xebb(%rip),%r14
lea    0xed3(%rip),%r15
lea    0xeea(%rip),%r12
lea    0xf03(%rip),%r13
lea    0xf28(%rip),%rbx
lea    0x14(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <clrscr@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x14(%rsp),%eax
lea    -0x5(%rax),%ecx
cmp    $0xfffffffc,%ecx
jb     1180 <main+0x40>
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     12bd <main+0x17d>
lea    0xe25(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe97(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe9e(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
add    0x10(%rsp),%eax
jmp    12a7 <main+0x167>
lea    0xe64(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe6b(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x10(%rsp),%eax
sub    0xc(%rsp),%eax
jmp    12a7 <main+0x167>
lea    0xe34(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe3b(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
imul   0x10(%rsp),%eax
jmp    12a7 <main+0x167>
lea    0xe03(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe0a(%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)
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xde6(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <getch@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"select the operation from list\00"
@.str.1 = [30 x i8] c"\0A 1.ADDITION \0A 2.SUBSTRACTION\00"
@.str.2 = [32 x i8] c"\0A 3.MULTIPLICATION \0A 4.DIVISION\00"
@.str.3 = [21 x i8] c"\0A Enter your choice:\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [21 x i8] c"\0A enter two numbers:\00"
@.str.6 = [5 x i8] c"%d%d\00"
@.str.7 = [12 x i8] c"\0A result=%f\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
br label %5
5: ; preds = %18, %0
%6 = call i32 (...) @clrscr()
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
br label %12
12: ; preds = %5
%13 = load i32, i32* %3
%14 = icmp sgt i32 %13, 4
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = load i32, i32* %3
%17 = icmp slt i32 %16, 1
br label %18
18: ; preds = %15, %12
%19 = phi i1 [ true, %12 ], [ %17, %15 ]
br i1 %19, label %5, label %20
20: ; preds = %18
%21 = load i32, i32* %3
switch i32 %21, label %62 [
i32 1, label %22
i32 2, label %32
i32 3, label %42
i32 4, label %52
]
22: ; preds = %20
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%24 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32* %1, i32* %2)
%25 = load i32, i32* %1
%26 = load i32, i32* %2
%27 = add nsw i32 %25, %26
%28 = sitofp i32 %27 to float
store float %28, float* %4
%29 = load float, float* %4
%30 = fpext float %29 to double
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), double %30)
br label %62
32: ; preds = %20
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%34 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32* %1, i32* %2)
%35 = load i32, i32* %1
%36 = load i32, i32* %2
%37 = sub nsw i32 %35, %36
%38 = sitofp i32 %37 to float
store float %38, float* %4
%39 = load float, float* %4
%40 = fpext float %39 to double
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), double %40)
br label %62
42: ; preds = %20
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%44 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32* %1, i32* %2)
%45 = load i32, i32* %1
%46 = load i32, i32* %2
%47 = mul nsw i32 %45, %46
%48 = sitofp i32 %47 to float
store float %48, float* %4
%49 = load float, float* %4
%50 = fpext float %49 to double
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), double %50)
br label %62
52: ; preds = %20
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%54 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32* %1, i32* %2)
%55 = load i32, i32* %1
%56 = load i32, i32* %2
%57 = sdiv i32 %55, %56
%58 = sitofp i32 %57 to float
store float %58, float* %4
%59 = load float, float* %4
%60 = fpext float %59 to double
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), double %60)
br label %62
62: ; preds = %52, %20, %42, %32, %22
%63 = call i32 (...) @getch()
ret void
}

LLVM IR (-O2):
@.str = [31 x i8] c"select the operation from list\00"
@.str.1 = [30 x i8] c"\0A 1.ADDITION \0A 2.SUBSTRACTION\00"
@.str.2 = [32 x i8] c"\0A 3.MULTIPLICATION \0A 4.DIVISION\00"
@.str.3 = [21 x i8] c"\0A Enter your choice:\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [21 x i8] c"\0A enter two numbers:\00"
@.str.6 = [5 x i8] c"%d%d\00"
@.str.7 = [12 x i8] c"\0A result=%f\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 = %7, %0
%8 = call i32 (...) @clrscr()
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%14 = load i32, i32* %3
%15 = add i32 %14, -5
%16 = icmp ult i32 %15, -4
br i1 %16, label %7, label %17
17: ; preds = %7
switch i32 %14, label %47 [
i32 1, label %18
i32 2, label %24
i32 3, label %30
i32 4, label %36
]
18: ; preds = %17
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%20 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32* %1, i32* %2)
%21 = load i32, i32* %1
%22 = load i32, i32* %2
%23 = add nsw i32 %22, %21
br label %42
24: ; preds = %17
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%26 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32* %1, i32* %2)
%27 = load i32, i32* %1
%28 = load i32, i32* %2
%29 = sub nsw i32 %27, %28
br label %42
30: ; preds = %17
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%32 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32* %1, i32* %2)
%33 = load i32, i32* %1
%34 = load i32, i32* %2
%35 = mul nsw i32 %34, %33
br label %42
36: ; preds = %17
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%38 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32* %1, i32* %2)
%39 = load i32, i32* %1
%40 = load i32, i32* %2
%41 = sdiv i32 %39, %40
br label %42
42: ; preds = %18, %24, %30, %36
%43 = phi i32 [ %41, %36 ], [ %35, %30 ], [ %29, %24 ], [ %23, %18 ]
%44 = sitofp i32 %43 to float
%45 = fpext float %44 to double
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), double %45)
br label %47
47: ; preds = %42, %17
%48 = call i32 (...) @getch()
ret void
}