#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 */
scalar_t__ realloc(char **, int);
char *strdup(char const *);
void add_header(char ***additional_headers, int *n_additional_headers,
                const char *in) {
  *additional_headers = (char **)realloc(
      *additional_headers, (*n_additional_headers + 1) * sizeof(char **));
  (*additional_headers)[*n_additional_headers] = strdup(in);
  (*n_additional_headers)++;
}


x86 assembly (clang, -O0):
<add_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%esi
call   1030 <realloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rdi
call   1040 <strdup@plt>
mov    %rax,%rdx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x10(%rbp),%rcx
movslq (%rcx),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_header>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%r15
mov    (%rdi),%rdi
mov    (%rsi),%eax
lea    0x8(,%rax,8),%esi
call   1030 <realloc@plt>
mov    %rax,%rbx
mov    %rax,(%r15)
mov    %r14,%rdi
call   1040 <strdup@plt>
movslq (%r12),%rcx
mov    %rax,(%rbx,%rcx,8)
lea    0x1(%rcx),%eax
mov    %eax,(%r12)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @add_header(i8*** %0, i32* %1, i8* %2) {
%4 = alloca i8***
%5 = alloca i32*
%6 = alloca i8*
store i8*** %0, i8**** %4
store i32* %1, i32** %5
store i8* %2, i8** %6
%7 = load i8***, i8**** %4
%8 = load i8**, i8*** %7
%9 = load i32*, i32** %5
%10 = load i32, i32* %9
%11 = add nsw i32 %10, 1
%12 = sext i32 %11 to i64
%13 = mul i64 %12, 8
%14 = trunc i64 %13 to i32
%15 = call i64 @realloc(i8** %8, i32 %14)
%16 = inttoptr i64 %15 to i8**
%17 = load i8***, i8**** %4
store i8** %16, i8*** %17
%18 = load i8*, i8** %6
%19 = call i8* @strdup(i8* %18)
%20 = load i8***, i8**** %4
%21 = load i8**, i8*** %20
%22 = load i32*, i32** %5
%23 = load i32, i32* %22
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %21, i64 %24
store i8* %19, i8** %25
%26 = load i32*, i32** %5
%27 = load i32, i32* %26
%28 = add nsw i32 %27, 1
store i32 %28, i32* %26
ret void
}

LLVM IR (-O2):
define void @add_header(i8*** nocapture %0, i32* nocapture %1, i8* nocapture %2) {
%4 = load i8**, i8*** %0
%5 = load i32, i32* %1
%6 = shl i32 %5, 3
%7 = add i32 %6, 8
%8 = tail call i64 @realloc(i8** %4, i32 %7)
%9 = inttoptr i64 %8 to i8**
store i8** %9, i8*** %0
%10 = tail call i8* @strdup(i8* %2)
%11 = load i32, i32* %1
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8*, i8** %9, i64 %12
store i8* %10, i8** %13
%14 = add nsw i32 %11, 1
store i32 %14, i32* %1
ret void
}