#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 **malloc(size_t);
int /*<<< orphan*/ string_init_copy(char **, char const *);
size_t string_list_length(char const **);
size_t string_list_init_copy(char ***list, const char **src_list) {
  size_t src_length = string_list_length(src_list);
  if (src_length) {
    *list = malloc((src_length + 1) * sizeof(char *));
    size_t i;
    for (i = 0; i < src_length; ++i)
      string_init_copy(list[i], src_list[i]);
    (*list)[src_length] = 0;
  } else
    *list = 0;
  return src_length;
}


x86 assembly (clang, -O0):
<string_list_init_copy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <string_list_length@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11cf <string_list_init_copy+0x9f>
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
shl    $0x3,%rdi
call   1040 <malloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11b7 <string_list_init_copy+0x87>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1050 <string_init_copy@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    117b <string_list_init_copy+0x4b>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
jmp    11da <string_list_init_copy+0xaa>
mov    -0x8(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_list_init_copy>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <string_list_length@plt>
mov    %rax,%r12
test   %rax,%rax
je     11a3 <string_list_init_copy+0x73>
lea    0x8(,%r12,8),%rdi
call   1040 <malloc@plt>
mov    %rax,(%r14)
mov    (%r15),%rsi
mov    %rax,%rdi
call   1050 <string_init_copy@plt>
cmp    $0x1,%r12
je     1196 <string_list_init_copy+0x66>
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r14,%rbx,8),%rdi
mov    (%r15,%rbx,8),%rsi
call   1050 <string_init_copy@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1180 <string_list_init_copy+0x50>
mov    (%r14),%rax
movq   $0x0,(%rax,%r12,8)
jmp    11aa <string_list_init_copy+0x7a>
movq   $0x0,(%r14)
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @string_list_init_copy(i8*** %0, i8** %1) {
%3 = alloca i8***
%4 = alloca i8**
%5 = alloca i64
%6 = alloca i64
store i8*** %0, i8**** %3
store i8** %1, i8*** %4
%7 = load i8**, i8*** %4
%8 = call i64 @string_list_length(i8** %7)
store i64 %8, i64* %5
%9 = load i64, i64* %5
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %39
11: ; preds = %2
%12 = load i64, i64* %5
%13 = add i64 %12, 1
%14 = mul i64 %13, 8
%15 = call i8** @malloc(i64 %14)
%16 = load i8***, i8**** %3
store i8** %15, i8*** %16
store i64 0, i64* %6
br label %17
17: ; preds = %31, %11
%18 = load i64, i64* %6
%19 = load i64, i64* %5
%20 = icmp ult i64 %18, %19
br i1 %20, label %21, label %34
21: ; preds = %17
%22 = load i8***, i8**** %3
%23 = load i64, i64* %6
%24 = getelementptr inbounds i8**, i8*** %22, i64 %23
%25 = load i8**, i8*** %24
%26 = load i8**, i8*** %4
%27 = load i64, i64* %6
%28 = getelementptr inbounds i8*, i8** %26, i64 %27
%29 = load i8*, i8** %28
%30 = call i32 @string_init_copy(i8** %25, i8* %29)
br label %31
31: ; preds = %21
%32 = load i64, i64* %6
%33 = add i64 %32, 1
store i64 %33, i64* %6
br label %17
34: ; preds = %17
%35 = load i8***, i8**** %3
%36 = load i8**, i8*** %35
%37 = load i64, i64* %5
%38 = getelementptr inbounds i8*, i8** %36, i64 %37
store i8* null, i8** %38
br label %41
39: ; preds = %2
%40 = load i8***, i8**** %3
store i8** null, i8*** %40
br label %41
41: ; preds = %39, %34
%42 = load i64, i64* %5
ret i64 %42
}

LLVM IR (-O2):
define i64 @string_list_init_copy(i8*** nocapture %0, i8** %1) {
%3 = tail call i64 @string_list_length(i8** %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %24, label %5
5: ; preds = %2
%6 = shl i64 %3, 3
%7 = add i64 %6, 8
%8 = tail call i8** @malloc(i64 %7)
store i8** %8, i8*** %0
%9 = load i8*, i8** %1
%10 = tail call i32 @string_init_copy(i8** %8, i8* %9)
%11 = icmp eq i64 %3, 1
br i1 %11, label %21, label %12
12: ; preds = %5, %12
%13 = phi i64 [ %19, %12 ], [ 1, %5 ]
%14 = getelementptr inbounds i8**, i8*** %0, i64 %13
%15 = load i8**, i8*** %14
%16 = getelementptr inbounds i8*, i8** %1, i64 %13
%17 = load i8*, i8** %16
%18 = tail call i32 @string_init_copy(i8** %15, i8* %17)
%19 = add nuw i64 %13, 1
%20 = icmp eq i64 %19, %3
br i1 %20, label %21, label %12
21: ; preds = %12, %5
%22 = load i8**, i8*** %0
%23 = getelementptr inbounds i8*, i8** %22, i64 %3
store i8* null, i8** %23
br label %25
24: ; preds = %2
store i8** null, i8*** %0
br label %25
25: ; preds = %24, %21
ret i64 %3
}