#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 num1, num2, result;
  char operation[4];
  scanf("%d %s %d", &num1, operation, &num2);
  if (strcmp(operation, "add") == 0) {
    result = num1 + num2;
    printf("%d", result);
  } else if (strcmp(operation, "sub") == 0) {
    result = num1 - num2;
    printf("%d", result);
  } else if (strcmp(operation, "mul") == 0) {
    result = num1 * num2;
    printf("%d", result);
  } else if (strcmp(operation, "div") == 0) {
    if (num2 == 0) {
      printf("error");
    } else {
      result = num1 / num2;
      printf("%d", result);
    }
  } else if (strcmp(operation, "mod") == 0) {
    if (num2 == 0) {
      printf("error");
    } else {
      result = num1 % num2;
      printf("%d", result);
    }
  } else {
    printf("error");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x14(%rbp),%rdx
lea    0xeb6(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rcx
call   1050 <scanf@plt>
lea    -0x14(%rbp),%rdi
lea    0xea7(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1190 <main+0x60>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d3 <main+0x1a3>
lea    -0x14(%rbp),%rdi
lea    0xe72(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11c9 <main+0x99>
mov    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ce <main+0x19e>
lea    -0x14(%rbp),%rdi
lea    0xe3d(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1203 <main+0xd3>
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c9 <main+0x199>
lea    -0x14(%rbp),%rdi
lea    0xe07(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    125a <main+0x12a>
cmpl   $0x0,-0xc(%rbp)
jne    123a <main+0x10a>
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1255 <main+0x125>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xdb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c4 <main+0x194>
lea    -0x14(%rbp),%rdi
lea    0xdba(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    12b1 <main+0x181>
cmpl   $0x0,-0xc(%rbp)
jne    1291 <main+0x161>
lea    0xd94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ac <main+0x17c>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xd61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12bf <main+0x18f>
lea    0xd61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c4 <main+0x194>
jmp    12c9 <main+0x199>
jmp    12ce <main+0x19e>
jmp    12d3 <main+0x1a3>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xec4(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0xc(%rsp),%rbx
lea    0x4(%rsp),%rcx
mov    %rbx,%rdx
call   1050 <scanf@plt>
lea    0xeaf(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11d9 <main+0xa9>
lea    0xe9f(%rip),%rsi
lea    0xc(%rsp),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11e3 <main+0xb3>
lea    0xe8d(%rip),%rsi
lea    0xc(%rsp),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11ed <main+0xbd>
lea    0xe7b(%rip),%rsi
lea    0xc(%rsp),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     120c <main+0xdc>
lea    0xe6f(%rip),%rsi
lea    0xc(%rsp),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1226 <main+0xf6>
mov    0x4(%rsp),%ecx
test   %ecx,%ecx
je     1226 <main+0xf6>
mov    0x8(%rsp),%eax
cltd
idiv   %ecx
lea    0xe31(%rip),%rdi
mov    %edx,%esi
jmp    11fd <main+0xcd>
mov    0x4(%rsp),%esi
add    0x8(%rsp),%esi
jmp    11f6 <main+0xc6>
mov    0x8(%rsp),%esi
sub    0x4(%rsp),%esi
jmp    11f6 <main+0xc6>
mov    0x4(%rsp),%esi
imul   0x8(%rsp),%esi
lea    0xe09(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
mov    0x4(%rsp),%ecx
test   %ecx,%ecx
je     1226 <main+0xf6>
mov    0x8(%rsp),%eax
cltd
idiv   %ecx
lea    0xde4(%rip),%rdi
mov    %eax,%esi
jmp    11fd <main+0xcd>
lea    0xdec(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1204 <main+0xd4>

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