#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*/ BUFSIZ;
char *allocateMemory(int /*<<< orphan*/);
char **reallocateMemory(char **, unsigned int);
int /*<<< orphan*/ strcpy(char *, char const *);
void appendStringToArray(const char *newString, char ***strings,
                         unsigned *numStrings) {
  *strings = reallocateMemory(*strings, (*numStrings + 1) * sizeof(char *));
  (*strings)[*numStrings] = allocateMemory(BUFSIZ);
  strcpy((*strings)[*numStrings], newString);
  ++(*numStrings);
}


x86 assembly (clang, -O0):
<appendStringToArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
add    $0x1,%eax
mov    %eax,%eax
shl    $0x3,%rax
mov    %eax,%esi
call   1040 <reallocateMemory@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    0x2e6e(%rip),%rax
mov    (%rax),%edi
call   1050 <allocateMemory@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%rcx
mov    (%rcx),%ecx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%rcx
mov    (%rcx),%ecx
mov    (%rax,%rcx,8),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<appendStringToArray>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
mov    (%rsi),%rdi
mov    (%rdx),%eax
lea    0x8(,%rax,8),%esi
call   1040 <reallocateMemory@plt>
mov    %rax,(%rbx)
mov    0x2e87(%rip),%rax
mov    (%rax),%edi
call   1050 <allocateMemory@plt>
mov    (%rbx),%rcx
mov    (%r14),%edx
mov    %rax,(%rcx,%rdx,8)
mov    (%rbx),%rax
mov    (%rax,%rdx,8),%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
addl   $0x1,(%r14)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@BUFSIZ = global i32 0
define void @appendStringToArray(i8* %0, i8*** %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8***
%6 = alloca i32*
store i8* %0, i8** %4
store i8*** %1, i8**** %5
store i32* %2, i32** %6
%7 = load i8***, i8**** %5
%8 = load i8**, i8*** %7
%9 = load i32*, i32** %6
%10 = load i32, i32* %9
%11 = add i32 %10, 1
%12 = zext i32 %11 to i64
%13 = mul i64 %12, 8
%14 = trunc i64 %13 to i32
%15 = call i8** @reallocateMemory(i8** %8, i32 %14)
%16 = load i8***, i8**** %5
store i8** %15, i8*** %16
%17 = load i32, i32* @BUFSIZ
%18 = call i8* @allocateMemory(i32 %17)
%19 = load i8***, i8**** %5
%20 = load i8**, i8*** %19
%21 = load i32*, i32** %6
%22 = load i32, i32* %21
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %20, i64 %23
store i8* %18, i8** %24
%25 = load i8***, i8**** %5
%26 = load i8**, i8*** %25
%27 = load i32*, i32** %6
%28 = load i32, i32* %27
%29 = zext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %26, i64 %29
%31 = load i8*, i8** %30
%32 = load i8*, i8** %4
%33 = call i32 @strcpy(i8* %31, i8* %32)
%34 = load i32*, i32** %6
%35 = load i32, i32* %34
%36 = add i32 %35, 1
store i32 %36, i32* %34
ret void
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
define void @appendStringToArray(i8* %0, i8*** nocapture %1, i32* nocapture %2) {
%4 = load i8**, i8*** %1
%5 = load i32, i32* %2
%6 = shl i32 %5, 3
%7 = add i32 %6, 8
%8 = tail call i8** @reallocateMemory(i8** %4, i32 %7)
store i8** %8, i8*** %1
%9 = load i32, i32* @BUFSIZ
%10 = tail call i8* @allocateMemory(i32 %9)
%11 = load i8**, i8*** %1
%12 = load i32, i32* %2
%13 = zext i32 %12 to i64
%14 = getelementptr inbounds i8*, i8** %11, i64 %13
store i8* %10, i8** %14
%15 = load i8**, i8*** %1
%16 = getelementptr inbounds i8*, i8** %15, i64 %13
%17 = load i8*, i8** %16
%18 = tail call i32 @strcpy(i8* %17, i8* %0)
%19 = load i32, i32* %2
%20 = add i32 %19, 1
store i32 %20, i32* %2
ret void
}