// File: /workspace/github_c_makefile_star2_O3/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 0x62bbd
movq %rdx, %r14
movq (%rdx), %rdi
testb $0x1, 0x8(%rdi)
jne 0x62c0b
movq (%rbx), %rsi
movq 0x60(%rbx), %rdi
addq $0x8, %rsi
leaq 0x14a3a(%rip), %rcx     # 0x77609
movl $0x2, %edx
callq 0x40afa
movq 0x8(%rbx), %rbx
movq %rbx, %rdi
callq 0x30465
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 0x30577
leaq -0x68(%rbp), %rsi
movq %rax, (%rsi)
movq 0x60(%rbx), %r15
movl (%r12), %edx
movq %r15, %rdi
callq 0x51bfb
testq %rax, %rax
je 0x62cf4
movq %rax, %r12
movl $0x0, -0x2c(%rbp)
movq %rbx, %rdi
movl $0x38, %esi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x312d8
movq 0x60(%rbx), %rdi
testq %rax, %rax
je 0x62cdc
movq %rax, -0x60(%rbp)
movq %rax, %rcx
movq %r12, -0x38(%rbp)
movq %r12, (%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rax)
movq %rdi, 0x10(%rax)
movl $0x0, 0x28(%rax)
movabsq $0xfeac1400000000, %rax # imm = 0xFEAC1400000000
movq %rcx, -0x48(%rbp)
movq %rax, 0x30(%rcx)
cmpl $0x1, %r13d
je 0x62cab
movq 0x8(%r14), %r15
movq %r15, %rdi
callq 0x3f362
movl (%r15), %eax
movl %eax, -0x2c(%rbp)
movq %rbx, %rdi
callq 0x31231
movq %rax, %r12
movq %rbx, %rdi
callq 0x311eb
movq %rax, %r15
movq %r12, -0x40(%rbp)
testq %r12, %r12
sete %al
testq %r15, %r15
sete %cl
orb %al, %cl
movq 0x60(%rbx), %rdi
cmpb $0x1, %cl
jne 0x62d0a
movq (%rbx), %rsi
addq $0x8, %rsi
leaq 0x135e6(%rip), %rcx     # 0x762d0
movl $0x1, %edx
jmp 0x62bd4
movq (%rbx), %rsi
addq $0x8, %rsi
leaq 0x1491d(%rip), %rcx     # 0x7761f
movq %r15, %rdi
jmp 0x62bcf
movq %rbx, -0x50(%rbp)
movl -0x2c(%rbp), %r8d
andl $0x1, %r8d
movq -0x68(%rbp), %r12
cmpl $0x3, %r13d
jb 0x62d26
movq 0x10(%r14), %r9
jmp 0x62d29
xorl %r9d, %r9d
movq -0x48(%rbp), %r14
movq -0x38(%rbp), %rsi
movq %r12, %rdx
movl $0x1, %ecx
pushq $0x0
pushq $0x0
callq 0x51dad
addq $0x10, %rsp
movq %rax, 0x8(%r14)
testq %rax, %rax
je 0x62e74
leaq -0x58(%rbp), %rsi
movq %r14, %rdi
movq $-0x1, %rdx
callq 0x64ad2
testq %rax, %rax
jle 0x62e29
movl $0x0, 0x28(%r15)
movl 0x30(%r15), %ecx
testb $0x4, %cl
je 0x62d97
movq $0x0, 0x20(%r15)
movl $0x0, 0x2c(%r15)
andl $-0x5, %ecx
movl %ecx, 0x30(%r15)
movq -0x58(%rbp), %r12
addq %r12, %rax
testb $0x2, -0x2c(%rbp)
jne 0x62da9
movq %rax, %r13
jmp 0x62dbc
movq %rax, %r13
cmpq %rax, %r12
jae 0x62dbc
leaq -0x1(%r13), %rax
cmpb $0xa, -0x1(%r13)
je 0x62da9
testb $0x4, -0x2c(%rbp)
jne 0x62df0
subl %r12d, %r13d
movq %r15, %rdi
movq %r12, %rsi
movl %r13d, %edx
callq 0x302f6
movq -0x40(%rbp), %rax
testb $0x40, 0x8(%rax)
je 0x62e19
movq -0x40(%rbp), %rax
movq (%rax), %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x3ef1d
jmp 0x62e19
movq %r12, %r14
cmpq %r13, %r12
jae 0x62e19
movsbq (%r14), %rbx
cmpq $-0x41, %rbx
ja 0x62dc2
callq 0xc170
movq (%rax), %rax
testb $0x20, 0x1(%rax,%rbx,2)
je 0x62dc2
incq %r14
cmpq %r13, %r14
jne 0x62df8
movq -0x48(%rbp), %r14
movq %r14, %rdi
leaq -0x58(%rbp), %rsi
jmp 0x62d5a
movq -0x60(%rbp), %rbx
addq $0x10, %rbx
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
testq %rax, %rax
je 0x62e44
movq 0x8(%r14), %rdi
callq *%rax
movq %rbx, %rdi
callq 0x317be
movl $0x2126, 0x34(%r14)     # imm = 0x2126
movq -0x50(%rbp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x313b9
movq %rbx, %rdi
movq -0x40(%rbp), %rsi
callq 0x307f4
jmp 0x62bfa
leaq 0x147d2(%rip), %rdx     # 0x7764d
movq -0x50(%rbp), %rbx
movq %rbx, %rdi
movl $0x1, %esi
movq %r12, %rcx
xorl %eax, %eax
callq 0x44ed3
jmp 0x62bd9