#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 */
char **xrealloc(char const **, int, char *);
int append_string(size_t *max, const char ***vec, const char *str,
                  const char *name) {
  size_t count;
  count = ++(*max);
  *vec = xrealloc(*vec, sizeof(char *) * count, "name");
  (*vec)[count - 1] = 0;
  (*vec)[count - 2] = str;
  return 0;
}


x86 assembly (clang, -O0):
<append_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rcx
mov    (%rcx),%rax
add    $0x1,%rax
mov    %rax,(%rcx)
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x28(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%esi
lea    0xeae(%rip),%rdx
call   1030 <xrealloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x28(%rbp),%rcx
sub    $0x1,%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x28(%rbp),%rcx
sub    $0x2,%rcx
mov    %rdx,(%rax,%rcx,8)
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<append_string>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    (%rdi),%rbx
lea    0x1(%rbx),%rsi
mov    %rsi,(%rdi)
mov    (%r15),%rdi
shl    $0x3,%esi
lea    0xece(%rip),%rdx
call   1030 <xrealloc@plt>
mov    %rax,(%r15)
movq   $0x0,(%rax,%rbx,8)
mov    (%r15),%rax
mov    %r14,-0x8(%rax,%rbx,8)
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"name\00"
define i32 @append_string(i64* %0, i8*** %1, i8* %2, i8* %3) {
%5 = alloca i64*
%6 = alloca i8***
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
store i64* %0, i64** %5
store i8*** %1, i8**** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%10 = load i64*, i64** %5
%11 = load i64, i64* %10
%12 = add i64 %11, 1
store i64 %12, i64* %10
store i64 %12, i64* %9
%13 = load i8***, i8**** %6
%14 = load i8**, i8*** %13
%15 = load i64, i64* %9
%16 = mul i64 8, %15
%17 = trunc i64 %16 to i32
%18 = call i8** @xrealloc(i8** %14, i32 %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%19 = load i8***, i8**** %6
store i8** %18, i8*** %19
%20 = load i8***, i8**** %6
%21 = load i8**, i8*** %20
%22 = load i64, i64* %9
%23 = sub i64 %22, 1
%24 = getelementptr inbounds i8*, i8** %21, i64 %23
store i8* null, i8** %24
%25 = load i8*, i8** %7
%26 = load i8***, i8**** %6
%27 = load i8**, i8*** %26
%28 = load i64, i64* %9
%29 = sub i64 %28, 2
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
store i8* %25, i8** %30
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"name\00"
define i32 @append_string(i64* nocapture %0, i8*** nocapture %1, i8* %2, i8* nocapture readnone %3) {
%5 = load i64, i64* %0
%6 = add i64 %5, 1
store i64 %6, i64* %0
%7 = load i8**, i8*** %1
%8 = trunc i64 %6 to i32
%9 = shl i32 %8, 3
%10 = tail call i8** @xrealloc(i8** %7, i32 %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8** %10, i8*** %1
%11 = getelementptr inbounds i8*, i8** %10, i64 %5
store i8* null, i8** %11
%12 = load i8**, i8*** %1
%13 = add i64 %5, -1
%14 = getelementptr inbounds i8*, i8** %12, i64 %13
store i8* %2, i8** %14
ret i32 0
}