// File: /workspace/github_c_makefile_star2_O3/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 $0xb8, %rsp
movq %rdi, %rbx
cmpl $0x2, %esi
jl 0x5d79e
movq %rdx, %r14
movq 0x8(%rdx), %rax
testb $0x40, 0x8(%rax)
je 0x5d79e
movq %rbx, %rdi
callq 0x31231
movq %rax, -0x30(%rbp)
testq %rax, %rax
je 0x5d79e
movq %rbx, -0x48(%rbp)
movq %r14, -0x58(%rbp)
movq 0x8(%r14), %rax
movq (%rax), %rdx
movq (%rdx), %rax
xorps %xmm0, %xmm0
movaps %xmm0, -0x90(%rbp)
movaps %xmm0, -0xa0(%rbp)
movaps %xmm0, -0x70(%rbp)
movaps %xmm0, -0x80(%rbp)
movq %rax, -0x90(%rbp)
movq %rax, -0x88(%rbp)
movl $0x20, %ecx
movl %ecx, -0x98(%rbp)
movaps %xmm0, -0xd0(%rbp)
movaps %xmm0, -0xe0(%rbp)
movaps %xmm0, -0xc0(%rbp)
movaps %xmm0, -0xb0(%rbp)
movq %rax, -0xd0(%rbp)
movq %rax, -0xc8(%rbp)
movl %ecx, -0xd8(%rbp)
movl 0x2c(%rdx), %eax
testl %eax, %eax
je 0x5d78b
leaq 0x10(%rdx), %r12
xorl %r14d, %r14d
leaq -0xa0(%rbp), %rbx
leaq -0xe0(%rbp), %r15
movq %rdx, -0x50(%rbp)
movq (%r12), %r12
movq (%r12), %rcx
movl 0x38(%r12), %r13d
movq (%rcx), %rcx
cmpl %r13d, 0x218(%rcx)
jbe 0x5d773
imull 0x220(%rcx), %r13d
movq 0x210(%rcx), %rcx
addq %rcx, %r13
movq %r13, -0x40(%rbp)
testq %rcx, %rcx
je 0x5d77b
movq (%rdx), %rdi
movq -0x58(%rbp), %rax
movq (%rax), %rsi
movl $0x1, %edx
leaq -0x40(%rbp), %rcx
movq %rbx, %r8
callq 0x4089b
movl %eax, -0x34(%rbp)
movq %r12, %rdi
movq %r15, %rsi
callq 0x3e2fe
movq -0x30(%rbp), %rax
testb $0x40, 0x8(%rax)
je 0x5d75a
cmpl $0x0, -0x34(%rbp)
cmoveq %rbx, %r13
movq -0x30(%rbp), %rax
movq (%rax), %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x3ef1d
movq %r15, %rdi
callq 0x30465
movq %rbx, %rdi
callq 0x30465
movq -0x50(%rbp), %rdx
movl 0x2c(%rdx), %eax
jmp 0x5d77b
movq $0x0, -0x40(%rbp)
addq $0x48, %r12
incl %r14d
cmpl %eax, %r14d
jb 0x5d6d5
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x30(%rbp), %rdi
callq 0x3e19f
jmp 0x5d7a7
movq 0x8(%rbx), %rdi
callq 0x30465
xorl %eax, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq