#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__ malloc(int);
scalar_t__ realloc(char **, int);
char *strdup(char *);
void BN_AddStringToList(char ***List, char S[], int *C) {
  int c;
  char **l;
  c = *C;
  l = *List;
  c++;
  if (c == 1)
    l = (char **)malloc(sizeof(char *));
  else
    l = (char **)realloc(l, c * sizeof(char *));
  l[c - 1] = strdup(S);
  *C = c;
  *List = l;
}


x86 assembly (clang, -O0):
<BN_AddStringToList>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jne    117e <BN_AddStringToList+0x4e>
mov    $0x8,%edi
call   1030 <malloc@plt>
mov    %rax,-0x28(%rbp)
jmp    1195 <BN_AddStringToList+0x65>
mov    -0x28(%rbp),%rdi
movslq -0x1c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%esi
call   1040 <realloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,%rdx
mov    -0x28(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BN_AddStringToList>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r12
mov    %rsi,%r15
mov    %rdi,%r14
movslq (%rdx),%r13
lea    0x1(%r13),%ebp
test   %r13,%r13
je     1161 <BN_AddStringToList+0x31>
mov    (%r14),%rdi
lea    0x0(,%rbp,8),%esi
call   1040 <realloc@plt>
jmp    116b <BN_AddStringToList+0x3b>
mov    $0x8,%edi
call   1030 <malloc@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1050 <strdup@plt>
mov    %rax,(%rbx,%r13,8)
mov    %ebp,(%r12)
mov    %rbx,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @BN_AddStringToList(i8*** %0, i8* %1, i32* %2) {
%4 = alloca i8***
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8**
store i8*** %0, i8**** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
%9 = load i32*, i32** %6
%10 = load i32, i32* %9
store i32 %10, i32* %7
%11 = load i8***, i8**** %4
%12 = load i8**, i8*** %11
store i8** %12, i8*** %8
%13 = load i32, i32* %7
%14 = add nsw i32 %13, 1
store i32 %14, i32* %7
%15 = load i32, i32* %7
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %20
17: ; preds = %3
%18 = call i64 @malloc(i32 8)
%19 = inttoptr i64 %18 to i8**
store i8** %19, i8*** %8
br label %28
20: ; preds = %3
%21 = load i8**, i8*** %8
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = mul i64 %23, 8
%25 = trunc i64 %24 to i32
%26 = call i64 @realloc(i8** %21, i32 %25)
%27 = inttoptr i64 %26 to i8**
store i8** %27, i8*** %8
br label %28
28: ; preds = %20, %17
%29 = load i8*, i8** %5
%30 = call i8* @strdup(i8* %29)
%31 = load i8**, i8*** %8
%32 = load i32, i32* %7
%33 = sub nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8*, i8** %31, i64 %34
store i8* %30, i8** %35
%36 = load i32, i32* %7
%37 = load i32*, i32** %6
store i32 %36, i32* %37
%38 = load i8**, i8*** %8
%39 = load i8***, i8**** %4
store i8** %38, i8*** %39
ret void
}

LLVM IR (-O2):
define void @BN_AddStringToList(i8*** nocapture %0, i8* nocapture %1, i32* nocapture %2) {
%4 = load i32, i32* %2
%5 = add nsw i32 %4, 1
%6 = icmp eq i32 %4, 0
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i64 @malloc(i32 8)
br label %13
9: ; preds = %3
%10 = load i8**, i8*** %0
%11 = shl i32 %5, 3
%12 = tail call i64 @realloc(i8** %10, i32 %11)
br label %13
13: ; preds = %9, %7
%14 = phi i64 [ %8, %7 ], [ %12, %9 ]
%15 = inttoptr i64 %14 to i8**
%16 = tail call i8* @strdup(i8* %1)
%17 = sext i32 %4 to i64
%18 = getelementptr inbounds i8*, i8** %15, i64 %17
store i8* %16, i8** %18
store i32 %5, i32* %2
store i8** %15, i8*** %0
ret void
}