// File: /workspace/github_c_makefile_star2_O2/ArtifexSoftware[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, (%rsp)
movq %rax, 0x10(%rsp)
callq 0x3ecc
movl %eax, 0xc(%rsp)
pushq $0x1
popq %r12
movq %rbx, %rdi
movl %r12d, %esi
callq 0xf8a8
testl %eax, %eax
je 0x4525
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xf64d
movq %rax, %r15
movq %rax, %rdi
callq 0x3200
movl %eax, %r12d
movq %r15, %rax
jmp 0x452c
leaq 0x24715(%rip), %rax     # 0x28c41
movq %rax, 0x30(%rsp)
cmpl $0x0, 0xc(%rsp)
jle 0x46b2
movq %rbx, %rdi
callq 0xee71
movq %rax, %rdi
callq 0x3100
testl %eax, %eax
jne 0x46de
movl %r12d, %eax
movq %rax, 0x28(%rsp)
xorl %r14d, %r14d
movl %r14d, %ebp
movq %rbx, 0x20(%rsp)
movl %r12d, 0x1c(%rsp)
cmpl %r14d, 0xc(%rsp)
je 0x468e
xorl %r13d, %r13d
movq %rbx, %rdi
movl %r13d, %esi
movl %r14d, %edx
callq 0x10e96
movq %rbx, %rdi
pushq $-0x1
popq %r15
movl %r15d, %esi
callq 0xf93a
testl %eax, %eax
je 0x45b8
movq %rbx, %rdi
movl %r15d, %esi
callq 0xf64d
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rdi
callq 0x3200
movl %eax, %r13d
movl %r13d, %r15d
testl %r14d, %r14d
je 0x4610
movq %rbx, %rdi
movl %r15d, %ebx
movl %r12d, %eax
movl %ebp, %ecx
leal (%rcx,%rax), %r15d
movl %r15d, %eax
movl %r13d, %ecx
leal (%rcx,%rax), %edx
cmpl $0x10000001, %edx       # imm = 0x10000001
jge 0x46d0
movq (%rsp), %rsi
incl %edx
callq 0xaa05
movq %rax, (%rsp)
testl %r12d, %r12d
jle 0x463d
movslq %ebp, %rdi
addq (%rsp), %rdi
movq 0x30(%rsp), %rsi
movq 0x28(%rsp), %rdx
callq 0x33d0
jmp 0x4640
movl %r13d, %eax
leal 0x1(%rax), %esi
movq %rbx, %rdi
callq 0xa9e8
movq %rax, (%rsp)
testl %r13d, %r13d
jle 0x4689
movq (%rsp), %rdi
movq 0x10(%rsp), %rsi
movl %r15d, %edx
callq 0x33d0
addl %ebp, %r13d
jmp 0x4673
movl %ebp, %r15d
testl %r13d, %r13d
movl 0x1c(%rsp), %r12d
jle 0x466b
movslq %r15d, %r15
movq (%rsp), %rdi
addq %r15, %rdi
movq 0x10(%rsp), %rsi
movl %ebx, %edx
callq 0x33d0
movl %r15d, %eax
addl %r13d, %eax
movl %eax, %r13d
jmp 0x466e
movl %r15d, %r13d
movq 0x20(%rsp), %rbx
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0x3f3d
incl %r14d
movl %r13d, %ebp
jmp 0x456c
movl %ebp, %r13d
jmp 0x4673
movq (%rsp), %rsi
movq %rbx, %rdi
movl %ebp, %edx
callq 0xe918
movq %rbx, %rdi
callq 0xf5a7
movq (%rsp), %rsi
movq (%rbx), %rdi
xorl %edx, %edx
callq *0x10(%rbx)
jmp 0x46c1
leaq 0x24cd8(%rip), %rsi     # 0x29391
movq %rbx, %rdi
callq 0x5a13
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2406b(%rip), %rsi     # 0x28742
xorl %eax, %eax
callq 0x9778
movq (%rsp), %rsi
movq (%rbx), %rdi
xorl %edx, %edx
callq *0x10(%rbx)
movq %rbx, %rdi
callq 0x7714