// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: pcache1TruncateUnsafe
static void pcache1TruncateUnsafe(
  PCache1 *pCache,             /* The cache to truncate */
  unsigned int iLimit          /* Drop pages with this pgno or larger */
){
  TESTONLY( int nPage = 0; )  /* To assert pCache->nPage is correct */
  unsigned int h, iStop;
  assert( sqlite3_mutex_held(pCache->pGroup->mutex) );
  assert( pCache->iMaxKey >= iLimit );
  assert( pCache->nHash > 0 );
  if( pCache->iMaxKey - iLimit < pCache->nHash ){
    /* If we are just shaving the last few pages off the end of the
    ** cache, then there is no point in scanning the entire hash table.
    ** Only scan those hash slots that might contain pages that need to
    ** be removed. */
    h = iLimit % pCache->nHash;
    iStop = pCache->iMaxKey % pCache->nHash;
    TESTONLY( nPage = -10; )  /* Disable the pCache->nPage validity check */
  }else{
    /* This is the general case where many pages are being removed.
    ** It is necessary to scan the entire hash table */
    h = pCache->nHash/2;
    iStop = h - 1;
  }
  for(;;){
    PgHdr1 **pp;
    PgHdr1 *pPage;
    assert( h<pCache->nHash );
    pp = &pCache->apHash[h];
    while( (pPage = *pp)!=0 ){
      if( pPage->iKey>=iLimit ){
        pCache->nPage--;
        *pp = pPage->pNext;
        if( PAGE_IS_UNPINNED(pPage) ) pcache1PinPage(pPage);
        pcache1FreePage(pPage);
      }else{
        pp = &pPage->pNext;
        TESTONLY( if( nPage>=0 ) nPage++; )
      }
    }
    if( h==iStop ) break;
    h = (h+1) % pCache->nHash;
  }
  assert( nPage<0 || pCache->nPage==(unsigned)nPage );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movl 0x2c(%rax), %eax
subl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x3c(%rcx), %eax
jae 0x46e326
movl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
xorl %edx, %edx
divl 0x3c(%rcx)
movl %edx, -0x10(%rbp)
movq -0x8(%rbp), %rax
movl 0x2c(%rax), %eax
movq -0x8(%rbp), %rcx
xorl %edx, %edx
divl 0x3c(%rcx)
movl %edx, -0x14(%rbp)
jmp 0x46e33b
movq -0x8(%rbp), %rax
movl 0x3c(%rax), %eax
shrl %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x46e33d
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movl -0x10(%rbp), %ecx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0x46e3b9
movq -0x28(%rbp), %rax
movl 0x10(%rax), %eax
cmpl -0xc(%rbp), %eax
jb 0x46e3ab
movq -0x8(%rbp), %rax
movl 0x38(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x38(%rax)
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x46e3a0
movq -0x28(%rbp), %rdi
callq 0x46dba0
movq -0x28(%rbp), %rdi
callq 0x46dca0
jmp 0x46e3b7
movq -0x28(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x20(%rbp)
jmp 0x46e353
movl -0x10(%rbp), %eax
cmpl -0x14(%rbp), %eax
jne 0x46e3c3
jmp 0x46e3da
movl -0x10(%rbp), %eax
addl $0x1, %eax
movq -0x8(%rbp), %rcx
xorl %edx, %edx
divl 0x3c(%rcx)
movl %edx, -0x10(%rbp)
jmp 0x46e33d
addq $0x30, %rsp
popq %rbp
retq