// File: /workspace/github_c_makefile_star2_O1/ccxvii[P]mujs/./jsarray.c
// Function: Ap_sort_cmp
static int Ap_sort_cmp(js_State *J, int idx_a, int idx_b)
{
	js_Object *obj = js_tovalue(J, 0)->u.object;
	if (obj->u.a.simple) {
		js_Value *val_a = &obj->u.a.array[idx_a];
		js_Value *val_b = &obj->u.a.array[idx_b];
		int und_a = val_a->t.type == JS_TUNDEFINED;
		int und_b = val_b->t.type == JS_TUNDEFINED;
		if (und_a) return und_b;
		if (und_b) return -1;
		if (js_iscallable(J, 1)) {
			double v;
			js_copy(J, 1); /* copy function */
			js_pushundefined(J); /* no 'this' binding */
			js_pushvalue(J, *val_a);
			js_pushvalue(J, *val_b);
			js_call(J, 2);
			v = js_tonumber(J, -1);
			js_pop(J, 1);
			if (isnan(v))
				return 0;
			if (v == 0)
				return 0;
			return v < 0 ? -1 : 1;
		} else {
			const char *str_a, *str_b;
			int c;
			js_pushvalue(J, *val_a);
			js_pushvalue(J, *val_b);
			str_a = js_tostring(J, -2);
			str_b = js_tostring(J, -1);
			c = strcmp(str_a, str_b);
			js_pop(J, 2);
			return c;
		}
	} else {
		int und_a, und_b;
		int has_a = js_hasindex(J, 0, idx_a);
		int has_b = js_hasindex(J, 0, idx_b);
		if (!has_a && !has_b) {
			return 0;
		}
		if (has_a && !has_b) {
			js_pop(J, 1);
			return -1;
		}
		if (!has_a && has_b) {
			js_pop(J, 1);
			return 1;
		}

		und_a = js_isundefined(J, -2);
		und_b = js_isundefined(J, -1);
		if (und_a) {
			js_pop(J, 2);
			return und_b;
		}
		if (und_b) {
			js_pop(J, 2);
			return -1;
		}

		if (js_iscallable(J, 1)) {
			double v;
			js_copy(J, 1); /* copy function */
			js_pushundefined(J); /* no 'this' binding */
			js_copy(J, -4);
			js_copy(J, -4);
			js_call(J, 2);
			v = js_tonumber(J, -1);
			js_pop(J, 3);
			if (isnan(v))
				return 0;
			if (v == 0)
				return 0;
			return v < 0 ? -1 : 1;
		} else {
			const char *str_a = js_tostring(J, -2);
			const char *str_b = js_tostring(J, -1);
			int c = strcmp(str_a, str_b);
			js_pop(J, 2);
			return c;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebp
movl %esi, %r14d
movq %rdi, %rbx
movslq 0x144(%rdi), %rax
leaq 0x23661(%rip), %rcx     # 0x403f8
testq %rax, %rax
js 0x1cdb2
cmpl 0x140(%rbx), %eax
jge 0x1cdb2
movq %rax, %rcx
shlq $0x4, %rcx
addq 0x148(%rbx), %rcx
movq (%rcx), %rcx
cmpl $0x0, 0x24(%rcx)
je 0x1cdec
movq 0x30(%rcx), %rax
movslq %r14d, %r15
shlq $0x4, %r15
movslq %ebp, %r14
shlq $0x4, %r14
cmpb $0x1, 0xf(%rax,%r15)
movb 0xf(%rax,%r14), %cl
jne 0x1cea3
xorl %ebp, %ebp
cmpb $0x1, %cl
sete %bpl
jmp 0x1d0f9
leaq 0x23605(%rip), %r15     # 0x403f8
movq %r15, %rsi
testl %eax, %eax
js 0x1ce13
movq %r15, %rsi
cmpl 0x140(%rbx), %eax
jge 0x1ce13
shlq $0x4, %rax
addq 0x148(%rbx), %rax
movq %rax, %rsi
movq %rbx, %rdi
callq 0x15489
movq %rbx, %rdi
movq %rax, %rsi
movl %r14d, %edx
callq 0x16a4d
movl %eax, %r14d
movslq 0x144(%rbx), %rax
testq %rax, %rax
js 0x1ce4e
cmpl 0x140(%rbx), %eax
jge 0x1ce4e
shlq $0x4, %rax
addq 0x148(%rbx), %rax
movq %rax, %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x15489
movq %rbx, %rdi
movq %rax, %rsi
movl %ebp, %edx
callq 0x16a4d
xorl %ebp, %ebp
movl %r14d, %ecx
orl %eax, %ecx
je 0x1d0f9
testl %r14d, %r14d
je 0x1cf34
testl %eax, %eax
jne 0x1cf34
movl 0x140(%rbx), %ecx
movl 0x144(%rbx), %eax
leal -0x1(%rcx), %edx
movl %edx, 0x140(%rbx)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x1cf5f
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpb $0x1, %cl
je 0x1d0f9
addq %rax, %r15
addq %rax, %r14
movq %rbx, %rdi
movl $0x1, %esi
callq 0x14e17
testl %eax, %eax
je 0x1cf6c
movq %rbx, %rdi
movl $0x1, %esi
callq 0x14073
movq %rbx, %rdi
callq 0x89b6
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq %rbx, %rdi
callq 0x14a7d
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq %rbx, %rdi
callq 0x14a7d
movq %rbx, %rdi
movl $0x2, %esi
callq 0x16c25
movslq 0x140(%rbx), %rax
testq %rax, %rax
jle 0x1d08c
movq 0x148(%rbx), %rcx
shlq $0x4, %rax
leaq (%rcx,%rax), %rsi
addq $-0x10, %rsi
jmp 0x1d093
testl %r14d, %r14d
jne 0x1d018
testl %eax, %eax
je 0x1d018
movl 0x140(%rbx), %ecx
movl 0x144(%rbx), %eax
leal -0x1(%rcx), %edx
movl %edx, 0x140(%rbx)
movl $0x1, %ebp
cmpl %eax, %ecx
jg 0x1d0f9
jmp 0x1d1ae
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq %rbx, %rdi
callq 0x14a7d
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq %rbx, %rdi
callq 0x14a7d
movslq 0x140(%rbx), %rax
leaq 0x23460(%rip), %r14     # 0x403f8
movq %r14, %rsi
cmpq $0x2, %rax
jl 0x1cfb4
movq 0x148(%rbx), %rcx
shlq $0x4, %rax
leaq (%rcx,%rax), %rsi
addq $-0x20, %rsi
movq %rbx, %rdi
callq 0x1533b
movq %rax, %r15
movslq 0x140(%rbx), %rax
testq %rax, %rax
jle 0x1cfde
movq 0x148(%rbx), %rcx
shlq $0x4, %rax
leaq (%rcx,%rax), %r14
addq $-0x10, %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1533b
movq %r15, %rdi
movq %rax, %rsi
callq 0x32f0
movl %eax, %ebp
movl 0x140(%rbx), %ecx
movl 0x144(%rbx), %eax
addl $-0x2, %ecx
movl %ecx, 0x140(%rbx)
cmpl %eax, %ecx
jge 0x1d0f9
jmp 0x1d1ae
movslq 0x140(%rbx), %rax
leaq 0x233d2(%rip), %rcx     # 0x403f8
movq %rcx, %rdx
cmpq $0x2, %rax
jl 0x1d044
movq 0x148(%rbx), %rdx
movq %rax, %rsi
shlq $0x4, %rsi
addq %rsi, %rdx
addq $-0x20, %rdx
movb 0xf(%rdx), %dl
testl %eax, %eax
jle 0x1d060
movq 0x148(%rbx), %rcx
movq %rax, %rsi
shlq $0x4, %rsi
addq %rsi, %rcx
addq $-0x10, %rcx
movb 0xf(%rcx), %cl
cmpb $0x1, %dl
jne 0x1d0d8
xorl %ebp, %ebp
cmpb $0x1, %cl
sete %cl
addl $-0x2, %eax
movl %eax, 0x140(%rbx)
movl 0x144(%rbx), %edx
cmpl %edx, %eax
jl 0x1d1c5
movb %cl, %bpl
jmp 0x1d0f9
leaq 0x23365(%rip), %rsi     # 0x403f8
movq %rbx, %rdi
callq 0x1514c
movl 0x140(%rbx), %ecx
movl 0x144(%rbx), %eax
leal -0x1(%rcx), %edx
movl %edx, 0x140(%rbx)
cmpl %eax, %ecx
jle 0x1d1ae
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
je 0x1d0d4
xorl %eax, %eax
ucomisd %xmm0, %xmm1
setbe %al
leal -0x1(,%rax,2), %ebp
jmp 0x1d0f9
xorl %ebp, %ebp
jmp 0x1d0f9
cmpb $0x1, %cl
jne 0x1d106
addl $-0x2, %eax
movl %eax, 0x140(%rbx)
movl 0x144(%rbx), %ecx
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jl 0x1d1cd
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
movl $0x1, %esi
callq 0x14e17
movq %rbx, %rdi
testl %eax, %eax
je 0x1d18c
movl $0x1, %esi
callq 0x14073
movq %rbx, %rdi
callq 0x89b6
movq %rbx, %rdi
movl $0xfffffffc, %esi       # imm = 0xFFFFFFFC
callq 0x14073
movq %rbx, %rdi
movl $0xfffffffc, %esi       # imm = 0xFFFFFFFC
callq 0x14073
movq %rbx, %rdi
movl $0x2, %esi
callq 0x16c25
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15111
movl 0x140(%rbx), %ecx
movl 0x144(%rbx), %eax
addl $-0x3, %ecx
movl %ecx, 0x140(%rbx)
cmpl %eax, %ecx
jl 0x1d1ae
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x1d0c2
jmp 0x1d0f9
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x14963
movq %rax, %r14
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x14963
movq %r14, %rdi
jmp 0x1cfec
movl %eax, 0x140(%rbx)
leaq 0x165b3(%rip), %rsi     # 0x3376e
movq %rbx, %rdi
xorl %eax, %eax
callq 0xc939
movl %edx, 0x140(%rbx)
jmp 0x1d1b4
movl %ecx, 0x140(%rbx)
jmp 0x1d1b4