// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: assemblePage
static void assemblePage(
  MemPage *pPage,   /* The page to be assemblied */
  int nCell,        /* The number of cells to add to this page */
  u8 **apCell,      /* Pointers to cell bodies */
  u16 *aSize        /* Sizes of the cells */
){
  int i;            /* Loop counter */
  u8 *pCellptr;     /* Address of next cell pointer */
  int cellbody;     /* Address of next cell body */
  u8 * const data = pPage->aData;             /* Pointer to data for pPage */
  const int hdr = pPage->hdrOffset;           /* Offset of header on pPage */
  const int nUsable = pPage->pBt->usableSize; /* Usable size of page */

  assert( pPage->nOverflow==0 );
  assert( sqlite3_mutex_held(pPage->pBt->mutex) );
  assert( nCell>=0 && nCell<=(int)MX_CELL(pPage->pBt)
            && (int)MX_CELL(pPage->pBt)<=10921);
  assert( sqlite3PagerIswriteable(pPage->pDbPage) );

  /* Check that the page has just been zeroed by zeroPage() */
  assert( pPage->nCell==0 );
  assert( get2byteNotZero(&data[hdr+5])==nUsable );

  pCellptr = &pPage->aCellIdx[nCell*2];
  cellbody = nUsable;
  for(i=nCell-1; i>=0; i--){
    u16 sz = aSize[i];
    pCellptr -= 2;
    cellbody -= sz;
    put2byte(pCellptr, cellbody);
    memcpy(&data[cellbody], apCell[i], sz);
  }
  put2byte(&data[hdr+3], nCell);
  put2byte(&data[hdr+5], cellbody);
  pPage->nFree -= (nCell*2 + nUsable - cellbody);
  pPage->nCell = (u16)nCell;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movzbl 0x5(%rax), %eax
movl %eax, -0x44(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movl 0x34(%rax), %eax
movl %eax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rax
movl -0xc(%rbp), %ecx
shll %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0xc(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jl 0x44e47
movq -0x20(%rbp), %rax
movslq -0x24(%rbp), %rcx
movw (%rax,%rcx,2), %ax
movw %ax, -0x4a(%rbp)
movq -0x30(%rbp), %rax
addq $-0x2, %rax
movq %rax, -0x30(%rbp)
movzwl -0x4a(%rbp), %ecx
movl -0x34(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
sarl $0x8, %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movb %cl, (%rax)
movl -0x34(%rbp), %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movb %cl, 0x1(%rax)
movq -0x40(%rbp), %rdi
movslq -0x34(%rbp), %rax
addq %rax, %rdi
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movzwl -0x4a(%rbp), %eax
movl %eax, %edx
callq 0x82f0
movl -0x24(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x44dd2
movl -0xc(%rbp), %eax
sarl $0x8, %eax
movb %al, %dl
movq -0x40(%rbp), %rax
movl -0x44(%rbp), %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl -0xc(%rbp), %eax
movb %al, %dl
movq -0x40(%rbp), %rax
movl -0x44(%rbp), %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movb %dl, 0x1(%rax,%rcx)
movl -0x34(%rbp), %eax
sarl $0x8, %eax
movb %al, %dl
movq -0x40(%rbp), %rax
movl -0x44(%rbp), %ecx
addl $0x5, %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl -0x34(%rbp), %eax
movb %al, %dl
movq -0x40(%rbp), %rax
movl -0x44(%rbp), %ecx
addl $0x5, %ecx
movslq %ecx, %rcx
movb %dl, 0x1(%rax,%rcx)
movl -0xc(%rbp), %edx
shll %edx
addl -0x48(%rbp), %edx
subl -0x34(%rbp), %edx
movq -0x8(%rbp), %rax
movzwl 0xe(%rax), %ecx
subl %edx, %ecx
movw %cx, 0xe(%rax)
movl -0xc(%rbp), %eax
movw %ax, %cx
movq -0x8(%rbp), %rax
movw %cx, 0x10(%rax)
addq $0x50, %rsp
popq %rbp
retq