// File: /workspace/github_c_makefile_star2_O1/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 0x63ee1
movq %rdx, %r14
movq (%rdx), %rdi
testb $0x1, 0x8(%rdi)
jne 0x63f33
movq (%rbx), %rsi
movq 0x60(%rbx), %rdi
addq $0x8, %rsi
leaq 0x1588f(%rip), %rcx     # 0x79782
movl $0x2, %edx
callq 0x4153c
movq 0x8(%rbx), %rbx
movq %rbx, %rdi
callq 0x309f2
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 0x30b04
leaq -0x30(%rbp), %rsi
movq %rax, (%rsi)
movq 0x60(%rbx), %rdi
movl (%r12), %edx
callq 0x53369
testq %rax, %rax
je 0x63fbb
movq %rax, %r13
cmpq $0x0, 0x18(%rax)
je 0x63fda
movq %rbx, %rdi
movl $0x38, %esi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x31892
movq 0x60(%rbx), %rdi
testq %rax, %rax
je 0x64000
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 0x64018
xorl %esi, %esi
jmp 0x6401c
movq -0x30(%rbp), %rcx
leaq 0x157d7(%rip), %rdx     # 0x7979d
movq %rbx, %rdi
movl $0x2, %esi
xorl %eax, %eax
callq 0x45d26
jmp 0x63efd
movq (%rbx), %rax
movq 0x8(%rax), %rcx
movq (%r13), %r8
leaq 0x15753(%rip), %rdx     # 0x7973f
movq %rbx, %rdi
movl $0x2, %esi
xorl %eax, %eax
callq 0x45d26
jmp 0x63efd
movq (%rbx), %rsi
addq $0x8, %rsi
leaq 0x142b7(%rip), %rcx     # 0x782c5
movl $0x1, %edx
jmp 0x63ef8
movq 0x8(%r14), %rsi
leaq 0x8(%r12), %rdx
callq *%rax
testl %eax, %eax
je 0x6404c
movq %r12, %rdi
addq $0x10, %rdi
callq 0x31d8f
movl $0x2126, 0x34(%r12)     # imm = 0x2126
movq %rbx, %rdi
movq %r12, %rsi
callq 0x31975
jmp 0x63efd
movq 0x8(%rbx), %rbx
movq %rbx, %rdi
callq 0x309f2
movq %r12, (%rbx)
movl $0x100, %eax            # imm = 0x100
jmp 0x63f15