// File: /workspace/github_c_makefile_star2_O0/aparrish[P]rwet-examples-c/ut_string_helpers.c
// Function: join_new
int join_new(char** s, const UT_array* src, const char* separator) {
	int len, i, separator_len, offset, src_len;
	char** elem = NULL;

	separator_len = strlen(separator);
	src_len = utarray_len(src);

	/* calculate the size for the needed buffer (length of all strings in src,
	   plus src_len * separator_len - 1 */
	len = 0;
	for (i = 0; i < src_len; i++) {
		len += strlen(*(char**)utarray_eltptr(src, i));
	}
	len += (src_len - 1) * separator_len;

	*s = (char*)malloc(len + 1);

	/* s = char**
   * *s = char*
   * **s char */

	/* blit chars into allocated buffer */
	offset = 0;
	for (i = 0; i < src_len; i++) {
		elem = (char**)utarray_eltptr(src, i);	
		if (i < src_len - 1) {
			offset += sprintf((*s) + offset, "%s%s", *elem, separator);
		}
		else {
			sprintf((*s) + offset, "%s", *elem);
		}
	}

	return len;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x18(%rbp), %rdi
callq 0x1050
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x338f
movl -0x20(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl (%rcx), %eax
jae 0x3363
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rcx
movslq -0x20(%rbp), %rdx
imulq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
jmp 0x336b
xorl %eax, %eax
movq %rax, -0x40(%rbp)
jmp 0x336b
movq -0x40(%rbp), %rax
movq (%rax), %rdi
callq 0x1050
movq %rax, %rcx
movslq -0x1c(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x1c(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x332f
movl -0x2c(%rbp), %eax
subl $0x1, %eax
imull -0x24(%rbp), %eax
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
callq 0x10b0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x347c
movl -0x20(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl (%rcx), %eax
jae 0x33fd
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rcx
movslq -0x20(%rbp), %rdx
imulq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
jmp 0x3405
xorl %eax, %eax
movq %rax, -0x48(%rbp)
jmp 0x3405
movq -0x48(%rbp), %rax
movq %rax, -0x38(%rbp)
movl -0x20(%rbp), %eax
movl -0x2c(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x3449
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movslq -0x28(%rbp), %rax
addq %rax, %rdi
movq -0x38(%rbp), %rax
movq (%rax), %rdx
movq -0x18(%rbp), %rcx
leaq 0xc3f(%rip), %rsi       # 0x4079
movb $0x0, %al
callq 0x10e0
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
jmp 0x346c
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movslq -0x28(%rbp), %rax
addq %rax, %rdi
movq -0x38(%rbp), %rax
movq (%rax), %rdx
leaq 0xbfd(%rip), %rsi       # 0x4062
movb $0x0, %al
callq 0x10e0
jmp 0x346e
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x33c5
movl -0x1c(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)