// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: sqlite3MemCompare
SQLITE_PRIVATE int sqlite3MemCompare(const Mem *pMem1, const Mem *pMem2, const CollSeq *pColl){
  int f1, f2;
  int combined_flags;

  f1 = pMem1->flags;
  f2 = pMem2->flags;
  combined_flags = f1|f2;
  assert( !sqlite3VdbeMemIsRowSet(pMem1) && !sqlite3VdbeMemIsRowSet(pMem2) );

  /* If one value is NULL, it is less than the other. If both values
  ** are NULL, return 0.
  */
  if( combined_flags&MEM_Null ){
    return (f2&MEM_Null) - (f1&MEM_Null);
  }

  /* At least one of the two values is a number
  */
  if( combined_flags&(MEM_Int|MEM_Real|MEM_IntReal) ){
    testcase( combined_flags & MEM_Int );
    testcase( combined_flags & MEM_Real );
    testcase( combined_flags & MEM_IntReal );
    if( (f1 & f2 & (MEM_Int|MEM_IntReal))!=0 ){
      testcase( f1 & f2 & MEM_Int );
      testcase( f1 & f2 & MEM_IntReal );
      if( pMem1->u.i < pMem2->u.i ) return -1;
      if( pMem1->u.i > pMem2->u.i ) return +1;
      return 0;
    }
    if( (f1 & f2 & MEM_Real)!=0 ){
      if( pMem1->u.r < pMem2->u.r ) return -1;
      if( pMem1->u.r > pMem2->u.r ) return +1;
      return 0;
    }
    if( (f1&(MEM_Int|MEM_IntReal))!=0 ){
      testcase( f1 & MEM_Int );
      testcase( f1 & MEM_IntReal );
      if( (f2&MEM_Real)!=0 ){
        return sqlite3IntFloatCompare(pMem1->u.i, pMem2->u.r);
      }else if( (f2&(MEM_Int|MEM_IntReal))!=0 ){
        if( pMem1->u.i < pMem2->u.i ) return -1;
        if( pMem1->u.i > pMem2->u.i ) return +1;
        return 0;
      }else{
        return -1;
      }
    }
    if( (f1&MEM_Real)!=0 ){
      if( (f2&(MEM_Int|MEM_IntReal))!=0 ){
        testcase( f2 & MEM_Int );
        testcase( f2 & MEM_IntReal );
        return -sqlite3IntFloatCompare(pMem2->u.i, pMem1->u.r);
      }else{
        return -1;
      }
    }
    return +1;
  }

  /* If one value is a string and the other is a blob, the string is less.
  ** If both are strings, compare using the collating functions.
  */
  if( combined_flags&MEM_Str ){
    if( (f1 & MEM_Str)==0 ){
      return 1;
    }
    if( (f2 & MEM_Str)==0 ){
      return -1;
    }

    assert( pMem1->enc==pMem2->enc || pMem1->db->mallocFailed );
    assert( pMem1->enc==SQLITE_UTF8 ||
            pMem1->enc==SQLITE_UTF16LE || pMem1->enc==SQLITE_UTF16BE );

    /* The collation sequence must be defined at this point, even if
    ** the user deletes the collation sequence after the vdbe program is
    ** compiled (this was not always the case).
    */
    assert( !pColl || pColl->xCmp );

    if( pColl ){
      return vdbeCompareMemString(pMem1, pMem2, pColl, 0);
    }
    /* If a NULL pointer was passed as the collate function, fall through
    ** to the blob case and use memcmp().  */
  }

  /* Both values must be blobs.  Compare using memcmp().  */
  return sqlite3BlobCompare(pMem1, pMem2);
}

// Assembly:
movzwl 0x8(%rdi), %eax
movzwl 0x8(%rsi), %ecx
movl %ecx, %r8d
orl %eax, %r8d
testb $0x1, %r8b
jne 0x2424d2
testb $0x2c, %r8b
je 0x2424dd
movl %ecx, %edx
andl %eax, %edx
testb $0x24, %dl
je 0x2424f1
movq (%rsi), %rax
cmpq %rax, (%rdi)
jl 0x242532
setg %al
movzbl %al, %eax
retq
andl $0x1, %ecx
andl $0x1, %eax
subl %eax, %ecx
movl %ecx, %eax
retq
testb $0x2, %r8b
je 0x2451d1
testb $0x2, %al
jne 0x242513
movl $0x1, %eax
retq
testb $0x8, %dl
jne 0x242524
testb $0x24, %al
je 0x242542
testb $0x8, %cl
jne 0x242571
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testb $0x24, %cl
je 0x2424dc
movq (%rsi), %rcx
cmpq %rcx, (%rdi)
jge 0x2424cb
jmp 0x2424dc
testb $0x2, %cl
je 0x242532
testq %rdx, %rdx
je 0x242597
xorl %ecx, %ecx
jmp 0x2450c6
movsd (%rdi), %xmm0
movsd (%rsi), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x242538
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
retq
xorl %eax, %eax
ucomisd %xmm1, %xmm0
seta %al
retq
testb $0x8, %al
je 0x2424eb
testb $0x24, %cl
je 0x242532
movq (%rsi), %rax
movq %rax, -0x10(%rsp)
fildll -0x10(%rsp)
fldl (%rdi)
xorl %ecx, %ecx
fxch %st(1)
fucomi %st(1), %st
seta %cl
negl %ecx
fxch %st(1)
fucompi %st(1), %st
fstp %st(0)
movl $0x1, %eax
jmp 0x242593
movq (%rdi), %rax
movq %rax, -0x8(%rsp)
fildll -0x8(%rsp)
fldl (%rsi)
xorl %ecx, %ecx
fxch %st(1)
fucomi %st(1), %st
seta %cl
fxch %st(1)
fucompi %st(1), %st
fstp %st(0)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmovbel %ecx, %eax
retq
jmp 0x2451d1