// File: /workspace/github_c_makefile_star2_O1/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9MemObjCmp
JX9_PRIVATE sxi32 jx9MemObjCmp(jx9_value *pObj1, jx9_value *pObj2, int bStrict, int iNest)
{
	sxi32 iComb; 
	sxi32 rc;
	if( bStrict ){
		sxi32 iF1, iF2;
		/* Strict comparisons with === */
		iF1 = pObj1->iFlags;
		iF2 = pObj2->iFlags;
		if( iF1 != iF2 ){
			/* Not of the same type */
			return 1;
		}
	}
	/* Combine flag together */
	iComb = pObj1->iFlags|pObj2->iFlags;
	if( iComb & (MEMOBJ_NULL|MEMOBJ_RES|MEMOBJ_BOOL) ){
		/* Convert to boolean: Keep in mind FALSE < TRUE */
		if( (pObj1->iFlags & MEMOBJ_BOOL) == 0 ){
			jx9MemObjToBool(pObj1);
		}
		if( (pObj2->iFlags & MEMOBJ_BOOL) == 0 ){
			jx9MemObjToBool(pObj2);
		}
		return (sxi32)((pObj1->x.iVal != 0) - (pObj2->x.iVal != 0));
	}else if ( iComb & MEMOBJ_HASHMAP ){
		/* Hashmap aka 'array' comparison */
		if( (pObj1->iFlags & MEMOBJ_HASHMAP) == 0 ){
			/* Array is always greater */
			return -1;
		}
		if( (pObj2->iFlags & MEMOBJ_HASHMAP) == 0 ){
			/* Array is always greater */
			return 1;
		}
		/* Perform the comparison */
		rc = jx9HashmapCmp((jx9_hashmap *)pObj1->x.pOther, (jx9_hashmap *)pObj2->x.pOther, bStrict);
		return rc;
	}else if ( iComb & MEMOBJ_STRING ){
		SyString s1, s2;
		/* Perform a strict string comparison.*/
		if( (pObj1->iFlags&MEMOBJ_STRING) == 0 ){
			jx9MemObjToString(pObj1);
		}
		if( (pObj2->iFlags&MEMOBJ_STRING) == 0 ){
			jx9MemObjToString(pObj2);
		}
		SyStringInitFromBuf(&s1, SyBlobData(&pObj1->sBlob), SyBlobLength(&pObj1->sBlob));
		SyStringInitFromBuf(&s2, SyBlobData(&pObj2->sBlob), SyBlobLength(&pObj2->sBlob));
		/*
		 * Strings are compared using memcmp(). If one value is an exact prefix of the
		 * other, then the shorter value is less than the longer value.
		 */
		rc = SyMemcmp((const void *)s1.zString, (const void *)s2.zString, SXMIN(s1.nByte, s2.nByte));
		if( rc == 0 ){
			if( s1.nByte != s2.nByte ){
				rc = s1.nByte < s2.nByte ? -1 : 1;
			}
		}
		return rc;
	}else if( iComb & (MEMOBJ_INT|MEMOBJ_REAL) ){
		/* Perform a numeric comparison if one of the operand is numeric(integer or real) */
		if( (pObj1->iFlags & (MEMOBJ_INT|MEMOBJ_REAL)) == 0 ){
			jx9MemObjToNumeric(pObj1);
		}
		if( (pObj2->iFlags & (MEMOBJ_INT|MEMOBJ_REAL)) == 0 ){
			jx9MemObjToNumeric(pObj2);
		}
		if( (pObj1->iFlags & pObj2->iFlags & MEMOBJ_INT) == 0) {
			jx9_real r1, r2;
			/* Compare as reals */
			if( (pObj1->iFlags & MEMOBJ_REAL) == 0 ){
				jx9MemObjToReal(pObj1);
			}
			r1 = pObj1->x.rVal;	
			if( (pObj2->iFlags & MEMOBJ_REAL) == 0 ){
				jx9MemObjToReal(pObj2);
			}
			r2 = pObj2->x.rVal;
			if( r1 > r2 ){
				return 1;
			}else if( r1 < r2 ){
				return -1;
			}
			return 0;
		}else{
			/* Integer comparison */
			if( pObj1->x.iVal > pObj2->x.iVal ){
				return 1;
			}else if( pObj1->x.iVal < pObj2->x.iVal ){
				return -1;
			}
			return 0;
		}
	}
	/* NOT REACHED */
	SXUNUSED(iNest);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %r15d
movq %rsi, %rbx
movq %rdi, %r14
testl %edx, %edx
je 0x450dc
movl 0x8(%r14), %ecx
movl $0x1, %eax
cmpl 0x8(%rbx), %ecx
jne 0x45119
movl 0x8(%r14), %ecx
movl 0x8(%rbx), %edx
movl %edx, %eax
orl %ecx, %eax
testl $0x128, %eax            # imm = 0x128
je 0x45128
testb $0x8, %cl
jne 0x450fb
movq %r14, %rdi
callq 0x446ef
testb $0x8, 0x8(%rbx)
jne 0x45109
movq %rbx, %rdi
callq 0x446ef
xorl %eax, %eax
cmpq $0x0, (%r14)
setne %al
cmpq $0x1, (%rbx)
adcl $-0x1, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testb $0x40, %al
jne 0x45180
testb $0x1, %al
jne 0x45239
testb $0x6, %al
je 0x45232
testb $0x6, %cl
jne 0x45149
movq %r14, %rdi
callq 0x4494c
testb $0x6, 0x8(%rbx)
jne 0x45157
movq %rbx, %rdi
callq 0x4494c
movl 0x8(%r14), %eax
movl 0x8(%rbx), %ecx
andl %eax, %ecx
testb $0x2, %cl
je 0x45293
movq (%rbx), %rcx
movl $0x1, %eax
cmpq %rcx, (%r14)
jg 0x45119
setl %al
movzbl %al, %eax
negl %eax
jmp 0x45119
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testb $0x40, %cl
je 0x45119
movl $0x1, %eax
testb $0x40, %dl
je 0x45119
movq (%r14), %rax
movq (%rbx), %rbx
cmpq %rbx, %rax
je 0x45232
movl 0x2c(%rax), %r13d
movl 0x2c(%rbx), %ecx
cmpl %ecx, %r13d
jne 0x452dc
movq 0x10(%rax), %r14
movq $0x0, -0x30(%rbp)
testl %r13d, %r13d
je 0x45232
leaq -0x30(%rbp), %r12
cmpl $0x1, 0x8(%r14)
jne 0x451e0
movq 0x10(%r14), %rsi
movq %rbx, %rdi
movq %r12, %rdx
callq 0x3fe39
jmp 0x451f3
movq 0x18(%r14), %rsi
movl 0x20(%r14), %edx
movq %rbx, %rdi
movq %r12, %rcx
callq 0x3fba1
testl %eax, %eax
jne 0x452ec
testl %r15d, %r15d
je 0x45212
movl 0x8(%r14), %ecx
movq -0x30(%rbp), %rdx
movl $0x1, %eax
cmpl 0x8(%rdx), %ecx
jne 0x45221
movq -0x30(%rbp), %rsi
movq %r14, %rdi
movl %r15d, %edx
callq 0x45abe
testl %eax, %eax
jne 0x45119
movq 0x48(%r14), %r14
decl %r13d
jne 0x451c8
xorl %eax, %eax
jmp 0x45119
testb $0x1, %cl
jne 0x45246
movq %r14, %rdi
callq 0x3fb4d
testb $0x1, 0x8(%rbx)
jne 0x45254
movq %rbx, %rdi
callq 0x3fb4d
movq 0x20(%r14), %rdi
movl 0x28(%r14), %r14d
movq 0x20(%rbx), %rsi
movl 0x28(%rbx), %ebx
cmpl %ebx, %r14d
movl %ebx, %edx
cmovbl %r14d, %edx
callq 0x34ebe
testl %eax, %eax
jne 0x45119
xorl %ecx, %ecx
cmpl %ebx, %r14d
movl $0x0, %eax
sbbl %eax, %eax
orl $0x1, %eax
cmpl %ebx, %r14d
cmovel %ecx, %eax
jmp 0x45119
testb $0x4, %al
jne 0x4529f
movq %r14, %rdi
callq 0x44891
movsd (%r14), %xmm1
testb $0x4, 0x8(%rbx)
jne 0x452bc
movq %rbx, %rdi
movsd %xmm1, -0x38(%rbp)
callq 0x44891
movsd -0x38(%rbp), %xmm1
movsd (%rbx), %xmm0
xorl %ecx, %ecx
ucomisd %xmm1, %xmm0
seta %cl
negl %ecx
ucomisd %xmm0, %xmm1
movl $0x1, %eax
cmovbel %ecx, %eax
jmp 0x45119
xorl %eax, %eax
cmpl %r13d, %ecx
adcl $-0x1, %eax
orl $0x1, %eax
jmp 0x45119
movl $0x1, %eax
jmp 0x45119