#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 *, ...);
scalar_t__ strcmp(char *, char *);
int main() {
  int checker;
  int a, b, c;
  char operation[4];
  char add[4] = "add";
  char sub[4] = "sub";
  char mul[4] = "mul";
  char div[4] = "div";
  char mod[4] = "mod";
  printf("first number:");
  scanf("%d", &a);
  printf("operation:");
  scanf("%s", &operation);
  printf("second number:");
  scanf("%d", &b);
  c = 0;
  checker = 0;
  if (strcmp(operation, add) == 0) {
    c = a + b;
    printf("%d\n", c);
    checker = 1;
  }
  if (strcmp(operation, sub) == 0) {
    c = b - a;
    printf("%d\n", c);
    checker = 1;
  }
  if (strcmp(operation, mul) == 0) {
    c = a * b;
    printf("%d\n", c);
    checker = 1;
  }
  if (strcmp(operation, div) == 0) {
    if (b == 0) {
      printf("error\n");
      checker = 1;
    } else {
      c = a / b;
      printf("%d\n", c);
      checker = 1;
    }
  }
  if (strcmp(operation, mod) == 0) {
    if (b == 0) {
      printf("error\n");
      checker = 1;
    } else {
      c = a % b;
      printf("%d\n", c);
      checker = 1;
    }
  }
  if (checker == 0) {
    printf("error\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xebb(%rip),%eax
mov    %eax,-0x1c(%rbp)
mov    0xeb6(%rip),%eax
mov    %eax,-0x20(%rbp)
mov    0xeb1(%rip),%eax
mov    %eax,-0x24(%rbp)
mov    0xeac(%rip),%eax
mov    %eax,-0x28(%rbp)
mov    0xea7(%rip),%eax
mov    %eax,-0x2c(%rbp)
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea1(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8f(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe61(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x8(%rbp)
lea    -0x18(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1212 <main+0xe2>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x8(%rbp)
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    124a <main+0x11a>
mov    -0x10(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe06(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x8(%rbp)
lea    -0x18(%rbp),%rdi
lea    -0x24(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1283 <main+0x153>
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xdcd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x8(%rbp)
lea    -0x18(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    12e5 <main+0x1b5>
cmpl   $0x0,-0x10(%rbp)
jne    12be <main+0x18e>
lea    0xd9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x8(%rbp)
jmp    12e0 <main+0x1b0>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xd70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x8(%rbp)
jmp    12e5 <main+0x1b5>
lea    -0x18(%rbp),%rdi
lea    -0x2c(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1347 <main+0x217>
cmpl   $0x0,-0x10(%rbp)
jne    1320 <main+0x1f0>
lea    0xd39(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x8(%rbp)
jmp    1342 <main+0x212>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xd0e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x8(%rbp)
jmp    1347 <main+0x217>
cmpl   $0x0,-0x8(%rbp)
jne    135f <main+0x22f>
lea    0xcee(%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   %r14
push   %rbx
sub    $0x20,%rsp
movl   $0x646461,0x1c(%rsp)
movl   $0x627573,0x18(%rsp)
movl   $0x6c756d,0x14(%rsp)
movl   $0x766964,0x10(%rsp)
movl   $0x646f6d,0xc(%rsp)
lea    0xe89(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe87(%rip),%r14
lea    0x4(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xe74(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe71(%rip),%rdi
lea    0x8(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xe5e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rsp,%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0x1c(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    1201 <main+0xc1>
mov    (%rsp),%esi
add    0x4(%rsp),%esi
lea    0xe39(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%ebp
lea    0x8(%rsp),%rdi
lea    0x18(%rsp),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    122f <main+0xef>
mov    (%rsp),%esi
sub    0x4(%rsp),%esi
lea    0xe0b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%ebp
lea    0x8(%rsp),%rdi
lea    0x14(%rsp),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    125e <main+0x11e>
mov    (%rsp),%esi
imul   0x4(%rsp),%esi
lea    0xddc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%ebp
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    12a3 <main+0x163>
mov    (%rsp),%ecx
test   %ecx,%ecx
je     1292 <main+0x152>
mov    0x4(%rsp),%eax
cltd
idiv   %ecx
lea    0xda7(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    129e <main+0x15e>
lea    0xd99(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebp
lea    0x8(%rsp),%rdi
lea    0xc(%rsp),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12bd <main+0x17d>
test   %ebp,%ebp
jne    12e9 <main+0x1a9>
jmp    12dd <main+0x19d>
mov    (%rsp),%ecx
test   %ecx,%ecx
je     12dd <main+0x19d>
mov    0x4(%rsp),%eax
cltd
idiv   %ecx
lea    0xd5c(%rip),%rdi
mov    %edx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    12e9 <main+0x1a9>
lea    0xd4e(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.add = [4 x i8] c"add\00"
@__const.main.sub = [4 x i8] c"sub\00"
@__const.main.mul = [4 x i8] c"mul\00"
@__const.main.div = [4 x i8] c"div\00"
@__const.main.mod = [4 x i8] c"mod\00"
@.str = [14 x i8] c"first number:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [11 x i8] c"operation:\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [15 x i8] c"second number:\00"
@.str.5 = [4 x i8] c"%d\0A\00"
@.str.6 = [7 x i8] c"error\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [4 x i8]
%7 = alloca [4 x i8]
%8 = alloca [4 x i8]
%9 = alloca [4 x i8]
%10 = alloca [4 x i8]
%11 = alloca [4 x i8]
store i32 0, i32* %1
%12 = bitcast [4 x i8]* %7 to i8*
%13 = bitcast [4 x i8]* %8 to i8*
%14 = bitcast [4 x i8]* %9 to i8*
%15 = bitcast [4 x i8]* %10 to i8*
%16 = bitcast [4 x i8]* %11 to i8*
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), [4 x i8]* %6)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
store i32 0, i32* %5
store i32 0, i32* %2
%23 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%24 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%25 = call i64 @strcmp(i8* %23, i8* %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %33
27: ; preds = %0
%28 = load i32, i32* %3
%29 = load i32, i32* %4
%30 = add nsw i32 %28, %29
store i32 %30, i32* %5
%31 = load i32, i32* %5
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %31)
store i32 1, i32* %2
br label %33
33: ; preds = %27, %0
%34 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%35 = getelementptr inbounds [4 x i8], [4 x i8]* %8, i64 0, i64 0
%36 = call i64 @strcmp(i8* %34, i8* %35)
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %44
38: ; preds = %33
%39 = load i32, i32* %4
%40 = load i32, i32* %3
%41 = sub nsw i32 %39, %40
store i32 %41, i32* %5
%42 = load i32, i32* %5
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %42)
store i32 1, i32* %2
br label %44
44: ; preds = %38, %33
%45 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%46 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 0
%47 = call i64 @strcmp(i8* %45, i8* %46)
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %55
49: ; preds = %44
%50 = load i32, i32* %3
%51 = load i32, i32* %4
%52 = mul nsw i32 %50, %51
store i32 %52, i32* %5
%53 = load i32, i32* %5
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %53)
store i32 1, i32* %2
br label %55
55: ; preds = %49, %44
%56 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%57 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 0
%58 = call i64 @strcmp(i8* %56, i8* %57)
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %72
60: ; preds = %55
%61 = load i32, i32* %4
%62 = icmp eq i32 %61, 0
br i1 %62, label %63, label %65
63: ; preds = %60
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %2
br label %71
65: ; preds = %60
%66 = load i32, i32* %3
%67 = load i32, i32* %4
%68 = sdiv i32 %66, %67
store i32 %68, i32* %5
%69 = load i32, i32* %5
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %69)
store i32 1, i32* %2
br label %71
71: ; preds = %65, %63
br label %72
72: ; preds = %71, %55
%73 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%74 = getelementptr inbounds [4 x i8], [4 x i8]* %11, i64 0, i64 0
%75 = call i64 @strcmp(i8* %73, i8* %74)
%76 = icmp eq i64 %75, 0
br i1 %76, label %77, label %89
77: ; preds = %72
%78 = load i32, i32* %4
%79 = icmp eq i32 %78, 0
br i1 %79, label %80, label %82
80: ; preds = %77
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %2
br label %88
82: ; preds = %77
%83 = load i32, i32* %3
%84 = load i32, i32* %4
%85 = srem i32 %83, %84
store i32 %85, i32* %5
%86 = load i32, i32* %5
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %86)
store i32 1, i32* %2
br label %88
88: ; preds = %82, %80
br label %89
89: ; preds = %88, %72
%90 = load i32, i32* %2
%91 = icmp eq i32 %90, 0
br i1 %91, label %92, label %94
92: ; preds = %89
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %94
94: ; preds = %92, %89
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"first number:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [11 x i8] c"operation:\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [15 x i8] c"second number:\00"
@.str.5 = [4 x i8] c"%d\0A\00"
@str.8 = [6 x i8] c"error\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [4 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = bitcast i32* %1 to i8*
%10 = bitcast i32* %2 to i8*
%11 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%12 = bitcast i32* %4 to i8*
store i32 6579297, i32* %4
%13 = bitcast i32* %5 to i8*
store i32 6452595, i32* %5
%14 = bitcast i32* %6 to i8*
store i32 7107949, i32* %6
%15 = bitcast i32* %7 to i8*
store i32 7760228, i32* %7
%16 = bitcast i32* %8 to i8*
store i32 6582125, i32* %8
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), [4 x i8]* %3)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%23 = call i64 @strcmp(i8* %11, i8* %12)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %30
25: ; preds = %0
%26 = load i32, i32* %1
%27 = load i32, i32* %2
%28 = add nsw i32 %27, %26
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %25, %0
%31 = phi i32 [ 1, %25 ], [ 0, %0 ]
%32 = call i64 @strcmp(i8* %11, i8* %13)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %39
34: ; preds = %30
%35 = load i32, i32* %2
%36 = load i32, i32* %1
%37 = sub nsw i32 %35, %36
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %37)
br label %39
39: ; preds = %34, %30
%40 = phi i32 [ 1, %34 ], [ %31, %30 ]
%41 = call i64 @strcmp(i8* %11, i8* %14)
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %48
43: ; preds = %39
%44 = load i32, i32* %1
%45 = load i32, i32* %2
%46 = mul nsw i32 %45, %44
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %46)
br label %48
48: ; preds = %43, %39
%49 = phi i32 [ 1, %43 ], [ %40, %39 ]
%50 = call i64 @strcmp(i8* %11, i8* %15)
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %61
52: ; preds = %48
%53 = load i32, i32* %2
%54 = icmp eq i32 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %52
%56 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.8, i64 0, i64 0))
br label %61
57: ; preds = %52
%58 = load i32, i32* %1
%59 = sdiv i32 %58, %53
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %59)
br label %61
61: ; preds = %55, %57, %48
%62 = phi i32 [ 1, %55 ], [ 1, %57 ], [ %49, %48 ]
%63 = call i64 @strcmp(i8* %11, i8* %16)
%64 = icmp eq i64 %63, 0
br i1 %64, label %65, label %74
65: ; preds = %61
%66 = load i32, i32* %2
%67 = icmp eq i32 %66, 0
br i1 %67, label %68, label %70
68: ; preds = %65
%69 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.8, i64 0, i64 0))
br label %78
70: ; preds = %65
%71 = load i32, i32* %1
%72 = srem i32 %71, %66
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %72)
br label %78
74: ; preds = %61
%75 = icmp eq i32 %62, 0
br i1 %75, label %76, label %78
76: ; preds = %74
%77 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.8, i64 0, i64 0))
br label %78
78: ; preds = %70, %68, %76, %74
ret i32 0
}