// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: walRewriteChecksums
static int walRewriteChecksums(Wal *pWal, u32 iLast){
  const int szPage = pWal->szPage;/* Database page size */
  int rc = SQLITE_OK;             /* Return code */
  u8 *aBuf;                       /* Buffer to load data from wal file into */
  u8 aFrame[WAL_FRAME_HDRSIZE];   /* Buffer to assemble frame-headers in */
  u32 iRead;                      /* Next frame to read from wal file */
  i64 iCksumOff;

  aBuf = sqlite3_malloc(szPage + WAL_FRAME_HDRSIZE);
  if( aBuf==0 ) return SQLITE_NOMEM_BKPT;

  /* Find the checksum values to use as input for the recalculating the
  ** first checksum. If the first frame is frame 1 (implying that the current
  ** transaction restarted the wal file), these values must be read from the
  ** wal-file header. Otherwise, read them from the frame header of the
  ** previous frame.  */
  assert( pWal->iReCksum>0 );
  if( pWal->iReCksum==1 ){
    iCksumOff = 24;
  }else{
    iCksumOff = walFrameOffset(pWal->iReCksum-1, szPage) + 16;
  }
  rc = sqlite3OsRead(pWal->pWalFd, aBuf, sizeof(u32)*2, iCksumOff);
  pWal->hdr.aFrameCksum[0] = sqlite3Get4byte(aBuf);
  pWal->hdr.aFrameCksum[1] = sqlite3Get4byte(&aBuf[sizeof(u32)]);

  iRead = pWal->iReCksum;
  pWal->iReCksum = 0;
  for(; rc==SQLITE_OK && iRead<=iLast; iRead++){
    i64 iOff = walFrameOffset(iRead, szPage);
    rc = sqlite3OsRead(pWal->pWalFd, aBuf, szPage+WAL_FRAME_HDRSIZE, iOff);
    if( rc==SQLITE_OK ){
      u32 iPgno, nDbSize;
      iPgno = sqlite3Get4byte(aBuf);
      nDbSize = sqlite3Get4byte(&aBuf[4]);

      walEncodeFrame(pWal, iPgno, nDbSize, &aBuf[WAL_FRAME_HDRSIZE], aFrame);
      rc = sqlite3OsWrite(pWal->pWalFd, aFrame, sizeof(aFrame), iOff);
    }
  }

  sqlite3_free(aBuf);
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rax
movl 0x38(%rax), %eax
movl %eax, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x18(%rbp), %edi
addl $0x18, %edi
callq 0x3c0710
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x3de202
movl $0x7, -0x4(%rbp)
jmp 0x3de36f
movq -0x10(%rbp), %rax
cmpl $0x1, 0x7c(%rax)
jne 0x3de216
movq $0x18, -0x50(%rbp)
jmp 0x3de23e
movq -0x10(%rbp), %rax
movl 0x7c(%rax), %eax
subl $0x1, %eax
subl $0x1, %eax
movl %eax, %eax
movl -0x18(%rbp), %ecx
addl $0x18, %ecx
movslq %ecx, %rcx
imulq %rcx, %rax
addq $0x20, %rax
addq $0x10, %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x28(%rbp), %rsi
movq -0x50(%rbp), %rcx
movl $0x8, %edx
callq 0x3dfc00
movl %eax, -0x1c(%rbp)
movq -0x28(%rbp), %rdi
callq 0x3db720
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x60(%rax)
movq -0x28(%rbp), %rdi
addq $0x4, %rdi
callq 0x3db720
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x64(%rax)
movq -0x10(%rbp), %rax
movl 0x7c(%rax), %eax
movl %eax, -0x44(%rbp)
movq -0x10(%rbp), %rax
movl $0x0, 0x7c(%rax)
xorl %eax, %eax
cmpl $0x0, -0x1c(%rbp)
movb %al, -0x61(%rbp)
jne 0x3de2af
movl -0x44(%rbp), %eax
cmpl -0x14(%rbp), %eax
setbe %al
movb %al, -0x61(%rbp)
movb -0x61(%rbp), %al
testb $0x1, %al
jne 0x3de2bb
jmp 0x3de360
movl -0x44(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
movl -0x18(%rbp), %ecx
addl $0x18, %ecx
movslq %ecx, %rcx
imulq %rcx, %rax
addq $0x20, %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x28(%rbp), %rsi
movl -0x18(%rbp), %edx
addl $0x18, %edx
movq -0x58(%rbp), %rcx
callq 0x3dfc00
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x3de350
movq -0x28(%rbp), %rdi
callq 0x3db720
movl %eax, -0x5c(%rbp)
movq -0x28(%rbp), %rdi
addq $0x4, %rdi
callq 0x3db720
movl %eax, -0x60(%rbp)
movq -0x10(%rbp), %rdi
movl -0x5c(%rbp), %esi
movl -0x60(%rbp), %edx
movq -0x28(%rbp), %rcx
addq $0x18, %rcx
leaq -0x40(%rbp), %r8
callq 0x3dffd0
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
leaq -0x40(%rbp), %rsi
movq -0x58(%rbp), %rcx
movl $0x18, %edx
callq 0x3c6930
movl %eax, -0x1c(%rbp)
jmp 0x3de352
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x3de298
movq -0x28(%rbp), %rdi
callq 0x3c0800
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)