// File: /workspace/github_c_makefile_star2_O1/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 $0x38, %rsp
movl %edx, %ebx
movq %rsi, %r12
movq %rdi, %r15
movq $0x0, (%rdi)
callq 0x2dd2c
movl %eax, %r13d
testl %eax, %eax
jne 0x2e929
leaq 0x685bd(%rip), %rdi     # 0x966c0
movl $0x128, %esi            # imm = 0x128
callq 0x2e951
testq %rax, %rax
je 0x2e1cf
movq %rax, %r14
movq $-0x4, %rax
movl $0x0, 0x4(%r14,%rax)
addq $0x4, %rax
cmpq $0x124, %rax            # imm = 0x124
jb 0x2e120
testl %ebx, %ebx
movl $0x101, %r13d           # imm = 0x101
cmovnel %ebx, %r13d
leaq 0x68578(%rip), %rsi     # 0x966c0
movq %r14, %rdi
callq 0x36946
movq 0x30(%r14), %rdi
testq %rdi, %rdi
je 0x2e170
movq (%r14), %rax
movq 0x18(%rax), %rax
testq %rax, %rax
je 0x2e167
callq *%rax
xorl %eax, %eax
movq %rax, (%r14)
movq %rax, 0x30(%r14)
movq %r12, -0x30(%rbp)
xorps %xmm0, %xmm0
movups %xmm0, 0xc0(%r14)
movq %r14, 0xb8(%r14)
movl $0x0, 0xd0(%r14)
movl %r13d, %eax
andl $-0x9, %eax
movl %eax, %ecx
orl $0x44, %ecx
testb $0x10, %r13b
cmovel %eax, %ecx
movl %ecx, %r12d
orl $0x2, %r12d
testb $0x3, %cl
cmovnel %ecx, %r12d
testb $0x4, %r12b
jne 0x2e1da
testb $0x1, %r12b
jne 0x2e1e7
movl %r12d, %eax
andl $0xfffffef2, %eax       # imm = 0xFFFFFEF2
testb $0x2, %r12b
cmovnel %eax, %r12d
jmp 0x2e1eb
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
jmp 0x2e929
andl $0xfffffef4, %r12d      # imm = 0xFFFFFEF4
orl $0x2, %r12d
jmp 0x2e1eb
andl $-0xf, %r12d
movq 0x685ce(%rip), %rax     # 0x967c0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x2e2c0
movl %r12d, %eax
andl $0x80, %eax
jne 0x2e2c0
movq -0x30(%rbp), %rax
cmpb $0x0, (%rax)
je 0x2e2c0
movq -0x30(%rbp), %rax
leaq 0x2(%rax), %rbx
cmpb $0x0, -0x1(%rbx)
je 0x2e24b
cmpb $0x0, (%rbx)
je 0x2e253
cmpb $0x0, 0x1(%rbx)
je 0x2e250
leaq 0x4(%rbx), %rax
cmpb $0x0, 0x2(%rbx)
movq %rax, %rbx
jne 0x2e224
addq $-0x2, %rax
movq %rax, %rbx
jmp 0x2e253
decq %rbx
jmp 0x2e253
incq %rbx
subl -0x30(%rbp), %ebx
cmpl $0x8, %ebx
je 0x2e27e
cmpl $0x5, %ebx
jne 0x2e297
leaq 0x47714(%rip), %rsi     # 0x7597b
movq -0x30(%rbp), %rdi
movl $0x5, %edx
callq 0x3a837
testl %eax, %eax
je 0x2e2c0
cmpl $0x8, %ebx
jne 0x2e297
leaq 0x476fc(%rip), %rsi     # 0x75981
movq -0x30(%rbp), %rdi
movl $0x8, %edx
callq 0x3a837
testl %eax, %eax
je 0x2e2c0
leaq 0x47609(%rip), %rdi     # 0x758a7
movl $0x4, %esi
callq 0x3a34f
testq %rax, %rax
jne 0x2e2d8
leaq 0x4767e(%rip), %rdi     # 0x75932
movl $0x5, %esi
callq 0x3a34f
jmp 0x2e2d8
leaq 0x47598(%rip), %rdi     # 0x7585f
movl $0x3, %esi
callq 0x3a34f
orl $0x80, %r12d
testq %rax, %rax
movl %r13d, -0x54(%rbp)
je 0x2e356
movq %rax, -0x60(%rbp)
movq %r15, -0x38(%rbp)
movl %r12d, %ecx
andl $0x80, %ecx
movl %ecx, %edx
shrl $0x7, %edx
movl %r12d, %eax
shrl $0x6, %eax
andl $0x1, %eax
movl %ecx, -0x50(%rbp)
testl %ecx, %ecx
movl $0x1, %ecx
cmovel %eax, %ecx
movl %ecx, -0x48(%rbp)
movl %edx, -0x4c(%rbp)
testl %edx, %edx
jne 0x2e370
movq -0x30(%rbp), %rax
cmpb $0x0, (%rax)
movq %rax, %r15
movq -0x40(%rbp), %rcx
je 0x2e387
leaq 0x2(%rax), %r15
cmpb $0x0, -0x1(%r15)
je 0x2e37b
cmpb $0x0, (%r15)
je 0x2e383
cmpb $0x0, 0x1(%r15)
je 0x2e380
leaq 0x4(%r15), %rax
cmpb $0x0, 0x2(%r15)
movq %rax, %r15
jne 0x2e32b
addq $-0x2, %rax
movq %rax, %r15
jmp 0x2e383
leaq 0x475db(%rip), %rsi     # 0x75938
movq %r14, %rdi
callq 0x31af5
movl $0xffffffef, %r13d      # imm = 0xFFFFFFEF
jmp 0x2e5a4
xorl %r15d, %r15d
movl $0x260, %r13d           # imm = 0x260
jmp 0x2e398
decq %r15
jmp 0x2e383
incq %r15
movq -0x30(%rbp), %rax
subl %eax, %r15d
movl 0x10(%rcx), %eax
leal (%rax,%r15), %r13d
addl $0x261, %r13d           # imm = 0x261
movq %r14, %rdi
movl %r13d, %esi
callq 0x343ed
testq %rax, %rax
je 0x2e4e4
movq %rax, %rbx
testl %r13d, %r13d
je 0x2e3e9
movl %r13d, %eax
addq %rbx, %rax
movq %rbx, %rcx
movb $0x0, (%rcx)
incq %rcx
cmpq %rax, %rcx
jae 0x2e3e9
movb $0x0, (%rcx)
incq %rcx
cmpq %rax, %rcx
jae 0x2e3e9
movb $0x0, (%rcx)
incq %rcx
cmpq %rax, %rcx
jae 0x2e3e9
movb $0x0, (%rcx)
incq %rcx
cmpq %rax, %rcx
jb 0x2e3bd
movq %r14, (%rbx)
movq %r14, 0x8(%rbx)
movq %rbx, 0xd8(%r14)
movl $0x80, 0x250(%rbx)
movq %r14, %rdi
movl $0x400, %esi            # imm = 0x400
callq 0x343ed
movq %rax, 0x248(%rbx)
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x2e595
movl %r12d, %ecx
andl $0x1, %ecx
movl %ecx, -0x44(%rbp)
movl $0x400, %edx            # imm = 0x400
movq %rax, %rdi
xorl %esi, %esi
callq 0xc360
movl -0x4c(%rbp), %eax
movl %eax, 0x1fc(%rbx)
movl -0x48(%rbp), %eax
movl %eax, 0x204(%rbx)
movl -0x44(%rbp), %eax
movl %eax, 0x200(%rbx)
movl %r12d, 0x16c(%rbx)
movq -0x40(%rbp), %rax
movq %rax, 0x28(%rbx)
leaq 0x64(%rbx), %r12
movq %r12, %rdi
callq 0x3a3ee
leaq 0x168(%rbx), %rsi
movq %r12, %rdi
movl $0x4, %edx
callq 0x3a4c2
movl $0xffffffff, 0x258(%rbx) # imm = 0xFFFFFFFF
cmpl $0x0, -0x50(%rbp)
jne 0x2e57e
movq %rbx, %rcx
addq $0x260, %rcx            # imm = 0x260
movq %rcx, 0x18(%rbx)
movq -0x40(%rbp), %rdi
movq 0x30(%rdi), %rax
testq %rax, %rax
movq -0x30(%rbp), %r12
je 0x2e4ef
movl 0x10(%rdi), %edx
addl %r15d, %edx
movq %r12, %rsi
callq *%rax
testl %eax, %eax
je 0x2e4ef
movq 0x18(%rbx), %rsi
movq %r12, %rdi
movl %r15d, %edx
callq 0x34fc5
movq 0x18(%rbx), %rax
movl %r15d, %ecx
movb $0x0, (%rax,%rcx)
jmp 0x2e535
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
jmp 0x2e5a0
movq 0x18(%rbx), %rax
cmpb $0x0, (%rax)
movq %rax, %r15
je 0x2e532
leaq 0x2(%rax), %r15
cmpb $0x0, -0x1(%r15)
je 0x2e52a
cmpb $0x0, (%r15)
je 0x2e532
cmpb $0x0, 0x1(%r15)
je 0x2e52f
leaq 0x4(%r15), %rcx
cmpb $0x0, 0x2(%r15)
movq %rcx, %r15
jne 0x2e4ff
addq $-0x2, %rcx
movq %rcx, %r15
jmp 0x2e532
decq %r15
jmp 0x2e532
incq %r15
subl %eax, %r15d
movq (%rbx), %rdi
leal 0x12(%r15), %esi
callq 0x343ed
movq %rax, 0x20(%rbx)
testq %rax, %rax
je 0x2e595
movl %r15d, %r12d
movq 0x18(%rbx), %rdi
movq %rax, %rsi
movl %r15d, %edx
callq 0x34fc5
movq 0x20(%rbx), %rsi
addq %r12, %rsi
leaq 0x47400(%rip), %rdi     # 0x7596a
movl $0x10, %edx
callq 0x34fc5
movq 0x20(%rbx), %rax
movb $0x0, 0x10(%rax,%r12)
movq %rbx, %rdi
movq -0x60(%rbp), %rsi
callq 0x3a5f2
movl %eax, %r13d
testl %eax, %eax
je 0x2e67d
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3503f
movq -0x38(%rbp), %r15
testl %r13d, %r13d
jne 0x2e87a
movq $0x0, 0xe0(%r14)
xorl %r13d, %r13d
cmpl $0xea1495ba, 0x68b0b(%rip) # imm = 0xEA1495BA
je 0x2e716
leaq 0x6718e(%rip), %rsi     # 0x95760
xorl %ebx, %ebx
movl $0x6, %edi
xorl %eax, %eax
callq 0x3382e
cmpl $0x1, 0x68ac9(%rip)     # 0x970b0
jne 0x2e5f1
movq %r15, %r12
xorl %r15d, %r15d
jmp 0x2e618
movq 0x68aa8(%rip), %rbx     # 0x970a0
testq %rbx, %rbx
je 0x2e699
movq %r15, %r12
movl $0x3, %edi
callq *0x10(%rbx)
movq %rax, %r15
testq %rax, %rax
je 0x2e6ce
testq %r15, %r15
je 0x2e623
movq %r15, %rdi
callq *0x20(%rbx)
xorl %r13d, %r13d
cmpl $0xea1495ba, 0x68aa0(%rip) # imm = 0xEA1495BA
je 0x2e708
cmpq $0x0, 0x689b2(%rip)     # 0x96ff0
je 0x2e6d6
cmpl $0x2, 0x68a65(%rip)     # 0x970b0
jb 0x2e6fb
movq 0x68a48(%rip), %r13     # 0x970a0
movl $0x1, %edi
callq *0x10(%r13)
testq %rax, %rax
je 0x2e6f0
movq %rax, 0x689a7(%rip)     # 0x97018
movq %r13, 0x68970(%rip)     # 0x96fe8
xorl %r13d, %r13d
jmp 0x2e6f6
cmpl $0x0, 0x1fc(%rbx)
je 0x2e6bb
movabsq $0x400000005, %rax      # imm = 0x400000005
movq %rax, 0x1f0(%rbx)
jmp 0x2e6c6
leaq 0x648d0(%rip), %rbx     # 0x92f70
movl $0x3, %edi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x3382e
movl %eax, %r13d
testl %eax, %eax
jne 0x2e716
jmp 0x2e601
movq $0x0, 0x1f0(%rbx)
xorl %r13d, %r13d
jmp 0x2e5a0
movl $0xffffffe8, %r13d      # imm = 0xFFFFFFE8
jmp 0x2e713
movl $0x1, %edi
xorl %esi, %esi
xorl %eax, %eax
callq 0x3382e
movl %eax, %r13d
testl %eax, %eax
jne 0x2e708
jmp 0x2e644
movl $0xffffffe9, %r13d      # imm = 0xFFFFFFE9
testq %rax, %rax
je 0x2e708
movl $0xea1495ba, 0x689cb(%rip) # imm = 0xEA1495BA
xorl %r13d, %r13d
testq %r15, %r15
je 0x2e713
movq %r15, %rdi
callq *0x30(%rbx)
movq %r12, %r15
testl %r13d, %r13d
jne 0x2e87a
leaq 0x688c2(%rip), %rdi     # 0x96fe8
movl $0x120, %esi            # imm = 0x120
callq 0x2e951
testq %rax, %rax
je 0x2e783
movq %rax, %rbx
movl $0x120, %edx            # imm = 0x120
movq %rax, %rdi
xorl %esi, %esi
callq 0xc360
movl $0xf874bcd7, 0x118(%rbx) # imm = 0xF874BCD7
leaq 0x68890(%rip), %rsi     # 0x96fe8
movq %rbx, %rdi
callq 0x36946
movl %eax, %r13d
testl %eax, %eax
je 0x2e78e
movq %rbx, %rdi
callq 0x2ea67
leaq 0x68872(%rip), %rdi     # 0x96fe8
movq %rbx, %rsi
callq 0x2eb38
jmp 0x2e87a
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
jmp 0x2e87a
movq 0x30(%rbx), %rdi
testq %rdi, %rdi
je 0x2e7ae
movq (%rbx), %rax
movq 0x18(%rax), %rax
testq %rax, %rax
je 0x2e7a5
callq *%rax
xorl %eax, %eax
movq %rax, (%rbx)
movq %rax, 0x30(%rbx)
movq %rbx, %rax
addq $0xd0, %rax
xorps %xmm0, %xmm0
movups %xmm0, 0xd8(%rbx)
movq %rbx, 0xd0(%rbx)
movl $0x0, 0xe8(%rbx)
leaq 0xe1a6(%rip), %rcx      # 0x3c97f
movq %rcx, 0xc0(%rbx)
movq %rax, 0xc8(%rbx)
movq 0x688ca(%rip), %rax     # 0x970b8
movq %rax, 0xb8(%rbx)
cmpl $0x2, 0x688b4(%rip)     # 0x970b0
jb 0x2e81d
movq 0x6889b(%rip), %rax     # 0x970a0
movl $0x2, %edi
callq *0x10(%rax)
movq %rax, 0xf0(%rbx)
testq %rax, %rax
je 0x2e946
movq 0x68884(%rip), %rdi     # 0x970a8
testq %rdi, %rdi
je 0x2e833
movq 0x68870(%rip), %rax     # 0x970a0
callq *0x20(%rax)
movq 0x6888e(%rip), %rax     # 0x970c8
testq %rax, %rax
je 0x2e84d
movq %rax, 0x108(%rbx)
movq %rbx, 0x110(%rax)
movq %rbx, 0x68874(%rip)     # 0x970c8
incl 0x68866(%rip)           # 0x970c0
movq 0x68847(%rip), %rdi     # 0x970a8
testq %rdi, %rdi
je 0x2e870
movq 0x68833(%rip), %rax     # 0x970a0
callq *0x30(%rax)
movq %rbx, 0xe0(%r14)
xorl %r13d, %r13d
testl %r13d, %r13d
je 0x2e89b
movq %r14, %rdi
callq 0x2ea67
leaq 0x67e32(%rip), %rdi     # 0x966c0
movq %r14, %rsi
callq 0x2eb38
jmp 0x2e929
testb $0x20, -0x54(%rbp)
jne 0x2e8c5
cmpl $0x2, 0x67ee0(%rip)     # 0x96788
jb 0x2e8c5
movq 0x67ec7(%rip), %rax     # 0x96778
movl $0x2, %edi
callq *0x10(%rax)
movq %rax, 0xf8(%r14)
testq %rax, %rax
je 0x2e93b
movq 0x67eb4(%rip), %rdi     # 0x96780
testq %rdi, %rdi
je 0x2e8db
movq 0x67ea0(%rip), %rax     # 0x96778
callq *0x20(%rax)
movq 0x67eee(%rip), %rax     # 0x967d0
testq %rax, %rax
je 0x2e8f5
movq %rax, 0x110(%r14)
movq %r14, 0x118(%rax)
movq %r14, 0x67ed4(%rip)     # 0x967d0
incl 0x67ec6(%rip)           # 0x967c8
movq 0x67e77(%rip), %rdi     # 0x96780
testq %rdi, %rdi
je 0x2e918
movq 0x67e63(%rip), %rax     # 0x96778
callq *0x30(%rax)
movl $0xdb7c2712, 0x120(%r14) # imm = 0xDB7C2712
movq %r14, (%r15)
xorl %r13d, %r13d
movl %r13d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
jmp 0x2e87f
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
jmp 0x2e767