// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: sqlite3_backup_init
SQLITE_API sqlite3_backup *sqlite3_backup_init(
  sqlite3* pDestDb,                     /* Database to write to */
  const char *zDestDb,                  /* Name of database within pDestDb */
  sqlite3* pSrcDb,                      /* Database connection to read from */
  const char *zSrcDb                    /* Name of database within pSrcDb */
){
  sqlite3_backup *p;                    /* Value to return */

#ifdef SQLITE_ENABLE_API_ARMOR
  if( !sqlite3SafetyCheckOk(pSrcDb)||!sqlite3SafetyCheckOk(pDestDb) ){
    (void)SQLITE_MISUSE_BKPT;
    return 0;
  }
#endif

  /* Lock the source database handle. The destination database
  ** handle is not locked in this routine, but it is locked in
  ** sqlite3_backup_step(). The user is required to ensure that no
  ** other thread accesses the destination handle for the duration
  ** of the backup operation.  Any attempt to use the destination
  ** database connection while a backup is in progress may cause
  ** a malfunction or a deadlock.
  */
  sqlite3_mutex_enter(pSrcDb->mutex);
  sqlite3_mutex_enter(pDestDb->mutex);

  if( pSrcDb==pDestDb ){
    sqlite3ErrorWithMsg(
        pDestDb, SQLITE_ERROR, "source and destination must be distinct"
    );
    p = 0;
  }else {
    /* Allocate space for a new sqlite3_backup object...
    ** EVIDENCE-OF: R-64852-21591 The sqlite3_backup object is created by a
    ** call to sqlite3_backup_init() and is destroyed by a call to
    ** sqlite3_backup_finish(). */
    p = (sqlite3_backup *)sqlite3MallocZero(sizeof(sqlite3_backup));
    if( !p ){
      sqlite3Error(pDestDb, SQLITE_NOMEM_BKPT);
    }
  }

  /* If the allocation succeeded, populate the new object. */
  if( p ){
    p->pSrc = findBtree(pDestDb, pSrcDb, zSrcDb);
    p->pDest = findBtree(pDestDb, pDestDb, zDestDb);
    p->pDestDb = pDestDb;
    p->pSrcDb = pSrcDb;
    p->iNext = 1;
    p->isAttached = 0;

    if( 0==p->pSrc || 0==p->pDest
     || checkReadTransaction(pDestDb, p->pDest)!=SQLITE_OK
     ){
      /* One (or both) of the named databases did not exist or an OOM
      ** error was hit. Or there is a transaction open on the destination
      ** database. The error has already been written into the pDestDb
      ** handle. All that is left to do here is free the sqlite3_backup
      ** structure.  */
      sqlite3_free(p);
      p = 0;
    }
  }
  if( p ){
    p->pSrc->nBackup++;
  }

  sqlite3_mutex_leave(pDestDb->mutex);
  sqlite3_mutex_leave(pSrcDb->mutex);
  return p;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %r14
cmpq %rdi, %rdx
je 0x276297
movq %rcx, %r13
movq %rdx, %r15
movq %rsi, %r12
movl $0x48, %edi
callq 0x272ae6
testq %rax, %rax
je 0x2762b1
movq %rax, %rbx
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
movq $0x0, 0x40(%rax)
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x27643f
movq %rax, 0x28(%rbx)
movq %r14, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x27643f
movq %rax, 0x8(%rbx)
movq %r14, (%rbx)
movq %r15, 0x20(%rbx)
movl $0x1, 0x18(%rbx)
movl $0x0, 0x3c(%rbx)
movq 0x28(%rbx), %rcx
testq %rcx, %rcx
sete %dl
testq %rax, %rax
sete %sil
orb %dl, %sil
jne 0x27626a
cmpb $0x0, 0x10(%rax)
je 0x2762d5
leaq 0x15faca(%rip), %rdx    # 0x3d5d25
movq %r14, %rdi
movl $0x1, %esi
xorl %eax, %eax
callq 0x2762da
cmpl $0x0, 0x2453ef(%rip)    # 0x4bb660
je 0x27628c
movq %rbx, %rdi
callq *0x24541c(%rip)         # 0x4bb698
cltq
subq %rax, 0x248873(%rip)    # 0x4beaf8
decq 0x2488b4(%rip)          # 0x4beb40
movq %rbx, %rdi
callq *0x2453f3(%rip)         # 0x4bb688
jmp 0x2762c6
leaq 0x15f634(%rip), %rdx    # 0x3d58d2
xorl %ebx, %ebx
movq %r14, %rdi
movl $0x1, %esi
xorl %eax, %eax
callq 0x2762da
jmp 0x2762c8
movl $0x7, 0x50(%r14)
movq %r14, %rdi
movl $0x7, %esi
callq 0x284b1f
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
incl 0x18(%rcx)
jmp 0x2762c8