// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: pageInsertArray
static int pageInsertArray(
  MemPage *pPg,                   /* Page to add cells to */
  u8 *pBegin,                     /* End of cell-pointer array */
  u8 **ppData,                    /* IN/OUT: Page content-area pointer */
  u8 *pCellptr,                   /* Pointer to cell-pointer area */
  int iFirst,                     /* Index of first cell to add */
  int nCell,                      /* Number of cells to add to pPg */
  CellArray *pCArray              /* Array of cells */
){
  int i = iFirst;                 /* Loop counter - cell index to insert */
  u8 *aData = pPg->aData;         /* Complete page */
  u8 *pData = *ppData;            /* Content area.  A subset of aData[] */
  int iEnd = iFirst + nCell;      /* End of loop. One past last cell to ins */
  int k;                          /* Current slot in pCArray->apEnd[] */
  u8 *pEnd;                       /* Maximum extent of cell data */
  assert( CORRUPT_DB || pPg->hdrOffset==0 );    /* Never called on page 1 */
  if( iEnd<=iFirst ) return 0;
  for(k=0; pCArray->ixNx[k]<=i && ALWAYS(k<NB*2); k++){}
  pEnd = pCArray->apEnd[k];
  while( 1 /*Exit by break*/ ){
    int sz, rc;
    u8 *pSlot;
    assert( pCArray->szCell[i]!=0 );
    sz = pCArray->szCell[i];
    if( (aData[1]==0 && aData[2]==0) || (pSlot = pageFindSlot(pPg,sz,&rc))==0 ){
      if( (pData - pBegin)<sz ) return 1;
      pData -= sz;
      pSlot = pData;
    }
    /* pSlot and pCArray->apCell[i] will never overlap on a well-formed
    ** database.  But they might for a corrupt database.  Hence use memmove()
    ** since memcpy() sends SIGABORT with overlapping buffers on OpenBSD */
    assert( (pSlot+sz)<=pCArray->apCell[i]
         || pSlot>=(pCArray->apCell[i]+sz)
         || CORRUPT_DB );
    if( (uptr)(pCArray->apCell[i]+sz)>(uptr)pEnd
     && (uptr)(pCArray->apCell[i])<(uptr)pEnd
    ){
      assert( CORRUPT_DB );
      (void)SQLITE_CORRUPT_BKPT;
      return 1;
    }
    memmove(pSlot, pCArray->apCell[i], sz);
    put2byte(pCellptr, (pSlot - aData));
    pCellptr += 2;
    i++;
    if( i>=iEnd ) break;
    if( pCArray->ixNx[k]<=i ){
      k++;
      pEnd = pCArray->apEnd[k];
    }
  }
  *ppData = pData;
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, 0x28(%rsp)
testl %r9d, %r9d
jle 0x2a3c55
movq %rcx, %r14
movq 0x80(%rsp), %r13
movq %rdi, 0x30(%rsp)
movq 0x50(%rdi), %rax
movq %rax, 0x18(%rsp)
movq %rdx, 0x20(%rsp)
movq (%rdx), %rax
movq %rax, 0x10(%rsp)
addl %r8d, %r9d
xorl %ecx, %ecx
leaq 0x1(%rcx), %rax
cmpq $0x5, %rcx
ja 0x2a3b4a
cmpl %r8d, 0x50(%r13,%rcx,4)
movq %rax, %rcx
jle 0x2a3b36
leal -0x1(%rax), %ecx
movl %ecx, 0xc(%rsp)
movq 0x18(%r13,%rax,8), %r12
movslq %r8d, %r15
movslq %r9d, %rax
movq %rax, 0x38(%rsp)
incq %r15
movq 0x18(%r13), %rax
movzwl -0x2(%rax,%r15,2), %ebp
movq 0x18(%rsp), %rax
cmpb $0x0, 0x1(%rax)
jne 0x2a3b84
movq 0x18(%rsp), %rax
cmpb $0x0, 0x2(%rax)
je 0x2a3ba1
movq 0x30(%rsp), %rdi
movl %ebp, %esi
leaq 0x44(%rsp), %rdx
callq 0x2a2dcc
testq %rax, %rax
je 0x2a3ba1
movq %rax, %rbx
movl %ebp, %ebp
jmp 0x2a3bbf
movq 0x10(%rsp), %rbx
movq %rbx, %rax
subq 0x28(%rsp), %rax
cmpq %rbp, %rax
jl 0x2a3c41
subq %rbp, %rbx
movq %rbx, 0x10(%rsp)
movq 0x10(%r13), %rax
movq -0x8(%rax,%r15,8), %rsi
cmpq %r12, %rsi
jae 0x2a3bd6
leaq (%rsi,%rbp), %rax
cmpq %r12, %rax
ja 0x2a3c1b
movq %rbx, %rdi
movq %rbp, %rdx
callq 0x17cd0
subl 0x18(%rsp), %ebx
rolw $0x8, %bx
movw %bx, (%r14)
cmpq 0x38(%rsp), %r15
jge 0x2a3c48
movslq 0xc(%rsp), %rax
movslq 0x50(%r13,%rax,4), %rcx
cmpq %rcx, %r15
jl 0x2a3c0f
leal 0x1(%rax), %ecx
movl %ecx, 0xc(%rsp)
movq 0x28(%r13,%rax,8), %r12
incq %r15
addq $0x2, %r14
jmp 0x2a3b64
leaq 0x131fa9(%rip), %rsi    # 0x3d5bcb
leaq 0x1320b3(%rip), %rdx    # 0x3d5cdc
leaq 0x131e01(%rip), %r8     # 0x3d5a31
movl $0xb, %edi
movl $0x11780, %ecx          # imm = 0x11780
xorl %eax, %eax
callq 0x274d08
movl $0x1, %eax
jmp 0x2a3c57
movq 0x20(%rsp), %rax
movq 0x10(%rsp), %rcx
movq %rcx, (%rax)
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq