// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: unqliteCoreConfigure
static sxi32 unqliteCoreConfigure(sxi32 nOp, va_list ap)
{
	int rc = UNQLITE_OK;
	switch(nOp){
	    case UNQLITE_LIB_CONFIG_PAGE_SIZE: {
			/* Default page size: Must be a power of two */
			int iPage = va_arg(ap,int);
			if( iPage >= UNQLITE_MIN_PAGE_SIZE && iPage <= UNQLITE_MAX_PAGE_SIZE ){
				if( !(iPage & (iPage - 1)) ){
					sUnqlMPGlobal.iPageSize = iPage;
				}else{
					/* Invalid page size */
					rc = UNQLITE_INVALID;
				}
			}else{
				/* Invalid page size */
				rc = UNQLITE_INVALID;
			}
			break;
										   }
	    case UNQLITE_LIB_CONFIG_STORAGE_ENGINE: {
			/* Install a key value storage engine */
			unqlite_kv_methods *pMethods = va_arg(ap,unqlite_kv_methods *);
			/* Make sure we are delaing with a valid methods */
			if( pMethods == 0 || SX_EMPTY_STR(pMethods->zName) || pMethods->xSeek == 0 || pMethods->xData == 0
				|| pMethods->xKey == 0 || pMethods->xDataLength == 0 || pMethods->xKeyLength == 0 
				|| pMethods->szKv < (int)sizeof(unqlite_kv_engine) ){
					rc = UNQLITE_INVALID;
					break;
			}
			/* Install it */
			rc = SySetPut(&sUnqlMPGlobal.kv_storage,(const void *)&pMethods);
			break;
												}
	    case UNQLITE_LIB_CONFIG_VFS:{
			/* Install a virtual file system */
			unqlite_vfs *pVfs = va_arg(ap,unqlite_vfs *);
			if( pVfs ){
			 sUnqlMPGlobal.pVfs = pVfs;
			}
			break;
								}
		case UNQLITE_LIB_CONFIG_USER_MALLOC: {
			/* Use an alternative low-level memory allocation routines */
			const SyMemMethods *pMethods = va_arg(ap, const SyMemMethods *);
			/* Save the memory failure callback (if available) */
			ProcMemError xMemErr = sUnqlMPGlobal.sAllocator.xMemError;
			void *pMemErr = sUnqlMPGlobal.sAllocator.pUserData;
			if( pMethods == 0 ){
				/* Use the built-in memory allocation subsystem */
				rc = SyMemBackendInit(&sUnqlMPGlobal.sAllocator, xMemErr, pMemErr);
			}else{
				rc = SyMemBackendInitFromOthers(&sUnqlMPGlobal.sAllocator, pMethods, xMemErr, pMemErr);
			}
			break;
										  }
		case UNQLITE_LIB_CONFIG_MEM_ERR_CALLBACK: {
			/* Memory failure callback */
			ProcMemError xMemErr = va_arg(ap, ProcMemError);
			void *pUserData = va_arg(ap, void *);
			sUnqlMPGlobal.sAllocator.xMemError = xMemErr;
			sUnqlMPGlobal.sAllocator.pUserData = pUserData;
			break;
												 }	  
		case UNQLITE_LIB_CONFIG_USER_MUTEX: {
#if defined(UNQLITE_ENABLE_THREADS)
			/* Use an alternative low-level mutex subsystem */
			const SyMutexMethods *pMethods = va_arg(ap, const SyMutexMethods *);
#if defined (UNTRUST)
			if( pMethods == 0 ){
				rc = UNQLITE_CORRUPT;
			}
#endif
			/* Sanity check */
			if( pMethods->xEnter == 0 || pMethods->xLeave == 0 || pMethods->xNew == 0){
				/* At least three criticial callbacks xEnter(), xLeave() and xNew() must be supplied */
				rc = UNQLITE_CORRUPT;
				break;
			}
			if( sUnqlMPGlobal.pMutexMethods ){
				/* Overwrite the previous mutex subsystem */
				SyMutexRelease(sUnqlMPGlobal.pMutexMethods, sUnqlMPGlobal.pMutex);
				if( sUnqlMPGlobal.pMutexMethods->xGlobalRelease ){
					sUnqlMPGlobal.pMutexMethods->xGlobalRelease();
				}
				sUnqlMPGlobal.pMutex = 0;
			}
			/* Initialize and install the new mutex subsystem */
			if( pMethods->xGlobalInit ){
				rc = pMethods->xGlobalInit();
				if ( rc != UNQLITE_OK ){
					break;
				}
			}
			/* Create the global mutex */
			sUnqlMPGlobal.pMutex = pMethods->xNew(SXMUTEX_TYPE_FAST);
			if( sUnqlMPGlobal.pMutex == 0 ){
				/*
				 * If the supplied mutex subsystem is so sick that we are unable to
				 * create a single mutex, there is no much we can do here.
				 */
				if( pMethods->xGlobalRelease ){
					pMethods->xGlobalRelease();
				}
				rc = UNQLITE_CORRUPT;
				break;
			}
			sUnqlMPGlobal.pMutexMethods = pMethods;			
			if( sUnqlMPGlobal.nThreadingLevel == 0 ){
				/* Set a default threading level */
				sUnqlMPGlobal.nThreadingLevel = UNQLITE_THREAD_LEVEL_MULTI; 
			}
#endif
			break;
										   }
		case UNQLITE_LIB_CONFIG_THREAD_LEVEL_SINGLE:
#if defined(UNQLITE_ENABLE_THREADS)
			/* Single thread mode (Only one thread is allowed to play with the library) */
			sUnqlMPGlobal.nThreadingLevel = UNQLITE_THREAD_LEVEL_SINGLE;
			jx9_lib_config(JX9_LIB_CONFIG_THREAD_LEVEL_SINGLE);
#endif
			break;
		case UNQLITE_LIB_CONFIG_THREAD_LEVEL_MULTI:
#if defined(UNQLITE_ENABLE_THREADS)
			/* Multi-threading mode (library is thread safe and database handles and virtual machines
			 * may be shared between multiple threads).
			 */
			sUnqlMPGlobal.nThreadingLevel = UNQLITE_THREAD_LEVEL_MULTI;
			jx9_lib_config(JX9_LIB_CONFIG_THREAD_LEVEL_MULTI);
#endif
			break;
		default:
			/* Unknown configuration option */
			rc = UNQLITE_CORRUPT;
			break;
	}
	return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x4(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x60(%rbp)
subl $0x7, %eax
ja 0x53c24
movq -0x60(%rbp), %rax
leaq 0x6cdf8(%rip), %rcx     # 0xc04e0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rax
movq %rax, -0x70(%rbp)
movl (%rax), %eax
movl %eax, -0x64(%rbp)
cmpl $0x28, %eax
ja 0x5371c
movq -0x70(%rbp), %rcx
movl -0x64(%rbp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, -0x78(%rbp)
jmp 0x53733
movq -0x70(%rbp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x18(%rbp)
cmpl $0x200, -0x18(%rbp)     # imm = 0x200
jl 0x53772
cmpl $0x10000, -0x18(%rbp)   # imm = 0x10000
jg 0x53772
movl -0x18(%rbp), %eax
movl -0x18(%rbp), %ecx
subl $0x1, %ecx
andl %ecx, %eax
cmpl $0x0, %eax
jne 0x53769
movl -0x18(%rbp), %eax
movl %eax, 0x9b151(%rip)     # 0xee8b8
jmp 0x53770
movl $0xfffffff7, -0x14(%rbp) # imm = 0xFFFFFFF7
jmp 0x53779
movl $0xfffffff7, -0x14(%rbp) # imm = 0xFFFFFFF7
jmp 0x53c2b
movq -0x10(%rbp), %rax
movq %rax, -0x88(%rbp)
movl (%rax), %eax
movl %eax, -0x7c(%rbp)
cmpl $0x28, %eax
ja 0x537b2
movq -0x88(%rbp), %rcx
movl -0x7c(%rbp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, -0x90(%rbp)
jmp 0x537cf
movq -0x88(%rbp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x5384a
movq -0x20(%rbp), %rax
cmpq $0x0, (%rax)
je 0x5384a
movq -0x20(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x5384a
movq -0x20(%rbp), %rax
cmpq $0x0, 0x50(%rax)
je 0x5384a
movq -0x20(%rbp), %rax
cmpq $0x0, 0xa0(%rax)
je 0x5384a
movq -0x20(%rbp), %rax
cmpq $0x0, 0x90(%rax)
je 0x5384a
movq -0x20(%rbp), %rax
cmpq $0x0, 0x98(%rax)
je 0x5384a
movq -0x20(%rbp), %rax
cmpq $0x0, 0x88(%rax)
je 0x5384a
movq -0x20(%rbp), %rax
cmpl $0x8, 0x8(%rax)
jge 0x53856
movl $0xfffffff7, -0x14(%rbp) # imm = 0xFFFFFFF7
jmp 0x53c2b
leaq 0x9af63(%rip), %rdi     # 0xee7c0
addq $0xd0, %rdi
leaq -0x20(%rbp), %rsi
callq 0x5a7b0
movl %eax, -0x14(%rbp)
jmp 0x53c2b
movq -0x10(%rbp), %rax
movq %rax, -0xa0(%rbp)
movl (%rax), %eax
movl %eax, -0x94(%rbp)
cmpl $0x28, %eax
ja 0x538af
movq -0xa0(%rbp), %rcx
movl -0x94(%rbp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, -0xa8(%rbp)
jmp 0x538cc
movq -0xa0(%rbp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x538ec
movq -0x28(%rbp), %rax
movq %rax, 0x9afd4(%rip)     # 0xee8c0
jmp 0x53c2b
movq -0x10(%rbp), %rax
movq %rax, -0xb8(%rbp)
movl (%rax), %eax
movl %eax, -0xac(%rbp)
cmpl $0x28, %eax
ja 0x5392b
movq -0xb8(%rbp), %rcx
movl -0xac(%rbp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, -0xc0(%rbp)
jmp 0x53948
movq -0xb8(%rbp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq 0x9ae83(%rip), %rax     # 0xee7e0
movq %rax, -0x38(%rbp)
movq 0x9ae80(%rip), %rax     # 0xee7e8
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x5398c
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rdx
leaq 0x9ae3e(%rip), %rdi     # 0xee7c0
callq 0x5a990
movl %eax, -0x14(%rbp)
jmp 0x539a7
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x40(%rbp), %rcx
leaq 0x9ae21(%rip), %rdi     # 0xee7c0
callq 0x5aa30
movl %eax, -0x14(%rbp)
jmp 0x53c2b
movq -0x10(%rbp), %rax
movq %rax, -0xd0(%rbp)
movl (%rax), %eax
movl %eax, -0xc4(%rbp)
cmpl $0x28, %eax
ja 0x539e6
movq -0xd0(%rbp), %rcx
movl -0xc4(%rbp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, -0xd8(%rbp)
jmp 0x53a03
movq -0xd0(%rbp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, -0xd8(%rbp)
movq -0xd8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xe8(%rbp)
movl (%rax), %eax
movl %eax, -0xdc(%rbp)
cmpl $0x28, %eax
ja 0x53a4b
movq -0xe8(%rbp), %rcx
movl -0xdc(%rbp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, -0xf0(%rbp)
jmp 0x53a68
movq -0xe8(%rbp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, -0xf0(%rbp)
movq -0xf0(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rax
movq %rax, 0x9ad5f(%rip)     # 0xee7e0
movq -0x50(%rbp), %rax
movq %rax, 0x9ad5c(%rip)     # 0xee7e8
jmp 0x53c2b
movq -0x10(%rbp), %rax
movq %rax, -0x100(%rbp)
movl (%rax), %eax
movl %eax, -0xf4(%rbp)
cmpl $0x28, %eax
ja 0x53acb
movq -0x100(%rbp), %rcx
movl -0xf4(%rbp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, -0x108(%rbp)
jmp 0x53ae8
movq -0x100(%rbp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, -0x108(%rbp)
movq -0x108(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x53b17
movq -0x58(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0x53b17
movq -0x58(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x53b23
movl $0xffffffe8, -0x14(%rbp) # imm = 0xFFFFFFE8
jmp 0x53c2b
cmpq $0x0, 0x9ad4d(%rip)     # 0xee878
je 0x53b7c
cmpq $0x0, 0x9ad4b(%rip)     # 0xee880
je 0x53b59
movq 0x9ad3a(%rip), %rax     # 0xee878
cmpq $0x0, 0x18(%rax)
je 0x53b59
movq 0x9ad2c(%rip), %rax     # 0xee878
movq 0x18(%rax), %rax
movq 0x9ad29(%rip), %rdi     # 0xee880
callq *%rax
movq 0x9ad18(%rip), %rax     # 0xee878
cmpq $0x0, 0x8(%rax)
je 0x53b71
movq 0x9ad0a(%rip), %rax     # 0xee878
callq *0x8(%rax)
movq $0x0, 0x9ad04(%rip) # 0xee880
movq -0x58(%rbp), %rax
cmpq $0x0, (%rax)
je 0x53b9c
movq -0x58(%rbp), %rax
callq *(%rax)
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x53b9a
jmp 0x53c2b
jmp 0x53b9c
movq -0x58(%rbp), %rax
movl $0x1, %edi
callq *0x10(%rax)
movq %rax, 0x9acd1(%rip)     # 0xee880
cmpq $0x0, 0x9acc9(%rip)     # 0xee880
jne 0x53bd4
movq -0x58(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x53bcb
movq -0x58(%rbp), %rax
callq *0x8(%rax)
movl $0xffffffe8, -0x14(%rbp) # imm = 0xFFFFFFE8
jmp 0x53c2b
movq -0x58(%rbp), %rax
movq %rax, 0x9ac99(%rip)     # 0xee878
cmpl $0x0, 0x9aca2(%rip)     # 0xee888
jne 0x53bf2
movl $0x2, 0x9ac96(%rip)     # 0xee888
jmp 0x53c2b
movl $0x1, 0x9ac8a(%rip)     # 0xee888
movl $0x4, %edi
movb $0x0, %al
callq 0x5ab00
jmp 0x53c2b
movl $0x2, 0x9ac72(%rip)     # 0xee888
movl $0x5, %edi
movb $0x0, %al
callq 0x5ab00
jmp 0x53c2b
movl $0xffffffe8, -0x14(%rbp) # imm = 0xFFFFFFE8
movl -0x14(%rbp), %eax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
nopw (%rax,%rax)