// File: /workspace/github_c_makefile_star2_O1/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, %r15d      # imm = 0xFFFFFFE8
testq %rdi, %rdi
je 0x3dc62
movq %rdi, %rbx
cmpl $0xdead2bad, 0x6e8(%rdi) # imm = 0xDEAD2BAD
jne 0x3dc74
movl %r15d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rcx, %r12
movq %rdx, -0x48(%rbp)
movq %rsi, -0x38(%rbp)
cmpb $0x0, (%rsi)
movq %rsi, %r13
je 0x3dcbf
leaq 0x2(%rsi), %r13
cmpb $0x0, -0x1(%r13)
je 0x3dcb7
cmpb $0x0, (%r13)
je 0x3dcbf
cmpb $0x0, 0x1(%r13)
je 0x3dcbc
leaq 0x4(%r13), %rax
cmpb $0x0, 0x2(%r13)
movq %rax, %r13
jne 0x3dc8b
addq $-0x2, %rax
movq %rax, %r13
jmp 0x3dcbf
decq %r13
jmp 0x3dcbf
incq %r13
subl %esi, %r13d
movl %r13d, -0x30(%rbp)
movq -0x38(%rbp), %r14
movq %r12, -0x40(%rbp)
je 0x3dcf5
movsbq (%r14), %r15
cmpq $-0x41, %r15
ja 0x3dcf5
callq 0xc170
movq (%rax), %rax
testb $0x20, 0x1(%rax,%r15,2)
je 0x3dcf5
incq %r14
decl %r13d
jne 0x3dcd0
xorl %r13d, %r13d
movl %r13d, -0x30(%rbp)
movq %r14, -0x38(%rbp)
testl %r13d, %r13d
sete %r14b
je 0x3dd4b
movq -0x38(%rbp), %r12
leal -0x1(%r13), %eax
movb (%r12,%rax), %r15b
cmpb $-0x41, %r15b
ja 0x3dd4b
callq 0xc170
movq (%rax), %rax
movsbq %r15b, %rcx
testb $0x20, 0x1(%rax,%rcx,2)
je 0x3dd4b
cmpl $0x1, %r13d
sete %r14b
je 0x3dd48
leal -0x2(%r13), %ecx
movb (%r12,%rcx), %r15b
decl %r13d
cmpb $-0x41, %r15b
jbe 0x3dd20
jmp 0x3dd4b
xorl %r13d, %r13d
movl %r13d, -0x30(%rbp)
movq -0x48(%rbp), %r12
testq %r12, %r12
je 0x3ddd5
testb $0x1, %r14b
movq -0x40(%rbp), %r14
movl $0xffffffe8, %r15d      # imm = 0xFFFFFFE8
jne 0x3dc62
movq 0xb8(%rbx), %rdi
testq %rdi, %rdi
je 0x3dd82
movq 0x59321(%rip), %rax     # 0x970a0
callq *0x20(%rax)
cmpl $0x2, 0x59327(%rip)     # 0x970b0
jb 0x3dda1
movl $0xfffffff6, %r15d      # imm = 0xFFFFFFF6
cmpl $0xdead2bad, 0x6e8(%rbx) # imm = 0xDEAD2BAD
je 0x3dc62
leaq -0x38(%rbp), %rsi
movq %rbx, %rdi
movq %r12, %rdx
movq %r14, %rcx
callq 0x3012d
movl %eax, %r15d
movq 0xb8(%rbx), %rdi
testq %rdi, %rdi
je 0x3dc62
movq 0x592d3(%rip), %rax     # 0x970a0
callq *0x30(%rax)
jmp 0x3dc62
movl $0xffffffe8, %r15d      # imm = 0xFFFFFFE8
jmp 0x3dc62