// File: /workspace/github_c_makefile_star2_O1/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 $0x48, %rsp
movl %edx, -0x30(%rbp)
movq %rdi, %r14
cmpl $0x4, %ecx
jne 0x22ca5
movq 0x50(%r14), %rax
movl (%rax), %ecx
bswapl %ecx
cmpl %esi, %ecx
jne 0x22dc2
movl -0x30(%rbp), %ecx
bswapl %ecx
movl %ecx, (%rax)
jmp 0x22e23
movl %ecx, %r12d
movl %esi, -0x34(%rbp)
movb (%r14), %r15b
movq %r14, %rdi
callq 0x1cb41
movzwl 0x10(%r14), %ecx
testl %ecx, %ecx
je 0x22de1
movb %r15b, -0x29(%rbp)
movl -0x30(%rbp), %eax
movl %eax, %edx
shrl $0x18, %edx
movl %edx, -0x44(%rbp)
movl %eax, %edx
shrl $0x10, %edx
movl %edx, -0x40(%rbp)
shrl $0x8, %eax
movl %eax, -0x3c(%rbp)
movl %ecx, -0x38(%rbp)
movl %ecx, %r15d
xorl %ebx, %ebx
movl -0x34(%rbp), %esi
movzwl 0x12(%r14), %eax
movq 0x60(%r14), %rcx
movzbl (%rcx,%rbx,2), %edx
shll $0x8, %edx
movzbl 0x1(%rcx,%rbx,2), %r13d
orl %edx, %r13d
andl %eax, %r13d
addq 0x50(%r14), %r13
cmpb $0x3, %r12b
jne 0x22d4c
movq %r14, %rdi
movq %r13, %rsi
leaq -0x68(%rbp), %rdx
callq 0x21585
movzwl -0x4c(%rbp), %edx
xorl %eax, %eax
movb $0x1, %cl
testq %rdx, %rdx
je 0x22d43
leaq (%rdx,%r13), %rsi
addq $0x3, %rsi
movzwl 0x12(%r14), %edi
addq 0x50(%r14), %rdi
cmpq %rdi, %rsi
jbe 0x22d8d
movl -0x34(%rbp), %esi
testb %cl, %cl
jne 0x22d79
jmp 0x22d7b
movl (%r13), %eax
bswapl %eax
cmpl %esi, %eax
jne 0x22d79
movl -0x44(%rbp), %eax
movb %al, (%r13)
movl -0x40(%rbp), %eax
movb %al, 0x1(%r13)
movl -0x3c(%rbp), %eax
movb %al, 0x2(%r13)
movl -0x30(%rbp), %eax
movb %al, 0x3(%r13)
movl $0x2, %eax
jmp 0x22d7b
xorl %eax, %eax
testl %eax, %eax
jne 0x22de8
incq %rbx
cmpq %rbx, %r15
jne 0x22ceb
jmp 0x22df1
addq %rdx, %r13
movl (%r13), %edx
bswapl %edx
movl -0x34(%rbp), %esi
cmpl %esi, %edx
jne 0x22d46
movl -0x44(%rbp), %eax
movb %al, (%r13)
movl -0x40(%rbp), %eax
movb %al, 0x1(%r13)
movl -0x3c(%rbp), %eax
movb %al, 0x2(%r13)
movl -0x30(%rbp), %eax
movb %al, 0x3(%r13)
movl $0x2, %eax
xorl %ecx, %ecx
jmp 0x22d46
leaq 0x56a4b(%rip), %rsi     # 0x79814
leaq 0x56769(%rip), %rcx     # 0x79539
movl $0xb, %ebx
movl $0xb, %edi
movl $0xccd4, %edx           # imm = 0xCCD4
jmp 0x22e44
xorl %ebx, %ebx
movl -0x34(%rbp), %esi
jmp 0x22dfa
movb -0x29(%rbp), %r15b
movl -0x38(%rbp), %ecx
jmp 0x22dfa
movl -0x38(%rbp), %ecx
movl %ecx, %ebx
movb -0x29(%rbp), %r15b
cmpl %ecx, %ebx
jne 0x22e20
cmpb $0x5, %r12b
jne 0x22e27
movq 0x50(%r14), %rax
movzbl 0x5(%r14), %ecx
movl 0x8(%rax,%rcx), %edx
bswapl %edx
cmpl %esi, %edx
jne 0x22e27
movl -0x30(%rbp), %edx
bswapl %edx
movl %edx, 0x8(%rax,%rcx)
movb %r15b, (%r14)
xorl %ebx, %ebx
jmp 0x22e4b
leaq 0x569e6(%rip), %rsi     # 0x79814
leaq 0x56704(%rip), %rcx     # 0x79539
movl $0xb, %ebx
movl $0xb, %edi
movl $0xccf6, %edx           # imm = 0xCCF6
xorl %eax, %eax
callq 0xb8cc
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq