#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*/ __strAppend(char **, char *);
char *strCreate();
char *strJoin(char *glue, char **list, int size) {
  char *string;
  int i;
  string = strCreate();
  for (i = 0; i < size; i++) {
    if (i)
      __strAppend(&string, glue);
    __strAppend(&string, list[i]);
  }
  return string;
}


x86 assembly (clang, -O0):
<strJoin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    $0x0,%al
call   1030 <strCreate@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    118b <strJoin+0x6b>
cmpl   $0x0,-0x24(%rbp)
je     1168 <strJoin+0x48>
mov    -0x8(%rbp),%rsi
lea    -0x20(%rbp),%rdi
call   1040 <__strAppend@plt>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    -0x20(%rbp),%rdi
call   1040 <__strAppend@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1145 <strJoin+0x25>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strJoin>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %edx,%ebp
mov    %rsi,%r15
mov    %rdi,%r14
xor    %eax,%eax
call   1030 <strCreate@plt>
mov    %rax,0x8(%rsp)
test   %ebp,%ebp
jle    1195 <strJoin+0x75>
mov    (%r15),%rsi
lea    0x8(%rsp),%rdi
call   1040 <__strAppend@plt>
cmp    $0x1,%ebp
je     1190 <strJoin+0x70>
mov    %ebp,%r12d
mov    $0x1,%ebx
lea    0x8(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbp,%rdi
mov    %r14,%rsi
call   1040 <__strAppend@plt>
mov    (%r15,%rbx,8),%rsi
mov    %rbp,%rdi
call   1040 <__strAppend@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1170 <strJoin+0x50>
mov    0x8(%rsp),%rax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @strJoin(i8* %0, i8** %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i32 %2, i32* %6
%9 = call i8* (...) @strCreate()
store i8* %9, i8** %7
store i32 0, i32* %8
br label %10
10: ; preds = %27, %3
%11 = load i32, i32* %8
%12 = load i32, i32* %6
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %30
14: ; preds = %10
%15 = load i32, i32* %8
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i8*, i8** %4
%19 = call i32 @__strAppend(i8** %7, i8* %18)
br label %20
20: ; preds = %17, %14
%21 = load i8**, i8*** %5
%22 = load i32, i32* %8
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %21, i64 %23
%25 = load i8*, i8** %24
%26 = call i32 @__strAppend(i8** %7, i8* %25)
br label %27
27: ; preds = %20
%28 = load i32, i32* %8
%29 = add nsw i32 %28, 1
store i32 %29, i32* %8
br label %10
30: ; preds = %10
%31 = load i8*, i8** %7
ret i8* %31
}

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