// File: /workspace/github_c_makefile_star2_O0/jonof[P]jftekwar/jfbuild/src/mdsprite.c
// Function: loadvox
static int loadvox (const char *filnam)
{
	int i, j, k, x, y, z, pal[256], fil;
	unsigned char c[3], *tbuf;

	fil = kopen4load((char *)filnam,0); if (fil < 0) return(-1);
	kread(fil,&xsiz,4); xsiz = B_LITTLE32(xsiz);
	kread(fil,&ysiz,4); ysiz = B_LITTLE32(ysiz);
	kread(fil,&zsiz,4); zsiz = B_LITTLE32(zsiz);
	xpiv = ((float)xsiz)*.5;
	ypiv = ((float)ysiz)*.5;
	zpiv = ((float)zsiz)*.5;

	klseek(fil,-768,SEEK_END);
	for(i=0;i<256;i++)
		{ kread(fil,c,3); pal[i] = (((int)c[0])<<18)+(((int)c[1])<<10)+(((int)c[2])<<2)+(i<<24); }
	pal[255] = -1;

	vcolhashsizm1 = 8192-1;
	vcolhashead = (int *)malloc((vcolhashsizm1+1)*sizeof(int)); if (!vcolhashead) { kclose(fil); return(-1); }
	memset(vcolhashead,-1,(vcolhashsizm1+1)*sizeof(int));

	yzsiz = ysiz*zsiz; i = ((xsiz*yzsiz+31)>>3);
	vbit = (int *)malloc(i); if (!vbit) { kclose(fil); return(-1); }
	memset(vbit,0,i);

	tbuf = (unsigned char *)malloc(zsiz*sizeof(unsigned char)); if (!tbuf) { kclose(fil); return(-1); }

	klseek(fil,12,SEEK_SET);
	for(x=0;x<xsiz;x++)
		for(y=0,j=x*yzsiz;y<ysiz;y++,j+=zsiz)
		{
			kread(fil,tbuf,zsiz);
			for(z=zsiz-1;z>=0;z--)
				{ if (tbuf[z] != 255) { i = j+z; vbit[i>>5] |= (1<<SHIFTMOD32(i)); } }
		}

	klseek(fil,12,SEEK_SET);
	for(x=0;x<xsiz;x++)
		for(y=0,j=x*yzsiz;y<ysiz;y++,j+=zsiz)
		{
			kread(fil,tbuf,zsiz);
			for(z=0;z<zsiz;z++)
			{
				if (tbuf[z] == 255) continue;
				if ((!x) || (!y) || (!z) || (x == xsiz-1) || (y == ysiz-1) || (z == zsiz-1))
					{ putvox(x,y,z,pal[tbuf[z]]); continue; }
				k = j+z;
				if ((!(vbit[(k-yzsiz)>>5]&(1<<SHIFTMOD32(k-yzsiz)))) ||
					 (!(vbit[(k+yzsiz)>>5]&(1<<SHIFTMOD32(k+yzsiz)))) ||
					 (!(vbit[(k- zsiz)>>5]&(1<<SHIFTMOD32(k- zsiz)))) ||
					 (!(vbit[(k+ zsiz)>>5]&(1<<SHIFTMOD32(k+ zsiz)))) ||
					 (!(vbit[(k-    1)>>5]&(1<<SHIFTMOD32(k-    1)))) ||
					 (!(vbit[(k+    1)>>5]&(1<<SHIFTMOD32(k+    1)))))
					{ putvox(x,y,z,pal[tbuf[z]]); continue; }
			}
		}

	free(tbuf); kclose(fil); return(0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x440, %rsp            # imm = 0x440
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x2fee0
movl %eax, -0x434(%rbp)
cmpl $0x0, -0x434(%rbp)
jge 0x905a5
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x90baa
movl -0x434(%rbp), %edi
leaq 0x616a96(%rip), %rsi    # 0x6a7048
movl $0x4, %edx
callq 0x302b0
movl 0x616a86(%rip), %eax    # 0x6a7048
movl %eax, 0x616a80(%rip)    # 0x6a7048
movl -0x434(%rbp), %edi
leaq 0x616a77(%rip), %rsi    # 0x6a704c
movl $0x4, %edx
callq 0x302b0
movl 0x616a67(%rip), %eax    # 0x6a704c
movl %eax, 0x616a61(%rip)    # 0x6a704c
movl -0x434(%rbp), %edi
leaq 0x616a58(%rip), %rsi    # 0x6a7050
movl $0x4, %edx
callq 0x302b0
movl 0x616a48(%rip), %eax    # 0x6a7050
movl %eax, 0x616a42(%rip)    # 0x6a7050
cvtsi2ssl 0x616a32(%rip), %xmm0 # 0x6a7048
cvtss2sd %xmm0, %xmm0
movsd 0x25e2e(%rip), %xmm1    # 0xb6450
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x616a22(%rip)   # 0x6a7054
cvtsi2ssl 0x616a12(%rip), %xmm0 # 0x6a704c
cvtss2sd %xmm0, %xmm0
movsd 0x25e0a(%rip), %xmm1    # 0xb6450
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x616a02(%rip)   # 0x6a7058
cvtsi2ssl 0x6169f2(%rip), %xmm0 # 0x6a7050
cvtss2sd %xmm0, %xmm0
movsd 0x25de6(%rip), %xmm1    # 0xb6450
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x6169e2(%rip)   # 0x6a705c
movl -0x434(%rbp), %edi
movl $0xfffffd00, %esi       # imm = 0xFFFFFD00
movl $0x2, %edx
callq 0x30590
movl $0x0, -0x14(%rbp)
cmpl $0x100, -0x14(%rbp)     # imm = 0x100
jge 0x906f6
movl -0x434(%rbp), %edi
leaq -0x437(%rbp), %rsi
movl $0x3, %edx
callq 0x302b0
movzbl -0x437(%rbp), %ecx
shll $0x12, %ecx
movzbl -0x436(%rbp), %eax
shll $0xa, %eax
addl %eax, %ecx
movzbl -0x435(%rbp), %eax
shll $0x2, %eax
addl %eax, %ecx
movl -0x14(%rbp), %eax
shll $0x18, %eax
addl %eax, %ecx
movslq -0x14(%rbp), %rax
movl %ecx, -0x430(%rbp,%rax,4)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x90696
movl $0xffffffff, -0x34(%rbp) # imm = 0xFFFFFFFF
movl $0x1fff, 0x616981(%rip) # imm = 0x1FFF
movl 0x61697b(%rip), %eax    # 0x6a7088
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x2, %rdi
callq 0x68f0
movq %rax, 0x616955(%rip)    # 0x6a7078
cmpq $0x0, 0x61694d(%rip)    # 0x6a7078
jne 0x90744
movl -0x434(%rbp), %edi
callq 0x30960
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x90baa
movq 0x61692d(%rip), %rdi    # 0x6a7078
movl 0x616937(%rip), %eax    # 0x6a7088
addl $0x1, %eax
movslq %eax, %rdx
shlq $0x2, %rdx
movl $0xff, %esi
callq 0x62d0
movl 0x6168e1(%rip), %eax    # 0x6a704c
imull 0x6168de(%rip), %eax    # 0x6a7050
movl %eax, 0x616914(%rip)    # 0x6a708c
movl 0x6168ca(%rip), %eax    # 0x6a7048
imull 0x616907(%rip), %eax    # 0x6a708c
addl $0x1f, %eax
sarl $0x3, %eax
movl %eax, -0x14(%rbp)
movslq -0x14(%rbp), %rdi
callq 0x68f0
movq %rax, 0x6168ca(%rip)    # 0x6a7068
cmpq $0x0, 0x6168c2(%rip)    # 0x6a7068
jne 0x907bf
movl -0x434(%rbp), %edi
callq 0x30960
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x90baa
movq 0x6168a2(%rip), %rdi    # 0x6a7068
movslq -0x14(%rbp), %rdx
xorl %esi, %esi
callq 0x62d0
movslq 0x616878(%rip), %rdi    # 0x6a7050
shlq $0x0, %rdi
callq 0x68f0
movq %rax, -0x440(%rbp)
cmpq $0x0, -0x440(%rbp)
jne 0x90809
movl -0x434(%rbp), %edi
callq 0x30960
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x90baa
movl -0x434(%rbp), %edi
movl $0xc, %esi
xorl %edx, %edx
callq 0x30590
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl 0x61681d(%rip), %eax    # 0x6a7048
jge 0x908f6
movl $0x0, -0x24(%rbp)
movl -0x20(%rbp), %eax
imull 0x61684a(%rip), %eax    # 0x6a708c
movl %eax, -0x18(%rbp)
movl -0x24(%rbp), %eax
cmpl 0x6167fe(%rip), %eax    # 0x6a704c
jge 0x908e6
movl -0x434(%rbp), %edi
movq -0x440(%rbp), %rsi
movl 0x6167e9(%rip), %edx    # 0x6a7050
callq 0x302b0
movl 0x6167de(%rip), %eax    # 0x6a7050
subl $0x1, %eax
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
jl 0x908ca
movq -0x440(%rbp), %rax
movslq -0x28(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0xff, %eax
je 0x908bd
movl -0x18(%rbp), %eax
addl -0x28(%rbp), %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %ecx
movl $0x1, %edx
shll %cl, %edx
movq 0x6167ba(%rip), %rax    # 0x6a7068
movl -0x14(%rbp), %ecx
sarl $0x5, %ecx
movslq %ecx, %rcx
orl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
jmp 0x908bf
movl -0x28(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x90878
jmp 0x908cc
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movl 0x616775(%rip), %eax    # 0x6a7050
addl -0x18(%rbp), %eax
movl %eax, -0x18(%rbp)
jmp 0x90845
jmp 0x908e8
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x90822
movl -0x434(%rbp), %edi
movl $0xc, %esi
xorl %edx, %edx
callq 0x30590
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl 0x616730(%rip), %eax    # 0x6a7048
jge 0x90b8c
movl $0x0, -0x24(%rbp)
movl -0x20(%rbp), %eax
imull 0x61675d(%rip), %eax    # 0x6a708c
movl %eax, -0x18(%rbp)
movl -0x24(%rbp), %eax
cmpl 0x616711(%rip), %eax    # 0x6a704c
jge 0x90b7c
movl -0x434(%rbp), %edi
movq -0x440(%rbp), %rsi
movl 0x6166fc(%rip), %edx    # 0x6a7050
callq 0x302b0
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl 0x6166e7(%rip), %eax    # 0x6a7050
jge 0x90b60
movq -0x440(%rbp), %rax
movslq -0x28(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0xff, %eax
jne 0x9098a
jmp 0x90b52
cmpl $0x0, -0x20(%rbp)
je 0x909cc
cmpl $0x0, -0x24(%rbp)
je 0x909cc
cmpl $0x0, -0x28(%rbp)
je 0x909cc
movl -0x20(%rbp), %eax
movl 0x6166a3(%rip), %ecx    # 0x6a7048
subl $0x1, %ecx
cmpl %ecx, %eax
je 0x909cc
movl -0x24(%rbp), %eax
movl 0x616697(%rip), %ecx    # 0x6a704c
subl $0x1, %ecx
cmpl %ecx, %eax
je 0x909cc
movl -0x28(%rbp), %eax
movl 0x61668b(%rip), %ecx    # 0x6a7050
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x909f5
movl -0x20(%rbp), %edi
movl -0x24(%rbp), %esi
movl -0x28(%rbp), %edx
movq -0x440(%rbp), %rax
movslq -0x28(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl -0x430(%rbp,%rax,4), %ecx
callq 0x97720
jmp 0x90b52
movl -0x18(%rbp), %eax
addl -0x28(%rbp), %eax
movl %eax, -0x1c(%rbp)
movq 0x616663(%rip), %rax    # 0x6a7068
movl -0x1c(%rbp), %ecx
subl 0x61667e(%rip), %ecx    # 0x6a708c
sarl $0x5, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl -0x1c(%rbp), %ecx
subl 0x61666c(%rip), %ecx    # 0x6a708c
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0x90b2a
movq 0x61662d(%rip), %rax    # 0x6a7068
movl -0x1c(%rbp), %ecx
addl 0x616648(%rip), %ecx    # 0x6a708c
sarl $0x5, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl -0x1c(%rbp), %ecx
addl 0x616636(%rip), %ecx    # 0x6a708c
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0x90b2a
movq 0x6165f7(%rip), %rax    # 0x6a7068
movl -0x1c(%rbp), %ecx
subl 0x6165d6(%rip), %ecx    # 0x6a7050
sarl $0x5, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl -0x1c(%rbp), %ecx
subl 0x6165c4(%rip), %ecx    # 0x6a7050
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0x90b2a
movq 0x6165c1(%rip), %rax    # 0x6a7068
movl -0x1c(%rbp), %ecx
addl 0x6165a0(%rip), %ecx    # 0x6a7050
sarl $0x5, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl -0x1c(%rbp), %ecx
addl 0x61658e(%rip), %ecx    # 0x6a7050
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0x90b2a
movq 0x61658f(%rip), %rax    # 0x6a7068
movl -0x1c(%rbp), %ecx
subl $0x1, %ecx
sarl $0x5, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl -0x1c(%rbp), %ecx
subl $0x1, %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0x90b2a
movq 0x616563(%rip), %rax    # 0x6a7068
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
sarl $0x5, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
andl %ecx, %eax
cmpl $0x0, %eax
jne 0x90b50
movl -0x20(%rbp), %edi
movl -0x24(%rbp), %esi
movl -0x28(%rbp), %edx
movq -0x440(%rbp), %rax
movslq -0x28(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl -0x430(%rbp,%rax,4), %ecx
callq 0x97720
jmp 0x90b52
jmp 0x90b52
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x90960
jmp 0x90b62
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movl 0x6164df(%rip), %eax    # 0x6a7050
addl -0x18(%rbp), %eax
movl %eax, -0x18(%rbp)
jmp 0x90932
jmp 0x90b7e
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x9090f
movq -0x440(%rbp), %rdi
callq 0x61c0
movl -0x434(%rbp), %edi
callq 0x30960
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x440, %rsp            # imm = 0x440
popq %rbp
retq
nopw %cs:(%rax,%rax)