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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x25(%rbp),%rdx
lea    0xeaf(%rip),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rcx
call   1050 <scanf@plt>
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    -0x25(%rbp),%rdi
lea    0xe90(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11a6 <main+0x76>
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x25(%rbp),%rdi
lea    0xe5e(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11e0 <main+0xb0>
mov    -0x14(%rbp),%eax
sub    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x25(%rbp),%rdi
lea    0xe28(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    121b <main+0xeb>
mov    -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xdf7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x25(%rbp),%rdi
lea    0xdf1(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1265 <main+0x135>
cmpl   $0x0,-0x18(%rbp)
je     1260 <main+0x130>
mov    -0x14(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %eax,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xdb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1265 <main+0x135>
lea    -0x25(%rbp),%rdi
lea    0xdab(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    12af <main+0x17f>
cmpl   $0x0,-0x18(%rbp)
je     12aa <main+0x17a>
mov    -0x14(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xd68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12af <main+0x17f>
cmpl   $0x0,-0x20(%rbp)
jne    12c7 <main+0x197>
lea    0xd5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xec5(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x13(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1050 <scanf@plt>
xor    %eax,%eax
cmpl   $0x646461,0x13(%rsp)
je     11eb <main+0xbb>
cmpl   $0x627573,0x13(%rsp)
je     1214 <main+0xe4>
cmpl   $0x6c756d,0x13(%rsp)
je     123d <main+0x10d>
cmpl   $0x766964,0x13(%rsp)
mov    0x8(%rsp),%ecx
jne    11ad <main+0x7d>
test   %ecx,%ecx
je     11ad <main+0x7d>
mov    0xc(%rsp),%eax
cltd
idiv   %ecx
lea    0xe70(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%eax
mov    0x8(%rsp),%ecx
cmpl   $0x646f6d,0x13(%rsp)
jne    11d4 <main+0xa4>
test   %ecx,%ecx
je     11d4 <main+0xa4>
mov    0xc(%rsp),%eax
cltd
idiv   %ecx
lea    0xe42(%rip),%rdi
mov    %edx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11e4 <main+0xb4>
test   %eax,%eax
jne    11e4 <main+0xb4>
lea    0xe40(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret
mov    0x8(%rsp),%esi
add    0xc(%rsp),%esi
lea    0xe11(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%eax
cmpl   $0x627573,0x13(%rsp)
jne    116d <main+0x3d>
mov    0xc(%rsp),%esi
sub    0x8(%rsp),%esi
lea    0xde8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%eax
cmpl   $0x6c756d,0x13(%rsp)
jne    117b <main+0x4b>
mov    0x8(%rsp),%esi
imul   0xc(%rsp),%esi
lea    0xdbe(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%eax
jmp    117b <main+0x4b>

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

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