// File: /workspace/github_c_makefile_star2_O1/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9_hashmap_map
static int jx9_hashmap_map(jx9_context *pCtx, int nArg, jx9_value **apArg)
{
	jx9_value *pArray, *pValue, sKey, sResult;
	jx9_hashmap_node *pEntry;
	jx9_hashmap *pMap;
	sxu32 n;
	if( nArg < 2 || !jx9_value_is_json_array(apArg[1]) ){
		/* Invalid arguments, return NULL */
		jx9_result_null(pCtx);
		return JX9_OK;
	}
	/* Create a new array */
	pArray = jx9_context_new_array(pCtx);
	if( pArray == 0 ){
		jx9_result_null(pCtx);
		return JX9_OK;
	}
	/* Point to the internal representation of the input hashmap */
	pMap = (jx9_hashmap *)apArg[1]->x.pOther;
	jx9MemObjInit(pMap->pVm, &sResult);
	jx9MemObjInit(pMap->pVm, &sKey);
	/* Perform the requested operation */
	pEntry = pMap->pFirst;
	for( n = 0 ; n < pMap->nEntry ; n++ ){
		/* Extrcat the node value */
		pValue = HashmapExtractNodeValue(pEntry);
		if( pValue ){
			sxi32 rc;
			/* Invoke the supplied callback */
			rc = jx9VmCallUserFunction(pMap->pVm, apArg[0], 1, &pValue, &sResult);
			/* Extract the node key */
			jx9HashmapExtractNodeKey(pEntry, &sKey);
			if( rc != SXRET_OK ){
				/* An error occured while invoking the supplied callback [i.e: not defined] */
				jx9_array_add_elem(pArray, &sKey, pValue); /* Keep the same value */
			}else{
				/* Insert the callback return value */
				jx9_array_add_elem(pArray, &sKey, &sResult);
			}
			jx9MemObjRelease(&sKey);
			jx9MemObjRelease(&sResult);
		}
		/* Point to the next entry */
		pEntry = pEntry->pPrev; /* Reverse link */
	}
	jx9_result_value(pCtx, pArray);
	return JX9_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdi, %rbx
cmpl $0x2, %esi
jl 0x5f0c9
movq %rdx, %r14
movq 0x8(%rdx), %rax
testb $0x40, 0x8(%rax)
je 0x5f0c9
movq %rbx, %rdi
callq 0x317eb
movq %rax, -0x30(%rbp)
testq %rax, %rax
je 0x5f0c9
movq %rbx, -0x38(%rbp)
movq 0x8(%r14), %rax
movq (%rax), %rdx
movq (%rdx), %rax
xorps %xmm0, %xmm0
movaps %xmm0, -0xc0(%rbp)
movaps %xmm0, -0xa0(%rbp)
movaps %xmm0, -0xd0(%rbp)
movaps %xmm0, -0xb0(%rbp)
movq %rax, -0xc0(%rbp)
movq %rax, -0xb8(%rbp)
xorl %r15d, %r15d
movl %r15d, -0xa0(%rbp)
movl $0x20, %eax
movl %eax, -0xc8(%rbp)
movq (%rdx), %rcx
movaps %xmm0, -0x80(%rbp)
movaps %xmm0, -0x60(%rbp)
movaps %xmm0, -0x90(%rbp)
movaps %xmm0, -0x70(%rbp)
movq %rcx, -0x80(%rbp)
movq %rcx, -0x78(%rbp)
movl %r15d, -0x60(%rbp)
movl %eax, -0x88(%rbp)
cmpl %r15d, 0x2c(%rdx)
je 0x5f0e6
leaq 0x10(%rdx), %r12
movq %rdx, -0x48(%rbp)
movq %r14, -0x40(%rbp)
movq (%r12), %r12
movq (%r12), %rax
movq (%rax), %rax
movl 0x38(%r12), %r13d
cmpl %r13d, 0x218(%rax)
jbe 0x5f02a
imull 0x220(%rax), %r13d
addq 0x210(%rax), %r13
jmp 0x5f02d
xorl %r13d, %r13d
movq %r13, -0x50(%rbp)
testq %r13, %r13
je 0x5f0a7
movq (%rdx), %rdi
movq (%r14), %rsi
movl $0x1, %edx
leaq -0x50(%rbp), %rcx
leaq -0xd0(%rbp), %rbx
movq %rbx, %r8
callq 0x412d9
movl %eax, %r14d
movq %r12, %rdi
leaq -0x90(%rbp), %rsi
callq 0x3ed27
testl %r14d, %r14d
je 0x5f0ba
movq -0x30(%rbp), %rax
testb $0x40, 0x8(%rax)
je 0x5f08b
movq -0x30(%rbp), %rax
movq (%rax), %rdi
leaq -0x90(%rbp), %rsi
movq %r13, %rdx
callq 0x3f924
leaq -0x90(%rbp), %rdi
callq 0x309f2
movq %rbx, %rdi
callq 0x309f2
movq -0x40(%rbp), %r14
movq -0x48(%rbp), %rdx
addq $0x48, %r12
incl %r15d
cmpl 0x2c(%rdx), %r15d
jb 0x5f000
jmp 0x5f0e6
movq -0x30(%rbp), %rax
testb $0x40, 0x8(%rax)
movq %rbx, %r13
jne 0x5f075
jmp 0x5f08b
movq 0x8(%rbx), %rdi
callq 0x309f2
xorl %eax, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x30(%rbp), %rdi
callq 0x3ebc8
jmp 0x5f0d2