// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: SyZipExtractFromBuf
JX9_PRIVATE sxi32 SyZipExtractFromBuf(SyArchive *pArch, const char *zBuf, sxu32 nLen)
 {
 	const unsigned char *zCentral, *zEnd;
 	sxi32 rc;
#if defined(UNTRUST)
 	if( SXARCH_INVALID(pArch) || zBuf == 0 ){
 		return SXERR_INVALID;
 	}
#endif 	
 	/* The miminal size of a zip archive:
 	 * LOCAL_HDR_SZ + CENTRAL_HDR_SZ + END_OF_CENTRAL_HDR_SZ
 	 * 		30				46				22
 	 */
 	 if( nLen < SXZIP_LOCAL_HDRSZ + SXZIP_CENTRAL_HDRSZ + SXZIP_END_CENTRAL_HDRSZ ){
 	 	return SXERR_CORRUPT; /* Don't bother processing return immediately */
 	 }
 	  		
 	zEnd = (unsigned char *)&zBuf[nLen - SXZIP_END_CENTRAL_HDRSZ];
 	/* Find the end of central directory */
 	while( ((sxu32)((unsigned char *)&zBuf[nLen] - zEnd) < (SXZIP_END_CENTRAL_HDRSZ + SXI16_HIGH)) &&
		zEnd > (unsigned char *)zBuf && SyMemcmp(zEnd, "PK\005\006", sizeof(sxu32)) != 0 ){
 		zEnd--;
 	} 	
 	/* Parse the end of central directory */
 	rc = ParseEndOfCentralDirectory(&(*pArch), zEnd);
 	if( rc != SXRET_OK ){
 		return rc;
 	} 	
 	
 	/* Find the starting offset of the central directory */
 	zCentral = &zEnd[-(sxi32)pArch->nCentralSize];
 	if( zCentral <= (unsigned char *)zBuf || SyMemcmp(zCentral, "PK\001\002", sizeof(sxu32)) != 0 ){
 		if( pArch->nCentralOfft >= nLen ){
			/* Corrupted central directory offset */
 			return SXERR_CORRUPT;
 		}
 		zCentral = (unsigned char *)&zBuf[pArch->nCentralOfft];
 		if( SyMemcmp(zCentral, "PK\001\002", sizeof(sxu32)) != 0 ){
 			/* Corrupted zip archive */
 			return SXERR_CORRUPT;
 		}
 		/* Fall thru and extract all valid entries from the central directory */
 	}
 	rc = ZipExtract(&(*pArch), zCentral, (sxu32)(zEnd - zCentral), (void *)zBuf);
 	return rc;
 }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
cmpl $0x62, -0x1c(%rbp)
jae 0xa9da5
movl $0xffffffe8, -0x4(%rbp) # imm = 0xFFFFFFE8
jmp 0xa9eeb
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
subl $0x16, %ecx
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
addq %rcx, %rax
movq -0x30(%rbp), %rcx
subq %rcx, %rax
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x8015, %ecx           # imm = 0x8015
movb %al, -0x35(%rbp)
jae 0xa9e05
movq -0x30(%rbp), %rcx
xorl %eax, %eax
cmpq -0x18(%rbp), %rcx
movb %al, -0x35(%rbp)
jbe 0xa9e05
movq -0x30(%rbp), %rdi
leaq 0x1bd50(%rip), %rsi     # 0xc5b42
movl $0x4, %edx
callq 0x5d3c0
cmpl $0x0, %eax
setne %al
movb %al, -0x35(%rbp)
movb -0x35(%rbp), %al
testb $0x1, %al
jne 0xa9e0e
jmp 0xa9e1c
movq -0x30(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0xa9db8
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0xa9f80
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0xa9e3d
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xa9eeb
movq -0x30(%rbp), %rax
movq -0x10(%rbp), %rdx
xorl %ecx, %ecx
subl 0x40(%rdx), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x18(%rbp), %rax
jbe 0xa9e78
movq -0x28(%rbp), %rdi
leaq 0x1bcde(%rip), %rsi     # 0xc5b47
movl $0x4, %edx
callq 0x5d3c0
cmpl $0x0, %eax
je 0xa9ec4
movq -0x10(%rbp), %rax
movl 0x3c(%rax), %eax
cmpl -0x1c(%rbp), %eax
jb 0xa9e8d
movl $0xffffffe8, -0x4(%rbp) # imm = 0xFFFFFFE8
jmp 0xa9eeb
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movl 0x3c(%rcx), %ecx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
leaq 0x1bc9d(%rip), %rsi     # 0xc5b47
movl $0x4, %edx
callq 0x5d3c0
cmpl $0x0, %eax
je 0xa9ec2
movl $0xffffffe8, -0x4(%rbp) # imm = 0xFFFFFFE8
jmp 0xa9eeb
jmp 0xa9ec4
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rax
movq -0x28(%rbp), %rcx
subq %rcx, %rax
movl %eax, %edx
movq -0x18(%rbp), %rcx
callq 0xaa070
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)