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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x16(%rbp),%rdx
lea    0xeb6(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rcx
call   1050 <scanf@plt>
lea    -0x16(%rbp),%rdi
lea    0xea7(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    118a <main+0x5a>
mov    -0x8(%rbp),%esi
add    -0xc(%rbp),%esi
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1293 <main+0x163>
lea    -0x16(%rbp),%rdi
lea    0xe7c(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11bd <main+0x8d>
mov    -0x8(%rbp),%esi
sub    -0xc(%rbp),%esi
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    128e <main+0x15e>
lea    -0x16(%rbp),%rdi
lea    0xe4d(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11f1 <main+0xc1>
mov    -0x8(%rbp),%esi
imul   -0xc(%rbp),%esi
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1289 <main+0x159>
lea    -0x16(%rbp),%rdi
lea    0xe1d(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1231 <main+0x101>
cmpl   $0x0,-0xc(%rbp)
je     1231 <main+0x101>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %eax,%esi
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1284 <main+0x154>
lea    -0x16(%rbp),%rdi
lea    0xde1(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1271 <main+0x141>
cmpl   $0x0,-0xc(%rbp)
je     1271 <main+0x141>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,%esi
lea    0xda8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    127f <main+0x14f>
lea    0xda9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1284 <main+0x154>
jmp    1289 <main+0x159>
jmp    128e <main+0x15e>
jmp    1293 <main+0x163>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xec4(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0x16(%rsp),%rbx
lea    0xc(%rsp),%rcx
mov    %rbx,%rdx
call   1050 <scanf@plt>
lea    0xeaf(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11c3 <main+0x93>
lea    0xea3(%rip),%rsi
lea    0x16(%rsp),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11cd <main+0x9d>
lea    0xe91(%rip),%rsi
lea    0x16(%rsp),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11d7 <main+0xa7>
lea    0xe7f(%rip),%rsi
lea    0x16(%rsp),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    11f6 <main+0xc6>
mov    0xc(%rsp),%ecx
test   %ecx,%ecx
je     11f6 <main+0xc6>
mov    0x10(%rsp),%eax
cltd
idiv   %ecx
lea    0xe4e(%rip),%rdi
mov    %eax,%esi
jmp    11e7 <main+0xb7>
mov    0xc(%rsp),%esi
add    0x10(%rsp),%esi
jmp    11e0 <main+0xb0>
mov    0x10(%rsp),%esi
sub    0xc(%rsp),%esi
jmp    11e0 <main+0xb0>
mov    0xc(%rsp),%esi
imul   0x10(%rsp),%esi
lea    0xe26(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret
lea    0xe20(%rip),%rsi
lea    0x16(%rsp),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1226 <main+0xf6>
mov    0xc(%rsp),%ecx
test   %ecx,%ecx
je     1226 <main+0xf6>
mov    0x10(%rsp),%eax
cltd
idiv   %ecx
lea    0xdeb(%rip),%rdi
mov    %edx,%esi
jmp    11e7 <main+0xb7>
lea    0xdf4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11ee <main+0xbe>

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