// File: /workspace/github_c_makefile_star2_O0/shifengbin[P]bishe/Output/../Persistence/sqlite3.c
// Function: pcacheManageDirtyList
static void pcacheManageDirtyList(PgHdr *pPage, u8 addRemove){
  PCache *p = pPage->pCache;

  if( addRemove & PCACHE_DIRTYLIST_REMOVE ){
    assert( pPage->pDirtyNext || pPage==p->pDirtyTail );
    assert( pPage->pDirtyPrev || pPage==p->pDirty );
  
    /* Update the PCache1.pSynced variable if necessary. */
    if( p->pSynced==pPage ){
      PgHdr *pSynced = pPage->pDirtyPrev;
      while( pSynced && (pSynced->flags&PGHDR_NEED_SYNC) ){
        pSynced = pSynced->pDirtyPrev;
      }
      p->pSynced = pSynced;
    }
  
    if( pPage->pDirtyNext ){
      pPage->pDirtyNext->pDirtyPrev = pPage->pDirtyPrev;
    }else{
      assert( pPage==p->pDirtyTail );
      p->pDirtyTail = pPage->pDirtyPrev;
    }
    if( pPage->pDirtyPrev ){
      pPage->pDirtyPrev->pDirtyNext = pPage->pDirtyNext;
    }else{
      assert( pPage==p->pDirty );
      p->pDirty = pPage->pDirtyNext;
      if( p->pDirty==0 && p->bPurgeable ){
        assert( p->eCreate==1 );
        p->eCreate = 2;
      }
    }
    pPage->pDirtyNext = 0;
    pPage->pDirtyPrev = 0;
  }
  if( addRemove & PCACHE_DIRTYLIST_ADD ){
    assert( pPage->pDirtyNext==0 && pPage->pDirtyPrev==0 && p->pDirty!=pPage );
  
    pPage->pDirtyNext = p->pDirty;
    if( pPage->pDirtyNext ){
      assert( pPage->pDirtyNext->pDirtyPrev==0 );
      pPage->pDirtyNext->pDirtyPrev = pPage;
    }else{
      p->pDirtyTail = pPage;
      if( p->bPurgeable ){
        assert( p->eCreate==2 );
        p->eCreate = 1;
      }
    }
    p->pDirty = pPage;
    if( !p->pSynced && 0==(pPage->flags&PGHDR_NEED_SYNC) ){
      p->pSynced = pPage;
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movb %sil, %al
movq %rdi, -0x8(%rbp)
movb %al, -0x9(%rbp)
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x18(%rbp)
movzbl -0x9(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x2acf1
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
cmpq -0x8(%rbp), %rax
jne 0x2ac57
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x20(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x20(%rbp)
movb %al, -0x21(%rbp)
je 0x2ac34
movq -0x20(%rbp), %rax
movzwl 0x2c(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x21(%rbp)
movb -0x21(%rbp), %al
testb $0x1, %al
jne 0x2ac3d
jmp 0x2ac4b
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x2ac14
movq -0x20(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x38(%rax)
je 0x2ac78
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq %rcx, 0x40(%rax)
jmp 0x2ac88
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0x2aca9
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq %rcx, 0x38(%rax)
jmp 0x2acd9
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x2acd7
movq -0x18(%rbp), %rax
movzbl 0x2c(%rax), %eax
cmpl $0x0, %eax
je 0x2acd7
movq -0x18(%rbp), %rax
movb $0x2, 0x2d(%rax)
jmp 0x2acd9
movq -0x8(%rbp), %rax
movq $0x0, 0x38(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0x40(%rax)
movzbl -0x9(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x2ad82
movq -0x18(%rbp), %rax
movq (%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x38(%rax)
je 0x2ad2d
movq -0x8(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq %rcx, 0x40(%rax)
jmp 0x2ad4d
movq -0x8(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
cmpb $0x0, 0x2c(%rax)
je 0x2ad4b
movq -0x18(%rbp), %rax
movb $0x1, 0x2d(%rax)
jmp 0x2ad4d
movq -0x8(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x2ad80
movq -0x8(%rbp), %rax
movzwl 0x2c(%rax), %ecx
andl $0x8, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x2ad80
movq -0x8(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x2ad82
popq %rbp
retq
nopw %cs:(%rax,%rax)