// File: /workspace/github_c_makefile_star2_O0/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
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x77349
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x2c(%rbp)
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x30(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x30(%rbp), %eax
je 0x77347
movl $0x1, -0x4(%rbp)
jmp 0x7762b
jmp 0x77349
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x18(%rbp), %rcx
orl 0x8(%rcx), %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
andl $0x128, %eax            # imm = 0x128
cmpl $0x0, %eax
je 0x773c2
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
jne 0x7737f
movq -0x10(%rbp), %rdi
callq 0x76970
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
jne 0x77397
movq -0x18(%rbp), %rdi
callq 0x76970
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
setne %al
andb $0x1, %al
movzbl %al, %eax
movq -0x18(%rbp), %rcx
cmpq $0x0, (%rcx)
setne %cl
andb $0x1, %cl
movzbl %cl, %ecx
subl %ecx, %eax
movl %eax, -0x4(%rbp)
jmp 0x7762b
movl -0x24(%rbp), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x77427
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
jne 0x773e8
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7762b
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
jne 0x77403
movl $0x1, -0x4(%rbp)
jmp 0x7762b
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
movl -0x1c(%rbp), %edx
callq 0x78ce0
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x7762b
movl -0x24(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x774fe
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x7744e
movq -0x10(%rbp), %rdi
callq 0x6fef0
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x77466
movq -0x18(%rbp), %rdi
callq 0x6fef0
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movl 0x28(%rax), %eax
movl %eax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rax
movl 0x28(%rax), %eax
movl %eax, -0x48(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x68(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x48(%rbp), %eax
jae 0x774b2
movl -0x38(%rbp), %eax
movl %eax, -0x74(%rbp)
jmp 0x774b8
movl -0x48(%rbp), %eax
movl %eax, -0x74(%rbp)
movq -0x68(%rbp), %rsi
movq -0x70(%rbp), %rdi
movl -0x74(%rbp), %edx
callq 0x5d3c0
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
jne 0x774f3
movl -0x38(%rbp), %eax
cmpl -0x48(%rbp), %eax
je 0x774f1
movl -0x38(%rbp), %edx
movl -0x48(%rbp), %esi
movl $0x1, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl %esi, %edx
cmovbl %ecx, %eax
movl %eax, -0x28(%rbp)
jmp 0x774f3
movl -0x28(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x7762b
movl -0x24(%rbp), %eax
andl $0x6, %eax
cmpl $0x0, %eax
je 0x77617
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
andl $0x6, %eax
cmpl $0x0, %eax
jne 0x77525
movq -0x10(%rbp), %rdi
callq 0x76a30
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
andl $0x6, %eax
cmpl $0x0, %eax
jne 0x7753d
movq -0x18(%rbp), %rdi
callq 0x76a30
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x18(%rbp), %rcx
andl 0x8(%rcx), %eax
andl $0x2, %eax
cmpl $0x0, %eax
jne 0x775da
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
jne 0x7756f
movq -0x10(%rbp), %rdi
callq 0x769d0
movq -0x10(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
jne 0x77594
movq -0x18(%rbp), %rdi
callq 0x769d0
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x60(%rbp)
movsd -0x58(%rbp), %xmm0
ucomisd -0x60(%rbp), %xmm0
jbe 0x775b6
movl $0x1, -0x4(%rbp)
jmp 0x7762b
movsd -0x58(%rbp), %xmm1
movsd -0x60(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x775cf
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7762b
jmp 0x775d1
movl $0x0, -0x4(%rbp)
jmp 0x7762b
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
cmpq (%rcx), %rax
jle 0x775f3
movl $0x1, -0x4(%rbp)
jmp 0x7762b
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
cmpq (%rcx), %rax
jge 0x7760c
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7762b
jmp 0x7760e
movl $0x0, -0x4(%rbp)
jmp 0x7762b
jmp 0x77619
jmp 0x7761b
jmp 0x7761d
movl $0x0, -0x20(%rbp)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopw (%rax,%rax)