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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x110(%rbp),%rdx
lea    0xea9(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rcx
call   1050 <scanf@plt>
lea    -0x110(%rbp),%rdi
lea    0xe97(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    119f <main+0x6f>
mov    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ca <main+0x19a>
lea    -0x110(%rbp),%rdi
lea    0xe64(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11dc <main+0xac>
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c5 <main+0x195>
lea    -0x110(%rbp),%rdi
lea    0xe2b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1218 <main+0xe8>
mov    -0xc(%rbp),%eax
imul   -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c0 <main+0x190>
lea    -0x110(%rbp),%rdi
lea    0xdf3(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1260 <main+0x130>
cmpl   $0x0,-0xc(%rbp)
je     1260 <main+0x130>
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xdb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12bb <main+0x18b>
lea    -0x110(%rbp),%rdi
lea    0xdaf(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    12a8 <main+0x178>
cmpl   $0x0,-0xc(%rbp)
je     12a8 <main+0x178>
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%eax
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xd71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12b6 <main+0x186>
lea    0xd72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12bb <main+0x18b>
jmp    12c0 <main+0x190>
jmp    12c5 <main+0x195>
jmp    12ca <main+0x19a>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x118,%rsp
movl   $0x0,0xc(%rsp)
lea    0xeca(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
call   1040 <scanf@plt>
mov    0x10(%rsp),%eax
cmp    $0x627573,%eax
je     116d <main+0x4d>
cmp    $0x6c756d,%eax
je     1177 <main+0x57>
cmp    $0x646461,%eax
jne    119c <main+0x7c>
mov    0x8(%rsp),%esi
add    0xc(%rsp),%esi
jmp    1180 <main+0x60>
mov    0x8(%rsp),%esi
sub    0xc(%rsp),%esi
jmp    1180 <main+0x60>
mov    0x8(%rsp),%esi
imul   0xc(%rsp),%esi
mov    %esi,0x8(%rsp)
lea    0xe7e(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x118,%rsp
ret
mov    0xc(%rsp),%ecx
cmp    $0x766964,%eax
jne    11c1 <main+0xa1>
test   %ecx,%ecx
je     11c1 <main+0xa1>
mov    0x8(%rsp),%eax
cltd
idiv   %ecx
mov    %eax,0x8(%rsp)
lea    0xe4c(%rip),%rdi
mov    %eax,%esi
jmp    118b <main+0x6b>
cmp    $0x646f6d,%eax
jne    11e2 <main+0xc2>
test   %ecx,%ecx
je     11e2 <main+0xc2>
mov    0x8(%rsp),%eax
cltd
idiv   %ecx
mov    %edx,0x8(%rsp)
lea    0xe2b(%rip),%rdi
mov    %edx,%esi
jmp    118b <main+0x6b>
lea    0xe24(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1192 <main+0x72>

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

LLVM IR (-O2):
@.str = [9 x i8] c"%d %s %d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.7 = [6 x i8] c"error\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [256 x i8]
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%6 = getelementptr inbounds [256 x i8], [256 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 = bitcast [256 x i8]* %3 to i32*
%9 = load i32, i32* %8
switch i32 %9, label %25 [
i32 6579297, label %10
i32 6452595, label %15
i32 7107949, label %20
]
10: ; preds = %0
%11 = load i32, i32* %2
%12 = load i32, i32* %1
%13 = add nsw i32 %12, %11
store i32 %13, i32* %1
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %13)
br label %43
15: ; preds = %0
%16 = load i32, i32* %2
%17 = load i32, i32* %1
%18 = sub nsw i32 %17, %16
store i32 %18, i32* %1
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %18)
br label %43
20: ; preds = %0
%21 = load i32, i32* %2
%22 = load i32, i32* %1
%23 = mul nsw i32 %22, %21
store i32 %23, i32* %1
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %23)
br label %43
25: ; preds = %0
%26 = icmp eq i32 %9, 7760228
%27 = load i32, i32* %2
%28 = icmp ne i32 %27, 0
%29 = select i1 %26, i1 %28, i1 false
br i1 %29, label %30, label %34
30: ; preds = %25
%31 = load i32, i32* %1
%32 = sdiv i32 %31, %27
store i32 %32, i32* %1
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %32)
br label %43
34: ; preds = %25
%35 = icmp eq i32 %9, 6582125
%36 = select i1 %35, i1 %28, i1 false
br i1 %36, label %37, label %41
37: ; preds = %34
%38 = load i32, i32* %1
%39 = srem i32 %38, %27
store i32 %39, i32* %1
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %39)
br label %43
41: ; preds = %34
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %43
43: ; preds = %15, %30, %41, %37, %20, %10
ret i32 0
}