// File: /workspace/github_c_makefile_star2_O0/jonof[P]jftekwar/jfbuild/src/mdsprite.c
// Function: voxloadbufs
static int voxloadbufs(voxmodel *m)
{
	int i, j, vxi, ixi, xx, yy, zz;
	vert_t *vptr;
	GLfloat ru, rv, phack[2];
#if (VOXBORDWIDTH == 0)
	GLfloat uhack[2], vhack[2];
#endif
	int numindexes, numvertexes;
	GLushort *indexes;
	struct polymostvboitem *vertexes;

	ru = 1.f/((GLfloat)m->mytexx);
	rv = 1.f/((GLfloat)m->mytexy);
	phack[0] = 0; phack[1] = 1.f/256.f;
#if (VOXBORDWIDTH == 0)
	uhack[0] = ru*.125; uhack[1] = -uhack[0];
	vhack[0] = rv*.125; vhack[1] = -vhack[0];
#endif

	numindexes = 6 * m->qcnt;
	numvertexes = 4 * m->qcnt;
	indexes = (GLushort *)malloc(numindexes * sizeof(GLushort));
	vertexes = (struct polymostvboitem *)malloc(numvertexes * sizeof(struct polymostvboitem));

	for(i=0,vxi=0,ixi=0;i<m->qcnt;i++)
	{
		vptr = &m->quad[i].v[0];

		xx = vptr[0].x+vptr[2].x;
		yy = vptr[0].y+vptr[2].y;
		zz = vptr[0].z+vptr[2].z;

		indexes[ixi+0] = vxi+0;
		indexes[ixi+1] = vxi+1;
		indexes[ixi+2] = vxi+2;
		indexes[ixi+3] = vxi+0;
		indexes[ixi+4] = vxi+2;
		indexes[ixi+5] = vxi+3;
		ixi += 6;

		for(j=0;j<4;j++)
		{
#if (VOXBORDWIDTH == 0)
			vertexes[vxi+j].t.s = ((GLfloat)vptr[j].u)*ru+uhack[vptr[j].u!=vptr[0].u];
			vertexes[vxi+j].t.t = ((GLfloat)vptr[j].v)*rv+vhack[vptr[j].v!=vptr[0].v];
#else
			vertexes[vxi+j].t.s = ((GLfloat)vptr[j].u)*ru;
			vertexes[vxi+j].t.t = ((GLfloat)vptr[j].v)*rv;
#endif
			vertexes[vxi+j].v.x = ((GLfloat)vptr[j].x) - phack[xx>vptr[j].x*2] + phack[xx<vptr[j].x*2];
			vertexes[vxi+j].v.y = ((GLfloat)vptr[j].y) - phack[yy>vptr[j].y*2] + phack[yy<vptr[j].y*2];
			vertexes[vxi+j].v.z = ((GLfloat)vptr[j].z) - phack[zz>vptr[j].z*2] + phack[zz<vptr[j].z*2];
		}
		vxi += 4;
	}

	glfunc.glGenBuffers(1, &m->indexbuf);
	glfunc.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m->indexbuf);
	glfunc.glBufferData(GL_ELEMENT_ARRAY_BUFFER, numindexes * sizeof(GLushort), indexes, GL_STATIC_DRAW);
	m->indexcount = numindexes;

	glfunc.glGenBuffers(1, &m->vertexbuf);
	glfunc.glBindBuffer(GL_ARRAY_BUFFER, m->vertexbuf);
	glfunc.glBufferData(GL_ARRAY_BUFFER, numvertexes * sizeof(struct polymostvboitem), vertexes, GL_STATIC_DRAW);

	free(indexes);
	free(vertexes);

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
cvtsi2ssl 0x50(%rax), %xmm1
movss 0x1f843(%rip), %xmm0    # 0xb2e00
divss %xmm1, %xmm0
movss %xmm0, -0x34(%rbp)
movq -0x8(%rbp), %rax
cvtsi2ssl 0x54(%rax), %xmm1
movss 0x1f829(%rip), %xmm0    # 0xb2e00
divss %xmm1, %xmm0
movss %xmm0, -0x38(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x40(%rbp)
movss 0x23b84(%rip), %xmm0    # 0xb7174
movss %xmm0, -0x3c(%rbp)
movq -0x8(%rbp), %rax
imull $0x6, 0x28(%rax), %eax
movl %eax, -0x44(%rbp)
movq -0x8(%rbp), %rax
movl 0x28(%rax), %eax
shll $0x2, %eax
movl %eax, -0x48(%rbp)
movslq -0x44(%rbp), %rdi
shlq %rdi
callq 0x68f0
movq %rax, -0x50(%rbp)
movslq -0x48(%rbp), %rax
imulq $0x14, %rax, %rdi
callq 0x68f0
movq %rax, -0x58(%rbp)
movl $0x0, -0xc(%rbp)
movl $0x0, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
movl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x28(%rcx), %eax
jge 0x93917
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0xc(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movzwl (%rax), %eax
movq -0x30(%rbp), %rcx
movzwl 0x14(%rcx), %ecx
addl %ecx, %eax
movl %eax, -0x1c(%rbp)
movq -0x30(%rbp), %rax
movzwl 0x2(%rax), %eax
movq -0x30(%rbp), %rcx
movzwl 0x16(%rcx), %ecx
addl %ecx, %eax
movl %eax, -0x20(%rbp)
movq -0x30(%rbp), %rax
movzwl 0x4(%rax), %eax
movq -0x30(%rbp), %rcx
movzwl 0x18(%rcx), %ecx
addl %ecx, %eax
movl %eax, -0x24(%rbp)
movl -0x14(%rbp), %eax
addl $0x0, %eax
movw %ax, %dx
movq -0x50(%rbp), %rax
movl -0x18(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movw %ax, %dx
movq -0x50(%rbp), %rax
movl -0x18(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
movl -0x14(%rbp), %eax
addl $0x2, %eax
movw %ax, %dx
movq -0x50(%rbp), %rax
movl -0x18(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
movl -0x14(%rbp), %eax
addl $0x0, %eax
movw %ax, %dx
movq -0x50(%rbp), %rax
movl -0x18(%rbp), %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
movl -0x14(%rbp), %eax
addl $0x2, %eax
movw %ax, %dx
movq -0x50(%rbp), %rax
movl -0x18(%rbp), %ecx
addl $0x4, %ecx
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
movl -0x14(%rbp), %eax
addl $0x3, %eax
movw %ax, %dx
movq -0x50(%rbp), %rax
movl -0x18(%rbp), %ecx
addl $0x5, %ecx
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
movl -0x18(%rbp), %eax
addl $0x6, %eax
movl %eax, -0x18(%rbp)
movl $0x0, -0x10(%rbp)
cmpl $0x4, -0x10(%rbp)
jge 0x93900
movq -0x30(%rbp), %rax
movslq -0x10(%rbp), %rcx
movl %ecx, %edx
leaq (%rcx,%rcx,4), %rcx
movzwl 0x6(%rax,%rcx,2), %eax
cvtsi2ss %eax, %xmm0
movss -0x34(%rbp), %xmm1
mulss %xmm1, %xmm0
movq -0x58(%rbp), %rax
movl -0x14(%rbp), %ecx
addl %edx, %ecx
movslq %ecx, %rcx
leaq (%rcx,%rcx,4), %rcx
movss %xmm0, 0xc(%rax,%rcx,4)
movq -0x30(%rbp), %rax
movslq -0x10(%rbp), %rcx
movl %ecx, %edx
leaq (%rcx,%rcx,4), %rcx
movzwl 0x8(%rax,%rcx,2), %eax
cvtsi2ss %eax, %xmm0
movss -0x38(%rbp), %xmm1
mulss %xmm1, %xmm0
movq -0x58(%rbp), %rax
movl -0x14(%rbp), %ecx
addl %edx, %ecx
movslq %ecx, %rcx
leaq (%rcx,%rcx,4), %rcx
movss %xmm0, 0x10(%rax,%rcx,4)
movq -0x30(%rbp), %rax
movslq -0x10(%rbp), %rcx
movl %ecx, %edx
leaq (%rcx,%rcx,4), %rcx
movzwl (%rax,%rcx,2), %ecx
cvtsi2ss %ecx, %xmm0
movl -0x1c(%rbp), %eax
addl %ecx, %ecx
subl %ecx, %eax
setg %al
movzbl %al, %eax
movss -0x40(%rbp,%rax,4), %xmm1
subss %xmm1, %xmm0
setl %al
movzbl %al, %eax
movss -0x40(%rbp,%rax,4), %xmm1
addss %xmm1, %xmm0
movq -0x58(%rbp), %rax
movl -0x14(%rbp), %ecx
addl %edx, %ecx
movslq %ecx, %rcx
leaq (%rcx,%rcx,4), %rcx
movss %xmm0, (%rax,%rcx,4)
movq -0x30(%rbp), %rax
movslq -0x10(%rbp), %rcx
movl %ecx, %edx
leaq (%rcx,%rcx,4), %rcx
movzwl 0x2(%rax,%rcx,2), %ecx
cvtsi2ss %ecx, %xmm0
movl -0x20(%rbp), %eax
addl %ecx, %ecx
subl %ecx, %eax
setg %al
movzbl %al, %eax
movss -0x40(%rbp,%rax,4), %xmm1
subss %xmm1, %xmm0
setl %al
movzbl %al, %eax
movss -0x40(%rbp,%rax,4), %xmm1
addss %xmm1, %xmm0
movq -0x58(%rbp), %rax
movl -0x14(%rbp), %ecx
addl %edx, %ecx
movslq %ecx, %rcx
leaq (%rcx,%rcx,4), %rcx
movss %xmm0, 0x4(%rax,%rcx,4)
movq -0x30(%rbp), %rax
movslq -0x10(%rbp), %rcx
leaq (%rcx,%rcx,4), %rcx
movzwl 0x4(%rax,%rcx,2), %eax
cvtsi2ss %eax, %xmm0
movl -0x24(%rbp), %eax
movq -0x30(%rbp), %rcx
movslq -0x10(%rbp), %rdx
imulq $0xa, %rdx, %rdx
addq %rdx, %rcx
movzwl 0x4(%rcx), %ecx
shll %ecx
cmpl %ecx, %eax
setg %al
andb $0x1, %al
movzbl %al, %eax
cltq
subss -0x40(%rbp,%rax,4), %xmm0
movl -0x24(%rbp), %eax
movq -0x30(%rbp), %rcx
movslq -0x10(%rbp), %rdx
imulq $0xa, %rdx, %rdx
addq %rdx, %rcx
movzwl 0x4(%rcx), %ecx
shll %ecx
cmpl %ecx, %eax
setl %al
andb $0x1, %al
movzbl %al, %eax
cltq
addss -0x40(%rbp,%rax,4), %xmm0
movq -0x58(%rbp), %rax
movl -0x14(%rbp), %ecx
addl -0x10(%rbp), %ecx
movslq %ecx, %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, 0x8(%rax)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x93754
movl -0x14(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x14(%rbp)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x93643
leaq 0x559df2(%rip), %rax    # 0x5ed710
movq 0x118(%rax), %rax
movq -0x8(%rbp), %rsi
addq $0x78, %rsi
movl $0x1, %edi
callq *%rax
leaq 0x559dd5(%rip), %rax    # 0x5ed710
movq 0xf8(%rax), %rax
movq -0x8(%rbp), %rcx
movl 0x78(%rcx), %esi
movl $0x8893, %edi           # imm = 0x8893
callq *%rax
leaq 0x559db9(%rip), %rax    # 0x5ed710
movq 0x100(%rax), %rax
movslq -0x44(%rbp), %rsi
shlq %rsi
movq -0x50(%rbp), %rdx
movl $0x8893, %edi           # imm = 0x8893
movl $0x88e4, %ecx           # imm = 0x88E4
callq *%rax
movl -0x44(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x7c(%rax)
leaq 0x559d8a(%rip), %rax    # 0x5ed710
movq 0x118(%rax), %rax
movq -0x8(%rbp), %rsi
addq $0x74, %rsi
movl $0x1, %edi
callq *%rax
leaq 0x559d6d(%rip), %rax    # 0x5ed710
movq 0xf8(%rax), %rax
movq -0x8(%rbp), %rcx
movl 0x74(%rcx), %esi
movl $0x8892, %edi           # imm = 0x8892
callq *%rax
leaq 0x559d51(%rip), %rax    # 0x5ed710
movq 0x100(%rax), %rax
movslq -0x48(%rbp), %rcx
imulq $0x14, %rcx, %rsi
movq -0x58(%rbp), %rdx
movl $0x8892, %edi           # imm = 0x8892
movl $0x88e4, %ecx           # imm = 0x88E4
callq *%rax
movq -0x50(%rbp), %rdi
callq 0x61c0
movq -0x58(%rbp), %rdi
callq 0x61c0
xorl %eax, %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)