// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x70, %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
movzbl 0x1(%rax), %eax
movl %eax, -0x44(%rbp)
movq -0x40(%rbp), %rax
movzbl 0x1(%rax), %eax
movl %eax, -0x48(%rbp)
movq -0x38(%rbp), %rax
movq -0x38(%rbp), %rcx
movzbl (%rcx), %ecx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x40(%rbp), %rax
movq -0x40(%rbp), %rcx
movzbl (%rcx), %ecx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x48(%rbp), %eax
jne 0x40894c
movslq -0x44(%rbp), %rcx
leaq 0x19eb54(%rip), %rax    # 0x5a7414
movb (%rax,%rcx), %al
movb %al, -0x5d(%rbp)
movl $0x0, -0x5c(%rbp)
movl $0x0, -0x64(%rbp)
movl -0x64(%rbp), %eax
movzbl -0x5d(%rbp), %ecx
cmpl %ecx, %eax
jge 0x40894a
movq -0x50(%rbp), %rax
movslq -0x64(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movq -0x58(%rbp), %rcx
movslq -0x64(%rbp), %rdx
movzbl (%rcx,%rdx), %ecx
subl %ecx, %eax
movl %eax, -0x5c(%rbp)
cmpl $0x0, %eax
je 0x40893d
movq -0x50(%rbp), %rax
movzbl (%rax), %eax
movq -0x58(%rbp), %rcx
movzbl (%rcx), %ecx
xorl %ecx, %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x40893b
movq -0x50(%rbp), %rax
movzbl (%rax), %edx
andl $0x80, %edx
movl $0x1, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x5c(%rbp)
jmp 0x40894a
jmp 0x40893f
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x4088d4
jmp 0x4089ca
cmpl $0x7, -0x44(%rbp)
jle 0x408963
cmpl $0x7, -0x48(%rbp)
jle 0x408963
movl -0x44(%rbp), %eax
subl -0x48(%rbp), %eax
movl %eax, -0x5c(%rbp)
jmp 0x4089c8
cmpl $0x7, -0x48(%rbp)
jle 0x408972
movl $0x1, -0x5c(%rbp)
jmp 0x40898c
cmpl $0x7, -0x44(%rbp)
jle 0x408981
movl $0xffffffff, -0x5c(%rbp) # imm = 0xFFFFFFFF
jmp 0x40898a
movl -0x44(%rbp), %eax
subl -0x48(%rbp), %eax
movl %eax, -0x5c(%rbp)
jmp 0x40898c
cmpl $0x0, -0x5c(%rbp)
jle 0x4089ac
movq -0x50(%rbp), %rax
movzbl (%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x4089aa
movl $0xffffffff, -0x5c(%rbp) # imm = 0xFFFFFFFF
jmp 0x4089c6
movq -0x58(%rbp), %rax
movzbl (%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x4089c4
movl $0x1, -0x5c(%rbp)
jmp 0x4089c6
jmp 0x4089c8
jmp 0x4089ca
cmpl $0x0, -0x5c(%rbp)
jne 0x408a06
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x28(%rax), %rax
movzwl 0x6(%rax), %eax
cmpl $0x1, %eax
jle 0x408a04
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 0x408a24
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x28(%rax), %rax
movq 0x18(%rax), %rax
cmpb $0x0, (%rax)
je 0x408a22
imull $-0x1, -0x5c(%rbp), %eax
movl %eax, -0x5c(%rbp)
jmp 0x408a24
movl -0x5c(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)