#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 add_to_string_array(char ***, int, char *, int, int);
int append_array(char **source_array, int source_array_count,
                 char ***manipulate_array, int *manipulate_array_count,
                 int prevent_duplicates) {
  int i, code;
  for (i = 0; i < source_array_count; i++) {
    if ((code = add_to_string_array(manipulate_array, *manipulate_array_count,
                                    source_array[i], -1, prevent_duplicates)) ==
        -1) {
      return 1;
    }
    if (code == 0)
      (*manipulate_array_count)++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<append_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11a2 <append_array+0x92>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x2c(%rbp),%r8d
mov    $0xffffffff,%ecx
call   1030 <add_to_string_array@plt>
mov    %eax,-0x34(%rbp)
cmp    $0xffffffff,%eax
jne    117a <append_array+0x6a>
movl   $0x1,-0x4(%rbp)
jmp    11a9 <append_array+0x99>
cmpl   $0x0,-0x34(%rbp)
jne    118f <append_array+0x7f>
mov    -0x28(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    1194 <append_array+0x84>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1132 <append_array+0x22>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<append_array>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    1172 <append_array+0x62>
mov    %r8d,%r14d
mov    %rcx,%rbx
mov    %rdx,%r15
mov    %rdi,%r12
mov    %esi,%r13d
xor    %ebp,%ebp
jmp    114c <append_array+0x3c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
addl   $0x1,(%rbx)
add    $0x1,%rbp
cmp    %rbp,%r13
je     1172 <append_array+0x62>
mov    (%rbx),%esi
mov    (%r12,%rbp,8),%rdx
mov    %r15,%rdi
mov    $0xffffffff,%ecx
mov    %r14d,%r8d
call   1030 <add_to_string_array@plt>
test   %eax,%eax
je     1140 <append_array+0x30>
cmp    $0xffffffff,%eax
jne    1143 <append_array+0x33>
mov    $0x1,%eax
jmp    1174 <append_array+0x64>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @append_array(i8** nocapture %0, i32 %1, i8*** %2, i32* nocapture %3, i32 %4) {
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %21
7: ; preds = %5
%8 = zext i32 %1 to i64
br label %9
9: ; preds = %7, %18
%10 = phi i64 [ 0, %7 ], [ %19, %18 ]
%11 = load i32, i32* %3
%12 = getelementptr inbounds i8*, i8** %0, i64 %10
%13 = load i8*, i8** %12
%14 = tail call i32 @add_to_string_array(i8*** %2, i32 %11, i8* %13, i32 -1, i32 %4)
switch i32 %14, label %18 [
i32 -1, label %21
i32 0, label %15
]
15: ; preds = %9
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
br label %18
18: ; preds = %9, %15
%19 = add nuw nsw i64 %10, 1
%20 = icmp eq i64 %19, %8
br i1 %20, label %21, label %9
21: ; preds = %9, %18, %5
%22 = phi i32 [ 0, %5 ], [ 0, %18 ], [ 1, %9 ]
ret i32 %22
}