#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 *, char *, int *);
int main() {
  char ch;
  int n1, n2;
  do {
    printf("\n********************************************\n");
    printf("Enter number,operator and number\n");
    scanf("%d%c%d", &n1, &ch, &n2);
    switch (ch) {
    case '+':
      printf("Answer is %d\n", n1 + n2);
      break;
    case '-':
      printf("Answer is %d\n", n1 - n2);
      break;
    case '*':
      printf("Answer is %d\n", n1 * n2);
      break;
    case '/':
      printf("Answer is %d\n", n1 / n2);
      break;
    default:
      printf("Try again\n");
    }
  } while (ch != 27);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xee2(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x19(%rbp)
call   1030 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xefd(%rip),%rdi
call   1030 <printf@plt>
lea    0xf13(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x5(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1040 <scanf@plt>
movsbl -0x5(%rbp),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x5,%eax
ja     11f9 <main+0xd9>
mov    -0x18(%rbp),%rax
lea    0xe78(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0xc(%rbp),%esi
add    -0x10(%rbp),%esi
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1207 <main+0xe7>
mov    -0xc(%rbp),%esi
sub    -0x10(%rbp),%esi
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1207 <main+0xe7>
mov    -0xc(%rbp),%esi
imul   -0x10(%rbp),%esi
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1207 <main+0xe7>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %eax,%esi
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1207 <main+0xe7>
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    120c <main+0xec>
movsbl -0x5(%rbp),%eax
cmp    $0x1b,%eax
jne    112f <main+0xf>
xor    %eax,%eax
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    0xf16(%rip),%r15
lea    0xecc(%rip),%r12
lea    0x14(%rsp),%r13
lea    0xf(%rsp),%rbx
lea    0x10(%rsp),%rbp
lea    0xe9e(%rip),%r14
jmp    1190 <main+0x60>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0xf05(%rip),%rdi
call   1030 <puts@plt>
cmpb   $0x1b,0xf(%rsp)
je     1234 <main+0x104>
nopw   0x0(%rax,%rax,1)
lea    0xe96(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
mov    %rbp,%rcx
call   1050 <scanf@plt>
movsbl 0xf(%rsp),%eax
add    $0xffffffd6,%eax
cmp    $0x5,%eax
ja     1170 <main+0x40>
movslq (%r14,%rax,4),%rax
add    %r14,%rax
jmp    *%rax
mov    0x10(%rsp),%esi
imul   0x14(%rsp),%esi
jmp    11f8 <main+0xc8>
cs nopw 0x0(%rax,%rax,1)
mov    0x10(%rsp),%esi
add    0x14(%rsp),%esi
jmp    11f8 <main+0xc8>
nopw   0x0(%rax,%rax,1)
mov    0x14(%rsp),%esi
sub    0x10(%rsp),%esi
lea    0xe20(%rip),%rdi
jmp    1222 <main+0xf2>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x14(%rsp),%eax
cltd
idivl  0x10(%rsp)
lea    0xdff(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmpb   $0x1b,0xf(%rsp)
jne    1190 <main+0x60>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [47 x i8] c"\0A********************************************\0A\00"
@.str.1 = [34 x i8] c"Enter number,operator and number\0A\00"
@.str.2 = [7 x i8] c"%d%c%d\00"
@.str.3 = [14 x i8] c"Answer is %d\0A\00"
@.str.4 = [11 x i8] c"Try again\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
br label %5
5: ; preds = %34, %0
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32* %3, i8* %2, i32* %4)
%9 = load i8, i8* %2
%10 = sext i8 %9 to i32
switch i32 %10, label %31 [
i32 43, label %11
i32 45, label %16
i32 42, label %21
i32 47, label %26
]
11: ; preds = %5
%12 = load i32, i32* %3
%13 = load i32, i32* %4
%14 = add nsw i32 %12, %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %14)
br label %33
16: ; preds = %5
%17 = load i32, i32* %3
%18 = load i32, i32* %4
%19 = sub nsw i32 %17, %18
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %19)
br label %33
21: ; preds = %5
%22 = load i32, i32* %3
%23 = load i32, i32* %4
%24 = mul nsw i32 %22, %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %24)
br label %33
26: ; preds = %5
%27 = load i32, i32* %3
%28 = load i32, i32* %4
%29 = sdiv i32 %27, %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %29)
br label %33
31: ; preds = %5
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %33
33: ; preds = %31, %26, %21, %16, %11
br label %34
34: ; preds = %33
%35 = load i8, i8* %2
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %36, 27
br i1 %37, label %5, label %38
38: ; preds = %34
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [7 x i8] c"%d%c%d\00"
@.str.3 = [14 x i8] c"Answer is %d\0A\00"
@str = [46 x i8] c"\0A********************************************\00"
@str.5 = [33 x i8] c"Enter number,operator and number\00"
@str.6 = [10 x i8] c"Try again\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %2 to i8*
%5 = bitcast i32* %3 to i8*
br label %6
6: ; preds = %34, %0
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.5, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32* %2, i8* %1, i32* %3)
%10 = load i8, i8* %1
%11 = sext i8 %10 to i32
switch i32 %11, label %32 [
i32 43, label %12
i32 45, label %17
i32 42, label %22
i32 47, label %27
]
12: ; preds = %6
%13 = load i32, i32* %2
%14 = load i32, i32* %3
%15 = add nsw i32 %14, %13
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %15)
br label %34
17: ; preds = %6
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = sub nsw i32 %18, %19
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %20)
br label %34
22: ; preds = %6
%23 = load i32, i32* %2
%24 = load i32, i32* %3
%25 = mul nsw i32 %24, %23
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %25)
br label %34
27: ; preds = %6
%28 = load i32, i32* %2
%29 = load i32, i32* %3
%30 = sdiv i32 %28, %29
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %30)
br label %34
32: ; preds = %6
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.6, i64 0, i64 0))
br label %34
34: ; preds = %12, %17, %22, %27, %32
%35 = load i8, i8* %1
%36 = icmp eq i8 %35, 27
br i1 %36, label %37, label %6
37: ; preds = %34
ret i32 0
}