// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: GetCentralDirectoryEntry
static sxi32 GetCentralDirectoryEntry(SyArchive *pArch, SyArchiveEntry *pEntry, const unsigned char *zCentral, sxu32 *pNextOffset)
 { 
 	SyString *pName = &pEntry->sFileName; /* File name */
 	sxu16 nDosDate, nDosTime;
	sxu16 nComment = 0 ;
	sxu32 nMagic = 0; /* cc -O6 warning */
	sxi32 rc; 	
	nDosDate = nDosTime = 0; /* cc -O6 warning */
	SXUNUSED(pArch);
 	/* Sanity check */
 	rc = SyLittleEndianUnpack32(&nMagic, zCentral, sizeof(sxu32));
 	if( /* rc != SXRET_OK || */ nMagic != SXZIP_CENTRAL_MAGIC ){
 		rc = SXERR_CORRUPT; 		
 		/*
 		 * Try to recover by examing the next central directory record.
 		 * Dont worry here, there is no risk of an infinite loop since
		 * the buffer size is delimited.
 		 */

 		/* pName->nByte = 0; nComment = 0; pName->nExtra = 0 */
 		goto update;
 	}
 	/*
 	 * entry name length
 	 */
 	SyLittleEndianUnpack16((sxu16 *)&pName->nByte, &zCentral[28], sizeof(sxu16));
 	if( pName->nByte > SXI16_HIGH /* SXU16_HIGH */){
 		 rc = SXERR_BIG;
 		 goto update;
 	}
 	/* Extra information */
 	SyLittleEndianUnpack16(&pEntry->nExtra, &zCentral[30], sizeof(sxu16));
 	/* Comment length  */
 	SyLittleEndianUnpack16(&nComment, &zCentral[32], sizeof(sxu16)); 	
 	/* Compression method 0 == stored / 8 == deflated */
 	rc = SyLittleEndianUnpack16(&pEntry->nComprMeth, &zCentral[10], sizeof(sxu16));
 	/* DOS Timestamp */
 	SyLittleEndianUnpack16(&nDosTime, &zCentral[12], sizeof(sxu16));
 	SyLittleEndianUnpack16(&nDosDate, &zCentral[14], sizeof(sxu16));
 	SyDosTimeFormat((nDosDate << 16 | nDosTime), &pEntry->sFmt);
	/* Little hack to fix month index  */
	pEntry->sFmt.tm_mon--;
 	/* CRC32 */
 	rc = SyLittleEndianUnpack32(&pEntry->nCrc, &zCentral[16], sizeof(sxu32));
 	/* Content size before compression */
 	rc = SyLittleEndianUnpack32(&pEntry->nByte, &zCentral[24], sizeof(sxu32));
 	if(  pEntry->nByte > SXI32_HIGH ){
 		rc = SXERR_BIG;
 		goto update; 
 	} 	
 	/*
 	 * Content size after compression.
 	 * Note that if the file is stored pEntry->nByte should be equal to pEntry->nByteCompr
 	 */ 
 	rc = SyLittleEndianUnpack32(&pEntry->nByteCompr, &zCentral[20], sizeof(sxu32));
 	if( pEntry->nByteCompr > SXI32_HIGH ){
 		rc = SXERR_BIG;
 		goto update; 
 	} 	 	
 	/* Finally grab the contents offset */
 	SyLittleEndianUnpack32(&pEntry->nOfft, &zCentral[42], sizeof(sxu32));
 	if( pEntry->nOfft > SXI32_HIGH ){
 		rc = SXERR_BIG;
 		goto update;
 	} 	
  	 rc = SXRET_OK;
update:	  
 	/* Update the offset to point to the next central directory record */
 	*pNextOffset =  SXZIP_CENTRAL_HDRSZ + pName->nByte + pEntry->nExtra + nComment;
 	return rc; /* Report failure or success */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rax
addq $0x50, %rax
movq %rax, -0x28(%rbp)
movw $0x0, -0x2e(%rbp)
movl $0x0, -0x34(%rbp)
movw $0x0, -0x2c(%rbp)
movw $0x0, -0x2a(%rbp)
movq $0x0, -0x8(%rbp)
movq -0x18(%rbp), %rsi
leaq -0x34(%rbp), %rdi
movl $0x4, %edx
callq 0xaa300
movl %eax, -0x38(%rbp)
cmpl $0x2014b50, -0x34(%rbp) # imm = 0x2014B50
je 0xaa42f
movl $0xffffffe8, -0x38(%rbp) # imm = 0xFFFFFFE8
jmp 0xaa5b7
movq -0x28(%rbp), %rdi
addq $0x8, %rdi
movq -0x18(%rbp), %rsi
addq $0x1c, %rsi
movl $0x2, %edx
callq 0xaa370
movq -0x28(%rbp), %rax
cmpl $0x7fff, 0x8(%rax)      # imm = 0x7FFF
jbe 0xaa462
movl $0xffffffe0, -0x38(%rbp) # imm = 0xFFFFFFE0
jmp 0xaa5b7
movq -0x10(%rbp), %rdi
addq $0x4e, %rdi
movq -0x18(%rbp), %rsi
addq $0x1e, %rsi
movl $0x2, %edx
callq 0xaa370
movq -0x18(%rbp), %rsi
addq $0x20, %rsi
leaq -0x2e(%rbp), %rdi
movl $0x2, %edx
callq 0xaa370
movq -0x10(%rbp), %rdi
addq $0x4c, %rdi
movq -0x18(%rbp), %rsi
addq $0xa, %rsi
movl $0x2, %edx
callq 0xaa370
movl %eax, -0x38(%rbp)
movq -0x18(%rbp), %rsi
addq $0xc, %rsi
leaq -0x2c(%rbp), %rdi
movl $0x2, %edx
callq 0xaa370
movq -0x18(%rbp), %rsi
addq $0xe, %rsi
leaq -0x2a(%rbp), %rdi
movl $0x2, %edx
callq 0xaa370
movzwl -0x2a(%rbp), %edi
shll $0x10, %edi
movzwl -0x2c(%rbp), %eax
orl %eax, %edi
movq -0x10(%rbp), %rsi
addq $0x10, %rsi
callq 0x6a130
movq -0x10(%rbp), %rax
movl 0x20(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x20(%rax)
movq -0x10(%rbp), %rdi
addq $0xc, %rdi
movq -0x18(%rbp), %rsi
addq $0x10, %rsi
movl $0x4, %edx
callq 0xaa300
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x18, %rsi
movl $0x4, %edx
callq 0xaa300
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x7fffffff, (%rax)     # imm = 0x7FFFFFFF
jbe 0xaa54d
movl $0xffffffe0, -0x38(%rbp) # imm = 0xFFFFFFE0
jmp 0xaa5b7
movq -0x10(%rbp), %rdi
addq $0x4, %rdi
movq -0x18(%rbp), %rsi
addq $0x14, %rsi
movl $0x4, %edx
callq 0xaa300
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x7fffffff, 0x4(%rax)  # imm = 0x7FFFFFFF
jbe 0xaa580
movl $0xffffffe0, -0x38(%rbp) # imm = 0xFFFFFFE0
jmp 0xaa5b7
movq -0x10(%rbp), %rdi
addq $0x48, %rdi
movq -0x18(%rbp), %rsi
addq $0x2a, %rsi
movl $0x4, %edx
callq 0xaa300
movq -0x10(%rbp), %rax
cmpl $0x7fffffff, 0x48(%rax) # imm = 0x7FFFFFFF
jbe 0xaa5b0
movl $0xffffffe0, -0x38(%rbp) # imm = 0xFFFFFFE0
jmp 0xaa5b7
movl $0x0, -0x38(%rbp)
movq -0x28(%rbp), %rax
movl 0x8(%rax), %ecx
addl $0x2e, %ecx
movq -0x10(%rbp), %rax
movzwl 0x4e(%rax), %eax
addl %eax, %ecx
movzwl -0x2e(%rbp), %eax
addl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0x38(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq