// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9Builtin_file_get_contents
static int jx9Builtin_file_get_contents(jx9_context *pCtx, int nArg, jx9_value **apArg)
{
	const jx9_io_stream *pStream;
	jx9_int64 n, nRead, nMaxlen;
	int use_include  = FALSE;
	const char *zFile;
	char zBuf[8192];
	void *pHandle;
	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;
	}
	nMaxlen = -1;
	if( nArg > 1 ){
		use_include = jx9_value_to_bool(apArg[1]);
	}
	/* Try to open the file in read-only mode */
	pHandle = jx9StreamOpenHandle(pCtx->pVm, pStream, zFile, JX9_IO_OPEN_RDONLY, use_include, nArg > 2 ? apArg[2] : 0, FALSE, 0);
	if( pHandle == 0 ){
		jx9_context_throw_error_format(pCtx, JX9_CTX_ERR, "IO error while opening '%s'", zFile);
		jx9_result_bool(pCtx, 0);
		return JX9_OK;
	}
	if( nArg > 3 ){
		/* Extract the offset */
		n = jx9_value_to_int64(apArg[3]);
		if( n > 0 ){
			if( pStream->xSeek ){
				/* Seek to the desired offset */
				pStream->xSeek(pHandle, n, 0/*SEEK_SET*/);
			}
		}
		if( nArg > 4 ){
			/* Maximum data to read */
			nMaxlen = jx9_value_to_int64(apArg[4]);
		}
	}
	/* Perform the requested operation */
	nRead = 0;
	for(;;){
		n = pStream->xRead(pHandle, zBuf, 
			(nMaxlen > 0 && (nMaxlen < sizeof(zBuf))) ? nMaxlen : sizeof(zBuf));
		if( n < 1 ){
			/* EOF or IO error, break immediately */
			break;
		}
		/* Append data */
		jx9_result_string(pCtx, zBuf, (int)n);
		/* Increment read counter */
		nRead += n;
		if( nMaxlen > 0 && nRead >= nMaxlen ){
			/* Read limit reached */
			break;
		}
	}
	/* Close the stream */
	jx9StreamCloseHandle(pStream, pHandle);
	/* Check if we have read something */
	if( jx9_context_result_buf_length(pCtx) < 1 ){
		/* Nothing read, return FALSE */
		jx9_result_bool(pCtx, 0);
	}
	return JX9_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20b0, %rsp           # imm = 0x20B0
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movl $0x0, -0x44(%rbp)
cmpl $0x1, -0x14(%rbp)
jl 0xa7294
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x57480
cmpl $0x0, %eax
jne 0xa72c0
movq -0x10(%rbp), %rdi
movl $0x2, %esi
leaq 0x1e83e(%rip), %rdx     # 0xc5ae2
callq 0x580b0
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x57070
movl $0x0, -0x4(%rbp)
jmp 0xa7566
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq -0x205c(%rbp), %rsi
callq 0x56e20
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rdi
movl -0x205c(%rbp), %edx
leaq -0x50(%rbp), %rsi
callq 0x8e570
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0xa7325
movq -0x10(%rbp), %rdi
movl $0x2, %esi
leaq 0x1e7ef(%rip), %rdx     # 0xc5af8
callq 0x580b0
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x57070
movl $0x0, -0x4(%rbp)
jmp 0xa7566
movq $-0x1, -0x40(%rbp)
cmpl $0x1, -0x14(%rbp)
jle 0xa7343
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x56cf0
movl %eax, -0x44(%rbp)
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x2078(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x2070(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x2068(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x2060(%rbp)
cmpl $0x2, -0x14(%rbp)
jle 0xa7388
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x2080(%rbp)
jmp 0xa7393
xorl %eax, %eax
movq %rax, -0x2080(%rbp)
jmp 0xa7393
movl -0x2060(%rbp), %r8d
movq -0x2068(%rbp), %rdx
movq -0x2070(%rbp), %rsi
movq -0x2078(%rbp), %rdi
movq -0x2080(%rbp), %r9
movl $0x1, %ecx
xorl %eax, %eax
xorl %eax, %eax
movl $0x0, (%rsp)
movq $0x0, 0x8(%rsp)
callq 0x8e7e0
movq %rax, -0x2058(%rbp)
cmpq $0x0, -0x2058(%rbp)
jne 0xa7417
movq -0x10(%rbp), %rdi
movq -0x50(%rbp), %rcx
movl $0x1, %esi
leaq 0x1e72d(%rip), %rdx     # 0xc5b26
movb $0x0, %al
callq 0x79580
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x57070
movl $0x0, -0x4(%rbp)
jmp 0xa7566
cmpl $0x3, -0x14(%rbp)
jle 0xa7472
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x56d50
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jle 0xa7459
movq -0x28(%rbp), %rax
cmpq $0x0, 0x48(%rax)
je 0xa7457
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x2058(%rbp), %rdi
movq -0x30(%rbp), %rsi
xorl %edx, %edx
callq *%rax
jmp 0xa7459
cmpl $0x4, -0x14(%rbp)
jle 0xa7470
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x56d50
movq %rax, -0x40(%rbp)
jmp 0xa7472
movq $0x0, -0x38(%rbp)
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x2098(%rbp)
movq -0x2058(%rbp), %rax
movq %rax, -0x2090(%rbp)
leaq -0x2050(%rbp), %rax
movq %rax, -0x2088(%rbp)
cmpq $0x0, -0x40(%rbp)
jle 0xa74c3
cmpq $0x2000, -0x40(%rbp)    # imm = 0x2000
jae 0xa74c3
movq -0x40(%rbp), %rax
movq %rax, -0x20a0(%rbp)
jmp 0xa74d1
movl $0x2000, %eax           # imm = 0x2000
movq %rax, -0x20a0(%rbp)
jmp 0xa74d1
movq -0x2098(%rbp), %rax
movq -0x2088(%rbp), %rsi
movq -0x2090(%rbp), %rdi
movq -0x20a0(%rbp), %rdx
callq *%rax
movq %rax, -0x30(%rbp)
cmpq $0x1, -0x30(%rbp)
jge 0xa74fc
jmp 0xa7536
movq -0x10(%rbp), %rdi
leaq -0x2050(%rbp), %rsi
movq -0x30(%rbp), %rax
movl %eax, %edx
callq 0x57180
movq -0x30(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x40(%rbp)
jle 0xa7531
movq -0x38(%rbp), %rax
cmpq -0x40(%rbp), %rax
jl 0xa7531
jmp 0xa7536
jmp 0xa747a
movq -0x28(%rbp), %rdi
movq -0x2058(%rbp), %rsi
callq 0x8ea80
movq -0x10(%rbp), %rdi
callq 0x58490
cmpl $0x1, %eax
jae 0xa755f
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x57070
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20b0, %rsp           # imm = 0x20B0
popq %rbp
retq
nopw %cs:(%rax,%rax)