// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9_create_function
JX9_PRIVATE int jx9_create_function(jx9_vm *pVm, const char *zName, int (*xFunc)(jx9_context *, int, jx9_value **), void *pUserData)
{
	SyString sName;
	int rc;
	/* Ticket 1433-002: NULL VM is harmless operation */
	if ( JX9_VM_MISUSE(pVm) ){
		return JX9_CORRUPT;
	}
	SyStringInitFromBuf(&sName, zName, SyStrlen(zName));
	/* Remove leading and trailing white spaces */
	SyStringFullTrim(&sName);
	/* Ticket 1433-003: NULL values are not allowed */
	if( sName.nByte < 1 || xFunc == 0 ){
		return JX9_CORRUPT;
	}
#if defined(JX9_ENABLE_THREADS)
	 /* Acquire VM mutex */
	 SyMutexEnter(sJx9MPGlobal.pMutexMethods, pVm->pMutex); /* NO-OP if sJx9MPGlobal.nThreadingLevel != JX9_THREAD_LEVEL_MULTI */
	 if( sJx9MPGlobal.nThreadingLevel > JX9_THREAD_LEVEL_SINGLE && 
		 JX9_THRD_VM_RELEASE(pVm) ){
			 return JX9_ABORT; /* Another thread have released this instance */
	 }
#endif
	/* Install the foreign function */
	rc = jx9VmInstallForeignFunction(&(*pVm), &sName, xFunc, pUserData); 
#if defined(JX9_ENABLE_THREADS)
	 /* Leave VM mutex */
	 SyMutexLeave(sJx9MPGlobal.pMutexMethods, pVm->pMutex); /* NO-OP if sJx9MPGlobal.nThreadingLevel != JX9_THREAD_LEVEL_MULTI */
#endif
	return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl $0xffffffe8, %ebx       # imm = 0xFFFFFFE8
testq %rdi, %rdi
je 0x3d425
movq %rdi, %r14
cmpl $0xdead2bad, 0x6e8(%rdi) # imm = 0xDEAD2BAD
je 0x3d425
movq %rsi, %r13
cmpb $0x0, (%rsi)
movq %rsi, %rax
je 0x3d33b
leaq 0x2(%r13), %rax
cmpb $0x0, -0x1(%rax)
je 0x3d333
cmpb $0x0, (%rax)
je 0x3d33b
cmpb $0x0, 0x1(%rax)
je 0x3d338
leaq 0x4(%rax), %rsi
cmpb $0x0, 0x2(%rax)
movq %rsi, %rax
jne 0x3d30c
addq $-0x2, %rsi
movq %rsi, %rax
jmp 0x3d33b
decq %rax
jmp 0x3d33b
incq %rax
subl %r13d, %eax
je 0x3d425
movq %rdx, -0x38(%rbp)
movq %rcx, -0x30(%rbp)
movl %eax, %r15d
xorl %r12d, %r12d
movsbq (%r13,%r12), %rbx
cmpq $-0x41, %rbx
ja 0x3d377
callq 0xc170
movq (%rax), %rax
testb $0x20, 0x1(%rax,%rbx,2)
je 0x3d377
incq %r12
cmpl %r12d, %r15d
jne 0x3d352
jmp 0x3d3b1
leaq (%r12,%r13), %rax
movq %rax, -0x48(%rbp)
addq %r15, %r13
decq %r13
subq %r12, %r15
movq -0x38(%rbp), %r12
movsbq (%r13), %rbx
cmpq $-0x41, %rbx
ja 0x3d3b8
callq 0xc170
movq (%rax), %rax
testb $0x20, 0x1(%rax,%rbx,2)
je 0x3d3b8
decq %r15
decq %r13
testq %r15, %r15
jne 0x3d38c
movl $0xffffffe8, %ebx       # imm = 0xFFFFFFE8
jmp 0x3d425
movl %r15d, -0x40(%rbp)
testq %r12, %r12
movl $0xffffffe8, %ebx       # imm = 0xFFFFFFE8
movq -0x30(%rbp), %r15
je 0x3d425
movq 0xb8(%r14), %rdi
testq %rdi, %rdi
je 0x3d3e0
movq 0x57cc3(%rip), %rax     # 0x950a0
callq *0x20(%rax)
cmpl $0x2, 0x57cc9(%rip)     # 0x950b0
jb 0x3d3fb
movl $0xfffffff6, %ebx       # imm = 0xFFFFFFF6
cmpl $0xdead2bad, 0x6e8(%r14) # imm = 0xDEAD2BAD
je 0x3d425
leaq -0x48(%rbp), %rsi
movq %r14, %rdi
movq %r12, %rdx
movq %r15, %rcx
callq 0x2fc0c
movl %eax, %ebx
movq 0xb8(%r14), %rdi
testq %rdi, %rdi
je 0x3d425
movq 0x57c7e(%rip), %rax     # 0x950a0
callq *0x30(%rax)
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq