// File: /workspace/github_c_makefile_star2_O1/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, 0x30(%rsp)
testl %r9d, %r9d
jle 0x2ad7c9
movl %r8d, %r14d
movq %rcx, 0x20(%rsp)
movq 0x80(%rsp), %r13
movq %rdi, 0x38(%rsp)
movq 0x50(%rdi), %rax
movq %rax, 0x10(%rsp)
movq %rdx, 0x28(%rsp)
movq (%rdx), %rax
movq %rax, 0x8(%rsp)
addl %r8d, %r9d
movl %r9d, 0x1c(%rsp)
xorl %ecx, %ecx
leaq 0x1(%rcx), %rax
cmpq $0x5, %rcx
ja 0x2ad6b2
cmpl %r14d, 0x50(%r13,%rcx,4)
movq %rax, %rcx
jle 0x2ad69e
leal -0x1(%rax), %ecx
movl %ecx, 0x4(%rsp)
movq 0x18(%r13,%rax,8), %r15
movq 0x18(%r13), %rax
movslq %r14d, %rbp
movzwl (%rax,%rbp,2), %ebx
movq 0x10(%rsp), %rax
cmpb $0x0, 0x1(%rax)
jne 0x2ad6df
movq 0x10(%rsp), %rax
cmpb $0x0, 0x2(%rax)
je 0x2ad6fa
movq 0x38(%rsp), %rdi
movl %ebx, %esi
leaq 0x44(%rsp), %rdx
callq 0x2ac943
testq %rax, %rax
je 0x2ad6fa
movq %rax, %r12
jmp 0x2ad71d
movq 0x8(%rsp), %r12
movq %r12, %rcx
subq 0x30(%rsp), %rcx
movl $0x1, %eax
cmpq %rbx, %rcx
jl 0x2ad7af
subq %rbx, %r12
movq %r12, 0x8(%rsp)
movq 0x10(%r13), %rax
movq (%rax,%rbp,8), %rsi
movl %ebx, %edx
cmpq %r15, %rsi
jae 0x2ad762
leaq (%rsi,%rdx), %rax
cmpq %r15, %rax
jbe 0x2ad762
movl $0xb, %edi
leaq 0x131bde(%rip), %rsi    # 0x3df31f
leaq 0x131ce8(%rip), %rdx    # 0x3df430
movl $0x11780, %ecx          # imm = 0x11780
leaq 0x131a31(%rip), %r8     # 0x3df185
xorl %eax, %eax
callq 0x27e637
movl $0x1, %eax
jmp 0x2ad7af
movq %r12, %rdi
callq 0x17cd0
subl 0x10(%rsp), %r12d
rolw $0x8, %r12w
movq 0x20(%rsp), %rax
movw %r12w, (%rax)
addq $0x2, %rax
movq %rax, 0x20(%rsp)
incl %r14d
movl $0x6, %eax
cmpl 0x1c(%rsp), %r14d
jge 0x2ad7af
movslq 0x4(%rsp), %rcx
xorl %eax, %eax
cmpl %r14d, 0x50(%r13,%rcx,4)
jg 0x2ad7af
leal 0x1(%rcx), %edx
movl %edx, 0x4(%rsp)
movq 0x28(%r13,%rcx,8), %r15
testl %eax, %eax
je 0x2ad6be
cmpl $0x6, %eax
jne 0x2ad7cd
movq 0x28(%rsp), %rax
movq 0x8(%rsp), %rcx
movq %rcx, (%rax)
xorl %eax, %eax
jmp 0x2ad7d2
movl $0x1, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq