// File: /workspace/github_c_makefile_star2_O3/ArtifexSoftware[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), %rsi
testq %rsi, %rsi
js 0x1c8a3
cmpl 0x140(%rbx), %esi
jge 0x1c8a3
movq 0x148(%rbx), %rax
shlq $0x4, %rsi
movq (%rax,%rsi), %rax
cmpl $0x0, 0x24(%rax)
jne 0x1c8b4
addq 0x148(%rbx), %rsi
jmp 0x1c979
movq 0x23b4e(%rip), %rax     # 0x403f8
cmpl $0x0, 0x24(%rax)
je 0x1c972
movq 0x30(%rax), %rax
movslq %r14d, %r15
shlq $0x4, %r15
movslq %ebp, %r14
shlq $0x4, %r14
cmpb $0x1, 0xf(%rax,%r15)
movb 0xf(%rax,%r14), %cl
jne 0x1c8e1
xorl %ebp, %ebp
cmpb $0x1, %cl
sete %bpl
jmp 0x1cbce
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpb $0x1, %cl
je 0x1cbce
addq %rax, %r15
addq %rax, %r14
movq %rbx, %rdi
movl $0x1, %esi
callq 0x14940
testl %eax, %eax
je 0x1ca3a
movq %rbx, %rdi
movl $0x1, %esi
callq 0x13c1a
movq %rbx, %rdi
callq 0x88f1
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq %rbx, %rdi
callq 0x145a6
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq %rbx, %rdi
callq 0x145a6
movq %rbx, %rdi
movl $0x2, %esi
callq 0x16762
movslq 0x140(%rbx), %rax
testq %rax, %rax
jle 0x1cb1a
movq 0x148(%rbx), %rcx
shlq $0x4, %rax
leaq (%rcx,%rax), %rsi
addq $-0x10, %rsi
jmp 0x1cb21
leaq 0x23a7f(%rip), %rsi     # 0x403f8
movq %rbx, %rdi
callq 0x14fb2
movq %rbx, %rdi
movq %rax, %rsi
movl %r14d, %edx
callq 0x1658a
movl %eax, %r14d
movslq 0x144(%rbx), %rax
leaq 0x23a58(%rip), %rsi     # 0x403f8
testq %rax, %rax
js 0x1c9bb
cmpl 0x140(%rbx), %eax
jge 0x1c9bb
shlq $0x4, %rax
addq 0x148(%rbx), %rax
movq %rax, %rsi
movq %rbx, %rdi
callq 0x14fb2
movq %rbx, %rdi
movq %rax, %rsi
movl %ebp, %edx
callq 0x1658a
xorl %ebp, %ebp
movl %r14d, %ecx
orl %eax, %ecx
je 0x1cbce
testl %r14d, %r14d
je 0x1ca02
testl %eax, %eax
jne 0x1ca02
movl 0x140(%rbx), %ecx
movl 0x144(%rbx), %eax
leal -0x1(%rcx), %edx
movl %edx, 0x140(%rbx)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x1ca2d
testl %r14d, %r14d
jne 0x1cae6
testl %eax, %eax
je 0x1cae6
movl 0x140(%rbx), %ecx
movl 0x144(%rbx), %eax
leal -0x1(%rcx), %edx
movl %edx, 0x140(%rbx)
movl $0x1, %ebp
cmpl %eax, %ecx
jg 0x1cbce
jmp 0x1cc83
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq %rbx, %rdi
callq 0x145a6
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq %rbx, %rdi
callq 0x145a6
movslq 0x140(%rbx), %rax
leaq 0x23992(%rip), %r14     # 0x403f8
movq %r14, %rsi
cmpq $0x2, %rax
jl 0x1ca82
movq 0x148(%rbx), %rcx
shlq $0x4, %rax
leaq (%rcx,%rax), %rsi
addq $-0x20, %rsi
movq %rbx, %rdi
callq 0x14e64
movq %rax, %r15
movslq 0x140(%rbx), %rax
testq %rax, %rax
jle 0x1caac
movq 0x148(%rbx), %rcx
shlq $0x4, %rax
leaq (%rcx,%rax), %r14
addq $-0x10, %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x14e64
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 0x1cbce
jmp 0x1cc83
movslq 0x140(%rbx), %rax
cmpq $0x2, %rax
jge 0x1cb66
movb 0x2390e(%rip), %dl      # 0x40407
cmpl $0x1, %eax
jne 0x1cb9f
movq 0x148(%rbx), %rcx
movq %rax, %rsi
shlq $0x4, %rsi
cmpb $0x1, -0x1(%rcx,%rsi)
jmp 0x1cba6
leaq 0x238d7(%rip), %rsi     # 0x403f8
movq %rbx, %rdi
callq 0x14c75
movl 0x140(%rbx), %ecx
movl 0x144(%rbx), %eax
leal -0x1(%rcx), %edx
movl %edx, 0x140(%rbx)
cmpl %eax, %ecx
jle 0x1cc83
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
je 0x1cb62
xorl %eax, %eax
ucomisd %xmm0, %xmm1
setbe %al
leal -0x1(,%rax,2), %ebp
jmp 0x1cbce
xorl %ebp, %ebp
jmp 0x1cbce
movq 0x148(%rbx), %rdx
movq %rax, %rsi
shlq $0x4, %rsi
cmpb $0x1, -0x1(%rdx,%rsi)
sete %cl
cmpb $0x1, -0x11(%rdx,%rsi)
jne 0x1cbae
addl $-0x2, %eax
movl %eax, 0x140(%rbx)
movl 0x144(%rbx), %edx
cmpl %edx, %eax
jl 0x1cc9a
movzbl %cl, %ebp
jmp 0x1cbce
cmpb $0x1, 0x23861(%rip)     # 0x40407
sete %cl
cmpb $0x1, %dl
je 0x1cb83
testb %cl, %cl
je 0x1cbdb
addl $-0x2, %eax
movl %eax, 0x140(%rbx)
movl 0x144(%rbx), %ecx
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jl 0x1cca2
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
movl $0x1, %esi
callq 0x14940
movq %rbx, %rdi
testl %eax, %eax
je 0x1cc61
movl $0x1, %esi
callq 0x13c1a
movq %rbx, %rdi
callq 0x88f1
movq %rbx, %rdi
movl $0xfffffffc, %esi       # imm = 0xFFFFFFFC
callq 0x13c1a
movq %rbx, %rdi
movl $0xfffffffc, %esi       # imm = 0xFFFFFFFC
callq 0x13c1a
movq %rbx, %rdi
movl $0x2, %esi
callq 0x16762
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x14c3a
movl 0x140(%rbx), %ecx
movl 0x144(%rbx), %eax
addl $-0x3, %ecx
movl %ecx, 0x140(%rbx)
cmpl %eax, %ecx
jl 0x1cc83
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x1cb50
jmp 0x1cbce
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x1448c
movq %rax, %r14
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x1448c
movq %r14, %rdi
jmp 0x1caba
movl %eax, 0x140(%rbx)
leaq 0x16b0e(%rip), %rsi     # 0x3379e
movq %rbx, %rdi
xorl %eax, %eax
callq 0xc666
movl %edx, 0x140(%rbx)
jmp 0x1cc89
movl %ecx, 0x140(%rbx)
jmp 0x1cc89