// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x70, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movl %r9d, -0x30(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x34(%rbp)
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movl -0x2c(%rbp), %eax
addl -0x30(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jg 0x4080fe
movl $0x0, -0x4(%rbp)
jmp 0x4082c9
movl $0x0, -0x50(%rbp)
movq 0x10(%rbp), %rax
movslq -0x50(%rbp), %rcx
movl 0x50(%rax,%rcx,4), %ecx
xorl %eax, %eax
cmpl -0x34(%rbp), %ecx
movb %al, -0x69(%rbp)
jg 0x408125
cmpl $0x6, -0x50(%rbp)
setl %al
movb %al, -0x69(%rbp)
movb -0x69(%rbp), %al
testb $0x1, %al
jne 0x40812e
jmp 0x40813b
jmp 0x408130
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x408105
movq 0x10(%rbp), %rax
movslq -0x50(%rbp), %rcx
movq 0x20(%rax,%rcx,8), %rax
movq %rax, -0x58(%rbp)
movq 0x10(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x34(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
movl %eax, -0x5c(%rbp)
movq -0x40(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x0, %eax
jne 0x408179
movq -0x40(%rbp), %rax
movzbl 0x2(%rax), %eax
cmpl $0x0, %eax
je 0x408193
movq -0x10(%rbp), %rdi
movl -0x5c(%rbp), %esi
leaq -0x60(%rbp), %rdx
callq 0x404d10
movq %rax, -0x68(%rbp)
cmpq $0x0, %rax
jne 0x4081d1
movq -0x48(%rbp), %rax
movq -0x18(%rbp), %rcx
subq %rcx, %rax
movslq -0x5c(%rbp), %rcx
cmpq %rcx, %rax
jge 0x4081b3
movl $0x1, -0x4(%rbp)
jmp 0x4082c9
movl -0x5c(%rbp), %ecx
movq -0x48(%rbp), %rax
movslq %ecx, %rdx
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x68(%rbp)
movq 0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x5c(%rbp), %rcx
addq %rcx, %rax
movq -0x58(%rbp), %rcx
cmpq %rcx, %rax
jbe 0x408220
movq 0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq -0x58(%rbp), %rcx
cmpq %rcx, %rax
jae 0x408220
movl $0x11780, %edi          # imm = 0x11780
callq 0x3dff80
movl $0x1, -0x4(%rbp)
jmp 0x4082c9
movq -0x68(%rbp), %rdi
movq 0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movslq -0x5c(%rbp), %rdx
callq 0x19bf0
movq -0x68(%rbp), %rax
movq -0x40(%rbp), %rcx
subq %rcx, %rax
sarq $0x8, %rax
movb %al, %cl
movq -0x28(%rbp), %rax
movb %cl, (%rax)
movq -0x68(%rbp), %rax
movq -0x40(%rbp), %rcx
subq %rcx, %rax
movb %al, %cl
movq -0x28(%rbp), %rax
movb %cl, 0x1(%rax)
movq -0x28(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x28(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jl 0x408287
jmp 0x4082b7
movq 0x10(%rbp), %rax
movslq -0x50(%rbp), %rcx
movl 0x50(%rax,%rcx,4), %eax
cmpl -0x34(%rbp), %eax
jg 0x4082b2
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
movq 0x10(%rbp), %rax
movslq -0x50(%rbp), %rcx
movq 0x20(%rax,%rcx,8), %rax
movq %rax, -0x58(%rbp)
jmp 0x40814c
movq -0x48(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)