#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 int f1();
unsigned int f2();
unsigned int f3();
unsigned int f4(void) {
  return f1() + f1() + f1() + f1() + f2() + f2() + f2() + f2() + f3() + f3() +
         f3() + f3();
}


x86 assembly (clang, -O0):
<f4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    $0x0,%al
call   1050 <f1@plt>
mov    %eax,-0x2c(%rbp)
mov    $0x0,%al
call   1050 <f1@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    $0x0,%al
call   1050 <f1@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    $0x0,%al
call   1050 <f1@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   1030 <f2@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1030 <f2@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <f2@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1030 <f2@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1040 <f3@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1040 <f3@plt>
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1040 <f3@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1040 <f3@plt>
mov    %eax,%ecx
mov    -0x4(%rbp),%eax
add    %ecx,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f4>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <f1@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1050 <f1@plt>
mov    %eax,%ebp
add    %ebx,%ebp
xor    %eax,%eax
call   1050 <f1@plt>
mov    %eax,%ebx
add    %ebp,%ebx
xor    %eax,%eax
call   1050 <f1@plt>
mov    %eax,%ebp
add    %ebx,%ebp
xor    %eax,%eax
call   1030 <f2@plt>
mov    %eax,%ebx
add    %ebp,%ebx
xor    %eax,%eax
call   1030 <f2@plt>
mov    %eax,%ebp
add    %ebx,%ebp
xor    %eax,%eax
call   1030 <f2@plt>
mov    %eax,%ebx
add    %ebp,%ebx
xor    %eax,%eax
call   1030 <f2@plt>
mov    %eax,%ebp
add    %ebx,%ebp
xor    %eax,%eax
call   1040 <f3@plt>
mov    %eax,%ebx
add    %ebp,%ebx
xor    %eax,%eax
call   1040 <f3@plt>
mov    %eax,%ebp
add    %ebx,%ebp
xor    %eax,%eax
call   1040 <f3@plt>
mov    %eax,%ebx
add    %ebp,%ebx
xor    %eax,%eax
call   1040 <f3@plt>
add    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @f4() {
%1 = call i32 (...) @f1()
%2 = call i32 (...) @f1()
%3 = add i32 %1, %2
%4 = call i32 (...) @f1()
%5 = add i32 %3, %4
%6 = call i32 (...) @f1()
%7 = add i32 %5, %6
%8 = call i32 (...) @f2()
%9 = add i32 %7, %8
%10 = call i32 (...) @f2()
%11 = add i32 %9, %10
%12 = call i32 (...) @f2()
%13 = add i32 %11, %12
%14 = call i32 (...) @f2()
%15 = add i32 %13, %14
%16 = call i32 (...) @f3()
%17 = add i32 %15, %16
%18 = call i32 (...) @f3()
%19 = add i32 %17, %18
%20 = call i32 (...) @f3()
%21 = add i32 %19, %20
%22 = call i32 (...) @f3()
%23 = add i32 %21, %22
ret i32 %23
}

LLVM IR (-O2):
define i32 @f4() {
%1 = tail call i32 (...) @f1()
%2 = tail call i32 (...) @f1()
%3 = add i32 %2, %1
%4 = tail call i32 (...) @f1()
%5 = add i32 %3, %4
%6 = tail call i32 (...) @f1()
%7 = add i32 %5, %6
%8 = tail call i32 (...) @f2()
%9 = add i32 %7, %8
%10 = tail call i32 (...) @f2()
%11 = add i32 %9, %10
%12 = tail call i32 (...) @f2()
%13 = add i32 %11, %12
%14 = tail call i32 (...) @f2()
%15 = add i32 %13, %14
%16 = tail call i32 (...) @f3()
%17 = add i32 %15, %16
%18 = tail call i32 (...) @f3()
%19 = add i32 %17, %18
%20 = tail call i32 (...) @f3()
%21 = add i32 %19, %20
%22 = tail call i32 (...) @f3()
%23 = add i32 %21, %22
ret i32 %23
}