// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: vdbeSorterCompareInt
static int vdbeSorterCompareInt(
  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 int s1 = p1[1];                 /* Left hand serial type */
  const int s2 = p2[1];                 /* Right hand serial type */
  const u8 * const v1 = &p1[ p1[0] ];   /* Pointer to value 1 */
  const u8 * const v2 = &p2[ p2[0] ];   /* Pointer to value 2 */
  int res;                              /* Return value */

  assert( (s1>0 && s1<7) || s1==8 || s1==9 );
  assert( (s2>0 && s2<7) || s2==8 || s2==9 );

  if( s1==s2 ){
    /* The two values have the same sign. Compare using memcmp(). */
    static const u8 aLen[] = {0, 1, 2, 3, 4, 6, 8, 0, 0, 0 };
    const u8 n = aLen[s1];
    int i;
    res = 0;
    for(i=0; i<n; i++){
      if( (res = v1[i] - v2[i])!=0 ){
        if( ((v1[0] ^ v2[0]) & 0x80)!=0 ){
          res = v1[0] & 0x80 ? -1 : +1;
        }
        break;
      }
    }
  }else if( s1>7 && s2>7 ){
    res = s1 - s2;
  }else{
    if( s2>7 ){
      res = +1;
    }else if( s1>7 ){
      res = -1;
    }else{
      res = s1 - s2;
    }
    assert( res!=0 );

    if( res>0 ){
      if( *v1 & 0x80 ) res = -1;
    }else{
      if( *v2 & 0x80 ) res = +1;
    }
  }

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

  return res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
movzbl 0x1(%rdx), %eax
movl %eax, %r14d
movzbl 0x1(%r8), %ebx
movzbl (%rdx), %r10d
addq %rdx, %r10
movzbl (%r8), %r11d
addq %r8, %r11
cmpb %bl, %al
jne 0x249883
leaq 0x128abb(%rip), %rax    # 0x372300
movzbl (%r14,%rax), %ebx
xorl %r14d, %r14d
cmpq %r14, %rbx
je 0x2498e9
movzbl (%r10,%r14), %eax
movzbl (%r11,%r14), %ebp
incq %r14
subl %ebp, %eax
je 0x24984d
movb (%r10), %r10b
movb (%r11), %r11b
xorb %r10b, %r11b
jns 0x2498cb
xorl %eax, %eax
testb %r10b, %r10b
setns %al
leal -0x1(,%rax,2), %ebx
jmp 0x2498d1
cmpb $0x8, %r14b
setae %bpl
cmpb $0x8, %bl
setae %r15b
subl %ebx, %eax
testb %r15b, %bpl
jne 0x2498cb
cmpb $0x8, %r14b
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmovael %ebp, %eax
cmpb $0x8, %bl
movl $0x1, %ebx
movl %eax, %r14d
cmovael %ebx, %r14d
testl %r14d, %r14d
jle 0x2498c5
cmpb $0x0, (%r10)
cmovnsl %r14d, %ebp
movl %ebp, %eax
jmp 0x2498cb
cmpb $0x0, (%r11)
js 0x2498d1
movl %eax, %ebx
testl %eax, %eax
je 0x2498e9
movq 0x10(%rdi), %rax
movq 0x28(%rax), %rax
movq 0x18(%rax), %rcx
movl %ebx, %eax
negl %eax
cmpb $0x0, (%rcx)
cmovel %ebx, %eax
jmp 0x249906
movq 0x10(%rdi), %rax
movq 0x28(%rax), %r10
xorl %eax, %eax
cmpw $0x2, 0x6(%r10)
jb 0x249906
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x249a4b
popq %rbx
popq %r14
popq %r15
popq %rbp
retq