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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
lea    -0x13(%rbp),%rdx
lea    0xeaf(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rcx
call   1050 <scanf@plt>
lea    -0x13(%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    1269 <main+0x139>
lea    -0x13(%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    1264 <main+0x134>
lea    -0x13(%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    125f <main+0x12f>
lea    -0x13(%rbp),%rdi
lea    0xe33(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1216 <main+0xe6>
cmpl   $0x0,-0xc(%rbp)
je     120a <main+0xda>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %eax,-0x10(%rbp)
jmp    1211 <main+0xe1>
movl   $0x1,-0x18(%rbp)
jmp    125a <main+0x12a>
lea    -0x13(%rbp),%rdi
lea    0xdf8(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1255 <main+0x125>
cmpl   $0x0,-0xc(%rbp)
je     1249 <main+0x119>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,-0x10(%rbp)
jmp    1250 <main+0x120>
movl   $0x1,-0x18(%rbp)
jmp    1255 <main+0x125>
jmp    125a <main+0x12a>
jmp    125f <main+0x12f>
jmp    1264 <main+0x134>
jmp    1269 <main+0x139>
cmpl   $0x0,-0x18(%rbp)
jne    1289 <main+0x159>
mov    -0x10(%rbp),%esi
lea    0xd89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    129e <main+0x16e>
movl   $0x1,-0x18(%rbp)
lea    0xd86(%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     11cd <main+0x9d>
lea    0xe9f(%rip),%rsi
lea    0x5(%rsp),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11d7 <main+0xa7>
lea    0xe8d(%rip),%rsi
lea    0x5(%rsp),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11e1 <main+0xb1>
lea    0xe7b(%rip),%rsi
lea    0x5(%rsp),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11ec <main+0xbc>
lea    0xe69(%rip),%rsi
lea    0x5(%rsp),%rdi
call   1040 <strcmp@plt>
mov    0x8(%rsp),%ecx
test   %ecx,%ecx
je     1213 <main+0xe3>
mov    0xc(%rsp),%eax
cltd
idiv   %ecx
mov    %edx,%esi
jmp    11fd <main+0xcd>
mov    0x8(%rsp),%esi
add    0xc(%rsp),%esi
jmp    11fd <main+0xcd>
mov    0xc(%rsp),%esi
sub    0x8(%rsp),%esi
jmp    11fd <main+0xcd>
mov    0x8(%rsp),%esi
imul   0xc(%rsp),%esi
jmp    11fd <main+0xcd>
mov    0x8(%rsp),%ecx
test   %ecx,%ecx
je     1213 <main+0xe3>
mov    0xc(%rsp),%eax
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xe02(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe03(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    120b <main+0xdb>

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 = [4 x i8] c"mod\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [6 x i8] c"error\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [3 x i8]
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %6
%7 = getelementptr inbounds [3 x i8], [3 x i8]* %5, 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]* %5, 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 %62
16: ; preds = %0
%17 = getelementptr inbounds [3 x i8], [3 x i8]* %5, 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 %61
24: ; preds = %16
%25 = getelementptr inbounds [3 x i8], [3 x i8]* %5, 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 %60
32: ; preds = %24
%33 = getelementptr inbounds [3 x i8], [3 x i8]* %5, 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 %45
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 %44
43: ; preds = %36
store i32 1, i32* %6
br label %44
44: ; preds = %43, %39
br label %59
45: ; preds = %32
%46 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%47 = call i64 @strcmp(i8* %46, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %58
49: ; preds = %45
%50 = load i32, i32* %3
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %56
52: ; preds = %49
%53 = load i32, i32* %2
%54 = load i32, i32* %3
%55 = srem i32 %53, %54
store i32 %55, i32* %4
br label %57
56: ; preds = %49
store i32 1, i32* %6
br label %57
57: ; preds = %56, %52
br label %58
58: ; preds = %57, %45
br label %59
59: ; preds = %58, %44
br label %60
60: ; preds = %59, %28
br label %61
61: ; preds = %60, %20
br label %62
62: ; preds = %61, %12
%63 = load i32, i32* %6
%64 = icmp eq i32 %63, 0
br i1 %64, label %65, label %68
65: ; preds = %62
%66 = load i32, i32* %4
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %66)
br label %70
68: ; preds = %62
store i32 1, i32* %6
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %70
70: ; preds = %68, %65
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 = [4 x i8] c"mod\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [6 x i8] c"error\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 %45
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 %45
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 %45
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 %37
31: ; preds = %28
%32 = load i32, i32* %2
%33 = icmp eq i32 %32, 0
br i1 %33, label %48, label %34
34: ; preds = %31
%35 = load i32, i32* %1
%36 = sdiv i32 %35, %32
br label %45
37: ; preds = %28
%38 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
%40 = load i32, i32* %2
%41 = icmp eq i32 %40, 0
br i1 %41, label %48, label %42
42: ; preds = %37
%43 = load i32, i32* %1
%44 = srem i32 %43, %40
br label %45
45: ; preds = %10, %17, %24, %34, %42
%46 = phi i32 [ %44, %42 ], [ %36, %34 ], [ %27, %24 ], [ %20, %17 ], [ %13, %10 ]
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %46)
br label %50
48: ; preds = %31, %37
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %50
50: ; preds = %48, %45
ret i32 0
}