#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 */
unsigned char atoi(char *);
unsigned char calc(unsigned char, unsigned char, unsigned char);
int /*<<< orphan*/ printf(char *, unsigned char);
int main(int argc, char **argv) {
  if (argc != 4)
    return 1;
  unsigned char r;
  unsigned char op = argv[1][0];
  if (op != '+' && op != '-' && op != '*' && op != '/')
    return 1;
  unsigned char x = atoi(argv[2]);
  unsigned char y = atoi(argv[3]);
  r = calc(op, x, y);
  printf("result = %d\n", r);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     115c <main+0x2c>
movl   $0x1,-0x4(%rbp)
jmp    11f8 <main+0xc8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%al
mov    %al,-0x12(%rbp)
movzbl -0x12(%rbp),%eax
cmp    $0x2b,%eax
je     11a9 <main+0x79>
movzbl -0x12(%rbp),%eax
cmp    $0x2d,%eax
je     11a9 <main+0x79>
movzbl -0x12(%rbp),%eax
cmp    $0x2a,%eax
je     11a9 <main+0x79>
movzbl -0x12(%rbp),%eax
cmp    $0x2f,%eax
je     11a9 <main+0x79>
movl   $0x1,-0x4(%rbp)
jmp    11f8 <main+0xc8>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <atoi@plt>
mov    %al,-0x13(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1050 <atoi@plt>
mov    %al,-0x14(%rbp)
mov    -0x12(%rbp),%cl
mov    -0x13(%rbp),%al
movzbl %cl,%edi
movzbl %al,%esi
movzbl -0x14(%rbp),%edx
call   1040 <calc@plt>
mov    %al,-0x11(%rbp)
lea    0xe18(%rip),%rdi
movzbl -0x11(%rbp),%esi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0x1,%eax
cmp    $0x4,%edi
jne    1194 <main+0x64>
mov    %rsi,%rbx
mov    0x8(%rsi),%rcx
movzbl (%rcx),%ebp
cmp    $0x2f,%rbp
ja     1194 <main+0x64>
movabs $0xac0000000000,%rcx
bt     %rbp,%rcx
jae    1194 <main+0x64>
mov    0x10(%rbx),%rdi
call   1050 <atoi@plt>
mov    %eax,%r14d
mov    0x18(%rbx),%rdi
call   1050 <atoi@plt>
movzbl %bpl,%edi
movzbl %r14b,%esi
movzbl %al,%edx
call   1040 <calc@plt>
movzbl %al,%esi
lea    0xe73(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"result = %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca i8
%8 = alloca i8
%9 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 4
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 1, i32* %3
br label %50
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = getelementptr inbounds i8, i8* %16, i64 0
%18 = load i8, i8* %17
store i8 %18, i8* %7
%19 = load i8, i8* %7
%20 = zext i8 %19 to i32
%21 = icmp ne i32 %20, 43
br i1 %21, label %22, label %35
22: ; preds = %13
%23 = load i8, i8* %7
%24 = zext i8 %23 to i32
%25 = icmp ne i32 %24, 45
br i1 %25, label %26, label %35
26: ; preds = %22
%27 = load i8, i8* %7
%28 = zext i8 %27 to i32
%29 = icmp ne i32 %28, 42
br i1 %29, label %30, label %35
30: ; preds = %26
%31 = load i8, i8* %7
%32 = zext i8 %31 to i32
%33 = icmp ne i32 %32, 47
br i1 %33, label %34, label %35
34: ; preds = %30
store i32 1, i32* %3
br label %50
35: ; preds = %30, %26, %22, %13
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 2
%38 = load i8*, i8** %37
%39 = call zeroext i8 @atoi(i8* %38)
store i8 %39, i8* %8
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 3
%42 = load i8*, i8** %41
%43 = call zeroext i8 @atoi(i8* %42)
store i8 %43, i8* %9
%44 = load i8, i8* %7
%45 = load i8, i8* %8
%46 = load i8, i8* %9
%47 = call zeroext i8 @calc(i8 zeroext %44, i8 zeroext %45, i8 zeroext %46)
store i8 %47, i8* %6
%48 = load i8, i8* %6
%49 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8 zeroext %48)
store i32 0, i32* %3
br label %50
50: ; preds = %35, %34, %12
%51 = load i32, i32* %3
ret i32 %51
}

LLVM IR (-O2):
@.str = [13 x i8] c"result = %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %4, label %17
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = load i8, i8* %6
switch i8 %7, label %17 [
i8 47, label %8
i8 45, label %8
i8 43, label %8
i8 42, label %8
]
8: ; preds = %4, %4, %4, %4
%9 = getelementptr inbounds i8*, i8** %1, i64 2
%10 = load i8*, i8** %9
%11 = tail call zeroext i8 @atoi(i8* %10)
%12 = getelementptr inbounds i8*, i8** %1, i64 3
%13 = load i8*, i8** %12
%14 = tail call zeroext i8 @atoi(i8* %13)
%15 = tail call zeroext i8 @calc(i8 zeroext %7, i8 zeroext %11, i8 zeroext %14)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8 zeroext %15)
br label %17
17: ; preds = %8, %4, %2
%18 = phi i32 [ 1, %2 ], [ 0, %8 ], [ 1, %4 ]
ret i32 %18
}