// File: /workspace/github_c_makefile_star2_O1/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 $0x58, %rsp
movl $0xffffffe8, %r15d      # imm = 0xFFFFFFE8
cmpl $0x62, %edx
jb 0x66517
movl %edx, %r13d
movq %rdi, %r14
leal -0x16(%r13), %ebx
leaq (%rsi,%rbx), %r12
testl %ebx, %ebx
movq %rsi, -0x50(%rbp)
movq %r12, -0x38(%rbp)
je 0x65ff8
leaq 0x136ce(%rip), %rsi     # 0x7965e
movq %r12, %rdi
movl $0x4, %edx
callq 0x34ebe
testl %eax, %eax
je 0x65ff4
movq -0x50(%rbp), %rsi
leaq (%rbx,%rsi), %rcx
decq %rcx
movl $0x1, %edx
leaq 0x136a6(%rip), %r15     # 0x7965e
movq %rcx, %r12
movq %rdx, %rbx
cmpq %rsi, %rcx
jbe 0x65fee
leal 0x16(%rbx), %eax
cmpl $0x8015, %eax           # imm = 0x8015
jae 0x65fee
movq %r12, %rdi
movq %r15, %rsi
movl $0x4, %edx
callq 0x34ebe
movq -0x50(%rbp), %rsi
leaq -0x1(%r12), %rcx
leaq 0x1(%rbx), %rdx
testl %eax, %eax
jne 0x65fb8
subq %rbx, -0x38(%rbp)
jmp 0x65ff8
movq -0x50(%rbp), %rsi
movl $0xffffffe8, %r15d      # imm = 0xFFFFFFE8
cmpl $0x6054b50, (%r12)      # imm = 0x6054B50
jne 0x66021
movzwl 0x8(%r12), %eax
movw %ax, 0x34(%r14)
cmpl $0x7fff, 0x34(%r14)     # imm = 0x7FFF
jbe 0x66529
xorl %eax, %eax
testb %al, %al
je 0x66517
movslq 0x40(%r14), %rax
subq %rax, %r12
cmpq %rsi, %r12
jbe 0x66053
leaq 0x13625(%rip), %rsi     # 0x79663
movq %r12, %rdi
movl $0x4, %edx
callq 0x34ebe
movq -0x50(%rbp), %rsi
testl %eax, %eax
je 0x66085
movl 0x3c(%r14), %r12d
movl $0xffffffe8, %r15d      # imm = 0xFFFFFFE8
cmpl %r13d, %r12d
jae 0x66517
addq %rsi, %r12
leaq 0x135f3(%rip), %rsi     # 0x79663
movq %r12, %rdi
movl $0x4, %edx
callq 0x34ebe
testl %eax, %eax
jne 0x66517
movq %r14, -0x30(%rbp)
movq -0x38(%rbp), %rcx
subl %r12d, %ecx
je 0x664fa
movq -0x30(%rbp), %rax
leaq 0x38(%rax), %rdx
movq %rdx, -0x68(%rbp)
addq $0x10, %rax
movq %rax, -0x60(%rbp)
movq %r12, %rbx
xorl %r14d, %r14d
movq %rcx, -0x38(%rbp)
movq %r14, -0x48(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rdi
movl $0xa8, %esi
callq 0x2e951
testq %rax, %rax
je 0x664fa
movq %rax, %r13
xorl %r14d, %r14d
movl $0xa8, %edx
movq %rax, %rdi
xorl %esi, %esi
callq 0xc360
movl $0xdead635a, 0xa0(%r13) # imm = 0xDEAD635A
cmpl $0x2014b50, (%rbx)      # imm = 0x2014B50
jne 0x661f7
movzwl 0x1c(%rbx), %eax
movw %ax, 0x58(%r13)
cmpl $0x7fff, 0x58(%r13)     # imm = 0x7FFF
jbe 0x66119
xorl %r14d, %r14d
jmp 0x661f7
movzwl 0x1e(%rbx), %eax
movw %ax, 0x4e(%r13)
movzwl 0xa(%rbx), %eax
movzwl 0x20(%rbx), %r14d
movw %ax, 0x4c(%r13)
movzbl 0xc(%rbx), %eax
movzbl 0xd(%rbx), %esi
movl %esi, %edx
shll $0x8, %edx
movzbl 0xe(%rbx), %edi
movzbl 0xf(%rbx), %r8d
movl %r8d, %ecx
shll $0x8, %ecx
orl %edi, %ecx
orl %eax, %edx
movl $0x0, 0x30(%r13)
shrl %r8d
addl $0x7bc, %r8d            # imm = 0x7BC
movl %r8d, 0x24(%r13)
shrl $0x5, %ecx
andl $0xf, %ecx
andl $0x1f, %edi
movl %edi, 0x1c(%r13)
shrl $0x3, %esi
movl %esi, 0x18(%r13)
shrl $0x5, %edx
andl $0x3f, %edx
movl %edx, 0x14(%r13)
addl %eax, %eax
andl $0x3e, %eax
movl %eax, 0x10(%r13)
decl %ecx
movl %ecx, 0x20(%r13)
movl 0x10(%rbx), %eax
movl %eax, 0xc(%r13)
movzwl 0x18(%rbx), %eax
movzbl 0x1a(%rbx), %ecx
shll $0x10, %ecx
orl %eax, %ecx
movzbl 0x1b(%rbx), %eax
shll $0x18, %eax
orl %eax, %ecx
movl %ecx, (%r13)
testl %eax, %eax
js 0x661f7
movzwl 0x14(%rbx), %eax
movzbl 0x16(%rbx), %ecx
shll $0x10, %ecx
orl %eax, %ecx
movzbl 0x17(%rbx), %eax
shll $0x18, %eax
orl %eax, %ecx
movl %ecx, 0x4(%r13)
testl %eax, %eax
js 0x661f7
movzwl 0x2a(%rbx), %eax
movzbl 0x2c(%rbx), %ecx
shll $0x10, %ecx
orl %eax, %ecx
movzbl 0x2d(%rbx), %eax
shll $0x18, %eax
orl %eax, %ecx
movl %ecx, 0x48(%r13)
testl %eax, %eax
setns %al
jmp 0x661f9
xorl %eax, %eax
movl 0x58(%r13), %r15d
movzwl 0x4e(%r13), %ecx
movzwl %r14w, %edx
addl %r15d, %edx
leal (%rcx,%rdx), %r14d
addl $0x2e, %r14d
testb %al, %al
je 0x6623d
movl 0x48(%r13), %ecx
movq -0x50(%rbp), %rax
movq %rcx, -0x40(%rbp)
leaq (%rax,%rcx), %rbx
movq %rbx, %rdi
leaq 0x13439(%rip), %rsi     # 0x79668
movl $0x4, %edx
callq 0x34ebe
testl %eax, %eax
je 0x662a7
xorl %ebx, %ebx
movl %ebx, -0x78(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rdi
movq %r13, %rsi
callq 0x2eb38
movq -0x48(%rbp), %rax
addl %r14d, %eax
leaq (%r12,%rax), %rdi
movq -0x38(%rbp), %r15
movl %r15d, %esi
subl %eax, %esi
leaq 0x133f7(%rip), %rdx     # 0x79663
movl $0x4, %ecx
leaq -0x78(%rbp), %r8
callq 0x5b678
addl -0x78(%rbp), %r14d
testl %eax, %eax
cmovnel %ebx, %r14d
jne 0x664fa
addl -0x48(%rbp), %r14d
leaq (%r12,%r14), %rbx
movl %r14d, %eax
movq %rax, -0x48(%rbp)
cmpl %r15d, %r14d
jb 0x660b8
jmp 0x664fa
movzwl 0x1a(%rbx), %eax
movzwl 0x1c(%rbx), %ecx
addl -0x40(%rbp), %eax
addl %ecx, %eax
addl $0x1e, %eax
movl %eax, 0x48(%r13)
movq -0x48(%rbp), %rax
leal 0x2e(%rax), %esi
addq %r12, %rsi
movq %rsi, 0x50(%r13)
testl %r15d, %r15d
je 0x662f3
cmpl $0x0, (%r13)
jne 0x662df
leal -0x1(%r15), %eax
cmpb $0x2f, (%rsi,%rax)
jne 0x662f3
movq -0x30(%rbp), %rax
movq (%rax), %rdi
movl %r15d, %edx
callq 0x3e425
testq %rax, %rax
jne 0x66308
movq -0x30(%rbp), %rax
movq (%rax), %rdi
movq %r13, %rsi
callq 0x2eb38
movq -0x38(%rbp), %r15
jmp 0x6628a
movq %rax, %r15
movq %rax, 0x50(%r13)
movl 0x58(%r13), %esi
movl %esi, -0x40(%rbp)
movq %rax, %rdi
movq -0x30(%rbp), %rbx
callq *0x28(%rbx)
movl %eax, %edx
movq 0x18(%rbx), %rax
movl 0x30(%rbx), %ecx
decl %ecx
andl %edx, %ecx
movq (%rax,%rcx,8), %rbx
movq %r15, -0x78(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x70(%rbp)
testq %rbx, %rbx
je 0x66376
movq -0x58(%rbp), %rcx
cmpl 0x90(%rbx), %edx
jne 0x66369
leaq 0x50(%rbx), %rsi
leaq -0x78(%rbp), %rdi
movq -0x30(%rbp), %rax
movl %edx, %r15d
callq *0x20(%rax)
movl %r15d, %edx
movq -0x58(%rbp), %rcx
testl %eax, %eax
je 0x66382
movq 0x68(%rbx), %rbx
testq %rbx, %rbx
jne 0x66344
xorl %eax, %eax
jmp 0x66387
xorl %eax, %eax
movq -0x38(%rbp), %rdx
movq -0x58(%rbp), %rcx
jmp 0x6638b
movb $0x1, %al
movq %rbx, %rcx
movq -0x38(%rbp), %rdx
testb %al, %al
movq %rcx, -0x58(%rbp)
je 0x663a8
movq 0x78(%rcx), %rax
movq %rax, 0x78(%r13)
movq %r13, 0x78(%rcx)
leaq 0x60(%rcx), %rax
jmp 0x664e7
movq -0x30(%rbp), %rbx
movl 0x30(%rbx), %ecx
leal (%rcx,%rcx,2), %eax
cmpl %eax, 0x38(%rbx)
jbe 0x66488
movq (%rbx), %rdi
movl %ecx, %r15d
shll $0x4, %r15d
movl %r15d, %esi
movq %rcx, -0x40(%rbp)
callq 0x343ed
movq -0x40(%rbp), %r8
testq %rax, %rax
je 0x66488
movq %rax, %r9
testl %r15d, %r15d
je 0x6641e
movl %r15d, %ecx
movq %r9, %rax
addq %rcx, %rax
movq %r9, %rcx
movb $0x0, (%rcx)
incq %rcx
cmpq %rax, %rcx
jae 0x6641e
movb $0x0, (%rcx)
incq %rcx
cmpq %rax, %rcx
jae 0x6641e
movb $0x0, (%rcx)
incq %rcx
cmpq %rax, %rcx
jae 0x6641e
movb $0x0, (%rcx)
incq %rcx
cmpq %rax, %rcx
jb 0x663f2
addl %r8d, %r8d
movq -0x68(%rbp), %rax
movl (%rax), %eax
testl %eax, %eax
xorps %xmm0, %xmm0
je 0x66466
leal -0x1(%r8), %ecx
movq -0x60(%rbp), %rdx
movq (%rdx), %rdx
movups %xmm0, 0x68(%rdx)
movl 0x90(%rdx), %esi
andl %ecx, %esi
movq (%r9,%rsi,8), %rdi
movq %rdi, 0x68(%rdx)
movq (%r9,%rsi,8), %rdi
testq %rdi, %rdi
je 0x6645a
movq %rdx, 0x70(%rdi)
movq %rdx, (%r9,%rsi,8)
subq $-0x80, %rdx
decl %eax
jne 0x66436
movq -0x30(%rbp), %rbx
movq (%rbx), %rdi
movq 0x18(%rbx), %rsi
movq %r8, -0x40(%rbp)
movq %r9, %r15
callq 0x3503f
movq %r15, 0x18(%rbx)
movq -0x40(%rbp), %rax
movl %eax, 0x30(%rbx)
movq 0x50(%r13), %rdi
movl 0x58(%r13), %esi
callq *0x28(%rbx)
movl %eax, 0x90(%r13)
movq 0x18(%rbx), %rcx
movl 0x30(%rbx), %edx
decl %edx
andl %eax, %edx
movq (%rcx,%rdx,8), %rax
movq %rax, 0x68(%r13)
movq (%rcx,%rdx,8), %rax
testq %rax, %rax
je 0x664ba
movq %r13, 0x70(%rax)
movq %r13, (%rcx,%rdx,8)
movq -0x60(%rbp), %rax
movq (%rax), %rax
testq %rax, %rax
movq -0x38(%rbp), %rdx
je 0x664dc
movq %rax, 0x80(%r13)
movq %r13, 0x88(%rax)
movq -0x60(%rbp), %rax
movq %r13, (%rax)
movq -0x68(%rbp), %rax
incl (%rax)
addl -0x48(%rbp), %r14d
leaq (%r12,%r14), %rbx
cmpl %edx, %r14d
jb 0x660b4
movq -0x30(%rbp), %rcx
movq 0x10(%rcx), %rax
movq %rax, 0x8(%rcx)
xorl %eax, %eax
cmpl $0x0, 0x38(%rcx)
setne %al
leal (%rax,%rax,2), %r15d
addl $-0x3, %r15d
movl %r15d, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movzwl 0xc(%r12), %eax
movzbl 0xe(%r12), %ecx
shll $0x10, %ecx
orl %eax, %ecx
movzbl 0xf(%r12), %edx
shll $0x18, %edx
orl %edx, %ecx
movl %ecx, 0x40(%r14)
xorl %eax, %eax
testl %edx, %edx
js 0x66023
movl 0x10(%r12), %eax
movl %eax, 0x3c(%r14)
movb $0x1, %al
xorl %r15d, %r15d
jmp 0x66023