// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: walCleanupHash
static void walCleanupHash(Wal *pWal){
  WalHashLoc sLoc;                /* Hash table location */
  int iLimit = 0;                 /* Zero values greater than this */
  int nByte;                      /* Number of bytes to zero in aPgno[] */
  int i;                          /* Used to iterate through aHash[] */
  int rc;                         /* Return code form walHashGet() */

  assert( pWal->writeLock );
  testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE-1 );
  testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE );
  testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE+1 );

  if( pWal->hdr.mxFrame==0 ) return;

  /* Obtain pointers to the hash-table and page-number array containing
  ** the entry that corresponds to frame pWal->hdr.mxFrame. It is guaranteed
  ** that the page said hash-table and array reside on is already mapped.(1)
  */
  assert( pWal->nWiData>walFramePage(pWal->hdr.mxFrame) );
  assert( pWal->apWiData[walFramePage(pWal->hdr.mxFrame)] );
  rc = walHashGet(pWal, walFramePage(pWal->hdr.mxFrame), &sLoc);
  if( NEVER(rc) ) return; /* Defense-in-depth, in case (1) above is wrong */

  /* Zero all hash-table entries that correspond to frame numbers greater
  ** than pWal->hdr.mxFrame.
  */
  iLimit = pWal->hdr.mxFrame - sLoc.iZero;
  assert( iLimit>0 );
  for(i=0; i<HASHTABLE_NSLOT; i++){
    if( sLoc.aHash[i]>iLimit ){
      sLoc.aHash[i] = 0;
    }
  }

  /* Zero the entries in the aPgno array that correspond to frames with
  ** frame numbers greater than pWal->hdr.mxFrame.
  */
  nByte = (int)((char *)sLoc.aHash - (char *)&sLoc.aPgno[iLimit+1]);
  memset((void *)&sLoc.aPgno[iLimit+1], 0, nByte);

#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT
  /* Verify that the every entry in the mapping region is still reachable
  ** via the hash table even after the cleanup.
  */
  if( iLimit ){
    int j;           /* Loop counter */
    int iKey;        /* Hash key */
    for(j=1; j<=iLimit; j++){
      for(iKey=walHash(sLoc.aPgno[j]);sLoc.aHash[iKey];iKey=walNextHash(iKey)){
        if( sLoc.aHash[iKey]==j ) break;
      }
      assert( sLoc.aHash[iKey]==j );
    }
  }
#endif /* SQLITE_ENABLE_EXPENSIVE_ASSERT */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x58(%rax)
jne 0x3e0262
jmp 0x3e031b
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movl 0x58(%rax), %edi
callq 0x3dfc40
movq -0x38(%rbp), %rdi
movl %eax, %esi
leaq -0x20(%rbp), %rdx
callq 0x3dfeb0
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
je 0x3e0293
jmp 0x3e031b
movq -0x8(%rbp), %rax
movl 0x58(%rax), %eax
subl -0x10(%rbp), %eax
movl %eax, -0x24(%rbp)
movl $0x0, -0x2c(%rbp)
cmpl $0x2000, -0x2c(%rbp)    # imm = 0x2000
jge 0x3e02df
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movw (%rax,%rcx,2), %ax
movzwl %ax, %eax
cmpl -0x24(%rbp), %eax
jle 0x3e02d2
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movw $0x0, (%rax,%rcx,2)
jmp 0x3e02d4
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x3e02a7
movq -0x20(%rbp), %rax
movq -0x18(%rbp), %rcx
movl -0x24(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
shlq $0x2, %rdx
addq %rdx, %rcx
subq %rcx, %rax
movl %eax, -0x28(%rbp)
movq -0x18(%rbp), %rdi
movl -0x24(%rbp), %eax
addl $0x1, %eax
cltq
shlq $0x2, %rax
addq %rax, %rdi
movslq -0x28(%rbp), %rdx
xorl %esi, %esi
callq 0x19360
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)