// File: /workspace/github_c_makefile_star2_O3/shifengbin[P]bishe/Output/../Persistence/sqlite3.c
// Function: sqlite3_wal_checkpoint_v2
SQLITE_STDCALL sqlite3_wal_checkpoint_v2(
  sqlite3 *db,                    /* Database handle */
  const char *zDb,                /* Name of attached database (or NULL) */
  int eMode,                      /* SQLITE_CHECKPOINT_* value */
  int *pnLog,                     /* OUT: Size of WAL log in frames */
  int *pnCkpt                     /* OUT: Total number of frames checkpointed */
){
#ifdef SQLITE_OMIT_WAL
  return SQLITE_OK;
#else
  int rc;                         /* Return code */
  int iDb = SQLITE_MAX_ATTACHED;  /* sqlite3.aDb[] index of db to checkpoint */

#ifdef SQLITE_ENABLE_API_ARMOR
  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
#endif

  /* Initialize the output variables to -1 in case an error occurs. */
  if( pnLog ) *pnLog = -1;
  if( pnCkpt ) *pnCkpt = -1;

  assert( SQLITE_CHECKPOINT_PASSIVE==0 );
  assert( SQLITE_CHECKPOINT_FULL==1 );
  assert( SQLITE_CHECKPOINT_RESTART==2 );
  assert( SQLITE_CHECKPOINT_TRUNCATE==3 );
  if( eMode<SQLITE_CHECKPOINT_PASSIVE || eMode>SQLITE_CHECKPOINT_TRUNCATE ){
    /* EVIDENCE-OF: R-03996-12088 The M parameter must be a valid checkpoint
    ** mode: */
    return SQLITE_MISUSE;
  }

  sqlite3_mutex_enter(db->mutex);
  if( zDb && zDb[0] ){
    iDb = sqlite3FindDbName(db, zDb);
  }
  if( iDb<0 ){
    rc = SQLITE_ERROR;
    sqlite3ErrorWithMsg(db, SQLITE_ERROR, "unknown database: %s", zDb);
  }else{
    db->busyHandler.nBusy = 0;
    rc = sqlite3Checkpoint(db, iDb, eMode, pnLog, pnCkpt);
    sqlite3Error(db, rc);
  }
  rc = sqlite3ApiExit(db, rc);
  sqlite3_mutex_leave(db->mutex);
  return rc;
#endif
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r8, %r15
movq %rcx, %r12
movl %edx, %r13d
movq %rsi, %rax
movq %rdi, %rbx
testq %rcx, %rcx
je 0x19799
movl $0xffffffff, (%r12)     # imm = 0xFFFFFFFF
testq %r15, %r15
je 0x197a5
movl $0xffffffff, (%r15)     # imm = 0xFFFFFFFF
movl $0x15, %r14d
cmpl $0x3, %r13d
ja 0x19885
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x197ca
movq %rax, %r14
callq *0x77bf1(%rip)          # 0x913b8
movq %r14, %rax
movl $0xa, %esi
testq %rax, %rax
je 0x197ed
cmpb $0x0, (%rax)
je 0x197ed
movq %rbx, %rdi
movq %rax, %rsi
movq %rax, %r14
callq 0x19897
movl %eax, %esi
testl %eax, %eax
js 0x19834
movl $0x0, 0x2b8(%rbx)
movq %rbx, %rdi
movl %r13d, %edx
movq %r12, %rcx
movq %r15, %r8
callq 0x19936
movl %eax, %r14d
movl %eax, 0x44(%rbx)
movq 0x140(%rbx), %rdi
testq %rdi, %rdi
je 0x19853
movzwl 0x8(%rdi), %eax
testl $0x2460, %eax           # imm = 0x2460
je 0x1982c
callq 0x2a210
jmp 0x19853
movw $0x1, 0x8(%rdi)
jmp 0x19853
movq %r14, %rcx
leaq 0x61978(%rip), %rdx     # 0x7b1b6
movl $0x1, %r14d
movq %rbx, %rdi
movl $0x1, %esi
xorl %eax, %eax
callq 0xf060
cmpl $0xc0a, %r14d           # imm = 0xC0A
je 0x19868
cmpb $0x0, 0x51(%rbx)
jne 0x19868
andl 0x48(%rbx), %r14d
jmp 0x19876
movq %rbx, %rdi
callq 0x28667
movl $0x7, %r14d
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x19885
callq *0x77b43(%rip)          # 0x913c8
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq