// File: /workspace/github_c_makefile_star2_O3/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, %r15d
movq %rsi, %rbx
movq %rdi, %r12
movq $0x0, (%rdi)
callq 0x2d86c
movl %eax, %r13d
testl %eax, %eax
jne 0x2e119
movq %rbx, -0x38(%rbp)
leaq 0x66a8d(%rip), %rdi     # 0x946c0
movl $0x128, %esi            # imm = 0x128
callq 0x2e481
testq %rax, %rax
je 0x2dcfd
movq %rax, %rbx
movq $-0x4, %rax
movl $0x0, 0x4(%rbx,%rax)
addq $0x4, %rax
cmpq $0x124, %rax            # imm = 0x124
jb 0x2dc50
testl %r15d, %r15d
movl $0x101, %r13d           # imm = 0x101
cmovnel %r15d, %r13d
leaq 0x66a48(%rip), %rsi     # 0x946c0
movq %rbx, %rdi
callq 0x3622f
movq 0x30(%rbx), %rdi
testq %rdi, %rdi
movq -0x38(%rbp), %r15
je 0x2dca4
movq (%rbx), %rax
movq 0x18(%rax), %rax
testq %rax, %rax
je 0x2dc9b
callq *%rax
xorl %eax, %eax
movq %rax, (%rbx)
movq %rax, 0x30(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0xc0(%rbx)
movq %rbx, 0xb8(%rbx)
movl $0x0, 0xd0(%rbx)
movl %r13d, %eax
andl $-0x9, %eax
movl %eax, %ecx
orl $0x44, %ecx
testb $0x10, %r13b
cmovel %eax, %ecx
movl %ecx, %r14d
orl $0x2, %r14d
testb $0x3, %cl
cmovnel %ecx, %r14d
testb $0x4, %r14b
jne 0x2dd08
testb $0x1, %r14b
jne 0x2dd15
movl %r14d, %eax
andl $0xfffffef2, %eax       # imm = 0xFFFFFEF2
testb $0x2, %r14b
cmovnel %eax, %r14d
jmp 0x2dd19
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
jmp 0x2e119
andl $0xfffffef4, %r14d      # imm = 0xFFFFFEF4
orl $0x2, %r14d
jmp 0x2dd19
andl $-0xf, %r14d
movq 0x66aa0(%rip), %rax     # 0x947c0
movq %rax, -0x50(%rbp)
testq %r15, %r15
je 0x2ddd7
movl %r14d, %eax
andl $0x80, %eax
jne 0x2ddd7
cmpb $0x0, (%r15)
je 0x2ddd7
leaq 0x2(%r15), %rax
cmpb $0x0, -0x1(%rax)
je 0x2dd70
cmpb $0x0, (%rax)
je 0x2dd78
cmpb $0x0, 0x1(%rax)
je 0x2dd75
leaq 0x4(%rax), %rcx
cmpb $0x0, 0x2(%rax)
movq %rcx, %rax
jne 0x2dd49
addq $-0x2, %rcx
movq %rcx, %rax
jmp 0x2dd78
decq %rax
jmp 0x2dd78
incq %rax
subl %r15d, %eax
cmpl $0x8, %eax
je 0x2dd96
cmpl $0x5, %eax
jne 0x2ddae
leaq 0x45bf7(%rip), %rsi     # 0x73983
movq %r15, %rdi
movl $0x5, %edx
jmp 0x2dda5
leaq 0x45bec(%rip), %rsi     # 0x73989
movq %r15, %rdi
movl $0x8, %edx
callq 0x39f3f
testl %eax, %eax
je 0x2ddd7
leaq 0x45afa(%rip), %rdi     # 0x738af
movl $0x4, %esi
callq 0x39a5b
testq %rax, %rax
jne 0x2ddf8
leaq 0x45b6f(%rip), %rdi     # 0x7393a
movl $0x5, %esi
callq 0x39a5b
jmp 0x2ddef
leaq 0x45a89(%rip), %rdi     # 0x73867
movl $0x3, %esi
callq 0x39a5b
orl $0x80, %r14d
testq %rax, %rax
je 0x2de8b
movq %rax, -0x60(%rbp)
movl %r14d, %ecx
andl $0x80, %ecx
movl %ecx, %edx
shrl $0x7, %edx
movl %r14d, %eax
shrl $0x6, %eax
andl $0x1, %eax
movl %ecx, -0x48(%rbp)
testl %ecx, %ecx
movl $0x1, %ecx
cmovel %eax, %ecx
movl %ecx, -0x40(%rbp)
movl %edx, -0x44(%rbp)
testl %edx, %edx
movl %r13d, -0x3c(%rbp)
jne 0x2de66
cmpb $0x0, (%r15)
movq %r15, %rax
je 0x2deb1
leaq 0x2(%rax), %r15
cmpb $0x0, -0x1(%r15)
je 0x2dea5
cmpb $0x0, (%r15)
je 0x2dead
cmpb $0x0, 0x1(%r15)
je 0x2deaa
leaq 0x4(%r15), %rax
cmpb $0x0, 0x2(%r15)
movq %rax, %r15
jne 0x2de3b
addq $-0x2, %rax
movq %rax, %r15
jmp 0x2dead
movq %rbx, %rdi
movl $0x260, %esi            # imm = 0x260
callq 0x33d86
testq %rax, %rax
je 0x2e044
movq %rax, %rdx
addq $0x260, %rdx            # imm = 0x260
xorl %r15d, %r15d
jmp 0x2dee8
leaq 0x45aae(%rip), %rsi     # 0x73940
movq %rbx, %rdi
callq 0x31537
movl $0xffffffef, %r13d      # imm = 0xFFFFFFEF
jmp 0x2e102
decq %r15
jmp 0x2dead
incq %r15
movq -0x38(%rbp), %rax
subl %eax, %r15d
movq -0x50(%rbp), %rax
movl 0x10(%rax), %eax
leal (%rax,%r15), %r13d
addl $0x261, %r13d           # imm = 0x261
movq %rbx, %rdi
movl %r13d, %esi
callq 0x33d86
testq %rax, %rax
je 0x2e044
testl %r13d, %r13d
je 0x2df17
movl %r13d, %ecx
movq %rax, %rdx
addq %rcx, %rdx
movq %rax, %rcx
movb $0x0, (%rcx)
incq %rcx
cmpq %rdx, %rcx
jae 0x2df17
movb $0x0, (%rcx)
incq %rcx
cmpq %rdx, %rcx
jae 0x2df17
movb $0x0, (%rcx)
incq %rcx
cmpq %rdx, %rcx
jae 0x2df17
movb $0x0, (%rcx)
incq %rcx
cmpq %rdx, %rcx
jb 0x2deeb
movq %rax, -0x30(%rbp)
movq %rbx, (%rax)
movq %rbx, 0x8(%rax)
movq %rax, 0xd8(%rbx)
movl $0x80, 0x250(%rax)
movq %rbx, %rdi
movl $0x400, %esi            # imm = 0x400
callq 0x33d86
movq -0x30(%rbp), %rsi
movq %rax, 0x248(%rsi)
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x2e0fa
movq %r12, -0x58(%rbp)
movl %r14d, %r12d
andl $0x1, %r12d
movl $0x400, %edx            # imm = 0x400
movq %rax, %rdi
xorl %esi, %esi
callq 0xc360
movq -0x30(%rbp), %rax
movl -0x44(%rbp), %ecx
movl %ecx, 0x1fc(%rax)
movq -0x30(%rbp), %rax
movl -0x40(%rbp), %ecx
movl %ecx, 0x204(%rax)
movq -0x30(%rbp), %rax
movl %r12d, 0x200(%rax)
movq -0x30(%rbp), %rax
movl %r14d, 0x16c(%rax)
movq -0x50(%rbp), %r12
movq -0x30(%rbp), %rax
movq %r12, 0x28(%rax)
movq -0x30(%rbp), %rax
leaq 0x64(%rax), %r14
movq %r14, %rdi
callq 0x39afa
movq -0x30(%rbp), %rax
leaq 0x168(%rax), %rsi
movq %r14, %rdi
movl $0x4, %edx
callq 0x39bca
movq -0x30(%rbp), %rdi
movl $0xffffffff, 0x258(%rdi) # imm = 0xFFFFFFFF
cmpl $0x0, -0x48(%rbp)
jne 0x2e0e6
leaq 0x260(%rdi), %rcx
movq %rcx, 0x18(%rdi)
movq 0x30(%r12), %rax
testq %rax, %rax
je 0x2e04f
movl 0x10(%r12), %edx
addl %r15d, %edx
movq %r12, %rdi
movq -0x38(%rbp), %r14
movq %r14, %rsi
callq *%rax
movq -0x30(%rbp), %rdi
movq 0x18(%rdi), %rcx
testl %eax, %eax
je 0x2e04f
movq %r14, %rdi
movq %rcx, %rsi
movl %r15d, %edx
callq 0x34893
movq -0x30(%rbp), %rdi
movq 0x18(%rdi), %rax
movl %r15d, %ecx
movb $0x0, (%rax,%rcx)
jmp 0x2e091
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
jmp 0x2e102
cmpb $0x0, (%rcx)
movq %rcx, %r15
je 0x2e08e
leaq 0x2(%rcx), %r15
cmpb $0x0, -0x1(%r15)
je 0x2e086
cmpb $0x0, (%r15)
je 0x2e08e
cmpb $0x0, 0x1(%r15)
je 0x2e08b
leaq 0x4(%r15), %rax
cmpb $0x0, 0x2(%r15)
movq %rax, %r15
jne 0x2e05b
addq $-0x2, %rax
movq %rax, %r15
jmp 0x2e08e
decq %r15
jmp 0x2e08e
incq %r15
subl %ecx, %r15d
movq (%rdi), %rdi
leal 0x12(%r15), %esi
callq 0x33d86
movq -0x30(%rbp), %rsi
movq %rax, 0x20(%rsi)
testq %rax, %rax
je 0x2e0fa
movl %r15d, %r14d
movq 0x18(%rsi), %rdi
movq %rax, %rsi
movl %r15d, %edx
callq 0x34893
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rsi
addq %r14, %rsi
leaq 0x458a4(%rip), %rdi     # 0x73972
movl $0x10, %edx
callq 0x34893
movq -0x30(%rbp), %rdi
movq 0x20(%rdi), %rax
movb $0x0, 0x10(%rax,%r14)
movq -0x60(%rbp), %rsi
callq 0x39cfa
movq -0x30(%rbp), %rsi
movl %eax, %r13d
testl %eax, %eax
je 0x2e12b
movq %rbx, %rdi
callq 0x3490d
movq %rbx, %rdi
callq 0x2e588
leaq 0x665af(%rip), %rdi     # 0x946c0
movq %rbx, %rsi
callq 0x2e659
movl %r13d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
cmpl $0x0, 0x1fc(%rsi)
setne %al
leal (%rax,%rax,4), %ecx
shll $0x2, %eax
movl %ecx, 0x1f0(%rsi)
movl %eax, 0x1f4(%rsi)
movq $0x0, 0xe0(%rbx)
cmpl $0xea1495ba, 0x66f72(%rip) # imm = 0xEA1495BA
je 0x2e225
leaq 0x655f5(%rip), %rsi     # 0x93760
xorl %r15d, %r15d
movl $0x6, %edi
xorl %eax, %eax
callq 0x331d0
movl 0x66f2f(%rip), %r12d    # 0x950b0
cmpl $0x1, %r12d
jne 0x2e18c
xorl %r14d, %r14d
jmp 0x2e1b8
movq 0x66f0d(%rip), %r14     # 0x950a0
testq %r14, %r14
je 0x2e41c
movl $0x3, %edi
callq *0x10(%r14)
testq %rax, %rax
je 0x2e442
movq %rax, %r15
movq %rax, %rdi
callq *0x20(%r14)
cmpl $0xea1495ba, 0x66f0e(%rip) # imm = 0xEA1495BA
je 0x2e20c
cmpq $0x0, 0x66e24(%rip)     # 0x94ff0
je 0x2e44d
cmpl $0x2, 0x66ed7(%rip)     # 0x950b0
jb 0x2e202
movq 0x66ebe(%rip), %r13     # 0x950a0
movl $0x1, %edi
callq *0x10(%r13)
testq %rax, %rax
je 0x2e476
movq %rax, 0x66e1d(%rip)     # 0x95018
movq %r13, 0x66de6(%rip)     # 0x94fe8
movl $0xea1495ba, 0x66ec4(%rip) # imm = 0xEA1495BA
xorl %r13d, %r13d
cmpl $0x1, %r12d
je 0x2e21c
movq %r15, %rdi
callq *0x30(%r14)
testl %r13d, %r13d
jne 0x2e102
leaq 0x66dbc(%rip), %rdi     # 0x94fe8
movl $0x120, %esi            # imm = 0x120
callq 0x2e481
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x2e102
movq %rax, %r14
movl $0x120, %edx            # imm = 0x120
movq %rax, %rdi
xorl %esi, %esi
callq 0xc360
movl $0xf874bcd7, 0x118(%r14) # imm = 0xF874BCD7
leaq 0x66d7f(%rip), %rsi     # 0x94fe8
movq %r14, %rdi
callq 0x3622f
movl %eax, %r15d
testl %eax, %eax
je 0x2e297
movq %r14, %rdi
callq 0x2e588
leaq 0x66d61(%rip), %rdi     # 0x94fe8
movq %r14, %rsi
callq 0x2e659
movl %r15d, %r13d
jmp 0x2e102
movq 0x30(%r14), %rdi
testq %rdi, %rdi
je 0x2e2b7
movq (%r14), %rax
movq 0x18(%rax), %rax
testq %rax, %rax
je 0x2e2ae
callq *%rax
xorl %eax, %eax
movq %rax, (%r14)
movq %rax, 0x30(%r14)
movq %r14, %rax
addq $0xd0, %rax
xorps %xmm0, %xmm0
movups %xmm0, 0xd8(%r14)
movq %r14, 0xd0(%r14)
movl $0x0, 0xe8(%r14)
leaq 0xdd10(%rip), %rcx      # 0x3bff4
movq %rcx, 0xc0(%r14)
movq %rax, 0xc8(%r14)
movq 0x66dbf(%rip), %rax     # 0x950b8
movq %rax, 0xb8(%r14)
cmpl $0x2, 0x66da9(%rip)     # 0x950b0
jb 0x2e328
movq 0x66d90(%rip), %rax     # 0x950a0
movl $0x2, %edi
callq *0x10(%rax)
movq %rax, 0xf0(%r14)
testq %rax, %rax
je 0x2e46b
movq 0x66d79(%rip), %rdi     # 0x950a8
testq %rdi, %rdi
je 0x2e33e
movq 0x66d65(%rip), %rax     # 0x950a0
callq *0x20(%rax)
movq 0x66d83(%rip), %rax     # 0x950c8
testq %rax, %rax
je 0x2e358
movq %rax, 0x108(%r14)
movq %r14, 0x110(%rax)
movq %r14, 0x66d69(%rip)     # 0x950c8
incl 0x66d5b(%rip)           # 0x950c0
movq 0x66d3c(%rip), %rdi     # 0x950a8
testq %rdi, %rdi
je 0x2e37b
movq 0x66d28(%rip), %rax     # 0x950a0
callq *0x30(%rax)
movq %r14, 0xe0(%rbx)
testb $0x20, -0x3c(%rbp)
jne 0x2e3b0
cmpl $0x2, 0x663f9(%rip)     # 0x94788
jb 0x2e3b0
movq 0x663e0(%rip), %rax     # 0x94778
movl $0x2, %edi
callq *0x10(%rax)
movq %rax, 0xf8(%rbx)
testq %rax, %rax
je 0x2e102
movq 0x663c9(%rip), %rdi     # 0x94780
testq %rdi, %rdi
je 0x2e3c6
movq 0x663b5(%rip), %rax     # 0x94778
callq *0x20(%rax)
movq 0x66403(%rip), %rax     # 0x947d0
testq %rax, %rax
movq -0x58(%rbp), %r14
je 0x2e3e4
movq %rax, 0x110(%rbx)
movq %rbx, 0x118(%rax)
movq %rbx, 0x663e5(%rip)     # 0x947d0
incl 0x663d7(%rip)           # 0x947c8
movq 0x66388(%rip), %rdi     # 0x94780
testq %rdi, %rdi
je 0x2e407
movq 0x66374(%rip), %rax     # 0x94778
callq *0x30(%rax)
movl $0xdb7c2712, 0x120(%rbx) # imm = 0xDB7C2712
movq %rbx, (%r14)
xorl %r13d, %r13d
jmp 0x2e119
leaq 0x62b4d(%rip), %r14     # 0x90f70
movl $0x3, %edi
movq %r14, %rsi
xorl %eax, %eax
callq 0x331d0
movl %eax, %r13d
testl %eax, %eax
jne 0x2e102
jmp 0x2e19c
movl $0xffffffe8, %r13d      # imm = 0xFFFFFFE8
jmp 0x2e102
movl $0x1, %edi
xorl %esi, %esi
xorl %eax, %eax
callq 0x331d0
movl %eax, %r13d
testl %eax, %eax
jne 0x2e20f
jmp 0x2e1d2
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
jmp 0x2e278
movl $0xffffffe9, %r13d      # imm = 0xFFFFFFE9
jmp 0x2e20f