#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*/ free(int *);
int multi_sum(int, int, int, int, int, int, int);
int *multiply(int, int);
int /*<<< orphan*/ printf(char *, int);
int subtract(int *, int);
int sum(int, int);
int main() {
  printf("3 + 5 = %d\n", sum(3, 5));
  int *mult = multiply(3, 5);
  printf("3 * 5 = %d\n", *mult);
  free(mult);
  int sub_num = 3;
  printf("3 - 5 = %d\n", subtract(&sub_num, 5));
  printf("1 + 2 + 3 + 4 + 5 + 6 = %d\n", multi_sum(6, 1, 2, 3, 4, 5, 6));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x3,%edi
mov    $0x5,%esi
call   1070 <sum@plt>
mov    %eax,%esi
lea    0xe79(%rip),%rdi
call   1060 <printf@plt>
mov    $0x3,%edi
mov    $0x5,%esi
call   1040 <multiply@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xe60(%rip),%rdi
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movl   $0x3,-0x14(%rbp)
lea    -0x14(%rbp),%rdi
mov    $0x5,%esi
call   1080 <subtract@plt>
mov    %eax,%esi
lea    0xe40(%rip),%rdi
call   1060 <printf@plt>
mov    $0x6,%edi
mov    $0x1,%esi
mov    $0x2,%edx
mov    $0x3,%ecx
mov    $0x4,%r8d
mov    $0x5,%r9d
movl   $0x6,(%rsp)
call   1050 <multi_sum@plt>
mov    %eax,%esi
lea    0xe12(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    $0x3,%edi
mov    $0x5,%esi
call   1070 <sum@plt>
lea    0xe85(%rip),%rdi
mov    %eax,%esi
call   1060 <printf@plt>
mov    $0x3,%edi
mov    $0x5,%esi
call   1040 <multiply@plt>
mov    %rax,%rbx
mov    (%rax),%esi
lea    0xe6f(%rip),%rdi
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
movl   $0x3,0xc(%rsp)
lea    0xc(%rsp),%rdi
mov    $0x5,%esi
call   1080 <subtract@plt>
lea    0xe50(%rip),%rdi
mov    %eax,%esi
call   1060 <printf@plt>
movl   $0x6,(%rsp)
mov    $0x6,%edi
mov    $0x1,%esi
mov    $0x2,%edx
mov    $0x3,%ecx
mov    $0x4,%r8d
mov    $0x5,%r9d
call   1050 <multi_sum@plt>
lea    0xe22(%rip),%rdi
mov    %eax,%esi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"3 + 5 = %d\0A\00"
@.str.1 = [12 x i8] c"3 * 5 = %d\0A\00"
@.str.2 = [12 x i8] c"3 - 5 = %d\0A\00"
@.str.3 = [28 x i8] c"1 + 2 + 3 + 4 + 5 + 6 = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @sum(i32 3, i32 5)
%5 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = call i32* @multiply(i32 3, i32 5)
store i32* %6, i32** %2
%7 = load i32*, i32** %2
%8 = load i32, i32* %7
%9 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = load i32*, i32** %2
%11 = call i32 @free(i32* %10)
store i32 3, i32* %3
%12 = call i32 @subtract(i32* %3, i32 5)
%13 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = call i32 @multi_sum(i32 6, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6)
%15 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %14)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"3 + 5 = %d\0A\00"
@.str.1 = [12 x i8] c"3 * 5 = %d\0A\00"
@.str.2 = [12 x i8] c"3 - 5 = %d\0A\00"
@.str.3 = [28 x i8] c"1 + 2 + 3 + 4 + 5 + 6 = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call i32 @sum(i32 3, i32 5)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = tail call i32* @multiply(i32 3, i32 5)
%5 = load i32, i32* %4
%6 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = tail call i32 @free(i32* %4)
%8 = bitcast i32* %1 to i8*
store i32 3, i32* %1
%9 = call i32 @subtract(i32* %1, i32 5)
%10 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = call i32 @multi_sum(i32 6, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6)
%12 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %11)
ret i32 0
}