#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) {
  unsigned char r;
  unsigned char op = argv[1][0];
  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)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%al
mov    %al,-0x12(%rbp)
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    0xe6e(%rip),%rdi
movzbl -0x11(%rbp),%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    0x8(%rsi),%rax
mov    0x10(%rsi),%rdi
movzbl (%rax),%ebp
call   1050 <atoi@plt>
mov    %eax,%r14d
mov    0x18(%rbx),%rdi
call   1050 <atoi@plt>
movzbl %r14b,%esi
movzbl %al,%edx
mov    %ebp,%edi
call   1040 <calc@plt>
movzbl %al,%esi
lea    0xe95(%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 i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = load i8, i8* %13
store i8 %14, i8* %7
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 2
%17 = load i8*, i8** %16
%18 = call zeroext i8 @atoi(i8* %17)
store i8 %18, i8* %8
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 3
%21 = load i8*, i8** %20
%22 = call zeroext i8 @atoi(i8* %21)
store i8 %22, i8* %9
%23 = load i8, i8* %7
%24 = load i8, i8* %8
%25 = load i8, i8* %9
%26 = call zeroext i8 @calc(i8 zeroext %23, i8 zeroext %24, i8 zeroext %25)
store i8 %26, i8* %6
%27 = load i8, i8* %6
%28 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8 zeroext %27)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"result = %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = load i8, i8* %4
%6 = getelementptr inbounds i8*, i8** %1, i64 2
%7 = load i8*, i8** %6
%8 = tail call zeroext i8 @atoi(i8* %7)
%9 = getelementptr inbounds i8*, i8** %1, i64 3
%10 = load i8*, i8** %9
%11 = tail call zeroext i8 @atoi(i8* %10)
%12 = tail call zeroext i8 @calc(i8 zeroext %5, i8 zeroext %8, i8 zeroext %11)
%13 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8 zeroext %12)
ret i32 0
}