// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9Builtin_zip_entry_read
static int jx9Builtin_zip_entry_read(jx9_context *pCtx, int nArg, jx9_value **apArg)
{
	SyArchiveEntry *pEntry;
	zip_raw_data *pRaw;
	const char *zData;
	int iLength;
	if( nArg < 1 || !jx9_value_is_resource(apArg[0]) ){
		/* Missing/Invalid arguments */
		jx9_context_throw_error(pCtx, JX9_CTX_ERR, "Expecting a ZIP archive entry");
		/* return FALSE */
		jx9_result_bool(pCtx, 0);
		return JX9_OK;
	}
	/* Make sure we are dealing with a valid ZIP archive entry */
	pEntry = (SyArchiveEntry *)jx9_value_to_resource(apArg[0]);
	if( SXARCH_ENTRY_INVALID(pEntry) ){
		jx9_context_throw_error(pCtx, JX9_CTX_ERR, "Expecting a ZIP archive entry");
		/* return FALSE */
		jx9_result_bool(pCtx, 0);
		return JX9_OK;
	}
	zData = 0;
	if( pEntry->nReadCount >= pEntry->nByteCompr ){
		/* No more data to read, return FALSE */
		jx9_result_bool(pCtx, 0);
		return JX9_OK;
	}
	/* Set a default read length */
	iLength = 1024;
	if( nArg > 1 ){
		iLength = jx9_value_to_int(apArg[1]);
		if( iLength < 1 ){
			iLength = 1024;
		}
	}
	if( (sxu32)iLength > pEntry->nByteCompr - pEntry->nReadCount ){
		iLength = (int)(pEntry->nByteCompr - pEntry->nReadCount);
	}
	/* Return the entry contents */
	pRaw = (zip_raw_data *)pEntry->pUserData;
	if( pRaw->iType == ZIP_RAW_DATA_MEMBUF ){
		zData = (const char *)SyBlobDataAt(&pRaw->raw.sBlob, (pEntry->nOfft+pEntry->nReadCount));
	}else{
		const char *zMap = (const char *)pRaw->raw.mmap.pMap;
		/* Memory mmaped chunk */
		zData = &zMap[pEntry->nOfft+pEntry->nReadCount];
	}
	/* Increment the read counter */
	pEntry->nReadCount += iLength;
	/* Return the raw data */
	jx9_result_string(pCtx, zData, iLength);
	return JX9_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
cmpl $0x1, -0x14(%rbp)
jl 0xa529a
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x576d0
cmpl $0x0, %eax
jne 0xa52c6
movq -0x10(%rbp), %rdi
movl $0x1, %esi
leaq 0x208bf(%rip), %rdx     # 0xc5b69
callq 0x580b0
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x57070
movl $0x0, -0x4(%rbp)
jmp 0xa541e
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x56ec0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0xa52ed
movq -0x28(%rbp), %rax
cmpl $0xdead635a, 0xa0(%rax) # imm = 0xDEAD635A
je 0xa5319
movq -0x10(%rbp), %rdi
movl $0x1, %esi
leaq 0x2086c(%rip), %rdx     # 0xc5b69
callq 0x580b0
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x57070
movl $0x0, -0x4(%rbp)
jmp 0xa541e
movq $0x0, -0x38(%rbp)
movq -0x28(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x28(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jb 0xa5348
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x57070
movl $0x0, -0x4(%rbp)
jmp 0xa541e
movl $0x400, -0x3c(%rbp)     # imm = 0x400
cmpl $0x1, -0x14(%rbp)
jle 0xa5374
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x56c90
movl %eax, -0x3c(%rbp)
cmpl $0x1, -0x3c(%rbp)
jge 0xa5372
movl $0x400, -0x3c(%rbp)     # imm = 0x400
jmp 0xa5374
movl -0x3c(%rbp), %eax
movq -0x28(%rbp), %rcx
movl 0x4(%rcx), %ecx
movq -0x28(%rbp), %rdx
subl 0x8(%rdx), %ecx
cmpl %ecx, %eax
jbe 0xa539a
movq -0x28(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x28(%rbp), %rcx
subl 0x8(%rcx), %eax
movl %eax, -0x3c(%rbp)
movq -0x28(%rbp), %rax
movq 0x98(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x2, (%rax)
jne 0xa53d3
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x28(%rbp), %rcx
movl 0x48(%rcx), %ecx
movq -0x28(%rbp), %rdx
addl 0x8(%rdx), %ecx
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
jmp 0xa53fa
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq -0x28(%rbp), %rcx
movl 0x48(%rcx), %ecx
movq -0x28(%rbp), %rdx
addl 0x8(%rdx), %ecx
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movl -0x3c(%rbp), %ecx
movq -0x28(%rbp), %rax
addl 0x8(%rax), %ecx
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl -0x3c(%rbp), %edx
callq 0x57180
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)