// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq $0x0, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x8(%rbp), %rdi
xorl %esi, %esi
callq 0x4330
movl %eax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x150d0
cmpl $0x0, %eax
je 0x4bad
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x14b80
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x31e0
movl %eax, -0x24(%rbp)
jmp 0x4bbf
leaq 0x37738(%rip), %rax     # 0x3c2ec
movq %rax, -0x20(%rbp)
movl $0x1, -0x24(%rbp)
cmpl $0x0, -0x30(%rbp)
jg 0x4bda
movq -0x8(%rbp), %rdi
leaq 0x37e6c(%rip), %rsi     # 0x3ca3c
callq 0x66d0
jmp 0x4d77
movq -0x8(%rbp), %rdi
callq 0x14270
movq %rax, %rdi
callq 0x30e0
cmpl $0x0, %eax
je 0x4c06
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xd710
movq -0x8(%rbp), %rdi
callq 0x8cb0
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x30(%rbp), %eax
jge 0x4d51
movq -0x8(%rbp), %rdi
movl -0x28(%rbp), %edx
xorl %esi, %esi
callq 0x17aa0
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15240
cmpl $0x0, %eax
je 0x4c61
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x14b80
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x31e0
movl %eax, -0x34(%rbp)
jmp 0x4c68
movl $0x0, -0x34(%rbp)
cmpl $0x0, -0x28(%rbp)
jne 0x4ca6
movq -0x8(%rbp), %rdi
movl -0x34(%rbp), %esi
addl $0x1, %esi
callq 0xd9d0
movq %rax, -0x10(%rbp)
cmpl $0x0, -0x34(%rbp)
jle 0x4ca1
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movslq -0x34(%rbp), %rdx
callq 0x33a0
movl -0x34(%rbp), %eax
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x4d35
movl -0x2c(%rbp), %eax
addl -0x24(%rbp), %eax
addl -0x34(%rbp), %eax
cmpl $0x10000000, %eax       # imm = 0x10000000
jle 0x4cc8
movq -0x8(%rbp), %rdi
leaq 0x3712c(%rip), %rsi     # 0x3bded
movb $0x0, %al
callq 0xbd10
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x2c(%rbp), %edx
addl -0x24(%rbp), %edx
addl -0x34(%rbp), %edx
addl $0x1, %edx
callq 0xda20
movq %rax, -0x10(%rbp)
cmpl $0x0, -0x24(%rbp)
jle 0x4d0c
movq -0x10(%rbp), %rdi
movslq -0x2c(%rbp), %rax
addq %rax, %rdi
movq -0x20(%rbp), %rsi
movslq -0x24(%rbp), %rdx
callq 0x33a0
movl -0x24(%rbp), %eax
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x34(%rbp)
jle 0x4d33
movq -0x10(%rbp), %rdi
movslq -0x2c(%rbp), %rax
addq %rax, %rdi
movq -0x18(%rbp), %rsi
movslq -0x34(%rbp), %rdx
callq 0x33a0
movl -0x34(%rbp), %eax
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x4d35
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x4400
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x4c14
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x13a70
movq -0x8(%rbp), %rdi
callq 0x14a10
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xd710
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)