#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 *, ...);
main() {
  int l = 1;
  while ("l==1") {
    char op;
    int num1, num2, num3;
    printf("op");
    scanf("%c", &op);
    printf("num1");
    scanf("%d", &num1);
    printf("num2");
    scanf("%d", &num2);
    switch (op) {
    case '1':
    case '+':
      printf(" %d + %d = %d", num1, num2, num2 + num1);
      break;
    case '2':
    case '-':
      printf(" %d - %d = %d", num1, num2, num1 - num2);
      break;
    case '3':
    case '*':
      printf(" %d * %d = %d", num1, num2, num1 * num2);
      break;
    case '4':
    case '/':
      printf(" %d / %d = %d", num1, num2, num1 / num2);
      break;
    default:
      printf("error");
      break;
    }
    printf("%d\n", num3);
    scanf("%d", &l);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
lea    0xef4(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x21(%rbp)
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xee3(%rip),%rdi
lea    -0x9(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x21(%rbp),%al
lea    0xed3(%rip),%rdi
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xef5(%rip),%rdi
mov    %rdi,-0x30(%rbp)
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x21(%rbp),%al
lea    0xeb2(%rip),%rdi
call   1030 <printf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x21(%rbp),%al
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
movsbl -0x9(%rbp),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0xa,%eax
ja     124f <main+0x12f>
mov    -0x20(%rbp),%rax
lea    0xe40(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x14(%rbp),%ecx
add    -0x10(%rbp),%ecx
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    125d <main+0x13d>
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%ecx
sub    -0x14(%rbp),%ecx
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    125d <main+0x13d>
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%ecx
imul   -0x14(%rbp),%ecx
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    125d <main+0x13d>
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%eax
cltd
idivl  -0x14(%rbp)
mov    -0x34(%rbp),%edx
mov    %eax,%ecx
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    125d <main+0x13d>
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdf3(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
jmp    1136 <main+0x16>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movl   $0x1,0x14(%rsp)
lea    0xf26(%rip),%rbx
lea    0xef3(%rip),%r14
lea    0xc(%rsp),%r15
lea    0xf2a(%rip),%r12
lea    0x14(%rsp),%r13
lea    0xea4(%rip),%rbp
jmp    1191 <main+0x71>
xchg   %ax,%ax
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
mov    %esi,%ecx
sub    %edx,%ecx
lea    0xed7(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xe94(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe89(%rip),%rdi
lea    0xb(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xe79(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movsbl 0xb(%rsp),%eax
add    $0xffffffd6,%eax
cmp    $0xa,%eax
ja     125d <main+0x13d>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
mov    %edx,%ecx
imul   %esi,%ecx
lea    0xe47(%rip),%rdi
jmp    1173 <main+0x53>
cs nopw 0x0(%rax,%rax,1)
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
lea    (%rdx,%rsi,1),%ecx
lea    0xe0a(%rip),%rdi
jmp    1173 <main+0x53>
nopw   0x0(%rax,%rax,1)
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%ecx
mov    %esi,%eax
cltd
idiv   %ecx
lea    0xe12(%rip),%rdi
mov    %ecx,%edx
mov    %eax,%ecx
jmp    1173 <main+0x53>
lea    0xe10(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    117a <main+0x5a>

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

LLVM IR (-O2):
@.str.1 = [3 x i8] c"op\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [5 x i8] c"num1\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [5 x i8] c"num2\00"
@.str.6 = [14 x i8] c" %d + %d = %d\00"
@.str.7 = [14 x i8] c" %d - %d = %d\00"
@.str.8 = [14 x i8] c" %d * %d = %d\00"
@.str.9 = [14 x i8] c" %d / %d = %d\00"
@.str.10 = [6 x i8] c"error\00"
@.str.11 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
store i32 1, i32* %1
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
br label %8
8: ; preds = %39, %0
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %4)
%15 = load i8, i8* %2
%16 = sext i8 %15 to i32
switch i32 %16, label %37 [
i32 49, label %17
i32 43, label %17
i32 50, label %22
i32 45, label %22
i32 51, label %27
i32 42, label %27
i32 52, label %32
i32 47, label %32
]
17: ; preds = %8, %8
%18 = load i32, i32* %3
%19 = load i32, i32* %4
%20 = add nsw i32 %19, %18
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %18, i32 %19, i32 %20)
br label %39
22: ; preds = %8, %8
%23 = load i32, i32* %3
%24 = load i32, i32* %4
%25 = sub nsw i32 %23, %24
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i32 %23, i32 %24, i32 %25)
br label %39
27: ; preds = %8, %8
%28 = load i32, i32* %3
%29 = load i32, i32* %4
%30 = mul nsw i32 %29, %28
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i32 %28, i32 %29, i32 %30)
br label %39
32: ; preds = %8, %8
%33 = load i32, i32* %3
%34 = load i32, i32* %4
%35 = sdiv i32 %33, %34
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i32 %33, i32 %34, i32 %35)
br label %39
37: ; preds = %8
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
br label %39
39: ; preds = %37, %32, %27, %22, %17
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i32 undef)
%41 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
br label %8
}