// File: /workspace/github_c_makefile_star2_O2/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: unqlite_open
int unqlite_open(unqlite **ppDB,const char *zFilename,unsigned int iMode)
{
	unqlite *pHandle;
	int rc;
#if defined(UNTRUST)
	if( ppDB == 0 ){
		return UNQLITE_CORRUPT;
	}
#endif
	*ppDB = 0;
	/* One-time automatic library initialization */
	rc = unqliteCoreInitialize();
	if( rc != UNQLITE_OK ){
		return rc;
	}
	/* Allocate a new database handle */
	pHandle = (unqlite *)SyMemBackendPoolAlloc(&sUnqlMPGlobal.sAllocator, sizeof(unqlite));
	if( pHandle == 0 ){
		return UNQLITE_NOMEM;
	}
	/* Zero the structure */
	SyZero(pHandle,sizeof(unqlite));
	if( iMode < 1 ){
		/* Assume a read-only database */
		iMode = UNQLITE_OPEN_READONLY|UNQLITE_OPEN_MMAP;
	}
	/* Init the database */
	rc = unqliteInitDatabase(pHandle,&sUnqlMPGlobal.sAllocator,zFilename,iMode);
	if( rc != UNQLITE_OK ){
		goto Release;
	}
#if defined(UNQLITE_ENABLE_THREADS)
	if( !(iMode & UNQLITE_OPEN_NOMUTEX) && (sUnqlMPGlobal.nThreadingLevel > UNQLITE_THREAD_LEVEL_SINGLE) ){
		 /* Associate a recursive mutex with this instance */
		 pHandle->pMutex = SyMutexNew(sUnqlMPGlobal.pMutexMethods, SXMUTEX_TYPE_RECURSIVE);
		 if( pHandle->pMutex == 0 ){
			 rc = UNQLITE_NOMEM;
			 goto Release;
		 }
	 }
#endif
	/* Link to the list of active DB handles */
#if defined(UNQLITE_ENABLE_THREADS)
	/* Enter the global mutex */
	 SyMutexEnter(sUnqlMPGlobal.pMutexMethods, sUnqlMPGlobal.pMutex); /* NO-OP if sUnqlMPGlobal.nThreadingLevel == UNQLITE_THREAD_LEVEL_SINGLE */
#endif
	 MACRO_LD_PUSH(sUnqlMPGlobal.pDB,pHandle);
	 sUnqlMPGlobal.nDB++;
#if defined(UNQLITE_ENABLE_THREADS)
	/* Leave the global mutex */
	 SyMutexLeave(sUnqlMPGlobal.pMutexMethods, sUnqlMPGlobal.pMutex); /* NO-OP if sUnqlMPGlobal.nThreadingLevel == UNQLITE_THREAD_LEVEL_SINGLE */
#endif
	/* Set the magic number to identify a valid DB handle */
	 pHandle->nMagic = UNQLITE_DB_MAGIC;
	/* Make the handle available to the caller */
	*ppDB = pHandle;
	return UNQLITE_OK;
Release:
	SyMemBackendRelease(&pHandle->sMem);
	SyMemBackendPoolFree(&sUnqlMPGlobal.sAllocator,pHandle);
	return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %edx, %r13d
movq %rsi, %r14
movq %rdi, %r15
andq $0x0, (%rdi)
callq 0x26f8e
movl %eax, %r12d
testl %eax, %eax
jne 0x276bd
leaq 0x603af(%rip), %rdi     # 0x876e0
movl $0x128, %esi            # imm = 0x128
callq 0x279f7
testq %rax, %rax
je 0x273d2
movq %rax, %rbx
movq %r14, -0x30(%rbp)
movq %rax, %rdi
movl $0x128, %esi            # imm = 0x128
callq 0x27aea
testl %r13d, %r13d
movl $0x101, %r12d           # imm = 0x101
cmovnel %r13d, %r12d
leaq 0x60374(%rip), %rsi     # 0x876e0
movq %rbx, %rdi
callq 0x2eaa1
movq %rbx, %rdi
callq 0x2eaf6
xorps %xmm0, %xmm0
movups %xmm0, 0xc0(%rbx)
movq %rbx, 0xb8(%rbx)
andl $0x0, 0xd0(%rbx)
movl %r12d, %eax
andl $-0x9, %eax
movl %eax, %ecx
orl $0x44, %ecx
testb $0x10, %r12b
cmovel %eax, %ecx
movl %ecx, %r14d
orl $0x2, %r14d
testb $0x3, %cl
cmovnel %ecx, %r14d
testb $0x4, %r14b
jne 0x273db
testb $0x1, %r14b
jne 0x273e8
movl %r14d, %eax
andl $0xfffffef2, %eax       # imm = 0xFFFFFEF2
testb $0x2, %r14b
cmovnel %eax, %r14d
jmp 0x273ec
pushq $-0x1
popq %r12
jmp 0x276bd
andl $0xfffffef4, %r14d      # imm = 0xFFFFFEF4
orl $0x2, %r14d
jmp 0x273ec
andl $-0xf, %r14d
movq 0x603ed(%rip), %r13     # 0x877e0
cmpq $0x0, -0x30(%rbp)
je 0x27467
movl %r14d, %eax
andl $0x80, %eax
jne 0x27467
movq -0x30(%rbp), %rax
cmpb $0x0, (%rax)
je 0x27467
movq -0x30(%rbp), %rdi
callq 0x28e24
cmpl $0x8, %eax
je 0x2742b
cmpl $0x5, %eax
jne 0x27442
leaq 0x3c53c(%rip), %rsi     # 0x63963
pushq $0x5
jmp 0x27434
leaq 0x3c537(%rip), %rsi     # 0x63969
pushq $0x8
popq %rdx
movq -0x30(%rbp), %rdi
callq 0x32436
testl %eax, %eax
je 0x27467
leaq 0x3c446(%rip), %rdi     # 0x6388f
pushq $0x4
popq %rsi
callq 0x32082
testq %rax, %rax
jne 0x27486
leaq 0x3c4bd(%rip), %rdi     # 0x6391a
pushq $0x5
popq %rsi
callq 0x32082
jmp 0x2747d
leaq 0x3c3d9(%rip), %rdi     # 0x63847
pushq $0x3
popq %rsi
callq 0x32082
orl $0x80, %r14d
testq %rax, %rax
je 0x27613
movq %rax, -0x60(%rbp)
movl %r12d, -0x3c(%rbp)
movq %r15, -0x58(%rbp)
movq %rbx, -0x38(%rbp)
movl %r14d, %r15d
andl $0x80, %r15d
movl %r15d, %ecx
shrl $0x7, %ecx
movl %r14d, %eax
shrl $0x6, %eax
andl $0x1, %eax
testl %r15d, %r15d
pushq $0x1
popq %rdx
cmovel %eax, %edx
movl %edx, -0x40(%rbp)
movl %ecx, -0x44(%rbp)
testl %ecx, %ecx
movq %r13, -0x68(%rbp)
jne 0x274e4
movq -0x30(%rbp), %rdi
callq 0x28e24
movl 0x10(%r13), %edx
movq %rax, -0x50(%rbp)
leal (%rax,%rdx), %r12d
addl $0x261, %r12d           # imm = 0x261
jmp 0x274f2
movq $0x0, -0x50(%rbp)
movl $0x260, %r12d           # imm = 0x260
movq -0x38(%rbp), %rbx
movq %rbx, %rdi
movl %r12d, %esi
callq 0x2ca19
testq %rax, %rax
je 0x27626
movq %rax, %r13
movq %rax, %rdi
movl %r12d, %esi
callq 0x27aea
movq %rbx, (%r13)
movq %rbx, 0x8(%r13)
movq %r13, 0xd8(%rbx)
movl $0x80, 0x250(%r13)
movq %rbx, %rdi
movl $0x400, %esi            # imm = 0x400
callq 0x2ca19
movq %rax, 0x248(%r13)
pushq $-0x1
popq %r12
testq %rax, %rax
je 0x2762c
movl %r14d, %ebx
andl $0x1, %ebx
movq %rax, %rdi
movl $0x400, %esi            # imm = 0x400
callq 0x27aea
movl -0x44(%rbp), %eax
movl %eax, 0x1fc(%r13)
movl -0x40(%rbp), %eax
movl %eax, 0x204(%r13)
movl %ebx, 0x200(%r13)
movl %r14d, 0x16c(%r13)
movq -0x68(%rbp), %rbx
movq %rbx, 0x28(%r13)
leaq 0x64(%r13), %r14
movq %r14, %rdi
callq 0x320f6
leaq 0x168(%r13), %rsi
pushq $0x4
popq %rdx
movq %r14, %rdi
callq 0x321c8
orl $-0x1, 0x258(%r13)
testl %r15d, %r15d
jne 0x27684
movq %r13, %rcx
addq $0x260, %rcx            # imm = 0x260
movq %rcx, 0x18(%r13)
movq %rbx, %rdi
movq 0x30(%rbx), %rax
testq %rax, %rax
movq -0x38(%rbp), %rbx
je 0x27632
movl 0x10(%rdi), %edx
movq -0x50(%rbp), %r15
addl %r15d, %edx
movq -0x30(%rbp), %r14
movq %r14, %rsi
callq *%rax
movq 0x18(%r13), %rcx
testl %eax, %eax
je 0x27632
movq %r14, %rdi
movq %rcx, %rsi
movl %r15d, %edx
callq 0x2d3b0
movq 0x18(%r13), %rax
movl %r15d, %ecx
movb $0x0, (%rax,%rcx)
jmp 0x2763d
leaq 0x3c306(%rip), %rsi     # 0x63920
movq %rbx, %rdi
callq 0x2a542
pushq $-0x11
jmp 0x27628
pushq $-0x1
popq %r12
jmp 0x276a6
movq -0x38(%rbp), %rbx
jmp 0x2769b
movq %rcx, %rdi
callq 0x28e24
movl %eax, %r15d
movq (%r13), %rdi
leal 0x12(%r15), %esi
callq 0x2ca19
movq %rax, 0x20(%r13)
testq %rax, %rax
je 0x2769b
movl %r15d, %ebx
movq 0x18(%r13), %rdi
movq %rax, %rsi
movl %r15d, %edx
callq 0x2d3b0
movq 0x20(%r13), %rsi
addq %rbx, %rsi
leaq 0x3c2df(%rip), %rdi     # 0x63952
pushq $0x10
popq %rdx
callq 0x2d3b0
movq 0x20(%r13), %rax
movb $0x0, 0x10(%rax,%rbx)
movq %r13, %rdi
movq -0x60(%rbp), %rsi
callq 0x3223e
movl %eax, %r12d
testl %eax, %eax
movq -0x38(%rbp), %rbx
je 0x276cf
movq %rbx, %rdi
movq %r13, %rsi
callq 0x2d420
movq %rbx, %rdi
callq 0x27b23
leaq 0x6002b(%rip), %rdi     # 0x876e0
movq %rbx, %rsi
callq 0x27bf8
movl %r12d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
cmpl $0x0, 0x1fc(%r13)
setne %al
leal (%rax,%rax,4), %ecx
shll $0x2, %eax
movl %ecx, 0x1f0(%r13)
movl %eax, 0x1f4(%r13)
andq $0x0, 0xe0(%rbx)
cmpl $0xea1495ba, 0x609ee(%rip) # imm = 0xEA1495BA
je 0x277c6
leaq 0x5f061(%rip), %rsi     # 0x86770
xorl %r13d, %r13d
pushq $0x6
popq %rdi
xorl %eax, %eax
callq 0x2bf6b
movl 0x609ad(%rip), %r14d    # 0x880d0
cmpl $0x1, %r14d
jne 0x2772e
xorl %r15d, %r15d
jmp 0x27758
movq 0x6098b(%rip), %r15     # 0x880c0
testq %r15, %r15
je 0x2799a
pushq $0x3
popq %rdi
callq *0x10(%r15)
testq %rax, %rax
je 0x279be
movq %rax, %r13
movq %rax, %rdi
callq *0x20(%r15)
cmpl $0xea1495ba, 0x6098e(%rip) # imm = 0xEA1495BA
je 0x277ad
cmpq $0x0, 0x608a4(%rip)     # 0x88010
je 0x279c5
cmpl $0x2, 0x60957(%rip)     # 0x880d0
jb 0x277a3
movq 0x6093e(%rip), %rbx     # 0x880c0
pushq $0x1
popq %rdi
callq *0x10(%rbx)
testq %rax, %rax
je 0x279ea
movq %rax, 0x608a0(%rip)     # 0x88038
movq %rbx, 0x60869(%rip)     # 0x88008
movq -0x38(%rbp), %rbx
movl $0xea1495ba, 0x60943(%rip) # imm = 0xEA1495BA
xorl %r12d, %r12d
cmpl $0x1, %r14d
je 0x277bd
movq %r13, %rdi
callq *0x30(%r15)
testl %r12d, %r12d
jne 0x276a6
leaq 0x6083b(%rip), %rdi     # 0x88008
movl $0x120, %esi            # imm = 0x120
callq 0x279f7
pushq $-0x1
popq %r12
testq %rax, %rax
je 0x276a6
movq %rax, %r15
movq %rax, %rdi
movl $0x120, %esi            # imm = 0x120
callq 0x27aea
movl $0xf874bcd7, 0x118(%r15) # imm = 0xF874BCD7
leaq 0x60802(%rip), %rsi     # 0x88008
movq %r15, %rdi
callq 0x2eaa1
movl %eax, %r13d
testl %eax, %eax
je 0x27834
movq %r15, %rdi
callq 0x27b23
leaq 0x607e4(%rip), %rdi     # 0x88008
movq %r15, %rsi
callq 0x27bf8
movl %r13d, %r12d
jmp 0x276a6
movq %r15, %rdi
callq 0x2eaf6
movq %r15, %rax
xorps %xmm0, %xmm0
movups %xmm0, 0xd8(%r15)
movq %r15, 0xd0(%r15)
andl $0x0, 0xe8(%r15)
addq $0xd0, %rax
leaq 0xc8b8(%rip), %rcx      # 0x3411e
movq %rcx, 0xc0(%r15)
movq %rax, 0xc8(%r15)
movq 0x6085d(%rip), %rax     # 0x880d8
movq %rax, 0xb8(%r15)
cmpl $0x2, 0x60847(%rip)     # 0x880d0
jb 0x278a8
movq 0x6082e(%rip), %rax     # 0x880c0
pushq $0x2
popq %rdi
callq *0x10(%rax)
movq %rax, 0xf0(%r15)
testq %rax, %rax
je 0x279e1
movq 0x60819(%rip), %rdi     # 0x880c8
testq %rdi, %rdi
je 0x278be
movq 0x60805(%rip), %rax     # 0x880c0
callq *0x20(%rax)
movq 0x60823(%rip), %rax     # 0x880e8
testq %rax, %rax
je 0x278d8
movq %rax, 0x108(%r15)
movq %r15, 0x110(%rax)
movq %r15, 0x60809(%rip)     # 0x880e8
incl 0x607fb(%rip)           # 0x880e0
movq 0x607dc(%rip), %rdi     # 0x880c8
testq %rdi, %rdi
je 0x278fb
movq 0x607c8(%rip), %rax     # 0x880c0
callq *0x30(%rax)
movq %r15, 0xe0(%rbx)
testb $0x20, -0x3c(%rbp)
jne 0x2792e
cmpl $0x2, 0x5fe99(%rip)     # 0x877a8
jb 0x2792e
movq 0x5fe80(%rip), %rax     # 0x87798
pushq $0x2
popq %rdi
callq *0x10(%rax)
movq %rax, 0xf8(%rbx)
testq %rax, %rax
je 0x276a6
movq 0x5fe6b(%rip), %rdi     # 0x877a0
testq %rdi, %rdi
je 0x27944
movq 0x5fe57(%rip), %rax     # 0x87798
callq *0x20(%rax)
movq 0x5fea5(%rip), %rax     # 0x877f0
testq %rax, %rax
movq -0x58(%rbp), %r14
je 0x27962
movq %rax, 0x110(%rbx)
movq %rbx, 0x118(%rax)
movq %rbx, 0x5fe87(%rip)     # 0x877f0
incl 0x5fe79(%rip)           # 0x877e8
movq 0x5fe2a(%rip), %rdi     # 0x877a0
testq %rdi, %rdi
je 0x27985
movq 0x5fe16(%rip), %rax     # 0x87798
callq *0x30(%rax)
movl $0xdb7c2712, 0x120(%rbx) # imm = 0xDB7C2712
movq %rbx, (%r14)
xorl %r12d, %r12d
jmp 0x276bd
leaq 0x5c5df(%rip), %r15     # 0x83f80
pushq $0x3
popq %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x2bf6b
movl %eax, %r12d
testl %eax, %eax
jne 0x276a6
jmp 0x2773e
pushq $-0x18
jmp 0x27628
pushq $0x1
popq %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x2bf6b
movl %eax, %r12d
testl %eax, %eax
jne 0x277b0
jmp 0x27772
pushq $-0x1
popq %r13
jmp 0x27815
pushq $-0x17
popq %r12
movq -0x38(%rbp), %rbx
jmp 0x277b0