// File: /workspace/github_c_makefile_star2_O3/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: modifyPagePointer
static int modifyPagePointer(MemPage *pPage, Pgno iFrom, Pgno iTo, u8 eType){
  assert( sqlite3_mutex_held(pPage->pBt->mutex) );
  assert( sqlite3PagerIswriteable(pPage->pDbPage) );
  if( eType==PTRMAP_OVERFLOW2 ){
    /* The pointer is always the first 4 bytes of the page in this case.  */
    if( get4byte(pPage->aData)!=iFrom ){
      return SQLITE_CORRUPT_BKPT;
    }
    put4byte(pPage->aData, iTo);
  }else{
    u8 isInitOrig = pPage->isInit;
    int i;
    int nCell;

    btreeInitPage(pPage);
    nCell = pPage->nCell;

    for(i=0; i<nCell; i++){
      u8 *pCell = findCell(pPage, i);
      if( eType==PTRMAP_OVERFLOW1 ){
        CellInfo info;
        btreeParseCellPtr(pPage, pCell, &info);
        if( info.iOverflow
         && pCell+info.iOverflow+3<=pPage->aData+pPage->maskPage
         && iFrom==get4byte(&pCell[info.iOverflow])
        ){
          put4byte(&pCell[info.iOverflow], iTo);
          break;
        }
      }else{
        if( get4byte(pCell)==iFrom ){
          put4byte(pCell, iTo);
          break;
        }
      }
    }
  
    if( i==nCell ){
      if( eType!=PTRMAP_BTREE || 
          get4byte(&pPage->aData[pPage->hdrOffset+8])!=iFrom ){
        return SQLITE_CORRUPT_BKPT;
      }
      put4byte(&pPage->aData[pPage->hdrOffset+8], iTo);
    }

    pPage->isInit = isInitOrig;
  }
  return SQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %r14
cmpl $0x4, %ecx
jne 0x228a6
movq 0x50(%r14), %rax
movl (%rax), %ecx
bswapl %ecx
cmpl %esi, %ecx
jne 0x2294e
bswapl %edx
movl %edx, (%rax)
jmp 0x229db
movl %ecx, %r12d
movl %esi, -0x34(%rbp)
movl %edx, -0x30(%rbp)
movb (%r14), %al
movb %al, -0x29(%rbp)
movq %r14, %rdi
callq 0x1c99b
movzwl 0x10(%r14), %eax
testl %eax, %eax
je 0x2296d
movl %eax, -0x38(%rbp)
movl %eax, %r15d
xorl %r13d, %r13d
movl -0x34(%rbp), %esi
movzwl 0x12(%r14), %eax
movq 0x60(%r14), %rcx
movzbl (%rcx,%r13,2), %edx
shll $0x8, %edx
movzbl 0x1(%rcx,%r13,2), %ebx
orl %edx, %ebx
andl %eax, %ebx
addq 0x50(%r14), %rbx
cmpb $0x3, %r12b
jne 0x2293c
movq %r14, %rdi
movq %rbx, %rsi
leaq -0x58(%rbp), %rdx
callq 0x2121e
movl -0x34(%rbp), %esi
movzwl -0x3c(%rbp), %eax
testq %rax, %rax
je 0x22944
leaq (%rbx,%rax), %rcx
addq $0x3, %rcx
movzwl 0x12(%r14), %edx
addq 0x50(%r14), %rdx
cmpq %rdx, %rcx
ja 0x22944
addq %rax, %rbx
movl (%rbx), %eax
bswapl %eax
cmpl %esi, %eax
jne 0x22944
jmp 0x229ce
movl (%rbx), %eax
bswapl %eax
cmpl %esi, %eax
je 0x22975
incq %r13
cmpq %r13, %r15
jne 0x228d6
jmp 0x22984
leaq 0x56ebf(%rip), %rsi     # 0x79814
leaq 0x56bdd(%rip), %rcx     # 0x79539
movl $0xb, %ebx
movl $0xb, %edi
movl $0xccd4, %edx           # imm = 0xCCD4
jmp 0x229c5
xorl %r13d, %r13d
movl -0x34(%rbp), %esi
jmp 0x2297f
movl -0x30(%rbp), %eax
bswapl %eax
movl %eax, (%rbx)
movl -0x38(%rbp), %eax
cmpl %eax, %r13d
jne 0x229d5
cmpb $0x5, %r12b
jne 0x229a8
movq 0x50(%r14), %rax
movzbl 0x5(%r14), %ecx
movl 0x8(%rax,%rcx), %edx
bswapl %edx
cmpl %esi, %edx
jne 0x229a8
movl -0x30(%rbp), %edx
bswapl %edx
movl %edx, 0x8(%rax,%rcx)
jmp 0x229d5
leaq 0x56e65(%rip), %rsi     # 0x79814
leaq 0x56b83(%rip), %rcx     # 0x79539
movl $0xb, %ebx
movl $0xb, %edi
movl $0xccf6, %edx           # imm = 0xCCF6
xorl %eax, %eax
callq 0xb9c7
jmp 0x229dd
movl -0x30(%rbp), %eax
bswapl %eax
movl %eax, (%rbx)
movb -0x29(%rbp), %al
movb %al, (%r14)
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq