#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 *);
int /*<<< orphan*/ strcmp(char *, char *);
int main(void) {
  char command[6];
  int i, j;
  scanf("%d %s %d", &i, command, &j);
  if (!strcmp(command, "add"))
    printf("%d", i + j);
  else if (!strcmp(command, "sub"))
    printf("%d", i - j);
  else if (!strcmp(command, "mul"))
    printf("%d", i * j);
  else if (!strcmp(command, "div")) {
    if (j)
      printf("%d", i / j);
    else
      printf("error");
  } else if (!strcmp(command, "mod")) {
    if (j)
      printf("%d", i % j);
    else
      printf("error");
  } else
    printf("error");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xa(%rbp),%rdx
lea    0xeb6(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rcx
call   1050 <scanf@plt>
lea    -0xa(%rbp),%rdi
lea    0xea7(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1189 <main+0x59>
mov    -0x10(%rbp),%esi
add    -0x14(%rbp),%esi
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12b4 <main+0x184>
lea    -0xa(%rbp),%rdi
lea    0xe79(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11bb <main+0x8b>
mov    -0x10(%rbp),%esi
sub    -0x14(%rbp),%esi
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12af <main+0x17f>
lea    -0xa(%rbp),%rdi
lea    0xe4b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11ee <main+0xbe>
mov    -0x10(%rbp),%esi
imul   -0x14(%rbp),%esi
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12aa <main+0x17a>
lea    -0xa(%rbp),%rdi
lea    0xe1c(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1240 <main+0x110>
cmpl   $0x0,-0x14(%rbp)
je     122d <main+0xfd>
mov    -0x10(%rbp),%eax
cltd
idivl  -0x14(%rbp)
mov    %eax,%esi
lea    0xde5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123b <main+0x10b>
lea    0xde5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12a5 <main+0x175>
lea    -0xa(%rbp),%rdi
lea    0xdd4(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1292 <main+0x162>
cmpl   $0x0,-0x14(%rbp)
je     127f <main+0x14f>
mov    -0x10(%rbp),%eax
cltd
idivl  -0x14(%rbp)
mov    %edx,%esi
lea    0xd93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    128d <main+0x15d>
lea    0xd93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12a0 <main+0x170>
lea    0xd80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12a5 <main+0x175>
jmp    12aa <main+0x17a>
jmp    12af <main+0x17f>
jmp    12b4 <main+0x184>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xed5(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x12(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1040 <scanf@plt>
cmpl   $0x646461,0x12(%rsp)
je     118b <main+0x6b>
cmpl   $0x627573,0x12(%rsp)
je     1195 <main+0x75>
cmpl   $0x6c756d,0x12(%rsp)
je     119f <main+0x7f>
cmpl   $0x766964,0x12(%rsp)
je     11bd <main+0x9d>
cmpl   $0x646f6d,0x12(%rsp)
jne    11d7 <main+0xb7>
mov    0x8(%rsp),%ecx
test   %ecx,%ecx
je     11d7 <main+0xb7>
mov    0xc(%rsp),%eax
cltd
idiv   %ecx
lea    0xe7f(%rip),%rdi
mov    %edx,%esi
jmp    11af <main+0x8f>
mov    0x8(%rsp),%esi
add    0xc(%rsp),%esi
jmp    11a8 <main+0x88>
mov    0xc(%rsp),%esi
sub    0x8(%rsp),%esi
jmp    11a8 <main+0x88>
mov    0x8(%rsp),%esi
imul   0xc(%rsp),%esi
lea    0xe57(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret
mov    0x8(%rsp),%ecx
test   %ecx,%ecx
je     11d7 <main+0xb7>
mov    0xc(%rsp),%eax
cltd
idiv   %ecx
lea    0xe33(%rip),%rdi
mov    %eax,%esi
jmp    11af <main+0x8f>
lea    0xe3b(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11b6 <main+0x96>

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