#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 foo2(int, int, int, int);
int foo1(int a, int b, int c, int d) {
  int aa = foo2(a, b, c, d);
  int bb = foo2(1, 2, 3, 4);
  int cc = foo2(a, b, c, d);
  int dd = foo2(1, 2, 3, 4);
  int e = foo2(a, b, c, d);
  int f = foo2(1, 2, 3, 4);
  int g = foo2(a, b, c, d);
  int h = foo2(1, 2, 3, 4);
  int i = foo2(a, b, c, d);
  int j = foo2(1, 2, 3, 4);
  int k = foo2(a, b, c, d);
  return aa + bb + cc + dd + e + f + g + h + i + j + k;
}


x86 assembly (clang, -O0):
<foo1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1030 <foo2@plt>
mov    %eax,-0x14(%rbp)
mov    $0x1,%edi
mov    $0x2,%esi
mov    $0x3,%edx
mov    $0x4,%ecx
call   1030 <foo2@plt>
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1030 <foo2@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x1,%edi
mov    $0x2,%esi
mov    $0x3,%edx
mov    $0x4,%ecx
call   1030 <foo2@plt>
mov    %eax,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1030 <foo2@plt>
mov    %eax,-0x24(%rbp)
mov    $0x1,%edi
mov    $0x2,%esi
mov    $0x3,%edx
mov    $0x4,%ecx
call   1030 <foo2@plt>
mov    %eax,-0x28(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1030 <foo2@plt>
mov    %eax,-0x2c(%rbp)
mov    $0x1,%edi
mov    $0x2,%esi
mov    $0x3,%edx
mov    $0x4,%ecx
call   1030 <foo2@plt>
mov    %eax,-0x30(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1030 <foo2@plt>
mov    %eax,-0x34(%rbp)
mov    $0x1,%edi
mov    $0x2,%esi
mov    $0x3,%edx
mov    $0x4,%ecx
call   1030 <foo2@plt>
mov    %eax,-0x38(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1030 <foo2@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
add    -0x1c(%rbp),%eax
add    -0x20(%rbp),%eax
add    -0x24(%rbp),%eax
add    -0x28(%rbp),%eax
add    -0x2c(%rbp),%eax
add    -0x30(%rbp),%eax
add    -0x34(%rbp),%eax
add    -0x38(%rbp),%eax
add    -0x3c(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo1>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %esi,%r12d
mov    %edi,%ebx
call   1030 <foo2@plt>
mov    %eax,0x24(%rsp)
mov    $0x1,%edi
mov    $0x2,%esi
mov    $0x3,%edx
mov    $0x4,%ecx
call   1030 <foo2@plt>
mov    %eax,%ebp
mov    %ebx,%edi
mov    %r12d,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
call   1030 <foo2@plt>
mov    %eax,0x20(%rsp)
mov    $0x1,%edi
mov    $0x2,%esi
mov    $0x3,%edx
mov    $0x4,%ecx
call   1030 <foo2@plt>
mov    %eax,0x1c(%rsp)
mov    %ebx,%edi
mov    %r12d,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
call   1030 <foo2@plt>
mov    %eax,0x18(%rsp)
mov    $0x1,%edi
mov    $0x2,%esi
mov    $0x3,%edx
mov    $0x4,%ecx
call   1030 <foo2@plt>
mov    %eax,0x14(%rsp)
mov    %ebx,%edi
mov    %r12d,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
call   1030 <foo2@plt>
mov    %eax,0x10(%rsp)
mov    $0x1,%edi
mov    $0x2,%esi
mov    $0x3,%edx
mov    $0x4,%ecx
call   1030 <foo2@plt>
mov    %eax,0xc(%rsp)
mov    %ebx,%edi
mov    %r12d,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
call   1030 <foo2@plt>
mov    %eax,0x8(%rsp)
mov    $0x1,%edi
mov    $0x2,%esi
mov    $0x3,%edx
mov    $0x4,%ecx
call   1030 <foo2@plt>
mov    %eax,%r13d
mov    %ebx,%edi
mov    %r12d,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
call   1030 <foo2@plt>
add    0x24(%rsp),%ebp
add    0x20(%rsp),%ebp
add    0x1c(%rsp),%ebp
add    0x18(%rsp),%ebp
add    0x14(%rsp),%ebp
add    0x10(%rsp),%ebp
add    0xc(%rsp),%ebp
add    0x8(%rsp),%ebp
add    %r13d,%ebp
add    %ebp,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @foo1(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%20 = load i32, i32* %5
%21 = load i32, i32* %6
%22 = load i32, i32* %7
%23 = load i32, i32* %8
%24 = call i32 @foo2(i32 %20, i32 %21, i32 %22, i32 %23)
store i32 %24, i32* %9
%25 = call i32 @foo2(i32 1, i32 2, i32 3, i32 4)
store i32 %25, i32* %10
%26 = load i32, i32* %5
%27 = load i32, i32* %6
%28 = load i32, i32* %7
%29 = load i32, i32* %8
%30 = call i32 @foo2(i32 %26, i32 %27, i32 %28, i32 %29)
store i32 %30, i32* %11
%31 = call i32 @foo2(i32 1, i32 2, i32 3, i32 4)
store i32 %31, i32* %12
%32 = load i32, i32* %5
%33 = load i32, i32* %6
%34 = load i32, i32* %7
%35 = load i32, i32* %8
%36 = call i32 @foo2(i32 %32, i32 %33, i32 %34, i32 %35)
store i32 %36, i32* %13
%37 = call i32 @foo2(i32 1, i32 2, i32 3, i32 4)
store i32 %37, i32* %14
%38 = load i32, i32* %5
%39 = load i32, i32* %6
%40 = load i32, i32* %7
%41 = load i32, i32* %8
%42 = call i32 @foo2(i32 %38, i32 %39, i32 %40, i32 %41)
store i32 %42, i32* %15
%43 = call i32 @foo2(i32 1, i32 2, i32 3, i32 4)
store i32 %43, i32* %16
%44 = load i32, i32* %5
%45 = load i32, i32* %6
%46 = load i32, i32* %7
%47 = load i32, i32* %8
%48 = call i32 @foo2(i32 %44, i32 %45, i32 %46, i32 %47)
store i32 %48, i32* %17
%49 = call i32 @foo2(i32 1, i32 2, i32 3, i32 4)
store i32 %49, i32* %18
%50 = load i32, i32* %5
%51 = load i32, i32* %6
%52 = load i32, i32* %7
%53 = load i32, i32* %8
%54 = call i32 @foo2(i32 %50, i32 %51, i32 %52, i32 %53)
store i32 %54, i32* %19
%55 = load i32, i32* %9
%56 = load i32, i32* %10
%57 = add nsw i32 %55, %56
%58 = load i32, i32* %11
%59 = add nsw i32 %57, %58
%60 = load i32, i32* %12
%61 = add nsw i32 %59, %60
%62 = load i32, i32* %13
%63 = add nsw i32 %61, %62
%64 = load i32, i32* %14
%65 = add nsw i32 %63, %64
%66 = load i32, i32* %15
%67 = add nsw i32 %65, %66
%68 = load i32, i32* %16
%69 = add nsw i32 %67, %68
%70 = load i32, i32* %17
%71 = add nsw i32 %69, %70
%72 = load i32, i32* %18
%73 = add nsw i32 %71, %72
%74 = load i32, i32* %19
%75 = add nsw i32 %73, %74
ret i32 %75
}

LLVM IR (-O2):
define i32 @foo1(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call i32 @foo2(i32 %0, i32 %1, i32 %2, i32 %3)
%6 = tail call i32 @foo2(i32 1, i32 2, i32 3, i32 4)
%7 = tail call i32 @foo2(i32 %0, i32 %1, i32 %2, i32 %3)
%8 = tail call i32 @foo2(i32 1, i32 2, i32 3, i32 4)
%9 = tail call i32 @foo2(i32 %0, i32 %1, i32 %2, i32 %3)
%10 = tail call i32 @foo2(i32 1, i32 2, i32 3, i32 4)
%11 = tail call i32 @foo2(i32 %0, i32 %1, i32 %2, i32 %3)
%12 = tail call i32 @foo2(i32 1, i32 2, i32 3, i32 4)
%13 = tail call i32 @foo2(i32 %0, i32 %1, i32 %2, i32 %3)
%14 = tail call i32 @foo2(i32 1, i32 2, i32 3, i32 4)
%15 = tail call i32 @foo2(i32 %0, i32 %1, i32 %2, i32 %3)
%16 = add nsw i32 %6, %5
%17 = add nsw i32 %16, %7
%18 = add nsw i32 %17, %8
%19 = add nsw i32 %18, %9
%20 = add nsw i32 %19, %10
%21 = add nsw i32 %20, %11
%22 = add nsw i32 %21, %12
%23 = add nsw i32 %22, %13
%24 = add nsw i32 %23, %14
%25 = add nsw i32 %24, %15
ret i32 %25
}