// File: /workspace/github_c_makefile_star2_O3/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, -0x2c(%rbp)
movq %rdi, %r12
movzbl 0x6(%rdi), %r14d
movq 0x48(%rdi), %rax
movq 0x50(%rdi), %rbx
movslq 0x34(%rax), %r13
movq 0x60(%rdi), %rcx
movq %rcx, -0x60(%rbp)
movq (%rax), %rax
movq 0x108(%rax), %rcx
movzwl 0x5(%rbx,%r14), %eax
rolw $0x8, %ax
movzwl %ax, %eax
movq %rcx, -0x58(%rbp)
leaq (%rcx,%rax), %rdi
leaq (%rbx,%rax), %rsi
movl %r13d, %ecx
subl %eax, %ecx
movslq %ecx, %rdx
callq 0xa320
movl -0x2c(%rbp), %ecx
testl %ecx, %ecx
jle 0x3a00e
movq %r12, -0x38(%rbp)
movq %r14, -0x40(%rbp)
addq %rbx, %r13
movl %ecx, %eax
movq %rax, -0x48(%rbp)
xorl %r12d, %r12d
movq %r13, -0x50(%rbp)
movq %r13, %r14
movzwl (%r15,%r12,2), %eax
subq %rax, %r14
movq %r14, %r13
subq %rbx, %r13
movl %r13d, %ecx
rolw $0x8, %cx
movq -0x68(%rbp), %rax
movq (%rax,%r12,8), %rax
movq -0x60(%rbp), %rdx
leaq (%rdx,%r12,2), %rdx
addq $0x2, %rdx
movw %cx, -0x2(%rdx)
cmpq %rdx, %r14
jb 0x3a04f
movq %rax, %rcx
subq %rbx, %rcx
cmpq -0x50(%rbp), %rax
movq -0x58(%rbp), %rdx
leaq (%rdx,%rcx), %rsi
cmovaeq %rax, %rsi
cmpq %rbx, %rax
cmovbq %rax, %rsi
movzwl (%r15,%r12,2), %edx
movq %r14, %rdi
callq 0xa320
incq %r12
cmpq %r12, -0x48(%rbp)
jne 0x39f92
movl %r13d, %eax
shrl $0x8, %eax
movq -0x40(%rbp), %r14
movq -0x38(%rbp), %r12
movl -0x2c(%rbp), %ecx
jmp 0x3a014
movl %r13d, %eax
shrl $0x8, %eax
movw %cx, 0x12(%r12)
xorl %r15d, %r15d
movb %r15b, 0x1(%r12)
movw $0x0, 0x1(%rbx,%r14)
movb 0x13(%r12), %cl
movb %cl, 0x3(%rbx,%r14)
movb 0x12(%r12), %cl
movb %cl, 0x4(%rbx,%r14)
movb %al, 0x5(%rbx,%r14)
movb %r13b, 0x6(%rbx,%r14)
movb %r15b, 0x7(%rbx,%r14)
jmp 0x3a074
leaq 0x41492(%rip), %rsi     # 0x7b4e8
leaq 0x41130(%rip), %rcx     # 0x7b18d
movl $0xb, %r15d
movl $0xb, %edi
movl $0xf09c, %edx           # imm = 0xF09C
xorl %eax, %eax
callq 0xa4c0
movl %r15d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq