// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: vdbeSorterCompareText
static int vdbeSorterCompareText(
  SortSubtask *pTask,             /* Subtask context (for pKeyInfo) */
  int *pbKey2Cached,              /* True if pTask->pUnpacked is pKey2 */
  const void *pKey1, int nKey1,   /* Left side of comparison */
  const void *pKey2, int nKey2    /* Right side of comparison */
){
  const u8 * const p1 = (const u8 * const)pKey1;
  const u8 * const p2 = (const u8 * const)pKey2;
  const u8 * const v1 = &p1[ p1[0] ];   /* Pointer to value 1 */
  const u8 * const v2 = &p2[ p2[0] ];   /* Pointer to value 2 */

  int n1;
  int n2;
  int res;

  getVarint32NR(&p1[1], n1);
  getVarint32NR(&p2[1], n2);
  res = memcmp(v1, v2, (MIN(n1, n2) - 13)/2);
  if( res==0 ){
    res = n1 - n2;
  }

  if( res==0 ){
    if( pTask->pSorter->pKeyInfo->nKeyField>1 ){
      res = vdbeSorterCompareTail(
          pTask, pbKey2Cached, pKey1, nKey1, pKey2, nKey2
      );
    }
  }else{
    assert( !(pTask->pSorter->pKeyInfo->aSortFlags[0]&KEYINFO_ORDER_BIGNULL) );
    if( pTask->pSorter->pKeyInfo->aSortFlags[0] ){
      res = res * -1;
    }
  }

  return res;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movq -0x38(%rbp), %rcx
movzbl (%rcx), %ecx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rax
movq -0x40(%rbp), %rcx
movzbl (%rcx), %ecx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x38(%rbp), %rax
movzbl 0x1(%rax), %eax
movl %eax, -0x54(%rbp)
cmpl $0x80, -0x54(%rbp)
jl 0x408aab
movq -0x38(%rbp), %rdi
addq $0x1, %rdi
leaq -0x54(%rbp), %rsi
callq 0x3fa520
movq -0x40(%rbp), %rax
movzbl 0x1(%rax), %eax
movl %eax, -0x58(%rbp)
cmpl $0x80, -0x58(%rbp)
jl 0x408ad0
movq -0x40(%rbp), %rdi
addq $0x1, %rdi
leaq -0x58(%rbp), %rsi
callq 0x3fa520
movq -0x48(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x68(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x58(%rbp), %eax
jge 0x408af0
movl -0x54(%rbp), %eax
movl %eax, -0x74(%rbp)
jmp 0x408af6
movl -0x58(%rbp), %eax
movl %eax, -0x74(%rbp)
movq -0x68(%rbp), %rsi
movq -0x70(%rbp), %rdi
movl -0x74(%rbp), %eax
subl $0xd, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movslq %eax, %rdx
callq 0x192c0
movl %eax, -0x5c(%rbp)
cmpl $0x0, -0x5c(%rbp)
jne 0x408b26
movl -0x54(%rbp), %eax
subl -0x58(%rbp), %eax
movl %eax, -0x5c(%rbp)
cmpl $0x0, -0x5c(%rbp)
jne 0x408b62
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x28(%rax), %rax
movzwl 0x6(%rax), %eax
cmpl $0x1, %eax
jle 0x408b60
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movl -0x1c(%rbp), %ecx
movq -0x28(%rbp), %r8
movl -0x2c(%rbp), %r9d
callq 0x408c00
movl %eax, -0x5c(%rbp)
jmp 0x408b80
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x28(%rax), %rax
movq 0x18(%rax), %rax
cmpb $0x0, (%rax)
je 0x408b7e
imull $-0x1, -0x5c(%rbp), %eax
movl %eax, -0x5c(%rbp)
jmp 0x408b80
movl -0x5c(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)