// File: /workspace/github_c_makefile_star2_O0/ccxvii[P]mujs/./jsarray.c
// Function: Ap_splice
static void Ap_splice(js_State *J)
{
	int top = js_gettop(J);
	int len, start, del, add, k;

	len = js_getlength(J, 0);
	start = js_tointeger(J, 1);
	if (start < 0)
		start = (len + start) > 0 ? len + start : 0;
	else if (start > len)
		start = len;

	if (js_isdefined(J, 2))
		del = js_tointeger(J, 2);
	else
		del = len - start;
	if (del > len - start)
		del = len - start;
	if (del < 0)
		del = 0;

	js_newarray(J);

	/* copy deleted items to return array */
	for (k = 0; k < del; ++k)
		if (js_hasindex(J, 0, start + k))
			js_setindex(J, -2, k);
	js_setlength(J, -1, del);

	/* shift the tail to resize the hole left by deleted items */
	add = top - 3;
	if (add < del) {
		for (k = start; k < len - del; ++k) {
			if (js_hasindex(J, 0, k + del))
				js_setindex(J, 0, k + add);
			else
				js_delindex(J, 0, k + add);
		}
		for (k = len; k > len - del + add; --k)
			js_delindex(J, 0, k - 1);
	} else if (add > del) {
		for (k = len - del; k > start; --k) {
			if (js_hasindex(J, 0, k + del - 1))
				js_setindex(J, 0, k + add - 1);
			else
				js_delindex(J, 0, k + add - 1);
		}
	}

	/* copy new items into the hole */
	for (k = 0; k < add; ++k) {
		js_copy(J, 3 + k);
		js_setindex(J, 0, start + k);
	}

	js_setlength(J, 0, len - del + add);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x16000
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rdi
xorl %esi, %esi
callq 0x4330
movl %eax, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x43c0
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jge 0x5302
movl -0x10(%rbp), %eax
addl -0x14(%rbp), %eax
cmpl $0x0, %eax
jle 0x52f3
movl -0x10(%rbp), %eax
addl -0x14(%rbp), %eax
movl %eax, -0x24(%rbp)
jmp 0x52fa
xorl %eax, %eax
movl %eax, -0x24(%rbp)
jmp 0x52fa
movl -0x24(%rbp), %eax
movl %eax, -0x14(%rbp)
jmp 0x5312
movl -0x14(%rbp), %eax
cmpl -0x10(%rbp), %eax
jle 0x5310
movl -0x10(%rbp), %eax
movl %eax, -0x14(%rbp)
jmp 0x5312
movq -0x8(%rbp), %rdi
movl $0x2, %esi
callq 0x150d0
cmpl $0x0, %eax
je 0x5338
movq -0x8(%rbp), %rdi
movl $0x2, %esi
callq 0x43c0
movl %eax, -0x18(%rbp)
jmp 0x5341
movl -0x10(%rbp), %eax
subl -0x14(%rbp), %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
movl -0x10(%rbp), %ecx
subl -0x14(%rbp), %ecx
cmpl %ecx, %eax
jle 0x5357
movl -0x10(%rbp), %eax
subl -0x14(%rbp), %eax
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
jge 0x5364
movl $0x0, -0x18(%rbp)
movq -0x8(%rbp), %rdi
callq 0x13830
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x53b0
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %edx
addl -0x20(%rbp), %edx
xorl %esi, %esi
callq 0x17b20
cmpl $0x0, %eax
je 0x53a3
movq -0x8(%rbp), %rdi
movl -0x20(%rbp), %edx
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x13bb0
jmp 0x53a5
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x5374
movq -0x8(%rbp), %rdi
movl -0x18(%rbp), %edx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x4470
movl -0xc(%rbp), %eax
subl $0x3, %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x5464
movl -0x14(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl -0x10(%rbp), %ecx
subl -0x18(%rbp), %ecx
cmpl %ecx, %eax
jge 0x5430
movq -0x8(%rbp), %rdi
movl -0x20(%rbp), %edx
addl -0x18(%rbp), %edx
xorl %esi, %esi
callq 0x17b20
cmpl $0x0, %eax
je 0x5412
movq -0x8(%rbp), %rdi
movl -0x20(%rbp), %edx
addl -0x1c(%rbp), %edx
xorl %esi, %esi
callq 0x13bb0
jmp 0x5423
movq -0x8(%rbp), %rdi
movl -0x20(%rbp), %edx
addl -0x1c(%rbp), %edx
xorl %esi, %esi
callq 0x17cc0
jmp 0x5425
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x53dc
movl -0x10(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl -0x10(%rbp), %ecx
subl -0x18(%rbp), %ecx
addl -0x1c(%rbp), %ecx
cmpl %ecx, %eax
jle 0x5462
movq -0x8(%rbp), %rdi
movl -0x20(%rbp), %edx
subl $0x1, %edx
xorl %esi, %esi
callq 0x17cc0
movl -0x20(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x5436
jmp 0x54d1
movl -0x1c(%rbp), %eax
cmpl -0x18(%rbp), %eax
jle 0x54cf
movl -0x10(%rbp), %eax
subl -0x18(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x14(%rbp), %eax
jle 0x54cd
movq -0x8(%rbp), %rdi
movl -0x20(%rbp), %edx
addl -0x18(%rbp), %edx
subl $0x1, %edx
xorl %esi, %esi
callq 0x17b20
cmpl $0x0, %eax
je 0x54ac
movq -0x8(%rbp), %rdi
movl -0x20(%rbp), %edx
addl -0x1c(%rbp), %edx
subl $0x1, %edx
xorl %esi, %esi
callq 0x13bb0
jmp 0x54c0
movq -0x8(%rbp), %rdi
movl -0x20(%rbp), %edx
addl -0x1c(%rbp), %edx
subl $0x1, %edx
xorl %esi, %esi
callq 0x17cc0
jmp 0x54c2
movl -0x20(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x5475
jmp 0x54cf
jmp 0x54d1
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x550b
movq -0x8(%rbp), %rdi
movl -0x20(%rbp), %esi
addl $0x3, %esi
callq 0x14410
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %edx
addl -0x20(%rbp), %edx
xorl %esi, %esi
callq 0x13bb0
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x54d8
movq -0x8(%rbp), %rdi
movl -0x10(%rbp), %edx
subl -0x18(%rbp), %edx
addl -0x1c(%rbp), %edx
xorl %esi, %esi
callq 0x4470
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)