#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
char **realloc(char **, int);
int /*<<< orphan*/ stderr;
void _add_header(char ***hdrs, int *n, const char *name) {
  char **l_hdrs = *hdrs;
  int l_n = *n + 1;
  if ((l_hdrs = realloc(l_hdrs, sizeof(char *) * l_n)) == NULL) {
    fprintf(stderr, "Out of memory error\n");
    return;
  }
  l_hdrs[*n] = (char *)name;
  *n = l_n;
  *hdrs = l_hdrs;
}


x86 assembly (clang, -O0):
<_add_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%esi
call   1040 <realloc@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1186 <_add_header+0x66>
mov    0x2e6d(%rip),%rax
mov    (%rax),%edi
lea    0xe84(%rip),%rsi
call   1030 <fprintf@plt>
jmp    11ad <_add_header+0x8d>
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq (%rcx),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x24(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_add_header>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r14
mov    (%rdi),%rdi
mov    (%rsi),%ebx
lea    0x8(,%rbx,8),%esi
call   1040 <realloc@plt>
test   %rax,%rax
je     1165 <_add_header+0x45>
add    $0x1,%ebx
movslq (%r12),%rcx
mov    %r15,(%rax,%rcx,8)
mov    %ebx,(%r12)
mov    %rax,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    0x2e74(%rip),%rax
mov    (%rax),%edi
lea    0xe8b(%rip),%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [21 x i8] c"Out of memory error\0A\00"
define void @_add_header(i8*** %0, i32* %1, i8* %2) {
%4 = alloca i8***
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8**
%8 = alloca i32
store i8*** %0, i8**** %4
store i32* %1, i32** %5
store i8* %2, i8** %6
%9 = load i8***, i8**** %4
%10 = load i8**, i8*** %9
store i8** %10, i8*** %7
%11 = load i32*, i32** %5
%12 = load i32, i32* %11
%13 = add nsw i32 %12, 1
store i32 %13, i32* %8
%14 = load i8**, i8*** %7
%15 = load i32, i32* %8
%16 = sext i32 %15 to i64
%17 = mul i64 8, %16
%18 = trunc i64 %17 to i32
%19 = call i8** @realloc(i8** %14, i32 %18)
store i8** %19, i8*** %7
%20 = icmp eq i8** %19, null
br i1 %20, label %21, label %24
21: ; preds = %3
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %35
24: ; preds = %3
%25 = load i8*, i8** %6
%26 = load i8**, i8*** %7
%27 = load i32*, i32** %5
%28 = load i32, i32* %27
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %26, i64 %29
store i8* %25, i8** %30
%31 = load i32, i32* %8
%32 = load i32*, i32** %5
store i32 %31, i32* %32
%33 = load i8**, i8*** %7
%34 = load i8***, i8**** %4
store i8** %33, i8*** %34
br label %35
35: ; preds = %24, %21
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [21 x i8] c"Out of memory error\0A\00"
define void @_add_header(i8*** nocapture %0, i32* nocapture %1, i8* %2) {
%4 = load i8**, i8*** %0
%5 = load i32, i32* %1
%6 = add nsw i32 %5, 1
%7 = shl i32 %6, 3
%8 = tail call i8** @realloc(i8** %4, i32 %7)
%9 = icmp eq i8** %8, null
br i1 %9, label %10, label %13
10: ; preds = %3
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %17
13: ; preds = %3
%14 = load i32, i32* %1
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8*, i8** %8, i64 %15
store i8* %2, i8** %16
store i32 %6, i32* %1
store i8** %8, i8*** %0
br label %17
17: ; preds = %13, %10
ret void
}