// File: /workspace/github_c_makefile_star2_O1/shifengbin[P]bishe/Output/../Persistence/sqlite3.c
// Function: walCleanupHash
static void walCleanupHash(Wal *pWal){
  volatile ht_slot *aHash = 0;    /* Pointer to hash table to clear */
  volatile u32 *aPgno = 0;        /* Page number array for hash table */
  u32 iZero = 0;                  /* frame == (aHash[x]+iZero) */
  int iLimit = 0;                 /* Zero values greater than this */
  int nByte;                      /* Number of bytes to zero in aPgno[] */
  int i;                          /* Used to iterate through aHash[] */

  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.
  */
  assert( pWal->nWiData>walFramePage(pWal->hdr.mxFrame) );
  assert( pWal->apWiData[walFramePage(pWal->hdr.mxFrame)] );
  walHashGet(pWal, walFramePage(pWal->hdr.mxFrame), &aHash, &aPgno, &iZero);

  /* Zero all hash-table entries that correspond to frame numbers greater
  ** than pWal->hdr.mxFrame.
  */
  iLimit = pWal->hdr.mxFrame - iZero;
  assert( iLimit>0 );
  for(i=0; i<HASHTABLE_NSLOT; i++){
    if( aHash[i]>iLimit ){
      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 *)aHash - (char *)&aPgno[iLimit+1]);
  memset((void *)&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(aPgno[j]); aHash[iKey]; iKey=walNextHash(iKey)){
        if( aHash[iKey]==j ) break;
      }
      assert( aHash[iKey]==j );
    }
  }
#endif /* SQLITE_ENABLE_EXPENSIVE_ASSERT */
}

// Assembly:
movl 0x58(%rdi), %eax
testl %eax, %eax
je 0x21965
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
addl $0x1000, %eax           # imm = 0x1000
movabsq $0xffffffff021, %r14    # imm = 0xFFFFFFFF021
addq %rax, %r14
shrq $0xc, %r14
leaq -0x18(%rbp), %rdx
movl %r14d, %esi
callq 0x21120
testl %eax, %eax
je 0x21966
xorl %eax, %eax
xorl %ecx, %ecx
xorl %r14d, %r14d
jmp 0x21995
retq
movq -0x18(%rbp), %rax
testl %r14d, %r14d
je 0x21979
shll $0xc, %r14d
addl $-0x22, %r14d
jmp 0x21987
leaq 0x88(%rax), %rcx
movq %rcx, -0x18(%rbp)
xorl %r14d, %r14d
addq $0x4000, %rax           # imm = 0x4000
movq -0x18(%rbp), %rcx
addq $-0x4, %rcx
movl 0x58(%rbx), %edx
subl %r14d, %edx
xorl %esi, %esi
movzwl (%rax,%rsi,2), %edi
cmpl %edi, %edx
jge 0x219ab
movw $0x0, (%rax,%rsi,2)
incq %rsi
cmpq $0x2000, %rsi           # imm = 0x2000
jne 0x2199d
movslq %edx, %rdx
leaq (%rcx,%rdx,4), %rdi
addq $0x4, %rdi
subl %edi, %eax
movslq %eax, %rdx
xorl %esi, %esi
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0xa210