// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3MemCompare
SQLITE_PRIVATE int sqlite3MemCompare(const Mem *pMem1, const Mem *pMem2, const CollSeq *pColl){
  int rc;
  int f1, f2;
  int combined_flags;

  f1 = pMem1->flags;
  f2 = pMem2->flags;
  combined_flags = f1|f2;
  assert( (combined_flags & MEM_RowSet)==0 );
 
  /* 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);
  }

  /* If one value is a number and the other is not, the number is less.
  ** If both are numbers, compare as reals if one is a real, or as integers
  ** if both values are integers.
  */
  if( combined_flags&(MEM_Int|MEM_Real) ){
    double r1, r2;
    if( (f1 & f2 & MEM_Int)!=0 ){
      if( pMem1->u.i < pMem2->u.i ) return -1;
      if( pMem1->u.i > pMem2->u.i ) return 1;
      return 0;
    }
    if( (f1&MEM_Real)!=0 ){
      r1 = pMem1->r;
    }else if( (f1&MEM_Int)!=0 ){
      r1 = (double)pMem1->u.i;
    }else{
      return 1;
    }
    if( (f2&MEM_Real)!=0 ){
      r2 = pMem2->r;
    }else if( (f2&MEM_Int)!=0 ){
      r2 = (double)pMem2->u.i;
    }else{
      return -1;
    }
    if( r1<r2 ) return -1;
    if( r1>r2 ) return 1;
    return 0;
  }

  /* 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 );
    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 ){
      if( pMem1->enc==pColl->enc ){
        /* The strings are already in the correct encoding.  Call the
        ** comparison function directly */
        return pColl->xCmp(pColl->pUser,pMem1->n,pMem1->z,pMem2->n,pMem2->z);
      }else{
        const void *v1, *v2;
        int n1, n2;
        Mem c1;
        Mem c2;
        memset(&c1, 0, sizeof(c1));
        memset(&c2, 0, sizeof(c2));
        sqlite3VdbeMemShallowCopy(&c1, pMem1, MEM_Ephem);
        sqlite3VdbeMemShallowCopy(&c2, pMem2, MEM_Ephem);
        v1 = sqlite3ValueText((sqlite3_value*)&c1, pColl->enc);
        n1 = v1==0 ? 0 : c1.n;
        v2 = sqlite3ValueText((sqlite3_value*)&c2, pColl->enc);
        n2 = v2==0 ? 0 : c2.n;
        rc = pColl->xCmp(pColl->pUser, n1, v1, n2, v2);
        sqlite3VdbeMemRelease(&c1);
        sqlite3VdbeMemRelease(&c2);
        return rc;
      }
    }
    /* 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().  */
  rc = memcmp(pMem1->z, pMem2->z, (pMem1->n>pMem2->n)?pMem2->n:pMem1->n);
  if( rc==0 ){
    rc = pMem1->n - pMem2->n;
  }
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdx, %r14
movzwl 0x24(%rdi), %ecx
movzwl 0x24(%rsi), %ebx
movl %ebx, %edx
orl %ecx, %edx
testb $0x1, %dl
jne 0x29bb1
movq %rsi, %r15
movq %rdi, %rax
testb $0xc, %dl
je 0x29bbe
movl %ecx, %edx
andl $0x4, %edx
testl %ebx, %edx
je 0x29be8
movq 0x18(%r15), %rcx
cmpq %rcx, 0x18(%rax)
jl 0x29c60
setg %al
movzbl %al, %ebx
jmp 0x29c63
andl $0x1, %ebx
andl $0x1, %ecx
subl %ecx, %ebx
jmp 0x29c63
testb $0x2, %dl
jne 0x29bf9
movq 0x8(%rax), %rdi
movq 0x8(%r15), %rsi
movl 0x20(%rax), %eax
movl 0x20(%r15), %ecx
movl %eax, %ebx
subl %ecx, %ebx
cmovll %eax, %ecx
movslq %ecx, %rdx
callq 0x8180
testl %eax, %eax
cmovnel %eax, %ebx
jmp 0x29c63
testb $0x8, %cl
jne 0x29c02
testl %edx, %edx
je 0x29bfe
cvtsi2sdq 0x18(%rax), %xmm0
jmp 0x29c07
testb $0x2, %cl
jne 0x29c19
pushq $0x1
jmp 0x29c62
movsd 0x10(%rax), %xmm0
testb $0x8, %bl
jne 0x29c54
testb $0x4, %bl
je 0x29c60
cvtsi2sdq 0x18(%r15), %xmm1
jmp 0x29c5a
testb $0x2, %bl
je 0x29c60
testq %r14, %r14
je 0x29bc3
movb 0x27(%rax), %cl
cmpb 0x8(%r14), %cl
jne 0x29c7f
movq 0x10(%r14), %rdi
movq 0x18(%r14), %r9
movl 0x20(%rax), %esi
movq 0x8(%rax), %rdx
movl 0x20(%r15), %ecx
movq 0x8(%r15), %r8
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%r9
movsd 0x10(%r15), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x29c74
pushq $-0x1
popq %rbx
movl %ebx, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ebx, %ebx
ucomisd %xmm1, %xmm0
seta %bl
jmp 0x29c63
xorpd %xmm0, %xmm0
leaq -0x60(%rbp), %rbx
movapd %xmm0, (%rbx)
movapd %xmm0, 0x10(%rbx)
andq $0x0, 0x30(%rbx)
movapd %xmm0, 0x20(%rbx)
leaq -0xa0(%rbp), %r13
movapd %xmm0, (%r13)
movapd %xmm0, 0x10(%r13)
movapd %xmm0, 0x20(%r13)
andq $0x0, 0x30(%r13)
movq %rbx, %rdi
movq %rax, %rsi
movl $0x1000, %edx           # imm = 0x1000
callq 0x298e6
movq %r13, %rdi
movq %r15, %rsi
movl $0x1000, %edx           # imm = 0x1000
callq 0x298e6
movzbl 0x8(%r14), %esi
movq %rbx, %rdi
callq 0xe05a
movq %rax, %rbx
xorl %r15d, %r15d
movl $0x0, %r12d
testq %rax, %rax
je 0x29cfa
movl -0x40(%rbp), %r12d
movzbl 0x8(%r14), %esi
movq %r13, %rdi
callq 0xe05a
testq %rax, %rax
je 0x29d10
movl -0x80(%rbp), %r15d
movq 0x10(%r14), %rdi
movl %r12d, %esi
movq %rbx, %rdx
movl %r15d, %ecx
movq %rax, %r8
callq *0x18(%r14)
movl %eax, %ebx
leaq -0x60(%rbp), %rdi
callq 0xde44
movq %r13, %rdi
callq 0xde44
jmp 0x29c63