// File: /workspace/github_c_makefile_star2_O3/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 $0x28, %rsp
movq %rdi, %rbx
xorl %esi, %esi
movl %esi, %eax
movq %rax, (%rsp)
movq %rax, 0x10(%rsp)
callq 0x3f6c
movl %eax, 0xc(%rsp)
movl 0x144(%rbx), %eax
cmpl $-0x1, %eax
jl 0x4843
incl %eax
cmpl 0x140(%rbx), %eax
jge 0x4843
movq 0x148(%rbx), %rcx
movl %eax, %eax
movl %eax, %edx
shlq $0x4, %rdx
cmpb $0x1, 0xf(%rcx,%rdx)
je 0x484c
shlq $0x4, %rax
addq 0x148(%rbx), %rax
movq %rax, %rsi
jmp 0x4862
cmpb $0x1, 0x3bbbd(%rip)     # 0x40407
jne 0x485b
leaq 0x2f41e(%rip), %rax     # 0x33c71
movl $0x1, %r14d
jmp 0x487b
leaq 0x3bb96(%rip), %rsi     # 0x403f8
movq %rbx, %rdi
callq 0x14e64
movq %rax, %r15
movq %rax, %rdi
callq 0x3200
movl %eax, %r14d
movq %r15, %rax
movq %rax, 0x20(%rsp)
cmpl $0x0, 0xc(%rsp)
jle 0x4a25
movq %rbx, %rdi
callq 0x13b6c
movq %rax, %rdi
callq 0x3100
testl %eax, %eax
jne 0x4a6b
movl %r14d, %eax
movq %rax, 0x18(%rsp)
xorl %r13d, %r13d
movl %r13d, %r15d
movq %rbx, %rdi
xorl %esi, %esi
movl %r13d, %edx
callq 0x16538
movl 0x140(%rbx), %eax
testl %eax, %eax
jle 0x48ea
movl %eax, %ecx
decl %ecx
movq 0x148(%rbx), %rax
shlq $0x4, %rcx
movb 0xf(%rax,%rcx), %dl
decb %dl
cmpb $0x2, %dl
jb 0x48fd
addq %rcx, %rax
movq %rax, %rsi
jmp 0x4902
movb 0x3bb17(%rip), %al      # 0x40407
decb %al
leaq 0x3baff(%rip), %rsi     # 0x403f8
cmpb $0x2, %al
jae 0x4902
xorl %r12d, %r12d
jmp 0x491c
movq %rbx, %rdi
callq 0x14e64
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rdi
callq 0x3200
movl %eax, %r12d
testl %r13d, %r13d
je 0x496f
movl %r14d, %eax
movl %r15d, %ecx
leal (%rcx,%rax), %ebp
movl %ebp, %eax
movl %r12d, %ecx
leal (%rcx,%rax), %edx
cmpl $0x10000001, %edx       # imm = 0x10000001
jge 0x4a5a
movq (%rsp), %rsi
incl %edx
movq %rbx, %rdi
callq 0xde5c
movq %rax, (%rsp)
testl %r14d, %r14d
jle 0x49a1
movslq %r15d, %rdi
addq (%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rdx
callq 0x33d0
movl %ebp, %edx
jmp 0x49a4
movl %r12d, %eax
leal 0x1(%rax), %esi
movq %rbx, %rdi
callq 0xde05
movq %rax, (%rsp)
testl %r12d, %r12d
jle 0x499c
movq (%rsp), %rdi
movq 0x10(%rsp), %rsi
movl %r12d, %eax
movl %eax, %edx
callq 0x33d0
addl %r12d, %r15d
movl %r15d, %edx
jmp 0x49ca
movl %r15d, %edx
testl %r12d, %r12d
jle 0x49ca
movslq %edx, %r15
movq (%rsp), %rdi
addq %r15, %rdi
movq 0x10(%rsp), %rsi
movl %r12d, %eax
movl %eax, %edx
callq 0x33d0
movl %r15d, %eax
addl %r12d, %eax
movl %eax, %edx
movl 0x140(%rbx), %ecx
movl 0x144(%rbx), %eax
movl %ecx, %esi
decl %esi
movl %esi, 0x140(%rbx)
cmpl %eax, %ecx
jle 0x4a43
movl %r13d, %eax
incl %eax
movl %edx, %r15d
movl %eax, %r13d
cmpl %eax, 0xc(%rsp)
jne 0x48b1
movq (%rsp), %rsi
movq %rbx, %rdi
callq 0x133b3
movl 0x8198(%rbx), %eax
testl %eax, %eax
je 0x4a7f
decl %eax
movl %eax, 0x8198(%rbx)
movq (%rsp), %rsi
movq (%rbx), %rdi
xorl %edx, %edx
callq *0x10(%rbx)
jmp 0x4a34
leaq 0x2f98a(%rip), %rsi     # 0x343b6
movq %rbx, %rdi
callq 0x670c
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, 0x140(%rbx)
leaq 0x2ed4e(%rip), %rsi     # 0x3379e
xorl %eax, %eax
movq %rbx, %rdi
callq 0xc666
leaq 0x2ed11(%rip), %rsi     # 0x33772
xorl %eax, %eax
movq %rbx, %rdi
callq 0xc7e2
movq (%rsp), %rsi
movq (%rbx), %rdi
xorl %edx, %edx
callq *0x10(%rbx)
movq %rbx, %rdi
callq 0x8e1b
leaq 0x2edb3(%rip), %rsi     # 0x33839
jmp 0x4a50