#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 */
struct binary_exponential_buffer {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ add_endif(struct binary_exponential_buffer *);
int /*<<< orphan*/ add_include(struct binary_exponential_buffer *,
                               unsigned char *, unsigned char *);
int /*<<< orphan*/ add_include_guard(struct binary_exponential_buffer *,
                                     unsigned char *);
int /*<<< orphan*/
add_string_to_binary_exponential_buffer(void *,
                                        struct binary_exponential_buffer *);
int /*<<< orphan*/ add_string_to_binary_exponential_buffer_with_null_terminator(
    void *, struct binary_exponential_buffer *);
scalar_t__ binary_exponential_buffer_data(struct binary_exponential_buffer *);
unsigned int binary_exponential_buffer_size(struct binary_exponential_buffer *);
int /*<<< orphan*/ printf(char *, unsigned char *);
void build_header_section(struct binary_exponential_buffer *files,
                          struct binary_exponential_buffer *output,
                          unsigned char *relative_location) {
  unsigned int i;
  add_string_to_binary_exponential_buffer((void *)"\n", output);
  for (i = 0; i < binary_exponential_buffer_size(files); i++) {
    unsigned char *dependency =
        ((unsigned char **)binary_exponential_buffer_data(files))[i];
    printf("It has dependency %s.\n", dependency);
    add_include_guard(output, dependency);
    add_include(output, relative_location, dependency);
    add_endif(output);
  }
  add_string_to_binary_exponential_buffer_with_null_terminator((void *)"",
                                                               output);
}


x86 assembly (clang, -O0):
<build_header_section>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe76(%rip),%rdi
call   1080 <add_string_to_binary_exponential_buffer@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <binary_exponential_buffer_size@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
cmp    %ecx,%eax
jae    1220 <build_header_section+0xa0>
mov    -0x8(%rbp),%rdi
call   1090 <binary_exponential_buffer_data@plt>
mov    -0x1c(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
lea    0xe1a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1070 <add_include_guard@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <add_include@plt>
mov    -0x10(%rbp),%rdi
call   10a0 <add_endif@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ab <build_header_section+0x2b>
mov    -0x10(%rbp),%rsi
lea    0xdeb(%rip),%rdi
call   1050 <add_string_to_binary_exponential_buffer_with_null_terminator@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<build_header_section>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r13
mov    %rdi,%r15
lea    0xe7a(%rip),%rdi
call   1080 <add_string_to_binary_exponential_buffer@plt>
mov    %r15,%rdi
call   1060 <binary_exponential_buffer_size@plt>
test   %eax,%eax
je     120b <build_header_section+0x8b>
xor    %ebp,%ebp
lea    0xe4b(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rdi
call   1090 <binary_exponential_buffer_data@plt>
mov    (%rax,%rbp,8),%rbx
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1070 <add_include_guard@plt>
mov    %r13,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1030 <add_include@plt>
mov    %r13,%rdi
call   10a0 <add_endif@plt>
add    $0x1,%rbp
mov    %r15,%rdi
call   1060 <binary_exponential_buffer_size@plt>
mov    %eax,%eax
cmp    %rax,%rbp
jb     11c0 <build_header_section+0x40>
lea    0xe04(%rip),%rdi
mov    %r13,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <add_string_to_binary_exponential_buffer_with_null_terminator@plt>

LLVM IR (-O0):
%struct.binary_exponential_buffer = type { i32 }
@.str = [2 x i8] c"\0A\00"
@.str.1 = [23 x i8] c"It has dependency %s.\0A\00"
@.str.2 = [1 x i8] zeroinitializer
define void @build_header_section(%struct.binary_exponential_buffer* %0, %struct.binary_exponential_buffer* %1, i8* %2) {
%4 = alloca %struct.binary_exponential_buffer*
%5 = alloca %struct.binary_exponential_buffer*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
store %struct.binary_exponential_buffer* %0, %struct.binary_exponential_buffer** %4
store %struct.binary_exponential_buffer* %1, %struct.binary_exponential_buffer** %5
store i8* %2, i8** %6
%9 = load %struct.binary_exponential_buffer*, %struct.binary_exponential_buffer** %5
%10 = call i32 @add_string_to_binary_exponential_buffer(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %struct.binary_exponential_buffer* %9)
store i32 0, i32* %7
br label %11
11: ; preds = %35, %3
%12 = load i32, i32* %7
%13 = load %struct.binary_exponential_buffer*, %struct.binary_exponential_buffer** %4
%14 = call i32 @binary_exponential_buffer_size(%struct.binary_exponential_buffer* %13)
%15 = icmp ult i32 %12, %14
br i1 %15, label %16, label %38
16: ; preds = %11
%17 = load %struct.binary_exponential_buffer*, %struct.binary_exponential_buffer** %4
%18 = call i64 @binary_exponential_buffer_data(%struct.binary_exponential_buffer* %17)
%19 = inttoptr i64 %18 to i8**
%20 = load i32, i32* %7
%21 = zext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %19, i64 %21
%23 = load i8*, i8** %22
store i8* %23, i8** %8
%24 = load i8*, i8** %8
%25 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %24)
%26 = load %struct.binary_exponential_buffer*, %struct.binary_exponential_buffer** %5
%27 = load i8*, i8** %8
%28 = call i32 @add_include_guard(%struct.binary_exponential_buffer* %26, i8* %27)
%29 = load %struct.binary_exponential_buffer*, %struct.binary_exponential_buffer** %5
%30 = load i8*, i8** %6
%31 = load i8*, i8** %8
%32 = call i32 @add_include(%struct.binary_exponential_buffer* %29, i8* %30, i8* %31)
%33 = load %struct.binary_exponential_buffer*, %struct.binary_exponential_buffer** %5
%34 = call i32 @add_endif(%struct.binary_exponential_buffer* %33)
br label %35
35: ; preds = %16
%36 = load i32, i32* %7
%37 = add i32 %36, 1
store i32 %37, i32* %7
br label %11
38: ; preds = %11
%39 = load %struct.binary_exponential_buffer*, %struct.binary_exponential_buffer** %5
%40 = call i32 @add_string_to_binary_exponential_buffer_with_null_terminator(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), %struct.binary_exponential_buffer* %39)
ret void
}

LLVM IR (-O2):
%struct.binary_exponential_buffer = type { i32 }
@.str = [2 x i8] c"\0A\00"
@.str.1 = [23 x i8] c"It has dependency %s.\0A\00"
@.str.2 = [1 x i8] zeroinitializer
define void @build_header_section(%struct.binary_exponential_buffer* %0, %struct.binary_exponential_buffer* %1, i8* %2) {
%4 = tail call i32 @add_string_to_binary_exponential_buffer(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %struct.binary_exponential_buffer* %1)
%5 = tail call i32 @binary_exponential_buffer_size(%struct.binary_exponential_buffer* %0)
%6 = icmp eq i32 %5, 0
br i1 %6, label %21, label %7
7: ; preds = %3, %7
%8 = phi i64 [ %17, %7 ], [ 0, %3 ]
%9 = tail call i64 @binary_exponential_buffer_data(%struct.binary_exponential_buffer* %0)
%10 = inttoptr i64 %9 to i8**
%11 = getelementptr inbounds i8*, i8** %10, i64 %8
%12 = load i8*, i8** %11
%13 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = tail call i32 @add_include_guard(%struct.binary_exponential_buffer* %1, i8* %12)
%15 = tail call i32 @add_include(%struct.binary_exponential_buffer* %1, i8* %2, i8* %12)
%16 = tail call i32 @add_endif(%struct.binary_exponential_buffer* %1)
%17 = add nuw nsw i64 %8, 1
%18 = tail call i32 @binary_exponential_buffer_size(%struct.binary_exponential_buffer* %0)
%19 = zext i32 %18 to i64
%20 = icmp ult i64 %17, %19
br i1 %20, label %7, label %21
21: ; preds = %7, %3
%22 = tail call i32 @add_string_to_binary_exponential_buffer_with_null_terminator(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), %struct.binary_exponential_buffer* %1)
ret void
}