// File: /workspace/github_c_makefile_star2_O0/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
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movzbl 0x6(%rax), %eax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movl 0x34(%rax), %eax
movl %eax, -0x3c(%rbp)
movq -0x38(%rbp), %rax
movslq -0x3c(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq (%rax), %rdi
callq 0x4ca00
movq %rax, -0x60(%rbp)
movq -0x38(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl $0x5, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
shll $0x8, %eax
movq -0x38(%rbp), %rcx
movl -0x2c(%rbp), %edx
addl $0x5, %edx
movslq %edx, %rdx
movzbl 0x1(%rcx,%rdx), %ecx
orl %ecx, %eax
movl %eax, -0x4c(%rbp)
movq -0x60(%rbp), %rdi
movslq -0x4c(%rbp), %rax
addq %rax, %rdi
movq -0x38(%rbp), %rsi
movslq -0x4c(%rbp), %rax
addq %rax, %rsi
movl -0x3c(%rbp), %eax
subl -0x4c(%rbp), %eax
movslq %eax, %rdx
callq 0xb420
movq -0x48(%rbp), %rax
movq %rax, -0x68(%rbp)
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x4eb6a
movq -0x20(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
cmpq -0x38(%rbp), %rax
jb 0x4eacf
movq -0x70(%rbp), %rax
cmpq -0x48(%rbp), %rax
jae 0x4eacf
movq -0x60(%rbp), %rax
movq -0x70(%rbp), %rcx
movq -0x38(%rbp), %rdx
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
movq -0x28(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movzwl (%rax,%rcx,2), %ecx
movq -0x68(%rbp), %rax
movslq %ecx, %rdx
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq -0x38(%rbp), %rcx
subq %rcx, %rax
sarq $0x8, %rax
movb %al, %cl
movq -0x58(%rbp), %rax
movb %cl, (%rax)
movq -0x68(%rbp), %rax
movq -0x38(%rbp), %rcx
subq %rcx, %rax
movb %al, %cl
movq -0x58(%rbp), %rax
movb %cl, 0x1(%rax)
movq -0x58(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x58(%rbp)
movq -0x68(%rbp), %rax
cmpq -0x58(%rbp), %rax
jae 0x4eb41
movl $0xf09c, %edi           # imm = 0xF09C
callq 0x2a650
movl %eax, -0x4(%rbp)
jmp 0x4ec32
movq -0x68(%rbp), %rdi
movq -0x70(%rbp), %rsi
movq -0x28(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
movl %eax, %edx
callq 0xb420
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x4ea89
movl -0x14(%rbp), %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x12(%rax)
movq -0x10(%rbp), %rax
movb $0x0, 0x1(%rax)
movq -0x38(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movb $0x0, (%rax,%rcx)
movq -0x38(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movb $0x0, 0x1(%rax,%rcx)
movq -0x10(%rbp), %rax
movzwl 0x12(%rax), %eax
sarl $0x8, %eax
movb %al, %dl
movq -0x38(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movq -0x10(%rbp), %rax
movw 0x12(%rax), %ax
movb %al, %dl
movq -0x38(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movb %dl, 0x1(%rax,%rcx)
movq -0x68(%rbp), %rax
movq -0x38(%rbp), %rcx
subq %rcx, %rax
sarq $0x8, %rax
movb %al, %dl
movq -0x38(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl $0x5, %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movq -0x68(%rbp), %rax
movq -0x38(%rbp), %rcx
subq %rcx, %rax
movb %al, %dl
movq -0x38(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl $0x5, %ecx
movslq %ecx, %rcx
movb %dl, 0x1(%rax,%rcx)
movq -0x38(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl $0x7, %ecx
movslq %ecx, %rcx
movb $0x0, (%rax,%rcx)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)