#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 number1, number2, numb_sum;
  int correct_function = 0;
  char function[5];
  scanf("%d %s %d", &number1, function, &number2);
  if (!strcmp(function, "add")) {
    numb_sum = number1 + number2;
    correct_function = 1;
  }
  if (!strcmp(function, "mul")) {
    numb_sum = number1 * number2;
    correct_function = 1;
  }
  if (!strcmp(function, "sub")) {
    numb_sum = number1 - number2;
    correct_function = 1;
  }
  if (!strcmp(function, "div")) {
    if (number2 != 0) {
      numb_sum = number1 / number2;
      correct_function = 1;
    }
  }
  if (!strcmp(function, "mod")) {
    numb_sum = number1 % number2;
    correct_function = 1;
  }
  if (!correct_function) {
    printf("Error.You have selected an incorrect function!\n");
  } else {
    printf("%d\n", numb_sum);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x19(%rbp),%rdx
lea    0xeaf(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rcx
call   1050 <scanf@plt>
lea    -0x19(%rbp),%rdi
lea    0xea0(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1187 <main+0x57>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
lea    -0x19(%rbp),%rdi
lea    0xe7b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11b1 <main+0x81>
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
lea    -0x19(%rbp),%rdi
lea    0xe55(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11da <main+0xaa>
mov    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
lea    -0x19(%rbp),%rdi
lea    0xe30(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1213 <main+0xe3>
cmpl   $0x0,-0xc(%rbp)
je     120e <main+0xde>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %eax,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
jmp    1213 <main+0xe3>
lea    -0x19(%rbp),%rdi
lea    0xdfb(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    123d <main+0x10d>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    125a <main+0x12a>
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    126b <main+0x13b>
mov    -0x10(%rbp),%esi
lea    0xde9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xec5(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0xb(%rsp),%rdx
lea    0x10(%rsp),%rcx
call   1050 <scanf@plt>
mov    0xb(%rsp),%edx
cmp    $0x646461,%edx
sete   %r8b
mov    0x14(%rsp),%ecx
mov    0x10(%rsp),%edi
lea    (%rdi,%rcx,1),%esi
mov    %edi,%eax
imul   %ecx,%eax
cmp    $0x6c756d,%edx
sete   %r9b
cmovne %esi,%eax
mov    %ecx,%esi
sub    %edi,%esi
cmp    $0x627573,%edx
sete   %r10b
cmovne %eax,%esi
cmp    $0x766964,%edx
jne    11aa <main+0x7a>
test   %edi,%edi
je     11aa <main+0x7a>
mov    %ecx,%eax
cltd
idiv   %edi
cmpl   $0x646f6d,0xb(%rsp)
je     11ca <main+0x9a>
mov    %eax,%esi
jmp    11d1 <main+0xa1>
cmpl   $0x646f6d,0xb(%rsp)
je     11ca <main+0x9a>
or     %r9b,%r10b
or     %r8b,%r10b
jne    11d1 <main+0xa1>
lea    0xe5e(%rip),%rdi
call   1030 <puts@plt>
jmp    11df <main+0xaf>
mov    %ecx,%eax
cltd
idiv   %edi
mov    %edx,%esi
lea    0xe45(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
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"mul\00"
@.str.3 = [4 x i8] c"sub\00"
@.str.4 = [4 x i8] c"div\00"
@.str.5 = [4 x i8] c"mod\00"
@.str.6 = [48 x i8] c"Error.You have selected an incorrect function!\0A\00"
@.str.7 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [5 x i8]
store i32 0, i32* %1
store i32 0, i32* %5
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%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 [5 x i8], [5 x i8]* %6, i64 0, i64 0
%10 = call i32 @strcmp(i8* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp ne i32 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %0
%13 = load i32, i32* %2
%14 = load i32, i32* %3
%15 = add nsw i32 %13, %14
store i32 %15, i32* %4
store i32 1, i32* %5
br label %16
16: ; preds = %12, %0
%17 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%18 = call i32 @strcmp(i8* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp ne i32 %18, 0
br i1 %19, label %24, label %20
20: ; preds = %16
%21 = load i32, i32* %2
%22 = load i32, i32* %3
%23 = mul nsw i32 %21, %22
store i32 %23, i32* %4
store i32 1, i32* %5
br label %24
24: ; preds = %20, %16
%25 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%26 = call i32 @strcmp(i8* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%27 = icmp ne i32 %26, 0
br i1 %27, label %32, label %28
28: ; preds = %24
%29 = load i32, i32* %2
%30 = load i32, i32* %3
%31 = sub nsw i32 %29, %30
store i32 %31, i32* %4
store i32 1, i32* %5
br label %32
32: ; preds = %28, %24
%33 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%34 = call i32 @strcmp(i8* %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%35 = icmp ne i32 %34, 0
br i1 %35, label %44, label %36
36: ; preds = %32
%37 = load i32, i32* %3
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %43
39: ; preds = %36
%40 = load i32, i32* %2
%41 = load i32, i32* %3
%42 = sdiv i32 %40, %41
store i32 %42, i32* %4
store i32 1, i32* %5
br label %43
43: ; preds = %39, %36
br label %44
44: ; preds = %43, %32
%45 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%46 = call i32 @strcmp(i8* %45, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%47 = icmp ne i32 %46, 0
br i1 %47, label %52, label %48
48: ; preds = %44
%49 = load i32, i32* %2
%50 = load i32, i32* %3
%51 = srem i32 %49, %50
store i32 %51, i32* %4
store i32 1, i32* %5
br label %52
52: ; preds = %48, %44
%53 = load i32, i32* %5
%54 = icmp ne i32 %53, 0
br i1 %54, label %57, label %55
55: ; preds = %52
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.6, i64 0, i64 0))
br label %60
57: ; preds = %52
%58 = load i32, i32* %4
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %58)
br label %60
60: ; preds = %57, %55
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"mul\00"
@.str.3 = [4 x i8] c"sub\00"
@.str.4 = [4 x i8] c"div\00"
@.str.5 = [4 x i8] c"mod\00"
@.str.7 = [4 x i8] c"%d\0A\00"
@str = [47 x i8] c"Error.You have selected an incorrect function!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [5 x i8]
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = getelementptr inbounds [5 x i8], [5 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 i32 @bcmp(i8* dereferenceable(4) %6, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 4)
%9 = icmp eq i32 %8, 0
%10 = load i32, i32* %1
%11 = load i32, i32* %2
%12 = add nsw i32 %11, %10
%13 = select i1 %9, i32 %12, i32 undef
%14 = call i32 @bcmp(i8* dereferenceable(4) %6, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64 4)
%15 = icmp eq i32 %14, 0
%16 = mul nsw i32 %11, %10
%17 = select i1 %15, i32 %16, i32 %13
%18 = call i32 @bcmp(i8* dereferenceable(4) %6, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 4)
%19 = icmp eq i32 %18, 0
%20 = sub nsw i32 %10, %11
%21 = select i1 %19, i32 %20, i32 %17
%22 = select i1 %19, i1 true, i1 %15
%23 = select i1 %22, i1 true, i1 %9
%24 = call i32 @bcmp(i8* dereferenceable(4) %6, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i64 4)
%25 = icmp eq i32 %24, 0
%26 = icmp ne i32 %11, 0
%27 = select i1 %25, i1 %26, i1 false
br i1 %27, label %31, label %28
28: ; preds = %0
%29 = call i32 @bcmp(i8* dereferenceable(4) %6, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i64 4)
%30 = icmp eq i32 %29, 0
br i1 %30, label %35, label %37
31: ; preds = %0
%32 = sdiv i32 %10, %11
%33 = call i32 @bcmp(i8* dereferenceable(4) %6, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i64 4)
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %40
35: ; preds = %31, %28
%36 = srem i32 %10, %11
br label %40
37: ; preds = %28
br i1 %23, label %40, label %38
38: ; preds = %37
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str, i64 0, i64 0))
br label %43
40: ; preds = %31, %35, %37
%41 = phi i32 [ %36, %35 ], [ %21, %37 ], [ %32, %31 ]
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %40, %38
ret i32 0
}