#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 */
scalar_t__ EOF;
int calculate(char, int, int);
int /*<<< orphan*/ printf(char *, int);
scalar_t__ scanf(char *, int *, char *, int *);
int main(int argc, char **argv) {
  int lhs, rhs;
  char op;
  while (1) {
    if (scanf("%d %c %d", &lhs, &op, &rhs) == EOF)
      break;
    printf("%d\n", calculate(op, lhs, rhs));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x19(%rbp),%rdx
lea    -0x18(%rbp),%rcx
call   1050 <scanf@plt>
mov    0x2e83(%rip),%rcx
cmp    (%rcx),%rax
jne    1173 <main+0x43>
jmp    1197 <main+0x67>
mov    -0x19(%rbp),%al
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
movsbl %al,%edi
call   1040 <calculate@plt>
mov    %eax,%esi
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
jmp    1146 <main+0x16>
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    0xebb(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0xf(%rsp),%rdx
lea    0x10(%rsp),%rcx
call   1050 <scanf@plt>
mov    0x2e88(%rip),%rbp
cmp    0x0(%rbp),%rax
je     11c3 <main+0x93>
lea    0xe9c(%rip),%r14
lea    0xe8c(%rip),%r15
lea    0x14(%rsp),%r12
lea    0xf(%rsp),%r13
lea    0x10(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl 0xf(%rsp),%edi
mov    0x14(%rsp),%esi
mov    0x10(%rsp),%edx
call   1040 <calculate@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %rbx,%rcx
call   1050 <scanf@plt>
cmp    0x0(%rbp),%rax
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 = [9 x i8] c"%d %c %d\00"
@EOF = global i64 0
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %9
9: ; preds = %2, %14
%10 = call i64 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %6, i8* %8, i32* %7)
%11 = load i64, i64* @EOF
%12 = icmp eq i64 %10, %11
br i1 %12, label %13, label %14
13: ; preds = %9
br label %20
14: ; preds = %9
%15 = load i8, i8* %8
%16 = load i32, i32* %6
%17 = load i32, i32* %7
%18 = call i32 @calculate(i8 signext %15, i32 %16, i32 %17)
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %18)
br label %9
20: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"%d %c %d\00"
@EOF = global i64 0
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = call i64 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %3, i8* %5, i32* %4)
%9 = load i64, i64* @EOF
%10 = icmp eq i64 %8, %9
br i1 %10, label %20, label %11
11: ; preds = %2, %11
%12 = load i8, i8* %5
%13 = load i32, i32* %3
%14 = load i32, i32* %4
%15 = call i32 @calculate(i8 signext %12, i32 %13, i32 %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = call i64 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %3, i8* %5, i32* %4)
%18 = load i64, i64* @EOF
%19 = icmp eq i64 %17, %18
br i1 %19, label %20, label %11
20: ; preds = %11, %2
ret i32 0
}