// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
pushq $-0x18
popq %rax
movl %eax, -0x40(%rbp)
cmpl $0x62, %edx
jb 0x5629d
movq %rdi, -0x38(%rbp)
movq %rdx, -0x30(%rbp)
leal -0x16(%rdx), %r14d
addq %rsi, %r14
pushq $0x16
popq %rbx
xorl %r12d, %r12d
pushq $0x4
popq %r13
movq %rsi, -0x48(%rbp)
leaq (%r14,%r12), %r15
cmpq %rsi, %r15
jbe 0x55e38
cmpl $0x8014, %ebx           # imm = 0x8014
ja 0x55e38
movq %r15, %rdi
leaq 0x11828(%rip), %rsi     # 0x67649
movl %r13d, %edx
callq 0x2d30e
movq -0x48(%rbp), %rsi
testl %eax, %eax
je 0x55e38
decq %r12
incl %ebx
jmp 0x55e06
cmpl $0x6054b50, (%r14,%r12) # imm = 0x6054B50
jne 0x5629d
movzwl 0x8(%r14,%r12), %eax
movq -0x38(%rbp), %r13
movw %ax, 0x34(%r13)
cmpl $0x7fff, 0x34(%r13)     # imm = 0x7FFF
ja 0x5629d
movslq 0xc(%r14,%r12), %rax
movl %eax, 0x40(%r13)
testq %rax, %rax
js 0x5629d
movl 0x10(%r14,%r12), %ebx
movl %ebx, 0x3c(%r13)
subq %rax, %r15
cmpq %rsi, %r15
movq -0x30(%rbp), %r14
jbe 0x55ea4
leaq 0x117bd(%rip), %rsi     # 0x6764e
pushq $0x4
popq %rdx
movq %r15, %rdi
callq 0x2d30e
movq -0x48(%rbp), %rsi
testl %eax, %eax
je 0x55ed1
cmpl %r14d, %ebx
jae 0x5629d
addq %rsi, %rbx
leaq 0x11797(%rip), %rsi     # 0x6764e
pushq $0x4
popq %rdx
movq %rbx, %rdi
callq 0x2d30e
movq -0x48(%rbp), %rsi
movq %rbx, %r15
testl %eax, %eax
jne 0x5629d
movl %r15d, %eax
negl %eax
leal (%r14,%rsi), %ecx
addl $-0x16, %ecx
addq %r12, %rcx
movq %rax, -0x88(%rbp)
addq %rax, %rcx
movq %rcx, -0x90(%rbp)
leaq 0x38(%r13), %rax
movq %rax, -0x60(%rbp)
leaq 0x10(%r13), %rax
movq %rax, -0x50(%rbp)
leal (%r14,%rsi), %eax
addl $-0x44, %eax
addq %r12, %rax
movq %rax, -0x80(%rbp)
xorl %r12d, %r12d
cmpl -0x90(%rbp), %r12d
jae 0x5627f
movq -0x38(%rbp), %rax
movq (%rax), %rdi
movl $0xa8, %esi
callq 0x279f7
testq %rax, %rax
je 0x5627f
movq %rax, %r13
movl %r12d, %r14d
movq %rax, %rdi
movl $0xa8, %esi
callq 0x27aea
movl $0xdead635a, 0xa0(%r13) # imm = 0xDEAD635A
cmpl $0x2014b50, (%r15,%r14) # imm = 0x2014B50
movq %r14, -0x40(%rbp)
jne 0x55f7e
movzwl 0x1c(%r15,%r14), %eax
movw %ax, 0x58(%r13)
cmpl $0x7fff, 0x58(%r13)     # imm = 0x7FFF
jbe 0x56023
xorl %ebx, %ebx
xorl %eax, %eax
movl 0x58(%r13), %ecx
movzwl 0x4e(%r13), %r14d
movzwl %bx, %ebx
movq %rcx, -0x30(%rbp)
addl %ebx, %ecx
leal (%r14,%rcx), %r12d
addl $0x2e, %r12d
testb %al, %al
je 0x55fcb
movl 0x48(%r13), %ecx
movq -0x48(%rbp), %rax
movq %rcx, -0x58(%rbp)
leaq (%rax,%rcx), %rdi
movq %rdi, -0x78(%rbp)
leaq 0x11698(%rip), %rsi     # 0x67653
pushq $0x4
popq %rdx
callq 0x2d30e
testl %eax, %eax
je 0x56092
andl $0x0, -0x70(%rbp)
movq -0x38(%rbp), %rax
movq (%rax), %rdi
movq %r13, %rsi
callq 0x27bf8
movq -0x40(%rbp), %rcx
addl %ecx, %r12d
leaq (%r15,%r12), %rdi
movq -0x88(%rbp), %rax
movl %eax, %esi
subl %ecx, %esi
subl -0x30(%rbp), %esi
subl %ebx, %esi
subl %r14d, %esi
addl -0x80(%rbp), %esi
leaq 0x11648(%rip), %rdx     # 0x6764e
pushq $0x4
popq %rcx
leaq -0x70(%rbp), %r8
callq 0x4d7da
addl -0x70(%rbp), %r12d
testl %eax, %eax
je 0x55f12
jmp 0x5627f
movzwl 0x1e(%r15,%r14), %eax
movw %ax, 0x4e(%r13)
movzwl 0xa(%r15,%r14), %eax
movzwl 0x20(%r15,%r14), %ebx
movw %ax, 0x4c(%r13)
movl 0xc(%r15,%r14), %edi
movq %r13, %rsi
addq $0x10, %rsi
callq 0x33d2b
decl 0x20(%r13)
movl 0x10(%r15,%r14), %eax
movl %eax, 0xc(%r13)
movl 0x18(%r15,%r14), %eax
movl %eax, (%r13)
testl %eax, %eax
js 0x55f80
movl 0x14(%r15,%r14), %eax
movl %eax, 0x4(%r13)
testl %eax, %eax
js 0x55f80
movl 0x2a(%r15,%r14), %eax
movl %eax, 0x48(%r13)
testl %eax, %eax
setns %al
jmp 0x55f82
movq -0x78(%rbp), %rcx
movzwl 0x1a(%rcx), %eax
movzwl 0x1c(%rcx), %ecx
addl -0x58(%rbp), %eax
addl %ecx, %eax
addl $0x1e, %eax
movl %eax, 0x48(%r13)
movq -0x40(%rbp), %rbx
leal 0x2e(%rbx), %esi
addq %r15, %rsi
movq %rsi, 0x50(%r13)
movq -0x30(%rbp), %rdx
testl %edx, %edx
je 0x5614a
cmpl $0x0, (%r13)
jne 0x560d4
leal -0x1(%rdx), %eax
cmpb $0x2f, (%rsi,%rax)
jne 0x5614a
movq -0x38(%rbp), %rax
movq (%rax), %rdi
callq 0x35732
testq %rax, %rax
je 0x5614a
movq %rax, 0x50(%r13)
movl 0x58(%r13), %esi
movl %esi, -0x30(%rbp)
movq %rax, %rdi
movq -0x38(%rbp), %r14
movq %rax, -0x58(%rbp)
callq *0x28(%r14)
movl %eax, %ebx
movq 0x18(%r14), %rax
movl 0x30(%r14), %ecx
decl %ecx
andl %ebx, %ecx
movq (%rax,%rcx,8), %r14
movq -0x58(%rbp), %rax
movq %rax, -0x70(%rbp)
movl -0x30(%rbp), %eax
movl %eax, -0x68(%rbp)
testq %r14, %r14
je 0x56161
cmpl 0x90(%r14), %ebx
jne 0x56144
leaq 0x50(%r14), %rsi
leaq -0x70(%rbp), %rdi
movq -0x38(%rbp), %rax
callq *0x20(%rax)
testl %eax, %eax
je 0x561ec
movq 0x68(%r14), %r14
jmp 0x5611f
movq -0x38(%rbp), %rax
movq (%rax), %rdi
movq %r13, %rsi
callq 0x27bf8
addl %ebx, %r12d
jmp 0x55f12
movq -0x38(%rbp), %r14
movl 0x30(%r14), %ecx
leal (%rcx,%rcx,2), %eax
cmpl %eax, 0x38(%r14)
jbe 0x5621a
movq (%r14), %rdi
movl %ecx, %esi
shll $0x4, %esi
movl %esi, -0x30(%rbp)
movq %rcx, %rbx
callq 0x2ca19
testq %rax, %rax
je 0x5621a
movq %rbx, %rcx
movq %rax, %rbx
addl %ecx, %ecx
movq %rax, %rdi
movl -0x30(%rbp), %esi
movq %rcx, %r14
callq 0x27aea
movq -0x60(%rbp), %rax
movl (%rax), %eax
movq %r14, -0x30(%rbp)
leal -0x1(%r14), %ecx
movq -0x50(%rbp), %rdx
xorps %xmm0, %xmm0
subl $0x1, %eax
jb 0x561fe
movq (%rdx), %rdx
movups %xmm0, 0x68(%rdx)
movl 0x90(%rdx), %esi
andl %ecx, %esi
movq (%rbx,%rsi,8), %rdi
movq %rdi, 0x68(%rdx)
testq %rdi, %rdi
je 0x561e2
movq %rdx, 0x70(%rdi)
movq %rdx, (%rbx,%rsi,8)
subq $-0x80, %rdx
jmp 0x561bd
movq 0x78(%r14), %rax
movq %rax, 0x78(%r13)
movq %r13, 0x78(%r14)
addq $0x60, %r14
jmp 0x56273
movq -0x38(%rbp), %r14
movq (%r14), %rdi
movq 0x18(%r14), %rsi
callq 0x2d420
movq %rbx, 0x18(%r14)
movq -0x30(%rbp), %rax
movl %eax, 0x30(%r14)
movq 0x50(%r13), %rdi
movl 0x58(%r13), %esi
callq *0x28(%r14)
movl %eax, 0x90(%r13)
movq 0x18(%r14), %rcx
movl 0x30(%r14), %edx
decl %edx
andl %eax, %edx
movq (%rcx,%rdx,8), %rax
movq %rax, 0x68(%r13)
testq %rax, %rax
je 0x5624a
movq %r13, 0x70(%rax)
movq %r13, (%rcx,%rdx,8)
movq -0x50(%rbp), %rax
movq (%rax), %rax
testq %rax, %rax
je 0x56268
movq %rax, 0x80(%r13)
movq %r13, 0x88(%rax)
movq -0x50(%rbp), %rax
movq %r13, (%rax)
movq -0x60(%rbp), %r14
incl (%r14)
addl -0x40(%rbp), %r12d
jmp 0x55f12
movq -0x38(%rbp), %rcx
movq 0x10(%rcx), %rax
movq %rax, 0x8(%rcx)
xorl %eax, %eax
cmpl $0x0, 0x38(%rcx)
setne %al
leal (%rax,%rax,2), %eax
addl $-0x3, %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq