// File: /workspace/github_c_makefile_star2_O1/ccxvii[P]mujs/./jsarray.c
// Function: Ap_join
static void Ap_join(js_State *J)
{
	char * volatile out = NULL;
	const char * volatile r = NULL;
	const char *sep;
	int seplen;
	int k, n, len, rlen;

	len = js_getlength(J, 0);

	if (js_isdefined(J, 1)) {
		sep = js_tostring(J, 1);
		seplen = strlen(sep);
	} else {
		sep = ",";
		seplen = 1;
	}

	if (len <= 0) {
		js_pushliteral(J, "");
		return;
	}

	if (js_try(J)) {
		js_free(J, out);
		js_throw(J);
	}

	n = 0;
	for (k = 0; k < len; ++k) {
		js_getindex(J, 0, k);
		if (js_iscoercible(J, -1)) {
			r = js_tostring(J, -1);
			rlen = strlen(r);
		} else {
			rlen = 0;
		}

		if (k == 0) {
			out = js_malloc(J, rlen + 1);
			if (rlen > 0) {
				memcpy(out, r, rlen);
				n += rlen;
			}
		} else {
			if (n + seplen + rlen > JS_STRLIMIT)
				js_rangeerror(J, "invalid string length");
			out = js_realloc(J, out, n + seplen + rlen + 1);
			if (seplen > 0) {
				memcpy(out + n, sep, seplen);
				n += seplen;
			}
			if (rlen > 0) {
				memcpy(out + n, r, rlen);
				n += rlen;
			}
		}

		js_pop(J, 1);
	}

	js_pushlstring(J, out, n);
	js_endtry(J);
	js_free(J, out);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
xorl %esi, %esi
movl %esi, %eax
movq %rax, 0x8(%rsp)
movq %rax, 0x18(%rsp)
callq 0x3fcc
movl %eax, 0x14(%rsp)
movl 0x144(%rbx), %ecx
movl %ecx, %eax
incl %eax
leaq 0x3bb7e(%rip), %rdx     # 0x403f8
cmpl $-0x1, %ecx
jl 0x4894
cmpl 0x140(%rbx), %eax
jge 0x4894
movl %eax, %edx
shlq $0x4, %rdx
addq 0x148(%rbx), %rdx
cmpb $0x1, 0xf(%rdx)
jne 0x48a9
leaq 0x2f3a0(%rip), %rax     # 0x33c41
movl $0x1, %r14d
jmp 0x48e6
leaq 0x3bb48(%rip), %rsi     # 0x403f8
cmpl $-0x1, %ecx
jl 0x48cd
cmpl 0x140(%rbx), %eax
jge 0x48cd
movl %eax, %eax
shlq $0x4, %rax
addq 0x148(%rbx), %rax
movq %rax, %rsi
movq %rbx, %rdi
callq 0x1533b
movq %rax, %r15
movq %rax, %rdi
callq 0x3200
movl %eax, %r14d
movq %r15, %rax
movq %rax, 0x30(%rsp)
cmpl $0x0, 0x14(%rsp)
jle 0x4ab1
movq %rbx, %rdi
callq 0x13fbb
movq %rax, %rdi
callq 0x3100
testl %eax, %eax
jne 0x4af7
movl %r14d, 0x24(%rsp)
movl %r14d, %eax
movq %rax, 0x28(%rsp)
xorl %r13d, %r13d
leaq 0x3bad3(%rip), %r15     # 0x403f8
movl %r13d, %r12d
movl 0x24(%rsp), %r14d
movq %rbx, %rdi
xorl %esi, %esi
movl %r13d, %edx
callq 0x169fb
movl 0x140(%rbx), %ecx
movl %ecx, %eax
decl %eax
movq %r15, %rdx
testl %ecx, %ecx
jle 0x4958
movl %eax, %edx
shlq $0x4, %rdx
addq 0x148(%rbx), %rdx
movb 0xf(%rdx), %dl
decb %dl
xorl %ebp, %ebp
cmpb $0x2, %dl
jb 0x4994
movq %r15, %rsi
testl %ecx, %ecx
jle 0x497b
movl %eax, %eax
shlq $0x4, %rax
addq 0x148(%rbx), %rax
movq %rax, %rsi
movq %rbx, %rdi
callq 0x1533b
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rdi
callq 0x3200
movl %eax, %ebp
testl %r13d, %r13d
je 0x49f4
movl %r12d, %ecx
movl %r13d, 0x10(%rsp)
movq %r15, %r13
movl %r14d, %eax
leal (%rcx,%rax), %r15d
movl %r15d, %eax
movl %ebp, %ecx
leal (%rcx,%rax), %edx
cmpl $0x10000001, %edx       # imm = 0x10000001
jge 0x4ae6
movq 0x8(%rsp), %rsi
incl %edx
movq %rbx, %rdi
callq 0xe170
movq %rax, 0x8(%rsp)
testl %r14d, %r14d
jle 0x4a25
movslq %r12d, %rdi
addq 0x8(%rsp), %rdi
movq 0x30(%rsp), %rsi
movq 0x28(%rsp), %rdx
callq 0x33d0
movl %r15d, %edx
jmp 0x4a28
movl %ebp, %eax
leal 0x1(%rax), %esi
movq %rbx, %rdi
callq 0xe119
movq %rax, 0x8(%rsp)
testl %ebp, %ebp
jle 0x4a20
movq 0x8(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl %ebp, %eax
movl %eax, %edx
callq 0x33d0
addl %ebp, %r12d
movl %r12d, %edx
jmp 0x4a54
movl %r12d, %edx
testl %ebp, %ebp
jle 0x4a4c
movslq %edx, %r15
movq 0x8(%rsp), %rdi
addq %r15, %rdi
movq 0x18(%rsp), %rsi
movl %ebp, %eax
movl %eax, %edx
callq 0x33d0
movl %r15d, %eax
addl %ebp, %eax
movl %eax, %edx
movq %r13, %r15
movl 0x10(%rsp), %r13d
movl 0x140(%rbx), %ecx
movl 0x144(%rbx), %eax
movl %ecx, %esi
decl %esi
movl %esi, 0x140(%rbx)
cmpl %eax, %ecx
jle 0x4acf
movl %r13d, %eax
incl %eax
movl %edx, %r12d
movl %eax, %r13d
cmpl %eax, 0x14(%rsp)
jne 0x492d
movq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x13802
movl 0x8198(%rbx), %eax
testl %eax, %eax
je 0x4b0c
decl %eax
movl %eax, 0x8198(%rbx)
movq 0x8(%rsp), %rsi
movq (%rbx), %rdi
xorl %edx, %edx
callq *0x10(%rbx)
jmp 0x4ac0
leaq 0x2f8ce(%rip), %rsi     # 0x34386
movq %rbx, %rdi
callq 0x67c1
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, 0x140(%rbx)
leaq 0x2ec92(%rip), %rsi     # 0x3376e
xorl %eax, %eax
movq %rbx, %rdi
callq 0xc939
leaq 0x2ec55(%rip), %rsi     # 0x33742
xorl %eax, %eax
movq %rbx, %rdi
callq 0xcab5
movq 0x8(%rsp), %rsi
movq (%rbx), %rdi
xorl %edx, %edx
callq *0x10(%rbx)
movq %rbx, %rdi
callq 0x8ec6
leaq 0x2ecf6(%rip), %rsi     # 0x33809
jmp 0x4adc