// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: VmOverload
static jx9_vm_func * VmOverload(
	jx9_vm *pVm,         /* Target VM */
	jx9_vm_func *pList,  /* Linked list of candidates for overloading */
	jx9_value *aArg,     /* Array of passed arguments */
	int nArg             /* Total number of passed arguments  */
	)
{
	int iTarget, i, j, iCur, iMax;
	jx9_vm_func *apSet[10];   /* Maximum number of candidates */
	jx9_vm_func *pLink;
	SyString sArgSig;
	SyBlob sSig;

	pLink = pList;
	i = 0;
	/* Put functions expecting the same number of passed arguments */
	while( i < (int)SX_ARRAYSIZE(apSet) ){
		if( pLink == 0 ){
			break;
		}
		if( (int)SySetUsed(&pLink->aArgs) == nArg ){
			/* Candidate for overloading */
			apSet[i++] = pLink;
		}
		/* Point to the next entry */
		pLink = pLink->pNextName;
	}
	if( i < 1 ){
		/* No candidates, return the head of the list */
		return pList;
	}
	if( nArg < 1 || i < 2 ){
		/* Return the only candidate */
		return apSet[0];
	}
	/* Calculate function signature */
	SyBlobInit(&sSig, &pVm->sAllocator);
	for( j = 0 ; j < nArg ; j++ ){
		int c = 'n'; /* null */
		if( aArg[j].iFlags & MEMOBJ_HASHMAP ){
			/* Hashmap */
			c = 'h';
		}else if( aArg[j].iFlags & MEMOBJ_BOOL ){
			/* bool */
			c = 'b';
		}else if( aArg[j].iFlags & MEMOBJ_INT ){
			/* int */
			c = 'i';
		}else if( aArg[j].iFlags & MEMOBJ_STRING ){
			/* String */
			c = 's';
		}else if( aArg[j].iFlags & MEMOBJ_REAL ){
			/* Float */
			c = 'f';
		}
		if( c > 0 ){
			SyBlobAppend(&sSig, (const void *)&c, sizeof(char));
		}
	}
	SyStringInitFromBuf(&sArgSig, SyBlobData(&sSig), SyBlobLength(&sSig));
	iTarget = 0;
	iMax = -1;
	/* Select the appropriate function */
	for( j = 0 ; j < i ; j++ ){
		/* Compare the two signatures */
		iCur = VmOverloadCompare(&sArgSig, &apSet[j]->sSignature);
		if( iCur > iMax ){
			iMax = iCur;
			iTarget = j;
		}
	}
	SyBlobRelease(&sSig);
	/* Appropriate function for the current call context */
	return apSet[iTarget];
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x98(%rbp)
movl $0x0, -0x2c(%rbp)
cmpl $0xa, -0x2c(%rbp)
jge 0x77800
cmpq $0x0, -0x98(%rbp)
jne 0x777be
jmp 0x77800
movq -0x98(%rbp), %rax
movl 0x10(%rax), %eax
cmpl -0x24(%rbp), %eax
jne 0x777e9
movq -0x98(%rbp), %rcx
movl -0x2c(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x2c(%rbp)
cltq
movq %rcx, -0x90(%rbp,%rax,8)
movq -0x98(%rbp), %rax
movq 0xa8(%rax), %rax
movq %rax, -0x98(%rbp)
jmp 0x777ac
cmpl $0x1, -0x2c(%rbp)
jge 0x77813
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x779ea
cmpl $0x1, -0x24(%rbp)
jl 0x7781f
cmpl $0x2, -0x2c(%rbp)
jge 0x7782f
movq -0x90(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x779ea
movq -0x10(%rbp), %rsi
leaq -0xc8(%rbp), %rdi
callq 0x58bb0
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x77954
movl $0x6e, -0xcc(%rbp)
movq -0x20(%rbp), %rax
movslq -0x30(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x77885
movl $0x68, -0xcc(%rbp)
jmp 0x77923
movq -0x20(%rbp), %rax
movslq -0x30(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x778ab
movl $0x62, -0xcc(%rbp)
jmp 0x77921
movq -0x20(%rbp), %rax
movslq -0x30(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x778d1
movl $0x69, -0xcc(%rbp)
jmp 0x7791f
movq -0x20(%rbp), %rax
movslq -0x30(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x778f7
movl $0x73, -0xcc(%rbp)
jmp 0x7791d
movq -0x20(%rbp), %rax
movslq -0x30(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x7791b
movl $0x66, -0xcc(%rbp)
jmp 0x7791d
jmp 0x7791f
jmp 0x77921
jmp 0x77923
cmpl $0x0, -0xcc(%rbp)
jle 0x77944
leaq -0xc8(%rbp), %rdi
leaq -0xcc(%rbp), %rsi
movl $0x1, %edx
callq 0x5d9d0
jmp 0x77946
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x77846
movq -0xc0(%rbp), %rax
movq %rax, -0xa8(%rbp)
movl -0xb8(%rbp), %eax
movl %eax, -0xa0(%rbp)
movl $0x0, -0x28(%rbp)
movl $0xffffffff, -0x38(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x779ce
movslq -0x30(%rbp), %rax
movq -0x90(%rbp,%rax,8), %rsi
addq $0x90, %rsi
leaq -0xa8(%rbp), %rdi
callq 0x78f00
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x38(%rbp), %eax
jle 0x779c1
movl -0x34(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x30(%rbp), %eax
movl %eax, -0x28(%rbp)
jmp 0x779c3
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x77983
leaq -0xc8(%rbp), %rdi
callq 0x58c00
movslq -0x28(%rbp), %rax
movq -0x90(%rbp,%rax,8), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xd0, %rsp
popq %rbp
retq
nopw (%rax,%rax)