#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 f2(int, char *, int);
scalar_t__ f3(int, char *, long long);
scalar_t__ f4(int, int, int, int);
scalar_t__ f5(int, long);
scalar_t__ f6(int);
int test(void) {
  int a = f2(5, "a", 6);
  a += f3(6, "ab", 17LL);
  a += f4(7, 1, 2, 3);
  a += f5(8, 7L);
  a += f6(9);
  return a;
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x5,%edi
lea    0xe9c(%rip),%rsi
mov    $0x6,%edx
call   1030 <f2@plt>
mov    %eax,-0x4(%rbp)
mov    $0x6,%edi
lea    0xe85(%rip),%rsi
mov    $0x11,%edx
call   1050 <f3@plt>
mov    %rax,%rcx
movslq -0x4(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x4(%rbp)
mov    $0x7,%edi
mov    $0x1,%esi
mov    $0x2,%edx
mov    $0x3,%ecx
call   1070 <f4@plt>
mov    %rax,%rcx
movslq -0x4(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x4(%rbp)
mov    $0x8,%edi
mov    $0x7,%esi
call   1060 <f5@plt>
mov    %rax,%rcx
movslq -0x4(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x4(%rbp)
mov    $0x9,%edi
call   1040 <f6@plt>
mov    %rax,%rcx
movslq -0x4(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rbp
push   %rbx
push   %rax
lea    0xea6(%rip),%rsi
mov    $0x5,%edi
mov    $0x6,%edx
call   1030 <f2@plt>
mov    %eax,%ebp
lea    0xe90(%rip),%rsi
mov    $0x11,%edx
mov    $0x6,%edi
call   1050 <f3@plt>
mov    %rax,%rbx
add    %ebp,%ebx
mov    $0x7,%edi
mov    $0x1,%esi
mov    $0x2,%edx
mov    $0x3,%ecx
call   1070 <f4@plt>
mov    %rax,%rbp
add    %ebx,%ebp
mov    $0x7,%esi
mov    $0x8,%edi
call   1060 <f5@plt>
mov    %rax,%rbx
add    %ebp,%ebx
mov    $0x9,%edi
call   1040 <f6@plt>
add    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"a\00"
@.str.1 = [3 x i8] c"ab\00"
define i32 @test() {
%1 = alloca i32
%2 = call i32 @f2(i32 5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 6)
store i32 %2, i32* %1
%3 = call i64 @f3(i32 6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i64 17)
%4 = load i32, i32* %1
%5 = sext i32 %4 to i64
%6 = add nsw i64 %5, %3
%7 = trunc i64 %6 to i32
store i32 %7, i32* %1
%8 = call i64 @f4(i32 7, i32 1, i32 2, i32 3)
%9 = load i32, i32* %1
%10 = sext i32 %9 to i64
%11 = add nsw i64 %10, %8
%12 = trunc i64 %11 to i32
store i32 %12, i32* %1
%13 = call i64 @f5(i32 8, i64 7)
%14 = load i32, i32* %1
%15 = sext i32 %14 to i64
%16 = add nsw i64 %15, %13
%17 = trunc i64 %16 to i32
store i32 %17, i32* %1
%18 = call i64 @f6(i32 9)
%19 = load i32, i32* %1
%20 = sext i32 %19 to i64
%21 = add nsw i64 %20, %18
%22 = trunc i64 %21 to i32
store i32 %22, i32* %1
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@.str = [2 x i8] c"a\00"
@.str.1 = [3 x i8] c"ab\00"
define i32 @test() {
%1 = tail call i32 @f2(i32 5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 6)
%2 = tail call i64 @f3(i32 6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i64 17)
%3 = trunc i64 %2 to i32
%4 = add i32 %1, %3
%5 = tail call i64 @f4(i32 7, i32 1, i32 2, i32 3)
%6 = trunc i64 %5 to i32
%7 = add i32 %4, %6
%8 = tail call i64 @f5(i32 8, i64 7)
%9 = trunc i64 %8 to i32
%10 = add i32 %7, %9
%11 = tail call i64 @f6(i32 9)
%12 = trunc i64 %11 to i32
%13 = add i32 %10, %12
ret i32 %13
}