// File: /workspace/github_c_makefile_star2_O3/shifengbin[P]bishe/Output/../Persistence/sqlite3.c
// Function: pageFindSlot
static u8 *pageFindSlot(MemPage *pPg, int nByte, int *pRc){
  const int hdr = pPg->hdrOffset;
  u8 * const aData = pPg->aData;
  int iAddr = hdr + 1;
  int pc = get2byte(&aData[iAddr]);
  int x;
  int usableSize = pPg->pBt->usableSize;

  assert( pc>0 );
  do{
    int size;            /* Size of the free slot */
    /* EVIDENCE-OF: R-06866-39125 Freeblocks are always connected in order of
    ** increasing offset. */
    if( pc>usableSize-4 || pc<iAddr+4 ){
      *pRc = SQLITE_CORRUPT_BKPT;
      return 0;
    }
    /* EVIDENCE-OF: R-22710-53328 The third and fourth bytes of each
    ** freeblock form a big-endian integer which is the size of the freeblock
    ** in bytes, including the 4-byte header. */
    size = get2byte(&aData[pc+2]);
    if( (x = size - nByte)>=0 ){
      testcase( x==4 );
      testcase( x==3 );
      if( pc < pPg->cellOffset+2*pPg->nCell || size+pc > usableSize ){
        *pRc = SQLITE_CORRUPT_BKPT;
        return 0;
      }else if( x<4 ){
        /* EVIDENCE-OF: R-11498-58022 In a well-formed b-tree page, the total
        ** number of bytes in fragments may not exceed 60. */
        if( aData[hdr+7]>57 ) return 0;

        /* Remove the slot from the free-list. Update the number of
        ** fragmented bytes within the page. */
        memcpy(&aData[iAddr], &aData[pc], 2);
        aData[hdr+7] += (u8)x;
      }else{
        /* The slot remains on the free-list. Reduce its size to account
         ** for the portion used by the new allocation. */
        put2byte(&aData[pc+2], x);
      }
      return &aData[pc + x];
    }
    iAddr = pc;
    pc = get2byte(&aData[pc]);
  }while( pc );

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %r14
movzbl 0x6(%rdi), %eax
movq 0x48(%rdi), %rcx
movq 0x50(%rdi), %rbx
movzwl 0x1(%rbx,%rax), %r8d
rolw $0x8, %r8w
leaq 0x1(%rax), %rdx
movzwl %r8w, %r9d
movl 0x34(%rcx), %r8d
leal -0x4(%r8), %r11d
cmpl %r11d, %r9d
jg 0x39bc0
movl %r9d, %ecx
leal 0x4(%rdx), %r9d
cmpl %r9d, %ecx
jb 0x39bc0
movl %ecx, %r10d
movzwl 0x2(%rbx,%r10), %r9d
rolw $0x8, %r9w
movzwl %r9w, %r15d
movl %r15d, %r9d
subl %esi, %r9d
jns 0x39bdc
movzwl (%rbx,%r10), %edx
rolw $0x8, %dx
movzwl %dx, %r9d
movl %ecx, %edx
testw %r9w, %r9w
jne 0x39b7c
xorl %ebx, %ebx
jmp 0x39c3a
leaq 0x41921(%rip), %rsi     # 0x7b4e8
leaq 0x415bf(%rip), %rcx     # 0x7b18d
xorl %ebx, %ebx
movl $0xb, %edi
movl $0xdce9, %edx           # imm = 0xDCE9
jmp 0x39c2c
movzwl 0xe(%rdi), %esi
movzwl 0x12(%rdi), %edi
leal (%rsi,%rdi,2), %esi
cmpl %esi, %ecx
jb 0x39c12
addl %ecx, %r15d
cmpl %r8d, %r15d
jg 0x39c12
cmpl $0x3, %r9d
ja 0x39c48
cmpb $0x39, 0x7(%rbx,%rax)
ja 0x39bbc
movl %edx, %edx
movzwl (%rbx,%r10), %esi
movw %si, (%rbx,%rdx)
addb %r9b, 0x7(%rbx,%rax)
jmp 0x39c55
leaq 0x418cf(%rip), %rsi     # 0x7b4e8
leaq 0x4156d(%rip), %rcx     # 0x7b18d
xorl %ebx, %ebx
movl $0xb, %edi
movl $0xdcf4, %edx           # imm = 0xDCF4
xorl %eax, %eax
callq 0xa4c0
movl $0xb, (%r14)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl %r9d, %eax
rolw $0x8, %ax
movw %ax, 0x2(%rbx,%r10)
addl %ecx, %r9d
addq %r9, %rbx
jmp 0x39c3a