// File: /workspace/github_c_makefile_star2_O0/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
subq $0xf0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movzwl 0x24(%rax), %eax
movl %eax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movzwl 0x24(%rax), %eax
movl %eax, -0x2c(%rbp)
movl -0x28(%rbp), %eax
orl -0x2c(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x3b217
movl -0x2c(%rbp), %eax
andl $0x1, %eax
movl -0x28(%rbp), %ecx
andl $0x1, %ecx
subl %ecx, %eax
movl %eax, -0x4(%rbp)
jmp 0x3b571
movl -0x30(%rbp), %eax
andl $0xc, %eax
cmpl $0x0, %eax
je 0x3b346
movl -0x28(%rbp), %eax
andl -0x2c(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x3b27c
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jge 0x3b252
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3b571
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jle 0x3b270
movl $0x1, -0x4(%rbp)
jmp 0x3b571
movl $0x0, -0x4(%rbp)
jmp 0x3b571
movl -0x28(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x3b297
movq -0x10(%rbp), %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
jmp 0x3b2c1
movl -0x28(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x3b2b3
movq -0x10(%rbp), %rax
cvtsi2sdq 0x18(%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
jmp 0x3b2bf
movl $0x1, -0x4(%rbp)
jmp 0x3b571
jmp 0x3b2c1
movl -0x2c(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x3b2dc
movq -0x18(%rbp), %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x40(%rbp)
jmp 0x3b306
movl -0x2c(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x3b2f8
movq -0x18(%rbp), %rax
cvtsi2sdq 0x18(%rax), %xmm0
movsd %xmm0, -0x40(%rbp)
jmp 0x3b304
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3b571
jmp 0x3b306
movsd -0x38(%rbp), %xmm1
movsd -0x40(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x3b322
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3b571
movsd -0x38(%rbp), %xmm0
ucomisd -0x40(%rbp), %xmm0
jbe 0x3b33a
movl $0x1, -0x4(%rbp)
jmp 0x3b571
movl $0x0, -0x4(%rbp)
jmp 0x3b571
movl -0x30(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x3b4eb
movl -0x28(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
jne 0x3b36c
movl $0x1, -0x4(%rbp)
jmp 0x3b571
movl -0x2c(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
jne 0x3b383
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3b571
cmpq $0x0, -0x20(%rbp)
je 0x3b4e9
movq -0x10(%rbp), %rax
movzbl 0x27(%rax), %eax
movq -0x20(%rbp), %rcx
movzbl 0x8(%rcx), %ecx
cmpl %ecx, %eax
jne 0x3b3da
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x20(%rbp), %rcx
movq 0x10(%rcx), %rdi
movq -0x10(%rbp), %rcx
movl 0x20(%rcx), %esi
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rdx
movq -0x18(%rbp), %rcx
movl 0x20(%rcx), %ecx
movq -0x18(%rbp), %r8
movq 0x8(%r8), %r8
callq *%rax
movl %eax, -0x4(%rbp)
jmp 0x3b571
leaq -0x90(%rbp), %rdi
xorl %esi, %esi
movl $0x38, %edx
callq 0x8200
leaq -0xc8(%rbp), %rdi
xorl %esi, %esi
movl $0x38, %edx
callq 0x8200
movq -0x10(%rbp), %rsi
leaq -0x90(%rbp), %rdi
movl $0x1000, %edx           # imm = 0x1000
callq 0x3ac30
movq -0x18(%rbp), %rsi
leaq -0xc8(%rbp), %rdi
movl $0x1000, %edx           # imm = 0x1000
callq 0x3ac30
movq -0x20(%rbp), %rax
leaq -0x90(%rbp), %rdi
movzbl 0x8(%rax), %esi
callq 0x105e0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x3b453
xorl %eax, %eax
movl %eax, -0xcc(%rbp)
jmp 0x3b45c
movl -0x70(%rbp), %eax
movl %eax, -0xcc(%rbp)
movl -0xcc(%rbp), %eax
movl %eax, -0x54(%rbp)
movq -0x20(%rbp), %rax
leaq -0xc8(%rbp), %rdi
movzbl 0x8(%rax), %esi
callq 0x105e0
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x3b48e
xorl %eax, %eax
movl %eax, -0xd0(%rbp)
jmp 0x3b49a
movl -0xa8(%rbp), %eax
movl %eax, -0xd0(%rbp)
movl -0xd0(%rbp), %eax
movl %eax, -0x58(%rbp)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x20(%rbp), %rcx
movq 0x10(%rcx), %rdi
movl -0x54(%rbp), %esi
movq -0x48(%rbp), %rdx
movl -0x58(%rbp), %ecx
movq -0x50(%rbp), %r8
callq *%rax
movl %eax, -0x24(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x10190
leaq -0xc8(%rbp), %rdi
callq 0x10190
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3b571
jmp 0x3b4eb
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xe0(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xd8(%rbp)
movq -0x10(%rbp), %rax
movl 0x20(%rax), %eax
movq -0x18(%rbp), %rcx
cmpl 0x20(%rcx), %eax
jle 0x3b528
movq -0x18(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, -0xe4(%rbp)
jmp 0x3b535
movq -0x10(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, -0xe4(%rbp)
movq -0xd8(%rbp), %rsi
movq -0xe0(%rbp), %rdi
movl -0xe4(%rbp), %eax
movslq %eax, %rdx
callq 0x81c0
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x3b56b
movq -0x10(%rbp), %rax
movl 0x20(%rax), %eax
movq -0x18(%rbp), %rcx
subl 0x20(%rcx), %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xf0, %rsp
popq %rbp
retq
nopl (%rax)