// File: /workspace/github_c_makefile_star2_O0/jonof[P]jftekwar/jfbuild/src/kplib.c
// Function: kzaddstack
int kzaddstack (const char *zipnam)
{
	FILE *fil;
	int i, j, hashind, zipnamoffs, numfiles;
	char tempbuf[260+46];

	fil = fopen(zipnam,"rb"); if (!fil) return(-1);

		//Write ZIP filename to hash
	i = (int)strlen(zipnam)+1; if (!kzcheckhashsiz(i)) { fclose(fil); return(-1); }
	strcpy(&kzhashbuf[kzhashpos],zipnam);
	zipnamoffs = kzhashpos; kzhashpos += i;

	fseek(fil,-22,SEEK_END);
	if (fread(tempbuf,22,1,fil) != 1) { fclose(fil); return(-1); }
	if (*(unsigned int *)&tempbuf[0] == LSWAPIB(0x06054b50)) //Fast way of finding dir info
	{
		numfiles = SSWAPIB(*(unsigned short *)&tempbuf[10]);
		fseek(fil,LSWAPIB(*(unsigned int *)&tempbuf[16]),SEEK_SET);
	}
	else //Slow way of finding dir info (used when ZIP has junk at end)
	{
		fseek(fil,0,SEEK_SET); numfiles = 0;
		while (1)
		{
			if (!fread(&j,4,1,fil)) { numfiles = -1; break; }
			if ((unsigned)j == LSWAPIB(0x02014b50)) break; //Found central file header :)
			if ((unsigned)j != LSWAPIB(0x04034b50)) { numfiles = -1; break; }
			if (fread(tempbuf,26,1,fil) != 1) { fclose(fil); return(-1); }
			fseek(fil,LSWAPIB(*(unsigned int *)&tempbuf[14]) + SSWAPIB(*(unsigned short *)&tempbuf[24]) + SSWAPIB(*(unsigned short *)&tempbuf[22]),SEEK_CUR);
			numfiles++;
		}
		if (numfiles < 0) { fclose(fil); return(-1); }
		fseek(fil,-4,SEEK_CUR);
	}
	for(i=0;i<numfiles;i++)
	{
		if (fread(tempbuf,46,1,fil) != 1) { fclose(fil); return(-1); }
		if (*(int *)&tempbuf[0] != LSWAPIB(0x02014b50)) { fclose(fil); return(0); }

		j = SSWAPIB(*(unsigned short *)&tempbuf[28]); //filename length
		if (fread(&tempbuf[46],j,1,fil) != 1) { fclose(fil); return(-1); }
		tempbuf[j+46] = 0;

			//Write information into hash
		j = (int)strlen(&tempbuf[46])+17; if (!kzcheckhashsiz(j)) { fclose(fil); return(-1); }
		hashind = kzcalchash(&tempbuf[46]);
		*(int *)&kzhashbuf[kzhashpos] = kzhashead[hashind];
		*(int *)&kzhashbuf[kzhashpos+4] = kzlastfnam;
		*(int *)&kzhashbuf[kzhashpos+8] = zipnamoffs;
		*(unsigned int *)&kzhashbuf[kzhashpos+12] = LSWAPIB(*(unsigned int *)&tempbuf[42]); //zipseek
		strcpy(&kzhashbuf[kzhashpos+16],&tempbuf[46]);
		kzhashead[hashind] = kzhashpos; kzlastfnam = kzhashpos; kzhashpos += j;

		j  = SSWAPIB(*(unsigned short *)&tempbuf[30]); //extra field length
		j += SSWAPIB(*(unsigned short *)&tempbuf[32]); //file comment length
		fseek(fil,j,SEEK_CUR);
	}
	fclose(fil);
	return(0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x4b8b8(%rip), %rsi     # 0xb3652
callq 0x6c10
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x67db6
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6819b
movq -0x10(%rbp), %rdi
callq 0x63d0
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %edi
callq 0x681b0
cmpl $0x0, %eax
jne 0x67de7
movq -0x18(%rbp), %rdi
callq 0x6420
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6819b
movq 0x540d7a(%rip), %rdi    # 0x5a8b68
movslq 0x540d7f(%rip), %rax    # 0x5a8b74
addq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0x63e0
movl 0x540d6d(%rip), %eax    # 0x5a8b74
movl %eax, -0x28(%rbp)
movl -0x1c(%rbp), %eax
addl 0x540d61(%rip), %eax    # 0x5a8b74
movl %eax, 0x540d5b(%rip)    # 0x5a8b74
movq -0x18(%rbp), %rdi
movq $-0x16, %rsi
movl $0x2, %edx
callq 0x6ba0
leaq -0x160(%rbp), %rdi
movq -0x18(%rbp), %rcx
movl $0x16, %esi
movl $0x1, %edx
callq 0x64f0
cmpq $0x1, %rax
je 0x67e63
movq -0x18(%rbp), %rdi
callq 0x6420
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6819b
cmpl $0x6054b50, -0x160(%rbp) # imm = 0x6054B50
jne 0x67e91
movzwl -0x156(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x18(%rbp), %rdi
movl -0x150(%rbp), %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x6ba0
jmp 0x67f8a
movq -0x18(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x6ba0
movl $0x0, -0x2c(%rbp)
movq -0x18(%rbp), %rcx
leaq -0x20(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x64f0
cmpq $0x0, %rax
jne 0x67ed0
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
jmp 0x67f5a
cmpl $0x2014b50, -0x20(%rbp) # imm = 0x2014B50
jne 0x67edb
jmp 0x67f5a
cmpl $0x4034b50, -0x20(%rbp) # imm = 0x4034B50
je 0x67eed
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
jmp 0x67f5a
leaq -0x160(%rbp), %rdi
movq -0x18(%rbp), %rcx
movl $0x1a, %esi
movl $0x1, %edx
callq 0x64f0
cmpq $0x1, %rax
je 0x67f22
movq -0x18(%rbp), %rdi
callq 0x6420
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6819b
movq -0x18(%rbp), %rdi
movl -0x152(%rbp), %eax
movzwl -0x148(%rbp), %ecx
addl %ecx, %eax
movzwl -0x14a(%rbp), %ecx
addl %ecx, %eax
movl %eax, %eax
movl %eax, %esi
movl $0x1, %edx
callq 0x6ba0
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x67ea7
cmpl $0x0, -0x2c(%rbp)
jge 0x67f75
movq -0x18(%rbp), %rdi
callq 0x6420
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6819b
movq -0x18(%rbp), %rdi
movq $-0x4, %rsi
movl $0x1, %edx
callq 0x6ba0
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x6818b
leaq -0x160(%rbp), %rdi
movq -0x18(%rbp), %rcx
movl $0x2e, %esi
movl $0x1, %edx
callq 0x64f0
cmpq $0x1, %rax
je 0x67fd2
movq -0x18(%rbp), %rdi
callq 0x6420
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6819b
cmpl $0x2014b50, -0x160(%rbp) # imm = 0x2014B50
je 0x67ff3
movq -0x18(%rbp), %rdi
callq 0x6420
movl $0x0, -0x4(%rbp)
jmp 0x6819b
movzwl -0x144(%rbp), %eax
movl %eax, -0x20(%rbp)
leaq -0x160(%rbp), %rdi
addq $0x2e, %rdi
movslq -0x20(%rbp), %rsi
movq -0x18(%rbp), %rcx
movl $0x1, %edx
callq 0x64f0
cmpq $0x1, %rax
je 0x68035
movq -0x18(%rbp), %rdi
callq 0x6420
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6819b
movl -0x20(%rbp), %eax
addl $0x2e, %eax
cltq
movb $0x0, -0x160(%rbp,%rax)
leaq -0x160(%rbp), %rdi
addq $0x2e, %rdi
callq 0x63d0
addl $0x11, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %edi
callq 0x681b0
cmpl $0x0, %eax
jne 0x6807d
movq -0x18(%rbp), %rdi
callq 0x6420
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6819b
leaq -0x160(%rbp), %rdi
addq $0x2e, %rdi
callq 0x682a0
movl %eax, -0x24(%rbp)
movslq -0x24(%rbp), %rcx
leaq 0x540ae5(%rip), %rax    # 0x5a8b80
movl (%rax,%rcx,4), %edx
movq 0x540ac3(%rip), %rax    # 0x5a8b68
movslq 0x540ac8(%rip), %rcx    # 0x5a8b74
movl %edx, (%rax,%rcx)
movl 0x540ecb(%rip), %edx    # 0x5a8f80
movq 0x540aac(%rip), %rax    # 0x5a8b68
movl 0x540ab2(%rip), %ecx    # 0x5a8b74
addl $0x4, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx)
movl -0x28(%rbp), %edx
movq 0x540a93(%rip), %rax    # 0x5a8b68
movl 0x540a99(%rip), %ecx    # 0x5a8b74
addl $0x8, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx)
movl -0x136(%rbp), %edx
movq 0x540a77(%rip), %rax    # 0x5a8b68
movl 0x540a7d(%rip), %ecx    # 0x5a8b74
addl $0xc, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx)
movq 0x540a61(%rip), %rdi    # 0x5a8b68
movl 0x540a67(%rip), %eax    # 0x5a8b74
addl $0x10, %eax
cltq
addq %rax, %rdi
leaq -0x160(%rbp), %rsi
addq $0x2e, %rsi
callq 0x63e0
movl 0x540a49(%rip), %edx    # 0x5a8b74
movslq -0x24(%rbp), %rcx
leaq 0x540a4a(%rip), %rax    # 0x5a8b80
movl %edx, (%rax,%rcx,4)
movl 0x540a35(%rip), %eax    # 0x5a8b74
movl %eax, 0x540e3b(%rip)    # 0x5a8f80
movl -0x20(%rbp), %eax
addl 0x540a26(%rip), %eax    # 0x5a8b74
movl %eax, 0x540a20(%rip)    # 0x5a8b74
movzwl -0x142(%rbp), %eax
movl %eax, -0x20(%rbp)
movzwl -0x140(%rbp), %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x20(%rbp), %rsi
movl $0x1, %edx
callq 0x6ba0
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x67f91
movq -0x18(%rbp), %rdi
callq 0x6420
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
nopw (%rax,%rax)