// File: /workspace/github_c_makefile_star2_O1/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9Builtin_file
static int jx9Builtin_file(jx9_context *pCtx, int nArg, jx9_value **apArg)
{
	const char *zFile, *zPtr, *zEnd, *zBuf;
	jx9_value *pArray, *pLine;
	const jx9_io_stream *pStream;
	int use_include = 0;
	io_private *pDev;
	jx9_int64 n;
	int iFlags;
	int nLen;
	
	if( nArg < 1 || !jx9_value_is_string(apArg[0]) ){
		/* Missing/Invalid arguments, return FALSE */
		jx9_context_throw_error(pCtx, JX9_CTX_WARNING, "Expecting a file path");
		jx9_result_bool(pCtx, 0);
		return JX9_OK;
	}
	/* Extract the file path */
	zFile = jx9_value_to_string(apArg[0], &nLen);
	/* Point to the target IO stream device */
	pStream = jx9VmGetStreamDevice(pCtx->pVm, &zFile, nLen);
	if( pStream == 0 ){
		jx9_context_throw_error(pCtx, JX9_CTX_WARNING, "No such stream device, JX9 is returning FALSE");
		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);
	iFlags = 0;
	if( nArg > 1 ){
		iFlags = jx9_value_to_int(apArg[1]);
	}
	if( iFlags & 0x01 /*FILE_USE_INCLUDE_PATH*/ ){
		use_include = TRUE;
	}
	/* Create the array and the working value */
	pArray = jx9_context_new_array(pCtx);
	pLine = jx9_context_new_scalar(pCtx);
	if( pArray == 0 || pLine == 0 ){
		jx9_context_throw_error(pCtx, JX9_CTX_ERR, "JX9 is running out of memory");
		jx9_result_bool(pCtx, 0);
		return JX9_OK;
	}
	/* Try to open the file in read-only mode */
	pDev->pHandle = jx9StreamOpenHandle(pCtx->pVm, pStream, zFile, JX9_IO_OPEN_RDONLY, use_include, nArg > 2 ? apArg[2] : 0, FALSE, 0);
	if( pDev->pHandle == 0 ){
		jx9_context_throw_error_format(pCtx, JX9_CTX_ERR, "IO error while opening '%s'", zFile);
		jx9_result_bool(pCtx, 0);
		/* Don't worry about freeing memory, everything will be released automatically
		 * as soon we return from this function.
		 */
		return JX9_OK;
	}
	/* Perform the requested operation */
	for(;;){
		/* Try to extract a line */
		n = StreamReadLine(pDev, &zBuf, -1);
		if( n < 1 ){
			/* EOF or IO error */
			break;
		}
		/* Reset the cursor */
		jx9_value_reset_string_cursor(pLine);
		/* Remove line ending if requested by the caller */
		zPtr = zBuf;
		zEnd = &zBuf[n];
		if( iFlags & 0x02 /* FILE_IGNORE_NEW_LINES */ ){
			/* Ignore trailig lines */
			while( zPtr < zEnd && (zEnd[-1] == '\n' 
#ifdef __WINNT__
				|| zEnd[-1] == '\r'
#endif
				)){
					n--;
					zEnd--;
			}
		}
		if( iFlags & 0x04 /* FILE_SKIP_EMPTY_LINES */ ){
			/* Ignore empty lines */
			while( zPtr < zEnd && (unsigned char)zPtr[0] < 0xc0 && SyisSpace(zPtr[0]) ){
				zPtr++;
			}
			if( zPtr >= zEnd ){
				/* Empty line */
				continue;
			}
		}
		jx9_value_string(pLine, zBuf, (int)(zEnd-zBuf));
		/* Insert line */
		jx9_array_add_elem(pArray, 0/* Automatic index assign*/, pLine);
	}
	/* Close the stream */
	jx9StreamCloseHandle(pStream, pDev->pHandle);
	/* Release the io_private instance */
	ReleaseIOPrivate(pCtx, pDev);
	/* Return the created array */
	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 $0x48, %rsp
movq %rdi, %rbx
testl %esi, %esi
jle 0x64636
movq %rdx, %r14
movq (%rdx), %rdi
testb $0x1, 0x8(%rdi)
jne 0x64684
movq (%rbx), %rsi
movq 0x60(%rbx), %rdi
addq $0x8, %rsi
leaq 0x14fb6(%rip), %rcx     # 0x795fe
movl $0x2, %edx
callq 0x4153c
movq 0x8(%rbx), %rbx
movq %rbx, %rdi
callq 0x309f2
movq $0x0, (%rbx)
movl $0xfffffe90, %eax       # imm = 0xFFFFFE90
andl 0x8(%rbx), %eax
orl $0x8, %eax
movl %eax, 0x8(%rbx)
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %esi, %r13d
leaq -0x6c(%rbp), %r12
movq %r12, %rsi
callq 0x30b04
leaq -0x68(%rbp), %rsi
movq %rax, (%rsi)
movq 0x60(%rbx), %r15
movl (%r12), %edx
movq %r15, %rdi
callq 0x53369
movq %rax, -0x40(%rbp)
testq %rax, %rax
je 0x64774
movq %rbx, %rdi
movl $0x38, %esi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x31892
movq 0x60(%rbx), %rdi
testq %rax, %rax
je 0x6475c
movl $0x0, -0x2c(%rbp)
movq %rax, -0x58(%rbp)
movq %rax, %r12
movq -0x40(%rbp), %rax
movq %rax, (%r12)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%r12)
movq %rdi, 0x10(%r12)
movl $0x0, 0x28(%r12)
movabsq $0xfeac1400000000, %rax # imm = 0xFEAC1400000000
movq %rax, 0x30(%r12)
cmpl $0x1, %r13d
je 0x6472c
movq 0x8(%r14), %r15
movq %r15, %rdi
callq 0x3fd5f
movl (%r15), %eax
movl %eax, -0x2c(%rbp)
movq %rbx, %rdi
callq 0x317eb
movq %rax, -0x38(%rbp)
movq %rbx, %rdi
callq 0x317a5
movq %rax, %r15
cmpq $0x0, -0x38(%rbp)
sete %al
testq %r15, %r15
sete %cl
orb %al, %cl
movq 0x60(%rbx), %rdi
cmpb $0x1, %cl
jne 0x6478a
movq (%rbx), %rsi
addq $0x8, %rsi
leaq 0x13b5b(%rip), %rcx     # 0x782c5
movl $0x1, %edx
jmp 0x6464d
movq (%rbx), %rsi
addq $0x8, %rsi
leaq 0x14e92(%rip), %rcx     # 0x79614
movq %r15, %rdi
jmp 0x64648
movq %rbx, -0x48(%rbp)
movl -0x2c(%rbp), %r8d
andl $0x1, %r8d
movq -0x68(%rbp), %rbx
cmpl $0x3, %r13d
jl 0x647a6
movq 0x10(%r14), %r9
jmp 0x647a9
xorl %r9d, %r9d
movq -0x40(%rbp), %rsi
movq %rbx, %rdx
movl $0x1, %ecx
pushq $0x0
pushq $0x0
callq 0x534fd
addq $0x10, %rsp
movq %rax, 0x8(%r12)
testq %rax, %rax
je 0x64920
leaq -0x50(%rbp), %rsi
movq %r12, %rdi
movq $-0x1, %rdx
callq 0x66644
testq %rax, %rax
jle 0x648d3
movq %r12, -0x60(%rbp)
movl $0x0, 0x28(%r15)
movl 0x30(%r15), %ecx
testb $0x4, %cl
je 0x64818
movq $0x0, 0x20(%r15)
movl $0x0, 0x2c(%r15)
andl $-0x5, %ecx
movl %ecx, 0x30(%r15)
movq -0x50(%rbp), %r14
addq %r14, %rax
movl -0x2c(%rbp), %ecx
testb $0x2, %cl
jne 0x6482c
movq %rax, %r13
jmp 0x6483f
movq %rax, %r13
cmpq %rax, %r14
jae 0x6483f
leaq -0x1(%r13), %rax
cmpb $0xa, -0x1(%r13)
je 0x6482c
testb $0x4, %cl
jne 0x64872
subl %r14d, %r13d
movq %r15, %rdi
movq %r14, %rsi
movl %r13d, %edx
callq 0x3087c
movq -0x38(%rbp), %rax
testb $0x40, 0x8(%rax)
je 0x648b3
movq -0x38(%rbp), %rax
movq (%rax), %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x3f924
jmp 0x648b3
cmpq %r13, %r14
setb %r12b
jae 0x648b3
movb (%r14), %bl
cmpb $-0x41, %bl
ja 0x648ad
callq 0xc170
movq (%rax), %rax
leaq 0x1(%r14), %rcx
movsbq %bl, %rdx
testb $0x20, 0x1(%rax,%rdx,2)
je 0x648ad
cmpq %r13, %rcx
je 0x648b3
setb %r12b
movb (%rcx), %bl
incq %rcx
cmpb $-0x41, %bl
jbe 0x6488f
testb $0x1, %r12b
jne 0x64844
movq -0x60(%rbp), %r12
movq %r12, %rdi
leaq -0x50(%rbp), %rsi
movq $-0x1, %rdx
callq 0x66644
testq %rax, %rax
jg 0x647f0
movq -0x58(%rbp), %rbx
addq $0x10, %rbx
movq -0x40(%rbp), %rax
movq 0x20(%rax), %rax
testq %rax, %rax
je 0x648ef
movq 0x8(%r12), %rdi
callq *%rax
movq %rbx, %rdi
callq 0x31d8f
movl $0x2126, 0x34(%r12)     # imm = 0x2126
movq -0x48(%rbp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x31975
movq %rbx, %rdi
movq -0x38(%rbp), %rsi
callq 0x30d83
jmp 0x64673
leaq 0x14d1b(%rip), %rdx     # 0x79642
movq %rbx, %rcx
movq -0x48(%rbp), %rbx
movq %rbx, %rdi
movl $0x1, %esi
xorl %eax, %eax
callq 0x45d26
jmp 0x64652