// File: /workspace/github_c_makefile_star2_O0/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
subq $0x60, %rsp
movb %cl, %al
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movb %al, -0x19(%rbp)
movzbl -0x19(%rbp), %eax
cmpl $0x4, %eax
jne 0x2ded9
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rdi
callq 0x20a50
cmpl -0x14(%rbp), %eax
je 0x2dec4
movl $0xccd4, %edi           # imm = 0xCCD4
callq 0x24410
movl %eax, -0x4(%rbp)
jmp 0x2e079
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rdi
movl -0x18(%rbp), %esi
callq 0x22060
jmp 0x2e072
movq -0x10(%rbp), %rax
movb (%rax), %al
movb %al, -0x1a(%rbp)
movq -0x10(%rbp), %rdi
callq 0x24a60
movq -0x10(%rbp), %rax
movzwl 0x10(%rax), %eax
movl %eax, -0x24(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x2e007
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq -0x10(%rbp), %rcx
movzwl 0x12(%rcx), %ecx
movq -0x10(%rbp), %rdx
movq 0x60(%rdx), %rdx
movl -0x20(%rbp), %esi
shll %esi
movslq %esi, %rsi
movzbl (%rdx,%rsi), %edx
shll $0x8, %edx
movq -0x10(%rbp), %rsi
movq 0x60(%rsi), %rsi
movl -0x20(%rbp), %edi
shll %edi
movslq %edi, %rdi
movzbl 0x1(%rsi,%rdi), %esi
orl %esi, %edx
andl %edx, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movzbl -0x19(%rbp), %eax
cmpl $0x3, %eax
jne 0x2dfd9
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x2c070
movzwl -0x34(%rbp), %eax
cmpl $0x0, %eax
je 0x2dfd7
movq -0x30(%rbp), %rax
movzwl -0x34(%rbp), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
addq $0x3, %rax
movq -0x10(%rbp), %rcx
movq 0x50(%rcx), %rcx
movq -0x10(%rbp), %rdx
movzwl 0x12(%rdx), %edx
movslq %edx, %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
ja 0x2dfd7
movl -0x14(%rbp), %eax
movl %eax, -0x54(%rbp)
movq -0x30(%rbp), %rdi
movzwl -0x34(%rbp), %eax
addq %rax, %rdi
callq 0x20a50
movl %eax, %ecx
movl -0x54(%rbp), %eax
cmpl %ecx, %eax
jne 0x2dfd7
movq -0x30(%rbp), %rdi
movzwl -0x34(%rbp), %eax
addq %rax, %rdi
movl -0x18(%rbp), %esi
callq 0x22060
jmp 0x2e007
jmp 0x2dff7
movq -0x30(%rbp), %rdi
callq 0x20a50
cmpl -0x14(%rbp), %eax
jne 0x2dff5
movq -0x30(%rbp), %rdi
movl -0x18(%rbp), %esi
callq 0x22060
jmp 0x2e007
jmp 0x2dff7
jmp 0x2dff9
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x2defd
movl -0x20(%rbp), %eax
cmpl -0x24(%rbp), %eax
jne 0x2e069
movzbl -0x19(%rbp), %eax
cmpl $0x5, %eax
jne 0x2e03a
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rdi
movq -0x10(%rbp), %rax
movzbl 0x5(%rax), %eax
addl $0x8, %eax
cltq
addq %rax, %rdi
callq 0x20a50
cmpl -0x14(%rbp), %eax
je 0x2e049
movl $0xccf6, %edi           # imm = 0xCCF6
callq 0x24410
movl %eax, -0x4(%rbp)
jmp 0x2e079
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rdi
movq -0x10(%rbp), %rax
movzbl 0x5(%rax), %eax
addl $0x8, %eax
cltq
addq %rax, %rdi
movl -0x18(%rbp), %esi
callq 0x22060
movb -0x1a(%rbp), %cl
movq -0x10(%rbp), %rax
movb %cl, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)