// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/external/sqlite-3.33.0/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_PAGE(pPage);
    }
    put4byte(pPage->aData, iTo);
  }else{
    int i;
    int nCell;
    int rc;

    rc = pPage->isInit ? SQLITE_OK : btreeInitPage(pPage);
    if( rc ) return rc;
    nCell = pPage->nCell;

    for(i=0; i<nCell; i++){
      u8 *pCell = findCell(pPage, i);
      if( eType==PTRMAP_OVERFLOW1 ){
        CellInfo info;
        pPage->xParseCell(pPage, pCell, &info);
        if( info.nLocal<info.nPayload ){
          if( pCell+info.nSize > pPage->aData+pPage->pBt->usableSize ){
            return SQLITE_CORRUPT_PAGE(pPage);
          }
          if( iFrom==get4byte(pCell+info.nSize-4) ){
            put4byte(pCell+info.nSize-4, 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_PAGE(pPage);
      }
      put4byte(&pPage->aData[pPage->hdrOffset+8], iTo);
    }
  }
  return SQLITE_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %edx, %ebx
movq %rdi, %r14
cmpl $0x4, %ecx
jne 0x299381
movq 0x50(%r14), %rax
movl (%rax), %ecx
bswapl %ecx
cmpl %esi, %ecx
jne 0x2993b3
bswapl %ebx
movl %ebx, (%rax)
jmp 0x2993ae
movl %ecx, %r15d
xorl %r12d, %r12d
cmpb $0x0, (%r14)
jne 0x29939c
movq %r14, %rdi
movl %esi, %ebp
callq 0x294e54
movl %ebp, %esi
movl %eax, %r12d
xorl %ebp, %ebp
movl $0x0, %r13d
testl %r12d, %r12d
je 0x2993f1
testb %r13b, %r13b
je 0x2993df
xorl %r12d, %r12d
jmp 0x2993df
leaq 0x145f65(%rip), %rsi    # 0x3df31f
leaq 0x14606f(%rip), %rdx    # 0x3df430
leaq 0x145dbd(%rip), %r8     # 0x3df185
movl $0xb, %r12d
movl $0xb, %edi
movl $0x109f7, %ecx          # imm = 0x109F7
xorl %eax, %eax
callq 0x27e637
movl %r12d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movzwl 0x18(%r14), %eax
testl %eax, %eax
je 0x29955c
movl %ebx, %ecx
shrl $0x18, %ecx
movl %ecx, 0x18(%rsp)
movl %ebx, %ecx
shrl $0x10, %ecx
movl %ecx, 0x14(%rsp)
movl %ebx, %ecx
shrl $0x8, %ecx
movl %ecx, 0x10(%rsp)
movl %eax, 0xc(%rsp)
movl %eax, %edi
xorl %ebp, %ebp
movl %r15d, 0x1c(%rsp)
movzwl 0x1a(%r14), %eax
movq 0x60(%r14), %rcx
movzbl (%rcx,%rbp,2), %edx
shll $0x8, %edx
movzbl 0x1(%rcx,%rbp,2), %r13d
orl %edx, %r13d
andl %eax, %r13d
addq 0x50(%r14), %r13
cmpb $0x3, %r15b
jne 0x2994c7
movl %ebx, %r15d
movq %rdi, %rbx
movl %esi, %r12d
movq %r14, %rdi
movq %r13, %rsi
leaq 0x20(%rsp), %rdx
callq *0x80(%r14)
movzwl 0x34(%rsp), %ecx
xorl %eax, %eax
cmpl %ecx, 0x30(%rsp)
jbe 0x2994b7
movzwl 0x36(%rsp), %ecx
addq %rcx, %r13
movq 0x48(%r14), %rcx
movl 0x38(%rcx), %ecx
addq 0x50(%r14), %rcx
cmpq %rcx, %r13
jbe 0x299506
movl $0xb, %edi
leaq 0x145e87(%rip), %rsi    # 0x3df31f
leaq 0x145f91(%rip), %rdx    # 0x3df430
movl $0x10a0a, %ecx          # imm = 0x10A0A
leaq 0x145cda(%rip), %r8     # 0x3df185
xorl %eax, %eax
callq 0x27e637
movl $0x1, %eax
movl %r12d, %esi
movq %rbx, %rdi
movl %r15d, %ebx
movl 0x1c(%rsp), %r15d
jmp 0x2994f4
movl (%r13), %ecx
bswapl %ecx
xorl %eax, %eax
cmpl %esi, %ecx
jne 0x2994f4
movl 0x18(%rsp), %eax
movb %al, (%r13)
movl 0x14(%rsp), %eax
movb %al, 0x1(%r13)
movl 0x10(%rsp), %eax
movb %al, 0x2(%r13)
movb %bl, 0x3(%r13)
movl $0x2, %eax
testl %eax, %eax
jne 0x29953d
incq %rbp
cmpq %rbp, %rdi
jne 0x299426
jmp 0x299556
movl -0x4(%r13), %ecx
bswapl %ecx
movl %r12d, %esi
cmpl %r12d, %ecx
movq %rbx, %rdi
movl %r15d, %ebx
jne 0x2994c0
movl 0x18(%rsp), %eax
movb %al, -0x4(%r13)
movl 0x14(%rsp), %eax
movb %al, -0x3(%r13)
movl 0x10(%rsp), %eax
movb %al, -0x2(%r13)
movb %bl, -0x1(%r13)
movl $0x2, %eax
jmp 0x2994c0
cmpl $0x2, %eax
jne 0x299548
movl 0xc(%rsp), %eax
jmp 0x29955c
movl $0xb, %r12d
xorl %r13d, %r13d
jmp 0x2993a9
movl 0xc(%rsp), %eax
movl %eax, %ebp
movl $0xb, %r12d
movb $0x1, %r13b
cmpl %eax, %ebp
jne 0x2993a9
cmpb $0x5, %r15b
jne 0x299591
movq 0x50(%r14), %rax
movzbl 0x9(%r14), %ecx
movl 0x8(%rax,%rcx), %edx
bswapl %edx
cmpl %esi, %edx
jne 0x299591
bswapl %ebx
movl %ebx, 0x8(%rax,%rcx)
jmp 0x2993a9
leaq 0x145d87(%rip), %rsi    # 0x3df31f
leaq 0x145e91(%rip), %rdx    # 0x3df430
leaq 0x145bdf(%rip), %r8     # 0x3df185
xorl %r13d, %r13d
movl $0xb, %edi
movl $0x10a1c, %ecx          # imm = 0x10A1C
xorl %eax, %eax
callq 0x27e637
jmp 0x2993a9