// File: /workspace/github_c_makefile_star2_O1/shifengbin[P]bishe/Output/../Persistence/sqlite3.c
// Function: rebuildPage
static int rebuildPage(
  MemPage *pPg,                   /* Edit this page */
  int nCell,                      /* Final number of cells on page */
  u8 **apCell,                    /* Array of cells */
  u16 *szCell                     /* Array of cell sizes */
){
  const int hdr = pPg->hdrOffset;          /* Offset of header on pPg */
  u8 * const aData = pPg->aData;           /* Pointer to data for pPg */
  const int usableSize = pPg->pBt->usableSize;
  u8 * const pEnd = &aData[usableSize];
  int i;
  u8 *pCellptr = pPg->aCellIdx;
  u8 *pTmp = sqlite3PagerTempSpace(pPg->pBt->pPager);
  u8 *pData;

  i = get2byte(&aData[hdr+5]);
  memcpy(&pTmp[i], &aData[i], usableSize - i);

  pData = pEnd;
  for(i=0; i<nCell; i++){
    u8 *pCell = apCell[i];
    if( SQLITE_WITHIN(pCell,aData,pEnd) ){
      pCell = &pTmp[pCell - aData];
    }
    pData -= szCell[i];
    put2byte(pCellptr, (pData - aData));
    pCellptr += 2;
    if( pData < pCellptr ) return SQLITE_CORRUPT_BKPT;
    memcpy(pData, pCell, szCell[i]);
    assert( szCell[i]==pPg->xCellSize(pPg, pCell) || CORRUPT_DB );
    testcase( szCell[i]!=pPg->xCellSize(pPg,pCell) );
  }

  /* The pPg->nFree field is now set incorrectly. The caller will fix it. */
  pPg->nCell = nCell;
  pPg->nOverflow = 0;

  put2byte(&aData[hdr+1], 0);
  put2byte(&aData[hdr+3], pPg->nCell);
  put2byte(&aData[hdr+5], pData - aData);
  aData[hdr+7] = 0x00;
  return SQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, %r15
movq %rdx, -0x68(%rbp)
movl %esi, %ebx
movzbl 0x6(%rdi), %ecx
movq 0x48(%rdi), %rax
movq 0x50(%rdi), %rsi
movslq 0x34(%rax), %rdx
leaq (%rsi,%rdx), %r13
movq %rdi, -0x40(%rbp)
movq 0x60(%rdi), %rdi
movq %rdi, -0x60(%rbp)
movq (%rax), %rax
movq 0x108(%rax), %rdi
movq %rcx, -0x48(%rbp)
movzwl 0x5(%rsi,%rcx), %eax
rolw $0x8, %ax
movzwl %ax, %eax
movq %rdi, -0x58(%rbp)
addq %rax, %rdi
movq %rsi, -0x30(%rbp)
addq %rax, %rsi
subq %rax, %rdx
callq 0xa310
testl %ebx, %ebx
movl %ebx, -0x34(%rbp)
jle 0x3afba
movl %ebx, %r14d
xorl %r12d, %r12d
movq %r13, -0x50(%rbp)
movq %r13, %rbx
movq -0x30(%rbp), %rdi
movzwl (%r15,%r12,2), %eax
subq %rax, %rbx
movl %ebx, %ecx
subl %edi, %ecx
rolw $0x8, %cx
movq -0x68(%rbp), %rax
movq (%rax,%r12,8), %rax
movq -0x60(%rbp), %rdx
leaq (%rdx,%r12,2), %r13
addq $0x2, %r13
movw %cx, -0x2(%r13)
cmpq %r13, %rbx
jae 0x3af79
movl $0xb, %edi
leaq 0x42574(%rip), %rsi     # 0x7d4d8
movl $0xf09c, %edx           # imm = 0xF09C
leaq 0x4220d(%rip), %rcx     # 0x7d17d
xorl %eax, %eax
callq 0xa4b0
jmp 0x3afa3
movq %rax, %rcx
subq %rdi, %rcx
cmpq -0x50(%rbp), %rax
movq -0x58(%rbp), %rdx
leaq (%rdx,%rcx), %rsi
cmovaeq %rax, %rsi
cmpq %rdi, %rax
cmovbq %rax, %rsi
movzwl (%r15,%r12,2), %edx
movq %rbx, %rdi
callq 0xa310
cmpq %r13, %rbx
jb 0x3affb
incq %r12
cmpq %r12, %r14
movq -0x30(%rbp), %rdi
jne 0x3af2a
jmp 0x3afc1
movq %r13, %rbx
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rsi
movl -0x34(%rbp), %eax
movw %ax, 0x12(%rsi)
xorl %eax, %eax
movb %al, 0x1(%rsi)
movq -0x48(%rbp), %rdx
movw $0x0, 0x1(%rdi,%rdx)
movb 0x13(%rsi), %cl
movb %cl, 0x3(%rdi,%rdx)
movb 0x12(%rsi), %cl
movb %cl, 0x4(%rdi,%rdx)
subq %rdi, %rbx
movb %bh, 0x5(%rdi,%rdx)
movb %bl, 0x6(%rdi,%rdx)
movb %al, 0x7(%rdi,%rdx)
jmp 0x3b000
movl $0xb, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq