// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movl $0xa, -0x38(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x3d22e3
movq -0x28(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
cmpq $0x0, -0x30(%rbp)
je 0x3d22f4
movq -0x30(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
cmpl $0x0, -0x1c(%rbp)
jl 0x3d2300
cmpl $0x3, -0x1c(%rbp)
jle 0x3d230c
movl $0x15, -0x4(%rbp)
jmp 0x3d23c3
cmpq $0x0, -0x18(%rbp)
je 0x3d232f
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x3d232f
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x3d23d0
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
jge 0x3d2359
movl $0x1, -0x34(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rcx
movl $0x1, %esi
leaq 0x1d8af4(%rip), %rdx    # 0x5aae44
movb $0x0, %al
callq 0x3c50b0
jmp 0x3d238d
movq -0x10(%rbp), %rax
movl $0x0, 0x260(%rax)
movq -0x10(%rbp), %rdi
movl -0x38(%rbp), %esi
movl -0x1c(%rbp), %edx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
callq 0x3d2480
movl %eax, -0x34(%rbp)
movq -0x10(%rbp), %rdi
movl -0x34(%rbp), %esi
callq 0x3c5210
movq -0x10(%rbp), %rdi
movl -0x34(%rbp), %esi
callq 0x3c7380
movl %eax, -0x34(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0xc0(%rax)
jne 0x3d23bd
movq -0x10(%rbp), %rax
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %ecx
movl %ecx, 0x168(%rax)
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)