// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9Builtin_opendir
static int jx9Builtin_opendir(jx9_context *pCtx, int nArg, jx9_value **apArg)
{
	const jx9_io_stream *pStream;
	const char *zPath;
	io_private *pDev;
	int iLen, rc;
	if( nArg < 1 || !jx9_value_is_string(apArg[0]) ){
		/* Missing/Invalid arguments, return FALSE */
		jx9_context_throw_error(pCtx, JX9_CTX_WARNING, "Expecting a directory path");
		jx9_result_bool(pCtx, 0);
		return JX9_OK;
	}
	/* Extract the target path */
	zPath  = jx9_value_to_string(apArg[0], &iLen);
	/* Try to extract a stream */
	pStream = jx9VmGetStreamDevice(pCtx->pVm, &zPath, iLen);
	if( pStream == 0 ){
		jx9_context_throw_error_format(pCtx, JX9_CTX_WARNING, 
			"No stream device is associated with the given path(%s)", zPath);
		jx9_result_bool(pCtx, 0);
		return JX9_OK;
	}
	if( pStream->xOpenDir == 0 ){
		jx9_context_throw_error_format(pCtx, JX9_CTX_WARNING, 
			"IO routine(%s) not implemented in the underlying stream(%s) device", 
			jx9_function_name(pCtx), pStream->zName
			);
		jx9_result_bool(pCtx, 0);
		return JX9_OK;
	}
	/* Allocate a new IO private instance */
	pDev = (io_private *)jx9_context_alloc_chunk(pCtx, sizeof(io_private), TRUE, FALSE);
	if( pDev == 0 ){
		jx9_context_throw_error(pCtx, JX9_CTX_ERR, "JX9 is running out of memory");
		jx9_result_bool(pCtx, 0);
		return JX9_OK;
	}
	/* Initialize the structure */
	InitIOPrivate(pCtx->pVm, pStream, pDev);
	/* Open the target directory */
	rc = pStream->xOpenDir(zPath, nArg > 1 ? apArg[1] : 0, &pDev->pHandle);
	if( rc != JX9_OK ){
		/* IO error, return FALSE */
		ReleaseIOPrivate(pCtx, pDev);
		jx9_result_bool(pCtx, 0);
	}else{
		/* Return the handle as a resource */
		jx9_result_resource(pCtx, pDev);
	}
	return JX9_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
testl %esi, %esi
jle 0x6243d
movq %rdx, %r14
movq (%rdx), %rdi
testb $0x1, 0x8(%rdi)
jne 0x6248f
movq (%rbx), %rsi
movq 0x60(%rbx), %rdi
addq $0x8, %rsi
leaq 0x1533e(%rip), %rcx     # 0x7778d
movl $0x2, %edx
callq 0x40afa
movq 0x8(%rbx), %rbx
movq %rbx, %rdi
callq 0x30465
movq $0x0, (%rbx)
movl $0x8, %eax
movl $0xfffffe90, %ecx       # imm = 0xFFFFFE90
andl 0x8(%rbx), %ecx
orl %eax, %ecx
movl %ecx, 0x8(%rbx)
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %esi, %r15d
leaq -0x34(%rbp), %r12
movq %r12, %rsi
callq 0x30577
leaq -0x30(%rbp), %rsi
movq %rax, (%rsi)
movq 0x60(%rbx), %rdi
movl (%r12), %edx
callq 0x51bfb
testq %rax, %rax
je 0x62517
movq %rax, %r13
cmpq $0x0, 0x18(%rax)
je 0x62536
movq %rbx, %rdi
movl $0x38, %esi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x312d8
movq 0x60(%rbx), %rdi
testq %rax, %rax
je 0x6255c
movq %rax, %r12
movq %r13, (%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rax)
movq %rdi, 0x10(%rax)
movl $0x0, 0x28(%rax)
movabsq $0xfeac1400000000, %rax # imm = 0xFEAC1400000000
movq %rax, 0x30(%r12)
movq 0x18(%r13), %rax
movq -0x30(%rbp), %rdi
cmpl $0x1, %r15d
jne 0x62574
xorl %esi, %esi
jmp 0x62578
movq -0x30(%rbp), %rcx
leaq 0x15286(%rip), %rdx     # 0x777a8
movq %rbx, %rdi
movl $0x2, %esi
xorl %eax, %eax
callq 0x44ed3
jmp 0x62459
movq (%rbx), %rax
movq 0x8(%rax), %rcx
movq (%r13), %r8
leaq 0x15202(%rip), %rdx     # 0x7774a
movq %rbx, %rdi
movl $0x2, %esi
xorl %eax, %eax
callq 0x44ed3
jmp 0x62459
movq (%rbx), %rsi
addq $0x8, %rsi
leaq 0x13d66(%rip), %rcx     # 0x762d0
movl $0x1, %edx
jmp 0x62454
movq 0x8(%r14), %rsi
leaq 0x8(%r12), %rdx
callq *%rax
testl %eax, %eax
je 0x625a8
movq %r12, %rdi
addq $0x10, %rdi
callq 0x317be
movl $0x2126, 0x34(%r12)     # imm = 0x2126
movq %rbx, %rdi
movq %r12, %rsi
callq 0x313b9
jmp 0x62459
movq 0x8(%rbx), %rbx
movq %rbx, %rdi
callq 0x30465
movq %r12, (%rbx)
movl $0x100, %eax            # imm = 0x100
jmp 0x62471