// File: /workspace/github_c_makefile_star2_O1/jonof[P]jftekwar/jfbuild/src/mdsprite.c
// Function: addquad
static void addquad (int x0, int y0, int z0, int x1, int y1, int z1, int x2, int y2, int z2, int face)
{
	int i, j, x, y, z, xx, yy, nx = 0, ny = 0, nz = 0, *lptr;
	voxrect_t *qptr;

	x = abs(x2-x0); y = abs(y2-y0); z = abs(z2-z0);
	if (!x) { x = y; y = z; i = 0; } else if (!y) { y = z; i = 1; } else i = 2;
	if (x < y) { z = x; x = y; y = z; i += 3; }
	z = shcnt[y*shcntp+x]++;
	lptr = &gvox->mytex[(shp[z].y+VOXBORDWIDTH)*gvox->mytexx+(shp[z].x+VOXBORDWIDTH)];
	switch(face)
	{
		case 0: ny = y1; x2 = x0; x0 = x1; x1 = x2; break;
		case 1: ny = y0; y0++; y1++; y2++; break;
		case 2: nz = z1; y0 = y2; y2 = y1; y1 = y0; z0++; z1++; z2++; break;
		case 3: nz = z0; break;
		case 4: nx = x1; y2 = y0; y0 = y1; y1 = y2; x0++; x1++; x2++; break;
		case 5: nx = x0; break;
	}
	for(yy=0;yy<y;yy++,lptr+=gvox->mytexx)
		for(xx=0;xx<x;xx++)
		{
			switch(face)
			{
				case 0: if (i < 3) { nx = x1+x-1-xx; nz = z1+yy;   } //back
								  else { nx = x1+y-1-yy; nz = z1+xx;   } break;
				case 1: if (i < 3) { nx = x0+xx;     nz = z0+yy;   } //front
								  else { nx = x0+yy;     nz = z0+xx;   } break;
				case 2: if (i < 3) { nx = x1-x+xx;   ny = y1-1-yy; } //bot
								  else { nx = x1-1-yy;   ny = y1-1-xx; } break;
				case 3: if (i < 3) { nx = x0+xx;     ny = y0+yy;   } //top
								  else { nx = x0+yy;     ny = y0+xx;   } break;
				case 4: if (i < 3) { ny = y1+x-1-xx; nz = z1+yy;   } //right
								  else { ny = y1+y-1-yy; nz = z1+xx;   } break;
				case 5: if (i < 3) { ny = y0+xx;     nz = z0+yy;   } //left
								  else { ny = y0+yy;     nz = z0+xx;   } break;
			}
			lptr[xx] = getvox(nx,ny,nz);
		}

		//Extend borders horizontally
	for(yy=VOXBORDWIDTH;yy<y+VOXBORDWIDTH;yy++)
		for(xx=0;xx<VOXBORDWIDTH;xx++)
		{
			lptr = &gvox->mytex[(shp[z].y+yy)*gvox->mytexx+shp[z].x];
			lptr[xx] = lptr[VOXBORDWIDTH]; lptr[xx+x+VOXBORDWIDTH] = lptr[x-1+VOXBORDWIDTH];
		}
		//Extend borders vertically
	for(yy=0;yy<VOXBORDWIDTH;yy++)
	{
		memcpy(&gvox->mytex[(shp[z].y+yy)*gvox->mytexx+shp[z].x],
				 &gvox->mytex[(shp[z].y+VOXBORDWIDTH)*gvox->mytexx+shp[z].x],
				 (x+(VOXBORDWIDTH<<1))<<2);
		memcpy(&gvox->mytex[(shp[z].y+y+yy+VOXBORDWIDTH)*gvox->mytexx+shp[z].x],
				 &gvox->mytex[(shp[z].y+y-1+VOXBORDWIDTH)*gvox->mytexx+shp[z].x],
				 (x+(VOXBORDWIDTH<<1))<<2);
	}

	qptr = &gvox->quad[gvox->qcnt];
	qptr->v[0].x = x0; qptr->v[0].y = y0; qptr->v[0].z = z0;
	qptr->v[1].x = x1; qptr->v[1].y = y1; qptr->v[1].z = z1;
	qptr->v[2].x = x2; qptr->v[2].y = y2; qptr->v[2].z = z2;
	for(j=0;j<3;j++) { qptr->v[j].u = shp[z].x+VOXBORDWIDTH; qptr->v[j].v = shp[z].y+VOXBORDWIDTH; }
	if (i < 3) qptr->v[1].u += x; else qptr->v[1].v += y;
	qptr->v[2].u += x; qptr->v[2].v += y;

	qptr->v[3].u = qptr->v[0].u - qptr->v[1].u + qptr->v[2].u;
	qptr->v[3].v = qptr->v[0].v - qptr->v[1].v + qptr->v[2].v;
	qptr->v[3].x = qptr->v[0].x - qptr->v[1].x + qptr->v[2].x;
	qptr->v[3].y = qptr->v[0].y - qptr->v[1].y + qptr->v[2].y;
	qptr->v[3].z = qptr->v[0].z - qptr->v[1].z + qptr->v[2].z;
	if (gvox->qfacind[face] < 0) gvox->qfacind[face] = gvox->qcnt;
	gvox->qcnt++;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movl 0xf8(%rsp), %r11d
movl %r11d, %eax
subl %esi, %eax
movl %eax, %r14d
negl %r14d
cmovsl %eax, %r14d
movl 0x100(%rsp), %ebp
movl %ebp, %eax
movq %rdx, 0x38(%rsp)
subl %edx, %eax
movl %eax, %r10d
negl %r10d
cmovsl %eax, %r10d
movq %r11, 0x28(%rsp)
cmpl %esi, %r11d
movl 0xf0(%rsp), %r15d
movl %r14d, %r11d
cmovel %r10d, %r11d
movl %r15d, %eax
subl %edi, %eax
cmovel %r10d, %r11d
movl %eax, %ebx
negl %ebx
cmovsl %eax, %ebx
cmpl %edi, %r15d
cmovel %r14d, %ebx
cmpl %r11d, %ebx
movl %r11d, %r10d
cmoval %ebx, %r10d
movl %r11d, 0x14(%rsp)
movl %r11d, %edx
movl %ebx, 0x10(%rsp)
cmovbl %ebx, %edx
movq %rcx, 0x8(%rsp)
movq 0x64f5b6(%rip), %rax    # 0x6b30d0
movl 0x64f5a8(%rip), %ecx    # 0x6b30c8
movq %rdx, 0x40(%rsp)
imull %edx, %ecx
movq %r10, 0x60(%rsp)
addl %r10d, %ecx
movslq %ecx, %rcx
movslq (%rax,%rcx,4), %rbx
leal 0x1(%rbx), %edx
movl %edx, (%rax,%rcx,4)
movl 0x108(%rsp), %r12d
xorl %eax, %eax
cmpq $0x5, %r12
ja 0x63c8a
leaq 0x164a0(%rip), %rcx     # 0x79ff8
movslq (%rcx,%r12,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
movl %edi, %ecx
movq %rcx, 0x30(%rsp)
movl %r8d, %ecx
movq %rcx, 0x18(%rsp)
movq %r9, 0x20(%rsp)
movl %edi, %r15d
movl 0xf8(%rsp), %ecx
movl %ecx, %r13d
movq %rsi, 0x28(%rsp)
xorl %edx, %edx
jmp 0x63cbc
incl %edi
movq 0x8(%rsp), %rdx
leal 0x1(%rdx), %ecx
movq %rcx, 0x30(%rsp)
incl %r15d
movl %esi, %ecx
movq %rcx, 0x18(%rsp)
movq %r9, 0x20(%rsp)
movl %esi, %r13d
movl %r8d, %ecx
movq %rcx, 0x28(%rsp)
jmp 0x63cb2
movq 0x38(%rsp), %rax
incl %eax
movq %rax, 0x38(%rsp)
leal 0x1(%r9), %eax
movq %rax, 0x20(%rsp)
incl %ebp
movq 0x8(%rsp), %rax
movq %rax, 0x30(%rsp)
movl 0xf8(%rsp), %eax
movq %rax, 0x18(%rsp)
movl %r8d, %r13d
xorl %edx, %edx
xorl %r8d, %r8d
movl %r9d, %eax
jmp 0x63cb5
movq 0x8(%rsp), %rax
movq %rax, 0x30(%rsp)
movl %r8d, %eax
movq %rax, 0x18(%rsp)
movq %r9, 0x20(%rsp)
movl 0xf8(%rsp), %eax
movl %eax, %r13d
movq %rsi, 0x28(%rsp)
xorl %edx, %edx
xorl %r8d, %r8d
movq 0x38(%rsp), %rax
jmp 0x63cb5
leal 0x1(%rsi), %ecx
incl %r8d
movl 0xf8(%rsp), %edx
incl %edx
movq 0x8(%rsp), %r10
movq %r10, 0x30(%rsp)
movq %r8, 0x18(%rsp)
movq %r9, 0x20(%rsp)
movl %edx, %r13d
movq %rcx, 0x28(%rsp)
xorl %edx, %edx
movl %esi, %r8d
jmp 0x63cb5
movq 0x8(%rsp), %rcx
movq %rcx, 0x30(%rsp)
movl %r8d, %ecx
movq %rcx, 0x18(%rsp)
movq %r9, 0x20(%rsp)
movl 0xf8(%rsp), %ecx
movl %ecx, %r13d
movq %rsi, 0x28(%rsp)
movl %edi, %edx
jmp 0x63cb2
movq 0x8(%rsp), %rcx
movq %rcx, 0x30(%rsp)
movl %r8d, %ecx
movq %rcx, 0x18(%rsp)
movq %r9, 0x20(%rsp)
movl 0xf8(%rsp), %ecx
movl %ecx, %r13d
movq %rsi, 0x28(%rsp)
xorl %edx, %edx
xorl %r8d, %r8d
movl %edi, %ecx
movq %rcx, 0x8(%rsp)
movq 0x64f4b5(%rip), %r9     # 0x6b3178
movq 0x64f3f6(%rip), %r14    # 0x6b30c0
cmpl $0x0, 0x40(%rsp)
movq %r9, 0x58(%rsp)
movl %ebp, 0x74(%rsp)
je 0x6400d
movl %r13d, 0x6c(%rsp)
movl %r15d, 0x70(%rsp)
movswq 0x2(%r9,%rbx,4), %rcx
incq %rcx
movslq 0x50(%r14), %rsi
imulq %rcx, %rsi
movq %rbx, 0x98(%rsp)
movswq (%r9,%rbx,4), %rcx
addq %rsi, %rcx
movq %r14, 0x90(%rsp)
movq 0x48(%r14), %rsi
leaq (%rsi,%rcx,4), %rsi
addq $0x4, %rsi
movq 0x60(%rsp), %r9
movq 0x18(%rsp), %rdi
leal (%rdi,%r9), %ecx
movl %ecx, 0x80(%rsp)
movq 0x40(%rsp), %rcx
addl %ecx, %edi
movq %rdi, 0xa0(%rsp)
movq 0x30(%rsp), %rdi
movl %edi, %r10d
subl %r9d, %r10d
movq %r10, 0xa8(%rsp)
leal (%rdi,%r9), %r10d
movl %r10d, 0x7c(%rsp)
addl %edi, %ecx
movl %ecx, 0x78(%rsp)
movl 0x64f352(%rip), %r15d   # 0x6b30bc
movq 0x64f337(%rip), %rdi    # 0x6b30a8
movslq 0x64f340(%rip), %r11    # 0x6b30b8
movq 0x64f321(%rip), %r10    # 0x6b30a0
movl %r9d, %ecx
xorl %r14d, %r14d
leaq 0x16284(%rip), %r13     # 0x7a010
cmpl $0x0, 0x60(%rsp)
je 0x63f89
movq 0x38(%rsp), %r9
addl %r14d, %r9d
movl %r9d, 0x54(%rsp)
movq 0x28(%rsp), %r9
leal (%r14,%r9), %r9d
movl %r9d, 0x50(%rsp)
movq 0x20(%rsp), %r9
leal (%r14,%r9), %r9d
movl %r9d, 0x4c(%rsp)
movl %r14d, %ebx
notl %ebx
movq 0xa0(%rsp), %r9
leal (%r9,%rbx), %r9d
movl %r9d, 0x8c(%rsp)
movq 0x8(%rsp), %r9
addl %r14d, %r9d
movl %r9d, 0x48(%rsp)
movq 0x18(%rsp), %r9
addl %ebx, %r9d
movl %r9d, 0x88(%rsp)
movq 0x30(%rsp), %r9
addl %ebx, %r9d
movl %r9d, 0x84(%rsp)
addl 0x78(%rsp), %ebx
movq %rbx, 0xb0(%rsp)
xorl %ebx, %ebx
cmpl $0x5, %r12d
ja 0x63f23
movl %r12d, %r9d
movslq (%r13,%r9,4), %r9
addq %r13, %r9
jmpq *%r9
movl 0x10(%rsp), %eax
cmpl 0x14(%rsp), %eax
jae 0x63efe
movq 0x20(%rsp), %rax
addl %ebx, %eax
movq 0xb0(%rsp), %rdx
jmp 0x63f23
movl 0x10(%rsp), %eax
cmpl 0x14(%rsp), %eax
jae 0x63ecc
movq 0x20(%rsp), %rax
addl %ebx, %eax
movl 0x8c(%rsp), %r8d
jmp 0x63f23
movl 0x10(%rsp), %edx
cmpl 0x14(%rsp), %edx
jae 0x63edc
movl %ebx, %r8d
notl %r8d
addl 0x18(%rsp), %r8d
movl 0x84(%rsp), %edx
jmp 0x63f23
movl 0x10(%rsp), %edx
cmpl 0x14(%rsp), %edx
jae 0x63ef0
movq 0x28(%rsp), %rdx
leal (%rdx,%rbx), %r8d
jmp 0x63eb3
movl 0x10(%rsp), %eax
cmpl 0x14(%rsp), %eax
jae 0x63f0c
movq 0x38(%rsp), %rax
addl %ebx, %eax
movl 0x48(%rsp), %edx
jmp 0x63f23
movl 0x10(%rsp), %eax
cmpl 0x14(%rsp), %eax
jae 0x63f16
movq 0x38(%rsp), %rax
addl %ebx, %eax
jmp 0x63ef7
movl %ebx, %r8d
notl %r8d
addl 0x80(%rsp), %r8d
jmp 0x63f06
movq 0xa8(%rsp), %rdx
addl %ebx, %edx
movl 0x88(%rsp), %r8d
jmp 0x63f23
movq 0x8(%rsp), %rdx
addl %ebx, %edx
movl 0x50(%rsp), %r8d
jmp 0x63f23
movl %ebx, %edx
notl %edx
addl 0x7c(%rsp), %edx
movl 0x4c(%rsp), %eax
jmp 0x63f23
movq 0x8(%rsp), %rax
leal (%rax,%rbx), %edx
jmp 0x63f1f
movq 0x28(%rsp), %rax
leal (%rax,%rbx), %r8d
movl 0x54(%rsp), %eax
movl %r15d, %r9d
imull %edx, %r9d
movl 0x64f150(%rip), %ebp    # 0x6b3080
imull %r8d, %ebp
addl %eax, %r9d
addl %ebp, %r9d
movslq %r9d, %r12
imulq $0x343fd, %r12, %r12    # imm = 0x343FD
andq %r11, %r12
movl (%rdi,%r12,4), %r12d
movl $0x808080, %ebp         # imm = 0x808080
testl %r12d, %r12d
js 0x63f72
movl %r12d, %r12d
leaq (%r12,%r12,2), %r12
leaq (%r10,%r12,4), %r12
cmpl %r9d, (%r12)
je 0x63f6d
movl 0x8(%r12), %r12d
jmp 0x63f50
movl 0x4(%r12), %ebp
movl %ebp, (%rsi,%rbx,4)
incq %rbx
cmpq %rcx, %rbx
movl 0x108(%rsp), %r12d
jne 0x63e14
incl %r14d
movq 0x90(%rsp), %r9
movslq 0x50(%r9), %r9
leaq (%rsi,%r9,4), %rsi
cmpl 0x40(%rsp), %r14d
jne 0x63d8c
movq 0x40(%rsp), %rax
negl %eax
movl $0x1, %edx
movq 0x98(%rsp), %rbx
movl 0x70(%rsp), %r15d
movq 0x90(%rsp), %r14
movl 0x6c(%rsp), %r13d
movq 0x58(%rsp), %r9
movq 0x48(%r14), %rsi
movswl 0x2(%r9,%rbx,4), %edi
addl %edx, %edi
movslq 0x50(%r14), %r8
movslq %edi, %rdi
imulq %r8, %rdi
movswq (%r9,%rbx,4), %r8
addq %rdi, %r8
leaq (%rsi,%r8,4), %rsi
movl 0x4(%rsi), %edi
movl %edi, (%rsi)
movl (%rsi,%rcx,4), %edi
movl %edi, 0x4(%rsi,%rcx,4)
leal (%rax,%rdx), %esi
incl %esi
incl %edx
cmpl $0x1, %esi
jne 0x63fd2
movq 0x48(%r14), %rax
movswl 0x2(%r9,%rbx,4), %ecx
movl 0x50(%r14), %edx
movl %edx, %esi
imull %ecx, %esi
movswl (%r9,%rbx,4), %r8d
addl %r8d, %esi
movslq %esi, %rsi
leaq (%rax,%rsi,4), %rdi
incl %ecx
imull %edx, %ecx
addl %r8d, %ecx
movslq %ecx, %rcx
leaq (%rax,%rcx,4), %rsi
movq 0x60(%rsp), %rax
leal 0x8(,%rax,4), %eax
movslq %eax, %rbp
movq %rbp, %rdx
callq 0x60c0
movq 0x48(%r14), %rax
movq 0x58(%rsp), %rcx
movswl 0x2(%rcx,%rbx,4), %ecx
movq 0x40(%rsp), %rsi
leal (%rsi,%rcx), %edx
addl %esi, %ecx
incl %ecx
movl 0x50(%r14), %esi
imull %esi, %ecx
movq 0x58(%rsp), %rdi
movswl (%rdi,%rbx,4), %r8d
addl %r8d, %ecx
movslq %ecx, %rcx
leaq (%rax,%rcx,4), %rdi
imull %esi, %edx
addl %r8d, %edx
movslq %edx, %rcx
leaq (%rax,%rcx,4), %rsi
movq %rbp, %rdx
callq 0x60c0
movq 0x58(%rsp), %rsi
movq 0x20(%r14), %rax
movslq 0x28(%r14), %rcx
leaq (%rcx,%rcx,4), %rcx
leaq (%rax,%rcx,8), %rax
movq 0x8(%rsp), %rcx
movw %cx, (%rax)
movq 0x28(%rsp), %rcx
movw %cx, 0x2(%rax)
movq 0x38(%rsp), %rcx
movw %cx, 0x4(%rax)
movq 0x30(%rsp), %rcx
movw %cx, 0xa(%rax)
movq 0x18(%rsp), %rcx
movw %cx, 0xc(%rax)
movq 0x20(%rsp), %rcx
movw %cx, 0xe(%rax)
movw %r15w, 0x14(%rax)
movw %r13w, 0x16(%rax)
movl 0x74(%rsp), %ecx
movw %cx, 0x18(%rax)
xorl %ecx, %ecx
movzwl (%rsi,%rbx,4), %edx
incl %edx
movw %dx, 0x6(%rax,%rcx)
movzwl 0x2(%rsi,%rbx,4), %edx
incl %edx
movw %dx, 0x8(%rax,%rcx)
addq $0xa, %rcx
cmpq $0x1e, %rcx
jne 0x640fd
xorl %ecx, %ecx
movl 0x10(%rsp), %edx
cmpl 0x14(%rsp), %edx
movq 0x60(%rsp), %rdi
movl %edi, %edx
movq 0x40(%rsp), %rsi
cmovbl %esi, %edx
setb %cl
addw %dx, 0x10(%rax,%rcx,2)
addw 0x1a(%rax), %di
movw %di, 0x1a(%rax)
addw 0x1c(%rax), %si
movw %si, 0x1c(%rax)
addw 0x6(%rax), %di
subw 0x10(%rax), %di
movw %di, 0x24(%rax)
addw 0x8(%rax), %si
subw 0x12(%rax), %si
movw %si, 0x26(%rax)
movzwl (%rax), %ecx
subw 0xa(%rax), %cx
addw 0x14(%rax), %cx
movzwl 0x2(%rax), %edx
movw %cx, 0x1e(%rax)
subw 0xc(%rax), %dx
addw 0x16(%rax), %dx
movw %dx, 0x20(%rax)
movzwl 0x4(%rax), %ecx
subw 0xe(%rax), %cx
addw 0x18(%rax), %cx
movw %cx, 0x22(%rax)
movslq %r12d, %rax
cmpl $0x0, 0x2c(%r14,%rax,4)
jns 0x641aa
movl 0x28(%r14), %ecx
movl %ecx, 0x2c(%r14,%rax,4)
incl 0x28(%r14)
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq