// File: /workspace/github_c_makefile_star2_O0/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
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
cmpl $0x2, -0x14(%rbp)
jl 0x9f67e
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x57610
cmpl $0x0, %eax
jne 0x9f693
movq -0x10(%rbp), %rdi
callq 0x57120
movl $0x0, -0x4(%rbp)
jmp 0x9f7ff
movq -0x10(%rbp), %rdi
callq 0x58570
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x9f6bc
movq -0x10(%rbp), %rdi
callq 0x57120
movl $0x0, -0x4(%rbp)
jmp 0x9f7ff
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
movq (%rax), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x6da90
movq -0xc0(%rbp), %rax
movq (%rax), %rdi
leaq -0x70(%rbp), %rsi
callq 0x6da90
movq -0xc0(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0xb8(%rbp)
movl $0x0, -0xc4(%rbp)
movl -0xc4(%rbp), %eax
movq -0xc0(%rbp), %rcx
cmpl 0x2c(%rcx), %eax
jae 0x9f7eb
movq -0xb8(%rbp), %rdi
callq 0x6ea20
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x9f7c5
movq -0xc0(%rbp), %rax
movq (%rax), %rdi
movq -0x20(%rbp), %rax
movq (%rax), %rsi
movl $0x1, %edx
leaq -0x30(%rbp), %rcx
leaq -0xb0(%rbp), %r8
callq 0x72830
movl %eax, -0xc8(%rbp)
movq -0xb8(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x6e950
cmpl $0x0, -0xc8(%rbp)
je 0x9f79c
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rdx
leaq -0x70(%rbp), %rsi
callq 0x57920
jmp 0x9f7b0
movq -0x28(%rbp), %rdi
leaq -0x70(%rbp), %rsi
leaq -0xb0(%rbp), %rdx
callq 0x57920
leaq -0x70(%rbp), %rdi
callq 0x56ab0
leaq -0xb0(%rbp), %rdi
callq 0x56ab0
movq -0xb8(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0xb8(%rbp)
movl -0xc4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc4(%rbp)
jmp 0x9f713
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x572c0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq
nopl (%rax,%rax)