#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, c, h;
  char opr[3];
  scanf("%d %s %d", &num1, &opr, &num2);
  if (strcmp(opr, "add") == 0) {
    c = 1;
  } else if (strcmp(opr, "sub") == 0) {
    c = 2;
  } else if (strcmp(opr, "mul") == 0) {
    c = 3;
  } else if (strcmp(opr, "div") == 0) {
    c = 4;
  } else if (strcmp(opr, "mod") == 0) {
    c = 5;
  }
  switch (c) {
  case 1:
    h = num1 + num2;
    printf("%d", h);
    break;
  case 2:
    h = num1 - num2;
    printf("%d", h);
    break;
  case 3:
    h = num1 * num2;
    printf("%d", h);
    break;
  case 4:
    if (num2 == 0) {
      printf("error");
    } else {
      h = num1 / num2;
      printf("%d", h);
    }
    break;
  case 5:
    if (num2 == 0) {
      printf("error");
    } else {
      h = num1 % num2;
      printf("%d", h);
    }
    break;
  default:
    printf("error");
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x17(%rbp),%rdx
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rcx
call   1050 <scanf@plt>
lea    -0x17(%rbp),%rdi
lea    0xebb(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    117d <main+0x4d>
movl   $0x1,-0x10(%rbp)
jmp    1224 <main+0xf4>
lea    -0x17(%rbp),%rdi
lea    0xe99(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11a3 <main+0x73>
movl   $0x2,-0x10(%rbp)
jmp    121f <main+0xef>
lea    -0x17(%rbp),%rdi
lea    0xe77(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11c9 <main+0x99>
movl   $0x3,-0x10(%rbp)
jmp    121a <main+0xea>
lea    -0x17(%rbp),%rdi
lea    0xe55(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11ef <main+0xbf>
movl   $0x4,-0x10(%rbp)
jmp    1215 <main+0xe5>
lea    -0x17(%rbp),%rdi
lea    0xe33(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1210 <main+0xe0>
movl   $0x5,-0x10(%rbp)
jmp    1215 <main+0xe5>
jmp    121a <main+0xea>
jmp    121f <main+0xef>
jmp    1224 <main+0xf4>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x4,%eax
ja     1325 <main+0x1f5>
mov    -0x20(%rbp),%rax
lea    0xdbc(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xdba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1333 <main+0x203>
mov    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xd9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1333 <main+0x203>
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xd7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1333 <main+0x203>
cmpl   $0x0,-0xc(%rbp)
jne    12c8 <main+0x198>
lea    0xd75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12e3 <main+0x1b3>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xd3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1333 <main+0x203>
cmpl   $0x0,-0xc(%rbp)
jne    1305 <main+0x1d5>
lea    0xd38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1320 <main+0x1f0>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xd01(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1333 <main+0x203>
lea    0xd05(%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    0xec4(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x5(%rsp),%rbx
lea    0x8(%rsp),%rcx
mov    %rbx,%rdx
call   1050 <scanf@plt>
lea    0xeaf(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11d4 <main+0xa4>
lea    0xe9f(%rip),%rsi
lea    0x5(%rsp),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11e5 <main+0xb5>
lea    0xe8d(%rip),%rsi
lea    0x5(%rsp),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11f6 <main+0xc6>
lea    0xe7b(%rip),%rsi
lea    0x5(%rsp),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1208 <main+0xd8>
lea    0xe69(%rip),%rsi
lea    0x5(%rsp),%rdi
call   1040 <strcmp@plt>
mov    0x8(%rsp),%ecx
test   %ecx,%ecx
je     122f <main+0xff>
mov    0xc(%rsp),%eax
cltd
idiv   %ecx
lea    0xe36(%rip),%rdi
mov    %edx,%esi
jmp    1220 <main+0xf0>
mov    0x8(%rsp),%esi
add    0xc(%rsp),%esi
lea    0xe23(%rip),%rdi
jmp    1220 <main+0xf0>
mov    0xc(%rsp),%esi
sub    0x8(%rsp),%esi
lea    0xe12(%rip),%rdi
jmp    1220 <main+0xf0>
mov    0x8(%rsp),%esi
imul   0xc(%rsp),%esi
lea    0xe00(%rip),%rdi
jmp    1220 <main+0xf0>
mov    0x8(%rsp),%ecx
test   %ecx,%ecx
je     122f <main+0xff>
mov    0xc(%rsp),%eax
cltd
idiv   %ecx
lea    0xde8(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xde7(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1227 <main+0xf7>

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