#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 calc(int, int, char);
int /*<<< orphan*/ printf(char *, int, int, char, int);
void main() {
  int a = 100, b = 20;
  printf("calc(%d, %d, %c) = %d\n", a, b, '+', calc(a, b, '+'));
  printf("calc(%d, %d, %c) = %d\n", a, b, '-', calc(a, b, '-'));
  printf("calc(%d, %d, %c) = %d\n", a, b, '*', calc(a, b, '*'));
  printf("calc(%d, %d, %c) = %d\n", a, b, '/', calc(a, b, '/'));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x64,-0x4(%rbp)
movl   $0x14,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0x2b,%edx
call   1040 <calc@plt>
mov    -0x28(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    %eax,%r8d
lea    0xe9e(%rip),%rdi
mov    $0x2b,%ecx
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0x2d,%edx
call   1040 <calc@plt>
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    %eax,%r8d
lea    0xe68(%rip),%rdi
mov    $0x2d,%ecx
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0x2a,%edx
call   1040 <calc@plt>
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    %eax,%r8d
lea    0xe32(%rip),%rdi
mov    $0x2a,%ecx
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0x2f,%edx
call   1040 <calc@plt>
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    %eax,%r8d
lea    0xdfc(%rip),%rdi
mov    $0x2f,%ecx
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x64,%edi
mov    $0x14,%esi
mov    $0x2b,%edx
call   1040 <calc@plt>
lea    0xec4(%rip),%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
mov    $0x14,%edx
mov    $0x2b,%ecx
mov    %eax,%r8d
call   1030 <printf@plt>
mov    $0x64,%edi
mov    $0x14,%esi
mov    $0x2d,%edx
call   1040 <calc@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
mov    $0x14,%edx
mov    $0x2d,%ecx
mov    %eax,%r8d
call   1030 <printf@plt>
mov    $0x64,%edi
mov    $0x14,%esi
mov    $0x2a,%edx
call   1040 <calc@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
mov    $0x14,%edx
mov    $0x2a,%ecx
mov    %eax,%r8d
call   1030 <printf@plt>
mov    $0x64,%edi
mov    $0x14,%esi
mov    $0x2f,%edx
call   1040 <calc@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
mov    $0x14,%edx
mov    $0x2f,%ecx
mov    %eax,%r8d
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"calc(%d, %d, %c) = %d\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
store i32 100, i32* %1
store i32 20, i32* %2
%3 = load i32, i32* %1
%4 = load i32, i32* %2
%5 = load i32, i32* %1
%6 = load i32, i32* %2
%7 = call i32 @calc(i32 %5, i32 %6, i8 signext 43)
%8 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %4, i8 signext 43, i32 %7)
%9 = load i32, i32* %1
%10 = load i32, i32* %2
%11 = load i32, i32* %1
%12 = load i32, i32* %2
%13 = call i32 @calc(i32 %11, i32 %12, i8 signext 45)
%14 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %10, i8 signext 45, i32 %13)
%15 = load i32, i32* %1
%16 = load i32, i32* %2
%17 = load i32, i32* %1
%18 = load i32, i32* %2
%19 = call i32 @calc(i32 %17, i32 %18, i8 signext 42)
%20 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %16, i8 signext 42, i32 %19)
%21 = load i32, i32* %1
%22 = load i32, i32* %2
%23 = load i32, i32* %1
%24 = load i32, i32* %2
%25 = call i32 @calc(i32 %23, i32 %24, i8 signext 47)
%26 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %21, i32 %22, i8 signext 47, i32 %25)
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"calc(%d, %d, %c) = %d\0A\00"
define void @main() {
%1 = tail call i32 @calc(i32 100, i32 20, i8 signext 43)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 100, i32 20, i8 signext 43, i32 %1)
%3 = tail call i32 @calc(i32 100, i32 20, i8 signext 45)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 100, i32 20, i8 signext 45, i32 %3)
%5 = tail call i32 @calc(i32 100, i32 20, i8 signext 42)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 100, i32 20, i8 signext 42, i32 %5)
%7 = tail call i32 @calc(i32 100, i32 20, i8 signext 47)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 100, i32 20, i8 signext 47, i32 %7)
ret void
}