// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: sqlite3_wal_checkpoint_v2
SQLITE_API int 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);

  /* If there are no active statements, clear the interrupt flag at this
  ** point.  */
  if( db->nVdbeActive==0 ){
    AtomicStore(&db->u1.isInterrupted, 0);
  }

  sqlite3_mutex_leave(db->mutex);
  return rc;
#endif
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r8, %r14
movq %rcx, %r15
movl %edx, %r12d
movq %rsi, %r13
movq %rdi, %rbx
testq %rcx, %rcx
je 0x280093
movl $0xffffffff, (%r15)     # imm = 0xFFFFFFFF
testq %r14, %r14
je 0x28009f
movl $0xffffffff, (%r14)     # imm = 0xFFFFFFFF
movl $0x15, %ebp
cmpl $0x3, %r12d
ja 0x28013b
movl $0xa, %esi
testq %r13, %r13
je 0x2800d0
cmpb $0x0, (%r13)
je 0x2800d0
movq %rbx, %rdi
movq %r13, %rsi
callq 0x280170
movl %eax, %esi
testl %eax, %eax
js 0x28014c
movl $0x0, 0x260(%rbx)
movq %rbx, %rdi
movl %r12d, %edx
movq %r15, %rcx
movq %r14, %r8
callq 0x28021e
movl %eax, %ebp
movl %eax, 0x50(%rbx)
testl %eax, %eax
jne 0x2800fe
cmpq $0x0, 0x160(%rbx)
je 0x28016c
movq %rbx, %rdi
movl %ebp, %esi
callq 0x284b1f
cmpl $0xc0a, %ebp            # imm = 0xC0A
je 0x28011b
cmpb $0x0, 0x61(%rbx)
jne 0x28011b
andl 0x54(%rbx), %ebp
jmp 0x280128
movq %rbx, %rdi
callq 0x28fd56
movl $0x7, %ebp
cmpl $0x0, 0xc0(%rbx)
jne 0x28013b
movl $0x0, 0x168(%rbx)
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x155872(%rip), %rdx    # 0x3d59c5
movl $0x1, %ebp
movq %rbx, %rdi
movl $0x1, %esi
movq %r13, %rcx
xorl %eax, %eax
callq 0x2762da
jmp 0x280108
xorl %ebp, %ebp
jmp 0x280108