// File: /workspace/github_c_makefile_star2_O3/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, %r13d      # imm = 0xFFFFFFE8
cmpl $0x62, %edx
jb 0x649c6
movl %edx, %ebx
movq %rsi, %r15
movq %rdi, -0x80(%rbp)
leal -0x16(%rbx), %r14d
leaq (%rsi,%r14), %r13
leaq 0x131a6(%rip), %rsi     # 0x77669
movq %r13, %rdi
movl $0x4, %edx
callq 0x347f1
testl %eax, %eax
movq %r15, -0x48(%rbp)
je 0x64524
leaq (%r14,%r15), %rcx
decq %rcx
movl $0x1, %edx
leaq 0x1317e(%rip), %r15     # 0x77669
movq %rcx, %r12
movq %rdx, %r14
cmpq -0x48(%rbp), %rcx
jbe 0x6451f
leal 0x16(%r14), %eax
cmpl $0x8015, %eax           # imm = 0x8015
jae 0x6451f
movq %r12, %rdi
movq %r15, %rsi
movl $0x4, %edx
callq 0x347f1
leaq -0x1(%r12), %rcx
leaq 0x1(%r14), %rdx
testl %eax, %eax
jne 0x644eb
subq %r14, %r13
jmp 0x64527
movq %r13, %r12
cmpl $0x6054b50, (%r12)      # imm = 0x6054B50
movq -0x80(%rbp), %r14
jne 0x649c0
movzwl 0x8(%r12), %eax
movw %ax, 0x34(%r14)
cmpl $0x7fff, 0x34(%r14)     # imm = 0x7FFF
ja 0x649c0
movslq 0xc(%r12), %rax
movl %eax, 0x40(%r14)
testq %rax, %rax
js 0x649c0
movq %r13, -0x38(%rbp)
movl 0x10(%r12), %r15d
movl %r15d, 0x3c(%r14)
subq %rax, %r12
cmpq -0x48(%rbp), %r12
movl $0xffffffe8, %r13d      # imm = 0xFFFFFFE8
jbe 0x64598
leaq 0x130e7(%rip), %rsi     # 0x7766e
movq %r12, %rdi
movl $0x4, %edx
callq 0x347f1
testl %eax, %eax
je 0x645c4
cmpl %ebx, %r15d
jae 0x649c6
addq -0x48(%rbp), %r15
leaq 0x130c2(%rip), %rsi     # 0x7766e
movq %r15, %rdi
movl $0x4, %edx
callq 0x347f1
movq %r15, %r12
testl %eax, %eax
jne 0x649c6
movq -0x38(%rbp), %rax
subl %r12d, %eax
movq %rax, -0x38(%rbp)
je 0x649d8
leaq 0x38(%r14), %rax
movq %rax, -0x60(%rbp)
leaq 0x10(%r14), %rax
movq %rax, -0x68(%rbp)
xorl %r15d, %r15d
movq %r12, %rbx
movq (%r14), %rdi
movl $0xa8, %esi
callq 0x2e481
testq %rax, %rax
je 0x649d8
movq %rax, %r13
movq %r15, -0x40(%rbp)
xorl %r15d, %r15d
movl $0xa8, %edx
movq %rax, %rdi
xorl %esi, %esi
callq 0xc360
movl $0xdead635a, 0xa0(%r13) # imm = 0xDEAD635A
cmpl $0x2014b50, (%rbx)      # imm = 0x2014B50
movl $0x0, %r10d
movl $0x0, %eax
jne 0x64938
movzwl 0x1c(%rbx), %eax
movw %ax, 0x58(%r13)
movl 0x58(%r13), %r10d
cmpq $0x7fff, %r10           # imm = 0x7FFF
jbe 0x6465c
xorl %r15d, %r15d
xorl %eax, %eax
jmp 0x64938
movzwl 0x1e(%rbx), %r15d
movw %r15w, 0x4e(%r13)
movzwl 0x20(%rbx), %eax
movzwl 0xa(%rbx), %ecx
movw %cx, 0x4c(%r13)
movzbl 0xc(%rbx), %ecx
movzbl 0xd(%rbx), %edi
movl %edi, %esi
shll $0x8, %esi
movzbl 0xe(%rbx), %r8d
movzbl 0xf(%rbx), %r9d
movl %r9d, %edx
shll $0x8, %edx
orl %r8d, %edx
orl %ecx, %esi
movl $0x0, 0x30(%r13)
shrl %r9d
addl $0x7bc, %r9d            # imm = 0x7BC
movl %r9d, 0x24(%r13)
shrl $0x5, %edx
andl $0xf, %edx
andl $0x1f, %r8d
movl %r8d, 0x1c(%r13)
shrl $0x3, %edi
movl %edi, 0x18(%r13)
shrl $0x5, %esi
andl $0x3f, %esi
movl %esi, 0x14(%r13)
addl %ecx, %ecx
andl $0x3e, %ecx
movl %ecx, 0x10(%r13)
decl %edx
movl %edx, 0x20(%r13)
movl 0x10(%rbx), %ecx
movl %ecx, 0xc(%r13)
movl 0x18(%rbx), %edx
movl %edx, (%r13)
testl %edx, %edx
js 0x64938
movl 0x14(%rbx), %ecx
movl %ecx, 0x4(%r13)
testl %ecx, %ecx
js 0x64938
movslq 0x2a(%rbx), %rbx
movl %ebx, 0x48(%r13)
testq %rbx, %rbx
js 0x64938
movl %edx, -0x50(%rbp)
movzwl %r15w, %ecx
addl %r10d, %ecx
leal (%rax,%rcx), %r15d
addl $0x2e, %r15d
movq -0x48(%rbp), %rax
leaq (%rax,%rbx), %rdi
movq %rdi, -0x58(%rbp)
leaq 0x12f3f(%rip), %rsi     # 0x77673
movl $0x4, %edx
movq %r10, -0x30(%rbp)
callq 0x347f1
testl %eax, %eax
jne 0x6494a
movq -0x58(%rbp), %rcx
movzwl 0x1a(%rcx), %eax
movzwl 0x1c(%rcx), %ecx
addl %ebx, %eax
addl %ecx, %eax
addl $0x1e, %eax
movl %eax, 0x48(%r13)
movq -0x40(%rbp), %rax
leal 0x2e(%rax), %esi
addq %r12, %rsi
movq %rsi, 0x50(%r13)
movq -0x30(%rbp), %rdx
testl %edx, %edx
je 0x6499b
cmpl $0x0, -0x50(%rbp)
jne 0x6478c
cmpb $0x2f, -0x1(%rsi,%rdx)
jne 0x6499b
movq (%r14), %rdi
callq 0x3da5b
testq %rax, %rax
je 0x6499b
movq %rax, 0x50(%r13)
movl 0x58(%r13), %esi
movl %esi, -0x58(%rbp)
movq %rax, %rdi
movq %rax, -0x50(%rbp)
callq *0x28(%r14)
movl %eax, %esi
movq 0x18(%r14), %rax
movl 0x30(%r14), %edx
leal -0x1(%rdx), %ecx
andl %esi, %ecx
movq (%rax,%rcx,8), %rbx
movq -0x50(%rbp), %rax
movq %rax, -0x78(%rbp)
movl -0x58(%rbp), %eax
movl %eax, -0x70(%rbp)
testq %rbx, %rbx
je 0x64808
movl %esi, -0x30(%rbp)
cmpl 0x90(%rbx), %esi
jne 0x647fb
leaq 0x50(%rbx), %rsi
leaq -0x78(%rbp), %rdi
callq *0x20(%r14)
movl -0x30(%rbp), %esi
testl %eax, %eax
je 0x649a8
movq 0x68(%rbx), %rbx
testq %rbx, %rbx
jne 0x647dc
movl 0x30(%r14), %edx
leal (%rdx,%rdx,2), %eax
movq -0x60(%rbp), %rbx
cmpl %eax, (%rbx)
jbe 0x648de
movq (%r14), %rdi
movl %edx, %esi
shll $0x4, %esi
movl %esi, -0x30(%rbp)
movq %rdx, %rbx
callq 0x33d86
movq %rbx, %r8
movq -0x60(%rbp), %rbx
testq %rax, %rax
je 0x648de
movl -0x30(%rbp), %ecx
testl %ecx, %ecx
je 0x64878
movl %ecx, %ecx
movq %rax, %rdx
addq %rcx, %rdx
movq %rax, %rcx
movb $0x0, (%rcx)
incq %rcx
cmpq %rdx, %rcx
jae 0x64878
movb $0x0, (%rcx)
incq %rcx
cmpq %rdx, %rcx
jae 0x64878
movb $0x0, (%rcx)
incq %rcx
cmpq %rdx, %rcx
jae 0x64878
movb $0x0, (%rcx)
incq %rcx
cmpq %rdx, %rcx
jb 0x6484c
addl %r8d, %r8d
movl (%rbx), %r9d
testl %r9d, %r9d
xorps %xmm0, %xmm0
je 0x648bb
leal -0x1(%r8), %ecx
movq -0x68(%rbp), %rdx
movq (%rdx), %rdx
movups %xmm0, 0x68(%rdx)
movl 0x90(%rdx), %esi
andl %ecx, %esi
movq (%rax,%rsi,8), %rdi
movq %rdi, 0x68(%rdx)
testq %rdi, %rdi
je 0x648ae
movq %rdx, 0x70(%rdi)
movq %rdx, (%rax,%rsi,8)
subq $-0x80, %rdx
decl %r9d
jne 0x6488e
movq (%r14), %rdi
movq 0x18(%r14), %rsi
movq %r8, -0x30(%rbp)
movq %rax, %rbx
callq 0x3490d
movq %rbx, 0x18(%r14)
movq -0x30(%rbp), %rax
movl %eax, 0x30(%r14)
movq -0x60(%rbp), %rbx
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 0x6490e
movq %r13, 0x70(%rax)
movq %r13, (%rcx,%rdx,8)
movq -0x68(%rbp), %rax
movq (%rax), %rax
testq %rax, %rax
je 0x6492c
movq %rax, 0x80(%r13)
movq %r13, 0x88(%rax)
movq -0x68(%rbp), %rax
movq %r13, (%rax)
jmp 0x649b8
movzwl %r15w, %ecx
movzwl %ax, %eax
addl %r10d, %eax
leal (%rcx,%rax), %r15d
addl $0x2e, %r15d
movl $0x0, -0x78(%rbp)
movq (%r14), %rdi
movq %r13, %rsi
callq 0x2e659
addl -0x40(%rbp), %r15d
leaq (%r12,%r15), %rdi
movq -0x38(%rbp), %rax
movl %eax, %esi
subl %r15d, %esi
leaq 0x12cfa(%rip), %rdx     # 0x7766e
movl $0x4, %ecx
leaq -0x78(%rbp), %r8
callq 0x59e90
testl %eax, %eax
jne 0x649d8
addl -0x78(%rbp), %r15d
cmpl -0x38(%rbp), %r15d
jae 0x649d8
movl %r15d, %ebx
addq %r12, %rbx
jmp 0x645eb
movq (%r14), %rdi
movq %r13, %rsi
callq 0x2e659
jmp 0x649ba
movq 0x78(%rbx), %rax
movq %rax, 0x78(%r13)
movq %r13, 0x78(%rbx)
addq $0x60, %rbx
incl (%rbx)
addl -0x40(%rbp), %r15d
jmp 0x6498a
movl $0xffffffe8, %r13d      # imm = 0xFFFFFFE8
movl %r13d, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%r14), %rax
movq %rax, 0x8(%r14)
xorl %eax, %eax
cmpl $0x0, 0x38(%r14)
setne %al
leal (%rax,%rax,2), %r13d
addl $-0x3, %r13d
jmp 0x649c6