#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 a;
  int b;
  int c;
  char p[5];
  int error = 0;
  scanf("%d %s %d", &a, p, &b);
  if (strcmp(p, "add") == 0) {
    c = a + b;
  } else if (strcmp(p, "sub") == 0) {
    c = a - b;
  } else if (strcmp(p, "mul") == 0) {
    c = a * b;
  } else if (strcmp(p, "div") == 0) {
    if (b != 0) {
      c = a / b;
    } else {
      error = 1;
    }
  } else if (strcmp(p, "mod") == 0) {
    if (b != 0) {
      c = a % b;
    } else {
      error = 1;
    }
  } else {
    error = 1;
    printf("error\n");
  }
  if (error == 0) {
    printf("%d\n", c);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    -0x15(%rbp),%rdx
lea    0xeaf(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rcx
call   1050 <scanf@plt>
lea    -0x15(%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    127e <main+0x14e>
lea    -0x15(%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    1279 <main+0x149>
lea    -0x15(%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    1274 <main+0x144>
lea    -0x15(%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,-0x1c(%rbp)
jmp    126f <main+0x13f>
lea    -0x15(%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,-0x1c(%rbp)
jmp    126a <main+0x13a>
movl   $0x1,-0x1c(%rbp)
lea    0xdba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    126f <main+0x13f>
jmp    1274 <main+0x144>
jmp    1279 <main+0x149>
jmp    127e <main+0x14e>
cmpl   $0x0,-0x1c(%rbp)
jne    1299 <main+0x169>
mov    -0x10(%rbp),%esi
lea    0xd92(%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    0xeb4(%rip),%rdi
lea    0x4(%rsp),%rsi
lea    0xb(%rsp),%rbx
mov    %rsp,%rcx
mov    %rbx,%rdx
call   1060 <scanf@plt>
lea    0xea1(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11db <main+0x9b>
lea    0xe91(%rip),%rsi
lea    0xb(%rsp),%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11e4 <main+0xa4>
lea    0xe7f(%rip),%rsi
lea    0xb(%rsp),%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11ed <main+0xad>
lea    0xe6d(%rip),%rsi
lea    0xb(%rsp),%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11f7 <main+0xb7>
lea    0xe5b(%rip),%rsi
lea    0xb(%rsp),%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1209 <main+0xc9>
lea    0xe4d(%rip),%rdi
call   1030 <puts@plt>
jmp    1227 <main+0xe7>
mov    (%rsp),%esi
add    0x4(%rsp),%esi
jmp    1219 <main+0xd9>
mov    0x4(%rsp),%esi
sub    (%rsp),%esi
jmp    1219 <main+0xd9>
mov    (%rsp),%esi
imul   0x4(%rsp),%esi
jmp    1219 <main+0xd9>
mov    (%rsp),%ecx
test   %ecx,%ecx
je     1227 <main+0xe7>
mov    0x4(%rsp),%eax
cltd
idiv   %ecx
mov    %eax,%esi
jmp    1219 <main+0xd9>
mov    (%rsp),%ecx
test   %ecx,%ecx
je     1227 <main+0xe7>
mov    0x4(%rsp),%eax
cltd
idiv   %ecx
mov    %edx,%esi
lea    0xdfd(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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