// File: /workspace/github_c_makefile_star2_O2/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: GenStateCompileFunc
static sxi32 GenStateCompileFunc(
	jx9_gen_state *pGen, /* Code generator state */
	SyString *pName,     /* Function name. NULL otherwise */
	sxi32 iFlags,        /* Control flags */
	jx9_vm_func **ppFunc /* OUT: function state */
	)
{
	jx9_vm_func *pFunc;
	SyToken *pEnd;
	sxu32 nLine;
	char *zName;
	sxi32 rc;
	/* Extract line number */
	nLine = pGen->pIn->nLine;
	/* Jump the left parenthesis '(' */
	pGen->pIn++;
	/* Delimit the function signature */
	jx9DelimitNestedTokens(pGen->pIn, pGen->pEnd, JX9_TK_LPAREN /* '(' */, JX9_TK_RPAREN /* ')' */, &pEnd);
	if( pEnd >= pGen->pEnd ){
		/* Syntax error */
		rc = jx9GenCompileError(pGen, E_ERROR, nLine, "Missing ')' after function '%z' signature", pName);
		if( rc == SXERR_ABORT ){
			/* Error count limit reached, abort immediately */
			return SXERR_ABORT;
		}
		pGen->pIn = pGen->pEnd;
		return SXRET_OK;
	}
	/* Create the function state */
	pFunc = (jx9_vm_func *)SyMemBackendPoolAlloc(&pGen->pVm->sAllocator, sizeof(jx9_vm_func));
	if( pFunc == 0 ){
		goto OutOfMem;
	}
	/* function ID */
	zName = SyMemBackendStrDup(&pGen->pVm->sAllocator, pName->zString, pName->nByte);
	if( zName == 0 ){
		/* Don't worry about freeing memory, everything will be released shortly */
		goto OutOfMem;
	}
	/* Initialize the function state */
	jx9VmInitFuncState(pGen->pVm, pFunc, zName, pName->nByte, iFlags, 0);
	if( pGen->pIn < pEnd ){
		/* Collect function arguments */
		rc = GenStateCollectFuncArgs(pFunc, &(*pGen), pEnd);
		if( rc == SXERR_ABORT ){
			/* Don't worry about freeing memory, everything will be released shortly */
			return SXERR_ABORT;
		}
	}
	/* Compile function body */
	pGen->pIn = &pEnd[1];
	/* Compile the body */
	rc = GenStateCompileFuncBody(&(*pGen), pFunc);
	if( rc == SXERR_ABORT ){
		return SXERR_ABORT;
	}
	if( ppFunc ){
		*ppFunc = pFunc;
	}
	/* Finally register the function */
	rc = jx9VmInstallUserFunction(pGen->pVm, pFunc, 0);
	return rc;
	/* Fall through if something goes wrong */
OutOfMem:
	/* If the supplied memory subsystem is so sick that we are unable to allocate
	 * a tiny chunk of memory, there is no much we can do here.
	 */
	return GenStateOutOfMem(pGen);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdx, -0x90(%rbp)
movq %rsi, %r15
movq %rdi, %rbx
movq 0x158(%rdi), %rdi
movq 0x160(%rbx), %rsi
movl 0x14(%rdi), %r14d
addq $0x20, %rdi
movq %rdi, 0x158(%rbx)
leaq -0x98(%rbp), %r12
movl $0x200, %edx            # imm = 0x200
movl $0x400, %ecx            # imm = 0x400
movq %r12, %r8
callq 0x424f6
movq (%r12), %r13
cmpq 0x160(%rbx), %r13
jae 0x42b0b
movq (%rbx), %rdi
movl $0xb0, %esi
callq 0x279f7
testq %rax, %rax
je 0x42bd0
movq %rax, %r14
movq (%rbx), %rdi
movq (%r15), %rsi
movl 0x8(%r15), %edx
callq 0x35732
testq %rax, %rax
je 0x42bd0
movq %rax, %r12
movq %r14, -0x30(%rbp)
movq (%rbx), %r14
movl 0x8(%r15), %r15d
movq -0x30(%rbp), %rdi
movl $0xb0, %esi
callq 0x27aea
movaps 0x20e81(%rip), %xmm0    # 0x63630
movq -0x30(%rbp), %rax
movups %xmm0, 0x10(%rax)
movq -0x30(%rbp), %rax
movq %r14, (%rax)
movq -0x30(%rbp), %rax
andq $0x0, 0x8(%rax)
movq -0x30(%rbp), %rax
andq $0x0, 0x20(%rax)
movq -0x30(%rbp), %rax
movq $0x40, 0x40(%rax)
movq -0x30(%rbp), %rax
movq %r14, 0x28(%rax)
xorps %xmm0, %xmm0
movq -0x30(%rbp), %rax
movups %xmm0, 0x30(%rax)
movq -0x30(%rbp), %rax
andq $0x0, 0x48(%rax)
movq -0x30(%rbp), %rax
leaq 0x60(%rax), %rdi
movq -0x30(%rbp), %rax
movq $0x18, 0x78(%rax)
movq -0x30(%rbp), %rax
movq %r14, 0x60(%rax)
movq -0x30(%rbp), %r14
movups %xmm0, 0x68(%r14)
andq $0x0, 0x80(%r14)
pushq $0x10
popq %rsi
movq %rdi, -0x88(%rbp)
callq 0x3eba8
andl $0x0, 0x88(%r14)
andq $0x0, 0xa0(%r14)
movq %r12, 0x50(%r14)
movl %r15d, 0x58(%r14)
movq 0x158(%rbx), %r15
cmpq %r13, %r15
jae 0x42b9b
movq (%rbx), %rax
leaq -0xd0(%rbp), %rcx
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rcx)
movq %rax, (%rcx)
andl $0x0, 0x18(%rcx)
leaq -0x78(%rbp), %r12
cmpq %r13, %r15
jae 0x42b57
movq %r12, %rdi
pushq $0x40
popq %rsi
callq 0x27aea
movq (%rbx), %rax
movabsq $0x1800000000, %rcx     # imm = 0x1800000000
movq %rcx, -0x54(%rbp)
andl $0x0, -0x58(%rbp)
andl $0x0, -0x4c(%rbp)
movq %rax, -0x68(%rbp)
andq $0x0, -0x60(%rbp)
andq $0x0, -0x48(%rbp)
movl 0x10(%r15), %eax
testb $0xc, %al
je 0x42923
testb $0x4, %al
je 0x4291f
movq 0x18(%r15), %rax
testw %ax, %ax
js 0x428fd
btl $0x10, %eax
jb 0x42906
btl $0x12, %eax
jb 0x4290f
btl $0x11, %eax
jb 0x42918
movq 0x158(%rbx), %rax
movl 0x14(%rax), %edx
movq %rbx, %rdi
pushq $0x2
popq %rsi
leaq 0x22edb(%rip), %rcx     # 0x657cc
movq %r15, %r8
xorl %eax, %eax
callq 0x3eed6
jmp 0x4291f
movl $0x8, -0x40(%rbp)
jmp 0x4291f
movl $0x2, -0x40(%rbp)
jmp 0x4291f
movl $0x1, -0x40(%rbp)
jmp 0x4291f
movl $0x4, -0x40(%rbp)
addq $0x20, %r15
cmpq %r13, %r15
jae 0x42b78
testb $0x10, 0x10(%r15)
je 0x42b44
leaq 0x20(%r15), %rax
cmpq %r13, %rax
jae 0x42b44
testb $0xc, 0x30(%r15)
je 0x42b44
movq (%rbx), %rdi
movq 0x20(%r15), %rsi
movl 0x28(%r15), %edx
callq 0x35732
testq %rax, %rax
je 0x42bd0
movq %rax, -0x78(%rbp)
movl 0x28(%r15), %eax
movl %eax, -0x70(%rbp)
leaq 0x40(%r15), %r12
cmpq %r13, %r12
jae 0x42a88
testb $0x40, 0x52(%r15)
je 0x42a73
leaq 0x60(%r15), %rax
xorl %edx, %edx
pushq $0x60
popq %rcx
pushq $0x1
popq %r14
leaq (%r15,%rcx), %r12
cmpq %r13, %r12
jae 0x429d2
movl 0x10(%r15,%rcx), %esi
btl $0x11, %esi
jae 0x429b0
testl %edx, %edx
jle 0x429d2
movl %esi, %edi
andl $0x1480, %edi           # imm = 0x1480
negl %edi
movl $0x0, %edi
sbbl %edi, %edi
testw $0xa40, %si             # imm = 0xA40
cmovnel %r14d, %edi
addl %edi, %edx
addq $0x20, %rcx
jmp 0x42998
cmpq $0x60, %rcx
jbe 0x42cba
movups 0x158(%rbx), %xmm0
movaps %xmm0, -0xb0(%rbp)
movq %rax, 0x158(%rbx)
movq %r12, 0x160(%rbx)
movq (%rbx), %rax
movq 0xf0(%rax), %rcx
movq %rcx, -0x80(%rbp)
leaq -0x68(%rbp), %rcx
movq %rcx, 0xf0(%rax)
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4012f
movl %eax, %r15d
movq (%rbx), %rdi
xorl %edx, %edx
cmpl $-0x3, %eax
setne %dl
movl %r14d, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x3ee6f
movq (%rbx), %rax
leaq 0xc8(%rax), %rcx
movq -0x80(%rbp), %rdx
testq %rdx, %rdx
cmovneq %rdx, %rcx
movq %rcx, 0xf0(%rax)
movaps -0xb0(%rbp), %xmm0
movups %xmm0, 0x158(%rbx)
cmpl $-0xa, %r15d
movq -0x30(%rbp), %r14
je 0x42bd8
cmpq %r13, %r12
jae 0x42a84
testb $0x2, 0x12(%r12)
je 0x42cdb
addq $0x20, %r12
movq %r12, %r15
movl -0x40(%rbp), %eax
testl %eax, %eax
leaq -0x78(%rbp), %r12
je 0x42afb
movl $0x6e, -0x34(%rbp)
leal -0x1(%rax), %ecx
cmpl $0x7, %ecx
ja 0x42ac1
leaq 0x1fd00(%rip), %rdx     # 0x627ac
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
pushq $0x1
popq %rdx
jmpq *%rax
movl $0x73, -0x34(%rbp)
jmp 0x42aeb
cmpl $0x40, %eax
pushq $0x1
popq %rdx
jne 0x42aeb
movl $0x68, -0x34(%rbp)
jmp 0x42aeb
movl $0x66, -0x34(%rbp)
jmp 0x42aeb
movl $0x62, -0x34(%rbp)
jmp 0x42aeb
movl $0x69, -0x34(%rbp)
leaq -0xd0(%rbp), %rdi
leaq -0x34(%rbp), %rsi
callq 0x2e250
movq %r14, %rdi
movq %r12, %rsi
callq 0x2be00
jmp 0x42878
leaq 0x22c90(%rip), %rcx     # 0x657a2
xorl %r12d, %r12d
pushq $0x1
popq %rsi
movq %rbx, %rdi
movl %r14d, %edx
movq %r15, %r8
xorl %eax, %eax
callq 0x3eed6
cmpl $-0xa, %eax
je 0x42bd8
movq 0x160(%rbx), %rax
movq %rax, 0x158(%rbx)
jmp 0x42bdc
movq 0x158(%rbx), %rax
movl 0x14(%rax), %edx
leaq 0x22cce(%rip), %rcx     # 0x65823
jmp 0x42b89
movl -0xc0(%rbp), %eax
testl %eax, %eax
je 0x42b9b
movq -0xc8(%rbp), %rcx
movq %rcx, 0x90(%r14)
movl %eax, 0x98(%r14)
jmp 0x42b9b
movq 0x158(%rbx), %rax
movl 0x14(%rax), %edx
leaq 0x22c84(%rip), %rcx     # 0x6580d
pushq $0x1
popq %rsi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3eed6
cmpl $-0xa, %eax
je 0x42bd8
movq -0x98(%rbp), %rax
addq $0x20, %rax
movq %rax, 0x158(%rbx)
movq (%rbx), %rax
movq 0xf0(%rax), %rax
movl 0x10(%rax), %edx
pushq $0xa
popq %rsi
leaq -0x78(%rbp), %r8
movq %rbx, %rdi
movq %r14, %rcx
callq 0x4246c
testl %eax, %eax
je 0x42bf1
movq %rbx, %rdi
callq 0x426d9
pushq $-0xa
popq %r12
movl %r12d, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%rbx), %rax
movq 0xf0(%rax), %r14
movq -0x88(%rbp), %rcx
movq %rcx, 0xf0(%rax)
movq %rbx, %rdi
callq 0x4254b
movq (%rbx), %rdi
pushq $0x1
popq %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x3ee6f
movq (%rbx), %rax
leaq 0xc8(%rax), %rcx
testq %r14, %r14
cmovneq %r14, %rcx
movq -0x30(%rbp), %r14
movq %rcx, 0xf0(%rax)
movq %rbx, %rdi
callq 0x426b3
movq -0x90(%rbp), %rax
testq %rax, %rax
je 0x42c59
movq %r14, (%rax)
movl $0x308, %r15d           # imm = 0x308
addq (%rbx), %r15
movq 0x50(%r14), %rsi
movl 0x58(%r14), %edx
movq %r15, %rdi
callq 0x3ae09
testq %rax, %rax
je 0x42c97
movq 0x10(%rax), %rcx
xorl %r12d, %r12d
cmpq %r14, %rcx
je 0x42bdc
movq %rcx, 0xa8(%r14)
movq %r14, 0x10(%rax)
jmp 0x42bdc
andq $0x0, 0xa8(%r14)
movq 0x50(%r14), %rsi
movl 0x58(%r14), %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x3b67d
movl %eax, %r12d
jmp 0x42bdc
movl 0x74(%r15), %edx
leaq 0x22b74(%rip), %rcx     # 0x65839
pushq $0x1
popq %rsi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3eed6
movq -0x30(%rbp), %r14
jmp 0x42b96
movl 0x14(%r12), %edx
leaq 0x22f71(%rip), %rcx     # 0x65c58
pushq $0x1
popq %rsi
movq %rbx, %rdi
movq %r12, %r8
xorl %eax, %eax
callq 0x3eed6
jmp 0x42b96