#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 *, ...);
scalar_t__ scanf(char *, int *, char *, int *);
int main() {
  int a, b;
  char c;
  while (scanf("%d%c%d", &a, &c, &b)) {
    if (a == 0 && b == 0 && c == ' ')
      break;
    else {
      switch (c) {
      case '+':
        printf("%d\n", a + b);
        break;
      case '-':
        printf("%d\n", a - b);
        break;
      case '*':
        printf("%d\n", a * b);
        break;
      case '/':
        printf("%d\n", a / b);
        break;
      case '%':
        printf("%d\n", a % b);
        break;
      default:
        printf("invalid op\n");
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xef6(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xd(%rbp),%rdx
lea    -0xc(%rbp),%rcx
call   1040 <scanf@plt>
cmp    $0x0,%rax
je     123d <main+0x11d>
cmpl   $0x0,-0x8(%rbp)
jne    1177 <main+0x57>
cmpl   $0x0,-0xc(%rbp)
jne    1177 <main+0x57>
movsbl -0xd(%rbp),%eax
cmp    $0x20,%eax
jne    1177 <main+0x57>
jmp    123d <main+0x11d>
movsbl -0xd(%rbp),%eax
add    $0xffffffdb,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0xa,%eax
ja     1225 <main+0x105>
mov    -0x18(%rbp),%rax
lea    0xe68(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%esi
add    -0xc(%rbp),%esi
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1233 <main+0x113>
mov    -0x8(%rbp),%esi
sub    -0xc(%rbp),%esi
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1233 <main+0x113>
mov    -0x8(%rbp),%esi
imul   -0xc(%rbp),%esi
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1233 <main+0x113>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %eax,%esi
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1233 <main+0x113>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,%esi
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1233 <main+0x113>
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1238 <main+0x118>
jmp    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    0xee7(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0xf(%rsp),%rdx
lea    0x10(%rsp),%rcx
call   1050 <scanf@plt>
test   %rax,%rax
je     1203 <main+0xd3>
lea    0xec3(%rip),%r15
lea    0x14(%rsp),%r12
lea    0xf(%rsp),%r13
lea    0x10(%rsp),%rbx
lea    0xe81(%rip),%r14
lea    0xead(%rip),%rbp
jmp    11aa <main+0x7a>
add    %eax,%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %rbx,%rcx
call   1050 <scanf@plt>
test   %rax,%rax
je     1203 <main+0xd3>
mov    0x14(%rsp),%eax
mov    0x10(%rsp),%esi
movzbl 0xf(%rsp),%ecx
test   %eax,%eax
jne    11c4 <main+0x94>
test   %esi,%esi
jne    11c4 <main+0x94>
cmp    $0x20,%cl
je     1203 <main+0xd3>
movsbl %cl,%ecx
add    $0xffffffdb,%ecx
cmp    $0xa,%ecx
ja     11e2 <main+0xb2>
movslq (%r14,%rcx,4),%rcx
add    %r14,%rcx
jmp    *%rcx
cltd
idiv   %esi
mov    %rbp,%rdi
mov    %edx,%esi
jmp    118d <main+0x5d>
lea    0xe4e(%rip),%rdi
call   1030 <puts@plt>
jmp    1194 <main+0x64>
imul   %eax,%esi
jmp    118a <main+0x5a>
sub    %esi,%eax
jmp    11fc <main+0xcc>
cltd
idiv   %esi
mov    %rbp,%rdi
mov    %eax,%esi
jmp    118d <main+0x5d>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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