#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 num1, num2, result, f = 0;
  char opr[3];
  scanf("%d %s %d", &num1, opr, &num2);
  if (!strcmp(opr, "add")) {
    result = num1 + num2;
    f = 1;
  }
  if (!strcmp(opr, "sub")) {
    result = num1 - num2;
    f = 1;
  }
  if (!strcmp(opr, "mul")) {
    result = num1 * num2;
    f = 1;
  }
  if (!strcmp(opr, "div")) {
    if (num2 != 0) {
      result = num1 / num2;
      f = 1;
    }
  }
  if (!strcmp(opr, "mod")) {
    if (num2 != 0) {
      result = num1 % num2;
      f = 1;
    }
  }
  if (f == 1) {
    printf("%d\n", result);
  } else {
    printf("error");
  }
  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)
movl   $0x0,-0x20(%rbp)
lea    -0x23(%rbp),%rdx
lea    0xea8(%rip),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rcx
call   1050 <scanf@plt>
lea    -0x23(%rbp),%rdi
lea    0xe99(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    118e <main+0x5e>
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
lea    -0x23(%rbp),%rdi
lea    0xe74(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11b7 <main+0x87>
mov    -0x14(%rbp),%eax
sub    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
lea    -0x23(%rbp),%rdi
lea    0xe4f(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11e1 <main+0xb1>
mov    -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
lea    -0x23(%rbp),%rdi
lea    0xe29(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    121a <main+0xea>
cmpl   $0x0,-0x18(%rbp)
je     1215 <main+0xe5>
mov    -0x14(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %eax,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
jmp    121a <main+0xea>
lea    -0x23(%rbp),%rdi
lea    0xdf4(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1253 <main+0x123>
cmpl   $0x0,-0x18(%rbp)
je     124e <main+0x11e>
mov    -0x14(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
jmp    1253 <main+0x123>
cmpl   $0x1,-0x20(%rbp)
jne    1273 <main+0x143>
mov    -0x1c(%rbp),%esi
lea    0xdb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1281 <main+0x151>
lea    0xda7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xebb(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0xd(%rsp),%r14
lea    0x10(%rsp),%rcx
mov    %r14,%rdx
call   1050 <scanf@plt>
lea    0xea6(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
sete   0xc(%rsp)
mov    0x14(%rsp),%r15d
mov    0x10(%rsp),%r13d
lea    (%r15,%r13,1),%ebp
lea    0xe86(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
mov    %r15d,%ebx
sub    %r13d,%ebx
test   %eax,%eax
sete   %r12b
cmovne %ebp,%ebx
lea    0xe6c(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
mov    %r13d,%ebp
imul   %r15d,%ebp
test   %eax,%eax
cmovne %ebx,%ebp
sete   %al
or     %r12b,%al
or     0xc(%rsp),%al
movzbl %al,%r12d
lea    0xe47(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    11ee <main+0xbe>
test   %r13d,%r13d
je     11ee <main+0xbe>
mov    %r15d,%eax
cltd
idiv   %r13d
mov    %eax,%ebp
mov    $0x1,%r12d
lea    0xe24(%rip),%rsi
lea    0xd(%rsp),%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    1213 <main+0xe3>
test   %r13d,%r13d
je     1213 <main+0xe3>
mov    %r15d,%eax
cltd
idiv   %r13d
mov    %edx,%ebp
jmp    1218 <main+0xe8>
test   %r12d,%r12d
je     122a <main+0xfa>
lea    0xdfe(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1238 <main+0x108>
lea    0xdf0(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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