#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 **realloc(char **, size_t);
int /*<<< orphan*/ string_init_copy(char **, char const *);
size_t string_list_length(char const **);
size_t string_list_push(char ***list, const char *string) {
  size_t length = string_list_length((const char **)list);
  *list = realloc(*list, (length + 2) * sizeof(char *));
  string_init_copy(list[length], string);
  (*list)[length + 1] = 0;
  return length + 1;
}


x86 assembly (clang, -O0):
<string_list_push>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <string_list_length@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
add    $0x2,%rsi
shl    $0x3,%rsi
call   1040 <realloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <string_init_copy@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%rcx
movq   $0x0,0x8(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_list_push>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1030 <string_list_length@plt>
mov    %rax,%rbx
mov    (%r15),%rdi
lea    0x10(,%rax,8),%rsi
call   1040 <realloc@plt>
mov    %rax,(%r15)
mov    (%r15,%rbx,8),%rdi
mov    %r14,%rsi
call   1050 <string_init_copy@plt>
mov    (%r15),%rax
movq   $0x0,0x8(%rax,%rbx,8)
add    $0x1,%rbx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i64 @string_list_push(i8*** %0, i8* %1) {
%3 = bitcast i8*** %0 to i8**
%4 = tail call i64 @string_list_length(i8** %3)
%5 = load i8**, i8*** %0
%6 = shl i64 %4, 3
%7 = add i64 %6, 16
%8 = tail call i8** @realloc(i8** %5, i64 %7)
store i8** %8, i8*** %0
%9 = getelementptr inbounds i8**, i8*** %0, i64 %4
%10 = load i8**, i8*** %9
%11 = tail call i32 @string_init_copy(i8** %10, i8* %1)
%12 = load i8**, i8*** %0
%13 = add i64 %4, 1
%14 = getelementptr inbounds i8*, i8** %12, i64 %13
store i8* null, i8** %14
ret i64 %13
}