// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: sqlite3VdbeRecordCompareWithSkip
SQLITE_PRIVATE int sqlite3VdbeRecordCompareWithSkip(
  int nKey1, const void *pKey1,   /* Left key */
  UnpackedRecord *pPKey2,         /* Right key */
  int bSkip                       /* If true, skip the first field */
){
  u32 d1;                         /* Offset into aKey[] of next data element */
  int i;                          /* Index of next field to compare */
  u32 szHdr1;                     /* Size of record header in bytes */
  u32 idx1;                       /* Offset of first type in header */
  int rc = 0;                     /* Return value */
  Mem *pRhs = pPKey2->aMem;       /* Next field of pPKey2 to compare */
  KeyInfo *pKeyInfo;
  const unsigned char *aKey1 = (const unsigned char *)pKey1;
  Mem mem1;

  /* If bSkip is true, then the caller has already determined that the first
  ** two elements in the keys are equal. Fix the various stack variables so
  ** that this routine begins comparing at the second field. */
  if( bSkip ){
    u32 s1;
    idx1 = 1 + getVarint32(&aKey1[1], s1);
    szHdr1 = aKey1[0];
    d1 = szHdr1 + sqlite3VdbeSerialTypeLen(s1);
    i = 1;
    pRhs++;
  }else{
    idx1 = getVarint32(aKey1, szHdr1);
    d1 = szHdr1;
    i = 0;
  }
  if( d1>(unsigned)nKey1 ){
    pPKey2->errCode = (u8)SQLITE_CORRUPT_BKPT;
    return 0;  /* Corruption */
  }

  VVA_ONLY( mem1.szMalloc = 0; ) /* Only needed by assert() statements */
  assert( pPKey2->pKeyInfo->nAllField>=pPKey2->nField
       || CORRUPT_DB );
  assert( pPKey2->pKeyInfo->aSortFlags!=0 );
  assert( pPKey2->pKeyInfo->nKeyField>0 );
  assert( idx1<=szHdr1 || CORRUPT_DB );
  do{
    u32 serial_type;

    /* RHS is an integer */
    if( pRhs->flags & (MEM_Int|MEM_IntReal) ){
      testcase( pRhs->flags & MEM_Int );
      testcase( pRhs->flags & MEM_IntReal );
      serial_type = aKey1[idx1];
      testcase( serial_type==12 );
      if( serial_type>=10 ){
        rc = +1;
      }else if( serial_type==0 ){
        rc = -1;
      }else if( serial_type==7 ){
        sqlite3VdbeSerialGet(&aKey1[d1], serial_type, &mem1);
        rc = -sqlite3IntFloatCompare(pRhs->u.i, mem1.u.r);
      }else{
        i64 lhs = vdbeRecordDecodeInt(serial_type, &aKey1[d1]);
        i64 rhs = pRhs->u.i;
        if( lhs<rhs ){
          rc = -1;
        }else if( lhs>rhs ){
          rc = +1;
        }
      }
    }

    /* RHS is real */
    else if( pRhs->flags & MEM_Real ){
      serial_type = aKey1[idx1];
      if( serial_type>=10 ){
        /* Serial types 12 or greater are strings and blobs (greater than
        ** numbers). Types 10 and 11 are currently "reserved for future
        ** use", so it doesn't really matter what the results of comparing
        ** them to numberic values are.  */
        rc = +1;
      }else if( serial_type==0 ){
        rc = -1;
      }else{
        sqlite3VdbeSerialGet(&aKey1[d1], serial_type, &mem1);
        if( serial_type==7 ){
          if( mem1.u.r<pRhs->u.r ){
            rc = -1;
          }else if( mem1.u.r>pRhs->u.r ){
            rc = +1;
          }
        }else{
          rc = sqlite3IntFloatCompare(mem1.u.i, pRhs->u.r);
        }
      }
    }

    /* RHS is a string */
    else if( pRhs->flags & MEM_Str ){
      getVarint32NR(&aKey1[idx1], serial_type);
      testcase( serial_type==12 );
      if( serial_type<12 ){
        rc = -1;
      }else if( !(serial_type & 0x01) ){
        rc = +1;
      }else{
        mem1.n = (serial_type - 12) / 2;
        testcase( (d1+mem1.n)==(unsigned)nKey1 );
        testcase( (d1+mem1.n+1)==(unsigned)nKey1 );
        if( (d1+mem1.n) > (unsigned)nKey1
         || (pKeyInfo = pPKey2->pKeyInfo)->nAllField<=i
        ){
          pPKey2->errCode = (u8)SQLITE_CORRUPT_BKPT;
          return 0;                /* Corruption */
        }else if( pKeyInfo->aColl[i] ){
          mem1.enc = pKeyInfo->enc;
          mem1.db = pKeyInfo->db;
          mem1.flags = MEM_Str;
          mem1.z = (char*)&aKey1[d1];
          rc = vdbeCompareMemString(
              &mem1, pRhs, pKeyInfo->aColl[i], &pPKey2->errCode
          );
        }else{
          int nCmp = MIN(mem1.n, pRhs->n);
          rc = memcmp(&aKey1[d1], pRhs->z, nCmp);
          if( rc==0 ) rc = mem1.n - pRhs->n;
        }
      }
    }

    /* RHS is a blob */
    else if( pRhs->flags & MEM_Blob ){
      assert( (pRhs->flags & MEM_Zero)==0 || pRhs->n==0 );
      getVarint32NR(&aKey1[idx1], serial_type);
      testcase( serial_type==12 );
      if( serial_type<12 || (serial_type & 0x01) ){
        rc = -1;
      }else{
        int nStr = (serial_type - 12) / 2;
        testcase( (d1+nStr)==(unsigned)nKey1 );
        testcase( (d1+nStr+1)==(unsigned)nKey1 );
        if( (d1+nStr) > (unsigned)nKey1 ){
          pPKey2->errCode = (u8)SQLITE_CORRUPT_BKPT;
          return 0;                /* Corruption */
        }else if( pRhs->flags & MEM_Zero ){
          if( !isAllZero((const char*)&aKey1[d1],nStr) ){
            rc = 1;
          }else{
            rc = nStr - pRhs->u.nZero;
          }
        }else{
          int nCmp = MIN(nStr, pRhs->n);
          rc = memcmp(&aKey1[d1], pRhs->z, nCmp);
          if( rc==0 ) rc = nStr - pRhs->n;
        }
      }
    }

    /* RHS is null */
    else{
      serial_type = aKey1[idx1];
      rc = (serial_type!=0);
    }

    if( rc!=0 ){
      int sortFlags = pPKey2->pKeyInfo->aSortFlags[i];
      if( sortFlags ){
        if( (sortFlags & KEYINFO_ORDER_BIGNULL)==0
         || ((sortFlags & KEYINFO_ORDER_DESC)
           !=(serial_type==0 || (pRhs->flags&MEM_Null)))
        ){
          rc = -rc;
        }
      }
      assert( vdbeRecordCompareDebug(nKey1, pKey1, pPKey2, rc) );
      assert( mem1.szMalloc==0 );  /* See comment below */
      return rc;
    }

    i++;
    if( i==pPKey2->nField ) break;
    pRhs++;
    d1 += sqlite3VdbeSerialTypeLen(serial_type);
    idx1 += sqlite3VarintLen(serial_type);
  }while( idx1<(unsigned)szHdr1 && d1<=(unsigned)nKey1 );

  /* No memory allocation is ever used on mem1.  Prove this using
  ** the following assert().  If the assert() fails, it indicates a
  ** memory leak and a need to call sqlite3VdbeMemRelease(&mem1).  */
  assert( mem1.szMalloc==0 );

  /* rc==0 here means that one or both of the keys ran out of fields and
  ** all the fields up to that point were equal. Return the default_rc
  ** value.  */
  assert( CORRUPT_DB
       || vdbeRecordCompareDebug(nKey1, pKey1, pPKey2, pPKey2->default_rc)
       || pPKey2->pKeyInfo->db->mallocFailed
  );
  pPKey2->eqSeen = 1;
  return pPKey2->default_rc;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdx, %r12
movq %rsi, %r15
movl %edi, 0x1c(%rsp)
movq 0x8(%rdx), %r14
testl %ecx, %ecx
je 0x2a985d
movsbl 0x1(%r15), %eax
testl %eax, %eax
js 0x2a9871
movl %eax, 0x60(%rsp)
movl $0x2, %r8d
jmp 0x2a9885
movsbl (%r15), %eax
testl %eax, %eax
js 0x2a98bf
movl %eax, 0x34(%rsp)
movl $0x1, %r8d
jmp 0x2a98d0
leaq 0x1(%r15), %rdi
leaq 0x60(%rsp), %rsi
callq 0x2a470c
incb %al
movzbl %al, %r8d
movzbl (%r15), %eax
movl %eax, 0x34(%rsp)
movl 0x60(%rsp), %r9d
cmpq $0x80, %r9
jb 0x2a98a4
addl $-0xc, %r9d
shrl %r9d
jmp 0x2a98b0
leaq 0x131d45(%rip), %rcx    # 0x3db5f0
movzbl (%r9,%rcx), %r9d
addl %eax, %r9d
addq $0x38, %r14
movl $0x1, %r10d
jmp 0x2a98d8
leaq 0x34(%rsp), %rsi
movq %r15, %rdi
callq 0x2a470c
movzbl %al, %r8d
xorl %r10d, %r10d
movl 0x34(%rsp), %r9d
cmpl 0x1c(%rsp), %r9d
jbe 0x2a9912
leaq 0x135a39(%rip), %rsi    # 0x3df31f
leaq 0x135b43(%rip), %rdx    # 0x3df430
leaq 0x135891(%rip), %r8     # 0x3df185
xorl %ebx, %ebx
movl $0xb, %edi
movl $0x14147, %ecx          # imm = 0x14147
xorl %eax, %eax
callq 0x27e637
movb $0xb, 0x13(%r12)
jmp 0x2a9f7e
leaq 0x13(%r12), %rax
movq %rax, 0x40(%rsp)
xorl %esi, %esi
movl 0x34(%rsp), %ebx
movl %ebx, 0x10(%rsp)
movzwl 0x8(%r14), %eax
testb $0x24, %al
je 0x2a99c2
movl %r8d, %eax
movzbl (%r15,%rax), %eax
movl %eax, 0x14(%rsp)
movl $0x1, %r13d
cmpl $0x9, %eax
ja 0x2a9d93
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
testl %eax, %eax
je 0x2a9d93
cmpl $0x7, %eax
jne 0x2a9a7c
movl %r9d, %edi
addq %r15, %rdi
movl $0x7, %esi
leaq 0x60(%rsp), %rdx
movl %r8d, %ebx
movq %r9, %r13
movl %r10d, %ebp
callq 0x2a47ba
movl %ebp, %r10d
movq %r13, %r9
movl %ebx, %r8d
movl 0x10(%rsp), %ebx
movq (%r14), %rax
movq %rax, 0x58(%rsp)
fildll 0x58(%rsp)
fldl 0x60(%rsp)
xorl %r13d, %r13d
fxch %st(1)
fucomi %st(1), %st
seta %r13b
negl %r13d
fxch %st(1)
fucompi %st(1), %st
fstp %st(0)
movl $0x1, %eax
cmoval %eax, %r13d
jmp 0x2a9d93
testb $0x8, %al
jne 0x2a99f0
movl %r8d, %edi
testb $0x2, %al
jne 0x2a9aa5
movzbl (%r15,%rdi), %ecx
movl %ecx, 0x14(%rsp)
testb $0x10, %al
jne 0x2a9b88
xorl %r13d, %r13d
testb %cl, %cl
setne %r13b
jmp 0x2a9d93
movq %r12, %rbp
movl %r8d, %eax
movzbl (%r15,%rax), %r12d
movl %r12d, 0x14(%rsp)
movl $0x1, %r13d
cmpl $0x9, %r12d
ja 0x2a9c4c
testl %r12d, %r12d
je 0x2a9c46
movq %rsi, 0x20(%rsp)
movl %r10d, 0xc(%rsp)
movl %r8d, 0x28(%rsp)
movq %r9, 0x38(%rsp)
movl %r9d, %edi
addq %r15, %rdi
movl %r12d, %esi
leaq 0x60(%rsp), %rdx
callq 0x2a47ba
movsd (%r14), %xmm0
cmpl $0x7, %r12d
jne 0x2a9c54
movsd 0x60(%rsp), %xmm1
ucomisd %xmm1, %xmm0
movq %rbp, %r12
movl 0xc(%rsp), %r10d
jbe 0x2a9e64
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movl 0x28(%rsp), %r8d
movq 0x38(%rsp), %r9
jmp 0x2a9d93
leal -0x1(%rax), %ecx
cmpl $0x5, %ecx
ja 0x2a9d80
movl %r9d, %eax
leaq 0x13027e(%rip), %rdx    # 0x3d9d10
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movsbq (%r15,%rax), %rax
jmp 0x2a9d83
movzbl (%r15,%rdi), %eax
movl %eax, 0x14(%rsp)
testb %al, %al
jns 0x2a9adf
addq %r15, %rdi
movq %rsi, 0x20(%rsp)
leaq 0x14(%rsp), %rsi
movl %r8d, %ebx
movq %r9, %r13
movl %r10d, %ebp
callq 0x2a470c
movq 0x20(%rsp), %rsi
movl %ebp, %r10d
movq %r13, %r9
movl %ebx, %r8d
movl 0x10(%rsp), %ebx
movl 0x14(%rsp), %eax
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
cmpl $0xc, %eax
jb 0x2a9d93
movl $0x1, %r13d
testb $0x1, %al
je 0x2a9d93
addl $-0xc, %eax
shrl %eax
movl %eax, 0x6c(%rsp)
leal (%rax,%r9), %ecx
cmpl 0x1c(%rsp), %ecx
ja 0x2a9c9d
movq (%r12), %rcx
movzwl 0x8(%rcx), %edx
cmpl %edx, %r10d
jge 0x2a9c9d
movl %r8d, 0x28(%rsp)
movl %r10d, 0xc(%rsp)
movslq %r10d, %rdx
movq 0x20(%rcx,%rdx,8), %rdx
testq %rdx, %rdx
je 0x2a9f1e
movb 0x4(%rcx), %al
movb %al, 0x6a(%rsp)
movq 0x10(%rcx), %rax
movq %rax, 0x88(%rsp)
movw $0x2, 0x68(%rsp)
movl %r9d, %eax
addq %r15, %rax
movq %rax, 0x70(%rsp)
leaq 0x60(%rsp), %rdi
movq %r14, %rsi
movq 0x40(%rsp), %rcx
movq %r9, %r13
callq 0x2a85b9
movq %r13, %r9
movl %eax, %r13d
jmp 0x2a9f49
testb %cl, %cl
jns 0x2a9bb9
addq %r15, %rdi
movq %rsi, 0x20(%rsp)
leaq 0x14(%rsp), %rsi
movl %r8d, %ebx
movq %r9, %r13
movl %r10d, %ebp
callq 0x2a470c
movq 0x20(%rsp), %rsi
movl %ebp, %r10d
movq %r13, %r9
movl %ebx, %r8d
movl 0x10(%rsp), %ebx
movl 0x14(%rsp), %eax
cmpl $0xc, %eax
setb %cl
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movl %eax, %edx
orb %cl, %dl
testb $0x1, %dl
jne 0x2a9d93
movl %r10d, 0xc(%rsp)
movq %r12, 0x20(%rsp)
addl $-0xc, %eax
movl %eax, %r13d
shrl %r13d
leal (%r9,%r13), %r12d
cmpl 0x1c(%rsp), %r12d
jbe 0x2a9e82
movl $0x0, 0x18(%rsp)
movl $0xb, %edi
movq %rsi, %rbp
leaq 0x135710(%rip), %rsi    # 0x3df31f
leaq 0x13581a(%rip), %rdx    # 0x3df430
movl $0x141b2, %ecx          # imm = 0x141B2
movl %r8d, %ebx
leaq 0x135560(%rip), %r8     # 0x3df185
xorl %eax, %eax
movq %r9, %r13
callq 0x27e637
movq %r13, %r9
movl %ebx, %r8d
movq 0x20(%rsp), %rax
movb $0xb, 0x13(%rax)
movl %ebp, %r13d
jmp 0x2a9ecd
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movq %rbp, %r12
jmp 0x2a9d93
movq 0x60(%rsp), %rax
movq %rax, 0x50(%rsp)
fildll 0x50(%rsp)
movsd %xmm0, 0x48(%rsp)
fldl 0x48(%rsp)
xorl %r13d, %r13d
fxch %st(1)
fucomi %st(1), %st
seta %r13b
fxch %st(1)
fucompi %st(1), %st
fstp %st(0)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmoval %eax, %r13d
movq %rbp, %r12
movl 0x28(%rsp), %r8d
movq 0x38(%rsp), %r9
movl 0xc(%rsp), %r10d
jmp 0x2a9d93
movl $0x0, 0x18(%rsp)
movl $0xb, %edi
movq %rsi, 0x20(%rsp)
leaq 0x135669(%rip), %rsi    # 0x3df31f
leaq 0x135773(%rip), %rdx    # 0x3df430
movl $0x14194, %ecx          # imm = 0x14194
movl %r8d, %ebx
leaq 0x1354b9(%rip), %r8     # 0x3df185
xorl %eax, %eax
movq %r9, %r13
movl %r10d, %ebp
callq 0x27e637
movq 0x20(%rsp), %rsi
movl %ebp, %r10d
movq %r13, %r9
movl %ebx, %r8d
movb $0xb, 0x13(%r12)
movl $0x1, %eax
movl 0x10(%rsp), %ebx
jmp 0x2a9e43
movl 0x2(%r15,%rax), %ecx
bswapl %ecx
movsbl (%r15,%rax), %edx
shll $0x8, %edx
movzbl 0x1(%r15,%rax), %eax
orl %edx, %eax
shlq $0x20, %rax
jmp 0x2a9d72
movsbq (%r15,%rax), %rcx
shlq $0x10, %rcx
movzbl 0x1(%r15,%rax), %edx
shll $0x8, %edx
orq %rcx, %rdx
movzbl 0x2(%r15,%rax), %eax
jmp 0x2a9d5e
movzbl (%r15,%rax), %ecx
shll $0x18, %ecx
movzbl 0x1(%r15,%rax), %edx
shll $0x10, %edx
movslq %ecx, %rcx
orq %rdx, %rcx
movzbl 0x2(%r15,%rax), %edx
shll $0x8, %edx
orq %rcx, %rdx
movzbl 0x3(%r15,%rax), %eax
orq %rdx, %rax
jmp 0x2a9d83
movsbq (%r15,%rax), %rcx
shlq $0x8, %rcx
movzbl 0x1(%r15,%rax), %eax
orq %rcx, %rax
jmp 0x2a9d83
movq (%r15,%rax), %rax
bswapq %rax
jmp 0x2a9d83
addl $-0x8, %eax
cmpq (%r14), %rax
jl 0x2a9d93
movl $0x1, %eax
cmovgl %eax, %esi
movl %esi, %r13d
testl %r13d, %r13d
je 0x2a9ddd
movq (%r12), %rax
movq 0x18(%rax), %rax
movslq %r10d, %rcx
movzbl (%rax,%rcx), %ecx
movl $0x1, %eax
testl %ecx, %ecx
je 0x2a9dd3
testb $0x2, %cl
je 0x2a9dd0
cmpl $0x0, 0x14(%rsp)
movl $0x1, %edx
je 0x2a9dc9
movzwl 0x8(%r14), %edx
andl $0x1, %edx
andl $0x1, %ecx
cmpl %edx, %ecx
je 0x2a9dd3
negl %r13d
movl %r13d, %esi
movl %r13d, 0x18(%rsp)
jmp 0x2a9e43
incl %r10d
movzwl 0x10(%r12), %eax
cmpl %eax, %r10d
jne 0x2a9df4
xorl %esi, %esi
movl $0x2, %eax
jmp 0x2a9e43
movl 0x14(%rsp), %eax
cmpq $0x80, %rax
jb 0x2a9e07
leal -0xc(%rax), %ecx
shrl %ecx
jmp 0x2a9e12
leaq 0x1317e2(%rip), %rcx    # 0x3db5f0
movzbl (%rax,%rcx), %ecx
movl $0x1, %edx
cmpl $0x80, %eax
jb 0x2a9e32
movq %rax, %rsi
shrq $0x7, %rsi
incl %edx
cmpq $0x3fff, %rax           # imm = 0x3FFF
movq %rsi, %rax
ja 0x2a9e21
addq $0x38, %r14
addl %r9d, %ecx
addl %edx, %r8d
xorl %eax, %eax
xorl %esi, %esi
movl %ecx, %r9d
testl %eax, %eax
jne 0x2a9f67
cmpl %ebx, %r8d
jae 0x2a9f6c
cmpl 0x1c(%rsp), %r9d
jbe 0x2a9926
jmp 0x2a9f6c
ucomisd %xmm0, %xmm1
movl 0x28(%rsp), %r8d
movq 0x38(%rsp), %r9
ja 0x2a9d93
movq 0x20(%rsp), %r13
jmp 0x2a9d93
testb $0x40, 0x9(%r14)
jne 0x2a9ef3
movl 0xc(%r14), %eax
movq %r14, 0x28(%rsp)
movl %r13d, %r14d
subl %eax, %r14d
cmovll %r13d, %eax
movl %r9d, %edi
addq %r15, %rdi
movq 0x28(%rsp), %rcx
movq 0x10(%rcx), %rsi
movslq %eax, %rdx
movl %r8d, %r13d
movq %r9, %rbx
callq 0x17300
movq %rbx, %r9
movl %r13d, %r8d
testl %eax, %eax
cmovnel %eax, %r14d
movl %r14d, %r13d
movq 0x28(%rsp), %r14
movl 0xc(%rsp), %r10d
movl 0x10(%rsp), %ebx
movl $0x1, %eax
cmpl 0x1c(%rsp), %r12d
movq 0x20(%rsp), %r12
jbe 0x2a9d93
movl %r13d, %esi
jmp 0x2a9e43
testl %eax, %eax
movl 0xc(%rsp), %r10d
movl 0x10(%rsp), %ebx
je 0x2a9f19
movl %r9d, %eax
addq %r15, %rax
movl %r13d, %ecx
xorl %edx, %edx
cmpb $0x0, (%rax,%rdx)
jne 0x2a9f5c
incq %rdx
cmpq %rdx, %rcx
jne 0x2a9f0b
subl (%r14), %r13d
jmp 0x2a9ed6
movl 0xc(%r14), %ecx
movl %eax, %r13d
subl %ecx, %r13d
cmovll %eax, %ecx
movl %r9d, %edi
addq %r15, %rdi
movq 0x10(%r14), %rsi
movslq %ecx, %rdx
movq %r9, %rbx
callq 0x17300
movq %rbx, %r9
testl %eax, %eax
cmovnel %eax, %r13d
movl 0x28(%rsp), %r8d
movl 0xc(%rsp), %r10d
movl 0x10(%rsp), %ebx
jmp 0x2a9d93
movl $0x1, %r13d
jmp 0x2a9ed6
cmpl $0x2, %eax
jne 0x2a9f7a
movb $0x1, 0x16(%r12)
movsbl 0x12(%r12), %ebx
jmp 0x2a9f7e
movl 0x18(%rsp), %ebx
movl %ebx, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq