// File: /workspace/github_c_makefile_star2_O3/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 $0x98, %rsp
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %rbx
movq 0x158(%rdi), %r14
movq 0x160(%rdi), %rax
movl 0x14(%r14), %edx
addq $0x20, %r14
movq %r14, 0x158(%rdi)
cmpq %rax, %r14
jae 0x4c0ce
movl $0x1, %ecx
movl 0x10(%r14), %esi
btl $0x9, %esi
jb 0x4c0c3
btl $0xa, %esi
jae 0x4c0c5
cmpl $0x2, %ecx
jl 0x4c0ce
decl %ecx
jmp 0x4c0c5
incl %ecx
addq $0x20, %r14
cmpq %rax, %r14
jb 0x4c0aa
cmpq %rax, %r14
jae 0x4c4ab
movq (%rbx), %rdi
movl $0xb0, %esi
callq 0x2e481
movq %rax, -0x38(%rbp)
testq %rax, %rax
je 0x4c558
movq (%rbx), %rdi
movq (%r12), %rsi
movl 0x8(%r12), %edx
callq 0x3da5b
testq %rax, %rax
je 0x4c558
movq %r15, -0x40(%rbp)
movq (%rbx), %r15
movl 0x8(%r12), %ecx
movl %ecx, -0x90(%rbp)
movq -0x38(%rbp), %r12
leaq 0x10(%r12), %rdi
xorl %r13d, %r13d
movl $0xa0, %edx
xorl %esi, %esi
movq %rax, -0xa0(%rbp)
callq 0xc360
movl $0x40, 0x18(%r12)
movq %r15, (%r12)
movq %r13, 0x8(%r12)
movabsq $0x4000000000, %rax     # imm = 0x4000000000
movq %rax, 0x3c(%r12)
movl %r13d, 0x44(%r12)
movq %r15, 0x28(%r12)
movq %r13, 0x48(%r12)
leaq 0x60(%r12), %rdi
movl %r13d, 0x70(%r12)
movl $0x18, 0x78(%r12)
movq %r15, 0x60(%r12)
movq -0x40(%rbp), %r15
movq %r13, 0x80(%r12)
movq %rdi, -0x98(%rbp)
movl $0x10, %esi
callq 0x480bd
movl %r13d, 0x88(%r12)
movq %r13, 0xa0(%r12)
movq -0xa0(%rbp), %rax
movq %rax, 0x50(%r12)
movl -0x90(%rbp), %eax
movl %eax, 0x58(%r12)
movq 0x158(%rbx), %r13
cmpq %r14, %r13
jae 0x4c528
movq (%rbx), %rax
xorps %xmm0, %xmm0
leaq -0xc0(%rbp), %rcx
movups %xmm0, 0x8(%rcx)
movq %rax, (%rcx)
movl $0x0, 0x18(%rcx)
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movaps %xmm0, -0x60(%rbp)
movaps %xmm0, -0x70(%rbp)
movaps %xmm0, -0x80(%rbp)
movq (%rbx), %rax
movl $0x18, -0x58(%rbp)
movq %rax, -0x70(%rbp)
movq $0x0, -0x50(%rbp)
movl 0x10(%r13), %eax
testb $0xc, %al
je 0x4c28e
testb $0x4, %al
je 0x4c28a
movq 0x18(%r13), %rax
testw %ax, %ax
js 0x4c268
btl $0x10, %eax
jb 0x4c271
btl $0x12, %eax
jb 0x4c27a
btl $0x11, %eax
jb 0x4c283
movq 0x158(%rbx), %rax
movl 0x14(%rax), %edx
movq %rbx, %rdi
movl $0x2, %esi
leaq 0x29590(%rip), %rcx     # 0x757ec
movq %r13, %r8
xorl %eax, %eax
callq 0x483d1
jmp 0x4c28a
movl $0x8, -0x48(%rbp)
jmp 0x4c28a
movl $0x2, -0x48(%rbp)
jmp 0x4c28a
movl $0x1, -0x48(%rbp)
jmp 0x4c28a
movl $0x4, -0x48(%rbp)
addq $0x20, %r13
cmpq %r14, %r13
jae 0x4c4fc
testb $0x10, 0x10(%r13)
je 0x4c4e9
leaq 0x20(%r13), %rax
cmpq %r14, %rax
jae 0x4c4e9
testb $0xc, 0x30(%r13)
je 0x4c4e9
movq (%rbx), %rdi
movq 0x20(%r13), %rsi
movl 0x28(%r13), %edx
callq 0x3da5b
testq %rax, %rax
je 0x4c558
movq %rax, -0x80(%rbp)
movl 0x28(%r13), %eax
movl %eax, -0x78(%rbp)
leaq 0x40(%r13), %r12
cmpq %r14, %r12
jae 0x4c3fd
testb $0x40, 0x52(%r13)
je 0x4c3e8
leaq 0x60(%r13), %rax
cmpq %r14, %rax
jae 0x4c674
movl $0x60, %ecx
xorl %edx, %edx
movq %rax, %r12
movl 0x10(%r12), %esi
btl $0x11, %esi
jae 0x4c31c
testl %edx, %edx
jle 0x4c34a
movl %esi, %edi
andl $0x1480, %edi           # imm = 0x1480
negl %edi
movl $0x0, %edi
sbbl %edi, %edi
testl $0xa40, %esi            # imm = 0xA40
movl $0x1, %esi
cmovnel %esi, %edi
addl %edi, %edx
addq $0x20, %rcx
addq $0x20, %r12
cmpq %r14, %r12
jb 0x4c30d
cmpq $0x60, %rcx
jbe 0x4c674
movups 0x158(%rbx), %xmm0
movaps %xmm0, -0x90(%rbp)
movq %rax, 0x158(%rbx)
movq %r12, 0x160(%rbx)
movq (%rbx), %rax
movq 0xf0(%rax), %r15
leaq -0x70(%rbp), %rcx
movq %rcx, 0xf0(%rax)
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x49789
movl %eax, %r13d
movq (%rbx), %rdi
xorl %edx, %edx
cmpl $-0x3, %eax
setne %dl
movl $0x1, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x48365
movq (%rbx), %rax
leaq 0xc8(%rax), %rcx
movq %r15, %rdx
movq -0x40(%rbp), %r15
testq %rdx, %rdx
cmovneq %rdx, %rcx
movq %rcx, 0xf0(%rax)
movaps -0x90(%rbp), %xmm0
movups %xmm0, 0x158(%rbx)
cmpl $-0xa, %r13d
je 0x4c573
cmpq %r14, %r12
jae 0x4c3f9
testb $0x2, 0x12(%r12)
je 0x4c690
addq $0x20, %r12
movq %r12, %r13
movl -0x48(%rbp), %eax
testl %eax, %eax
movq -0x38(%rbp), %r12
je 0x4c46f
movl $0x6e, -0x2c(%rbp)
leal -0x1(%rax), %ecx
cmpl $0x7, %ecx
ja 0x4c433
leaq 0x263a7(%rip), %rdx     # 0x727c8
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
movl $0x73, -0x2c(%rbp)
jmp 0x4c45a
cmpl $0x40, %eax
jne 0x4c45a
movl $0x68, -0x2c(%rbp)
jmp 0x4c45a
movl $0x66, -0x2c(%rbp)
jmp 0x4c45a
movl $0x62, -0x2c(%rbp)
jmp 0x4c45a
movl $0x69, -0x2c(%rbp)
leaq -0xc0(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
movl $0x1, %edx
callq 0x359ad
movq %r12, %rdi
leaq -0x80(%rbp), %rsi
callq 0x33094
cmpq %r14, %r13
jb 0x4c1f3
movl -0xb0(%rbp), %eax
testl %eax, %eax
je 0x4c528
movq -0xb8(%rbp), %rcx
movq %rcx, 0x90(%r12)
movl %eax, 0x98(%r12)
jmp 0x4c528
leaq 0x29310(%rip), %rcx     # 0x757c2
movq %rbx, %rdi
movl $0x1, %esi
movq %r12, %r8
xorl %eax, %eax
callq 0x483d1
movl %eax, %ecx
movl $0xfffffff6, %eax       # imm = 0xFFFFFFF6
cmpl $-0xa, %ecx
je 0x4c578
movq 0x160(%rbx), %rax
movq %rax, 0x158(%rbx)
xorl %eax, %eax
jmp 0x4c578
movq 0x158(%rbx), %rax
movl 0x14(%rax), %edx
leaq 0x29349(%rip), %rcx     # 0x75843
jmp 0x4c50d
movq 0x158(%rbx), %rax
movl 0x14(%rax), %edx
leaq 0x29320(%rip), %rcx     # 0x7582d
movq %rbx, %rdi
movl $0x1, %esi
xorl %eax, %eax
callq 0x483d1
movl %eax, %ecx
movl $0xfffffff6, %eax       # imm = 0xFFFFFFF6
cmpl $-0xa, %ecx
je 0x4c578
addq $0x20, %r14
movq %r14, 0x158(%rbx)
movq (%rbx), %rax
movq 0xf0(%rax), %rax
movl 0x10(%rax), %edx
leaq -0x80(%rbp), %r8
movq %rbx, %rdi
movl $0xa, %esi
movq %r12, %rcx
callq 0x4bdf9
testl %eax, %eax
je 0x4c58a
leaq 0x291fa(%rip), %rcx     # 0x75759
movq %rbx, %rdi
movl $0x1, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x483d1
movl $0xfffffff6, %eax       # imm = 0xFFFFFFF6
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%rbx), %rax
movq 0xf0(%rax), %r14
movq -0x98(%rbp), %rcx
movq %rcx, 0xf0(%rax)
movq %rbx, %rdi
callq 0x4bed4
movq (%rbx), %rdi
movl $0x1, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x48365
movq (%rbx), %rax
leaq 0xc8(%rax), %rcx
testq %r14, %r14
cmovneq %r14, %rcx
movq %rcx, 0xf0(%rax)
movq 0xc8(%rbx), %rdi
testq %rdi, %rdi
je 0x4c5f5
movq 0x8(%rdi), %rax
movq %rax, 0xc8(%rbx)
callq 0x484ee
testq %r15, %r15
je 0x4c5fd
movq %r12, (%r15)
movq (%rbx), %rax
leaq 0x308(%rax), %rbx
movl 0x58(%r12), %edx
testl %edx, %edx
je 0x4c653
cmpl $0x0, 0x330(%rax)
je 0x4c653
movq 0x50(%r12), %rsi
movq %rbx, %rdi
callq 0x448fa
testq %rax, %rax
je 0x4c64e
movq %rax, %rcx
movq 0x10(%rax), %rdx
xorl %eax, %eax
cmpq %r12, %rdx
je 0x4c578
movq %rdx, 0xa8(%r12)
movq %r12, 0x10(%rcx)
jmp 0x4c578
movl 0x58(%r12), %edx
movq $0x0, 0xa8(%r12)
movq 0x50(%r12), %rsi
movq %rbx, %rdi
movq %r12, %rcx
callq 0x445f4
jmp 0x4c578
movl 0x74(%r13), %edx
leaq 0x291da(%rip), %rcx     # 0x75859
movq %rbx, %rdi
movl $0x1, %esi
xorl %eax, %eax
callq 0x483d1
jmp 0x4c6ae
movl 0x14(%r12), %edx
leaq 0x295dc(%rip), %rcx     # 0x75c78
movq %rbx, %rdi
movl $0x1, %esi
movq %r12, %r8
xorl %eax, %eax
callq 0x483d1
movl %eax, %ecx
movq -0x38(%rbp), %r12
jmp 0x4c51e