#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 *);
scalar_t__ strcmp(char *, char *);
int main() {
  int num1, num2, answer, error = 0;
  char operator[3];
  scanf("%d %s %d", &num1, operator, & num2);
  if (strcmp(operator, "add") == 0) {
    answer = num1 + num2;
  } else if (strcmp(operator, "sub") == 0) {
    answer = num1 - num2;
  } else if (strcmp(operator, "mul") == 0) {
    answer = num1 * num2;
  } else if (strcmp(operator, "div") == 0) {
    if (num2 != 0) {
      answer = num1 / num2;
    } else {
      printf("error");
      error = 1;
    }
  } else if (strcmp(operator, "mod") == 0) {
    if (num2 != 0) {
      answer = num1 % num2;
    } else {
      printf("error");
      error = 1;
    }
  } else {
    printf("error");
    error = 1;
  }
  if (error != 1) {
    printf("%d", answer);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x17(%rbp),%rdx
lea    0xeaf(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rcx
call   1050 <scanf@plt>
lea    -0x17(%rbp),%rdi
lea    0xea0(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1186 <main+0x56>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    129a <main+0x16a>
lea    -0x17(%rbp),%rdi
lea    0xe7c(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11ae <main+0x7e>
mov    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    1295 <main+0x165>
lea    -0x17(%rbp),%rdi
lea    0xe58(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11d7 <main+0xa7>
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    1290 <main+0x160>
lea    -0x17(%rbp),%rdi
lea    0xe33(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1224 <main+0xf4>
cmpl   $0x0,-0xc(%rbp)
je     120a <main+0xda>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %eax,-0x10(%rbp)
jmp    121f <main+0xef>
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x14(%rbp)
jmp    128b <main+0x15b>
lea    -0x17(%rbp),%rdi
lea    0xdf0(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1271 <main+0x141>
cmpl   $0x0,-0xc(%rbp)
je     1257 <main+0x127>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,-0x10(%rbp)
jmp    126c <main+0x13c>
lea    0xdbb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x14(%rbp)
jmp    1286 <main+0x156>
lea    0xda1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x14(%rbp)
jmp    128b <main+0x15b>
jmp    1290 <main+0x160>
jmp    1295 <main+0x165>
jmp    129a <main+0x16a>
cmpl   $0x1,-0x14(%rbp)
je     12b5 <main+0x185>
mov    -0x10(%rbp),%esi
lea    0xd58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xec4(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x5(%rsp),%rbx
lea    0x8(%rsp),%rcx
mov    %rbx,%rdx
call   1050 <scanf@plt>
lea    0xeaf(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11d2 <main+0xa2>
lea    0xe9f(%rip),%rsi
lea    0x5(%rsp),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11dc <main+0xac>
lea    0xe8d(%rip),%rsi
lea    0x5(%rsp),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11e6 <main+0xb6>
lea    0xe7b(%rip),%rsi
lea    0x5(%rsp),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11f1 <main+0xc1>
lea    0xe6f(%rip),%rsi
lea    0x5(%rsp),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1218 <main+0xe8>
mov    0x8(%rsp),%ecx
test   %ecx,%ecx
je     1218 <main+0xe8>
mov    0xc(%rsp),%eax
cltd
idiv   %ecx
mov    %edx,%esi
jmp    1202 <main+0xd2>
mov    0x8(%rsp),%esi
add    0xc(%rsp),%esi
jmp    1202 <main+0xd2>
mov    0xc(%rsp),%esi
sub    0x8(%rsp),%esi
jmp    1202 <main+0xd2>
mov    0x8(%rsp),%esi
imul   0xc(%rsp),%esi
jmp    1202 <main+0xd2>
mov    0x8(%rsp),%ecx
test   %ecx,%ecx
je     1218 <main+0xe8>
mov    0xc(%rsp),%eax
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xdfd(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xdfa(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1210 <main+0xe0>

LLVM IR (-O0):
@.str = [9 x i8] c"%d %s %d\00"
@.str.1 = [4 x i8] c"add\00"
@.str.2 = [4 x i8] c"sub\00"
@.str.3 = [4 x i8] c"mul\00"
@.str.4 = [4 x i8] c"div\00"
@.str.5 = [6 x i8] c"error\00"
@.str.6 = [4 x i8] c"mod\00"
@.str.7 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [3 x i8]
store i32 0, i32* %1
store i32 0, i32* %5
%7 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%8 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %2, i8* %7, i32* %3)
%9 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%10 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %0
%13 = load i32, i32* %2
%14 = load i32, i32* %3
%15 = add nsw i32 %13, %14
store i32 %15, i32* %4
br label %66
16: ; preds = %0
%17 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = load i32, i32* %2
%22 = load i32, i32* %3
%23 = sub nsw i32 %21, %22
store i32 %23, i32* %4
br label %65
24: ; preds = %16
%25 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %24
%29 = load i32, i32* %2
%30 = load i32, i32* %3
%31 = mul nsw i32 %29, %30
store i32 %31, i32* %4
br label %64
32: ; preds = %24
%33 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%34 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %46
36: ; preds = %32
%37 = load i32, i32* %3
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %43
39: ; preds = %36
%40 = load i32, i32* %2
%41 = load i32, i32* %3
%42 = sdiv i32 %40, %41
store i32 %42, i32* %4
br label %45
43: ; preds = %36
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %5
br label %45
45: ; preds = %43, %39
br label %63
46: ; preds = %32
%47 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%48 = call i64 @strcmp(i8* %47, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %60
50: ; preds = %46
%51 = load i32, i32* %3
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %57
53: ; preds = %50
%54 = load i32, i32* %2
%55 = load i32, i32* %3
%56 = srem i32 %54, %55
store i32 %56, i32* %4
br label %59
57: ; preds = %50
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %5
br label %59
59: ; preds = %57, %53
br label %62
60: ; preds = %46
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %5
br label %62
62: ; preds = %60, %59
br label %63
63: ; preds = %62, %45
br label %64
64: ; preds = %63, %28
br label %65
65: ; preds = %64, %20
br label %66
66: ; preds = %65, %12
%67 = load i32, i32* %5
%68 = icmp ne i32 %67, 1
br i1 %68, label %69, label %72
69: ; preds = %66
%70 = load i32, i32* %4
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 %70)
br label %72
72: ; preds = %69, %66
ret i32 0
}

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