#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*/ sscanf(char *, char *, int *);
int main(int argc, char *argv[]) {
  int numbers[4];
  if (argc != 4)
    printf("Operators: +, -, x, / \nUsage: number1 operator number2\n");
  else {
    printf("\n");
    sscanf(argv[1], "%d", &numbers[1]);
    sscanf(argv[3], "%d", &numbers[3]);
    switch (*argv[2]) {
    case '+':
      printf("%d %s %d = %d", numbers[1], argv[2], numbers[3],
             numbers[1] + numbers[3]);
      break;
    case '-':
      printf("%d %s %d = %d", numbers[1], argv[2], numbers[3],
             numbers[1] - numbers[3]);
      break;
    case 'x':
      printf("%d %s %d = %d", numbers[1], argv[2], numbers[3],
             numbers[1] * numbers[3]);
      break;
    case '/':
      if (numbers[3] == 0) {
        printf("Cannot divide by 0.");
        break;
      } else {
        printf("%d %s %d = %d", numbers[1], argv[2], numbers[3],
               numbers[1] / numbers[3]);
        break;
      }
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     1153 <main+0x33>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12b6 <main+0x196>
lea    0xedc(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x1c(%rbp),%rdx
lea    0xecf(%rip),%rsi
mov    %rsi,-0x30(%rbp)
call   1040 <sscanf@plt>
mov    -0x30(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    -0x14(%rbp),%rdx
call   1040 <sscanf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movsbl (%rax),%eax
mov    %eax,-0x24(%rbp)
sub    $0x2b,%eax
je     11e1 <main+0xc1>
jmp    11ae <main+0x8e>
mov    -0x24(%rbp),%eax
sub    $0x2d,%eax
je     120a <main+0xea>
jmp    11bf <main+0x9f>
mov    -0x24(%rbp),%eax
sub    $0x2f,%eax
je     125d <main+0x13d>
jmp    11d0 <main+0xb0>
mov    -0x24(%rbp),%eax
sub    $0x78,%eax
je     1233 <main+0x113>
jmp    12a8 <main+0x188>
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
add    -0x14(%rbp),%r8d
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12a8 <main+0x188>
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
sub    -0x14(%rbp),%r8d
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12a8 <main+0x188>
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
imul   -0x14(%rbp),%r8d
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12a8 <main+0x188>
cmpl   $0x0,-0x14(%rbp)
jne    127a <main+0x15a>
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12a8 <main+0x188>
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x14(%rbp),%ecx
mov    -0x1c(%rbp),%eax
cltd
idivl  -0x14(%rbp)
mov    -0x38(%rbp),%rdx
mov    %eax,%r8d
lea    0xd97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
cmp    $0x4,%edi
jne    11ac <main+0x6c>
mov    %rsi,%rbx
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x8(%rbx),%rdi
lea    0x4(%rsp),%rdx
lea    0xea2(%rip),%r14
mov    %r14,%rsi
call   1060 <sscanf@plt>
mov    0x18(%rbx),%rdi
lea    0xc(%rsp),%rdx
mov    %r14,%rsi
call   1060 <sscanf@plt>
mov    0x10(%rbx),%rbx
movsbl (%rbx),%eax
cmp    $0x2e,%eax
jg     11ba <main+0x7a>
cmp    $0x2b,%eax
je     11df <main+0x9f>
cmp    $0x2d,%eax
jne    121c <main+0xdc>
mov    0x4(%rsp),%esi
mov    0xc(%rsp),%ecx
mov    %esi,%r8d
sub    %ecx,%r8d
jmp    11d3 <main+0x93>
lea    0xe6f(%rip),%rdi
call   1040 <puts@plt>
jmp    1226 <main+0xe6>
cmp    $0x2f,%eax
je     11f7 <main+0xb7>
cmp    $0x78,%eax
jne    121c <main+0xdc>
mov    0x4(%rsp),%esi
mov    0xc(%rsp),%ecx
mov    %ecx,%r8d
imul   %esi,%r8d
lea    0xe26(%rip),%rdi
mov    %rbx,%rdx
jmp    1215 <main+0xd5>
mov    0x4(%rsp),%esi
mov    0xc(%rsp),%ecx
lea    (%rcx,%rsi,1),%r8d
lea    0xe0e(%rip),%rdi
mov    %rbx,%rdx
jmp    1215 <main+0xd5>
mov    0xc(%rsp),%ecx
test   %ecx,%ecx
je     1230 <main+0xf0>
mov    0x4(%rsp),%esi
mov    %esi,%eax
cltd
idiv   %ecx
lea    0xdf1(%rip),%rdi
mov    %rbx,%rdx
mov    %eax,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
lea    0xdd7(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    121c <main+0xdc>

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

LLVM IR (-O2):
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [14 x i8] c"%d %s %d = %d\00"
@.str.4 = [20 x i8] c"Cannot divide by 0.\00"
@str = [55 x i8] c"Operators: +, -, x, / \0AUsage: number1 operator number2\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4 x i32]
%4 = bitcast [4 x i32]* %3 to i8*
%5 = icmp eq i32 %0, 4
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str, i64 0, i64 0))
br label %48
8: ; preds = %2
%9 = tail call i32 @putchar(i32 10)
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 1
%13 = call i32 @sscanf(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %12)
%14 = getelementptr inbounds i8*, i8** %1, i64 3
%15 = load i8*, i8** %14
%16 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 3
%17 = call i32 @sscanf(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %16)
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
switch i32 %21, label %46 [
i32 43, label %22
i32 45, label %27
i32 120, label %32
i32 47, label %37
]
22: ; preds = %8
%23 = load i32, i32* %12
%24 = load i32, i32* %16
%25 = add nsw i32 %24, %23
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %23, i8* %19, i32 %24, i32 %25)
br label %46
27: ; preds = %8
%28 = load i32, i32* %12
%29 = load i32, i32* %16
%30 = sub nsw i32 %28, %29
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %28, i8* %19, i32 %29, i32 %30)
br label %46
32: ; preds = %8
%33 = load i32, i32* %12
%34 = load i32, i32* %16
%35 = mul nsw i32 %34, %33
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %33, i8* %19, i32 %34, i32 %35)
br label %46
37: ; preds = %8
%38 = load i32, i32* %16
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %37
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
br label %46
42: ; preds = %37
%43 = load i32, i32* %12
%44 = sdiv i32 %43, %38
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %43, i8* %19, i32 %38, i32 %44)
br label %46
46: ; preds = %8, %42, %40, %32, %27, %22
%47 = call i32 @putchar(i32 10)
br label %48
48: ; preds = %46, %6
ret i32 0
}