#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 boo(int *);
scalar_t__ malloc(int);
int main() {
  int *a = (int *)malloc(8);
  int *b = (int *)malloc(8);
  *a = 5;
  *b = 4;
  return boo(a) + boo(a) + boo(b) + boo(b) + boo(a) + boo(b);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x8,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x8,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x5,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x4,(%rax)
mov    -0x10(%rbp),%rdi
call   1040 <boo@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <boo@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <boo@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <boo@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <boo@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <boo@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
add    %ecx,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0x8,%edi
call   1030 <malloc@plt>
mov    %rax,%r12
mov    $0x8,%edi
call   1030 <malloc@plt>
mov    %rax,%r14
movl   $0x5,(%r12)
movl   $0x4,(%rax)
mov    %r12,%rdi
call   1040 <boo@plt>
mov    %eax,%r15d
mov    %r12,%rdi
call   1040 <boo@plt>
mov    %eax,%ebp
add    %r15d,%ebp
mov    %r14,%rdi
call   1040 <boo@plt>
mov    %eax,%ebx
add    %ebp,%ebx
mov    %r14,%rdi
call   1040 <boo@plt>
mov    %eax,%ebp
add    %ebx,%ebp
mov    %r12,%rdi
call   1040 <boo@plt>
mov    %eax,%ebx
add    %ebp,%ebx
mov    %r14,%rdi
call   1040 <boo@plt>
add    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
store i32 0, i32* %1
%4 = call i64 @malloc(i32 8)
%5 = inttoptr i64 %4 to i32*
store i32* %5, i32** %2
%6 = call i64 @malloc(i32 8)
%7 = inttoptr i64 %6 to i32*
store i32* %7, i32** %3
%8 = load i32*, i32** %2
store i32 5, i32* %8
%9 = load i32*, i32** %3
store i32 4, i32* %9
%10 = load i32*, i32** %2
%11 = call i32 @boo(i32* %10)
%12 = load i32*, i32** %2
%13 = call i32 @boo(i32* %12)
%14 = add nsw i32 %11, %13
%15 = load i32*, i32** %3
%16 = call i32 @boo(i32* %15)
%17 = add nsw i32 %14, %16
%18 = load i32*, i32** %3
%19 = call i32 @boo(i32* %18)
%20 = add nsw i32 %17, %19
%21 = load i32*, i32** %2
%22 = call i32 @boo(i32* %21)
%23 = add nsw i32 %20, %22
%24 = load i32*, i32** %3
%25 = call i32 @boo(i32* %24)
%26 = add nsw i32 %23, %25
ret i32 %26
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i64 @malloc(i32 8)
%2 = inttoptr i64 %1 to i32*
%3 = tail call i64 @malloc(i32 8)
%4 = inttoptr i64 %3 to i32*
store i32 5, i32* %2
store i32 4, i32* %4
%5 = tail call i32 @boo(i32* %2)
%6 = tail call i32 @boo(i32* %2)
%7 = add nsw i32 %6, %5
%8 = tail call i32 @boo(i32* %4)
%9 = add nsw i32 %7, %8
%10 = tail call i32 @boo(i32* %4)
%11 = add nsw i32 %9, %10
%12 = tail call i32 @boo(i32* %2)
%13 = add nsw i32 %11, %12
%14 = tail call i32 @boo(i32* %4)
%15 = add nsw i32 %13, %14
ret i32 %15
}