// File: /workspace/github_c_makefile_star2_O3/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), %r14d
movl %r14d, %eax
subl %esi, %eax
movl %eax, %r11d
negl %r11d
cmovsl %eax, %r11d
movl 0x100(%rsp), %ebx
movl %ebx, %eax
movq %rdx, 0x38(%rsp)
subl %edx, %eax
movl %eax, %r10d
negl %r10d
cmovsl %eax, %r10d
movq %r14, 0x28(%rsp)
cmpl %esi, %r14d
movl 0xf0(%rsp), %r14d
movl %r11d, %edx
cmovel %r10d, %edx
movl %r14d, %eax
subl %edi, %eax
cmovel %r10d, %edx
movl %eax, %r12d
negl %r12d
cmovsl %eax, %r12d
cmpl %edi, %r14d
cmovel %r11d, %r12d
cmpl %edx, %r12d
movl %edx, %ebp
cmoval %r12d, %ebp
movq %rcx, 0x8(%rsp)
movl %edx, 0x14(%rsp)
cmovbl %r12d, %edx
movq 0x64e964(%rip), %rax    # 0x6b40c0
movl 0x64e956(%rip), %ecx    # 0x6b40b8
movq %rdx, 0x40(%rsp)
imull %edx, %ecx
addl %ebp, %ecx
movslq %ecx, %rcx
movslq (%rax,%rcx,4), %r11
leal 0x1(%r11), %edx
movl %edx, (%rax,%rcx,4)
movl 0x108(%rsp), %r13d
movq 0x64e927(%rip), %r15    # 0x6b40b0
xorl %eax, %eax
cmpq $0x5, %r13
ja 0x658d5
leaq 0x15d14(%rip), %rcx     # 0x7b4b0
movslq (%rcx,%r13,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, %r14d
movl 0xf8(%rsp), %ecx
movl %ecx, 0x10(%rsp)
movq %rsi, 0x28(%rsp)
xorl %edx, %edx
jmp 0x65908
incl %edi
movq 0x8(%rsp), %rdx
leal 0x1(%rdx), %ecx
movq %rcx, 0x30(%rsp)
incl %r14d
movl %esi, %ecx
movq %rcx, 0x18(%rsp)
movq %r9, 0x20(%rsp)
movl %esi, 0x10(%rsp)
movl %r8d, %ecx
movq %rcx, 0x28(%rsp)
jmp 0x658fe
movq 0x38(%rsp), %rax
incl %eax
movq %rax, 0x38(%rsp)
leal 0x1(%r9), %eax
movq %rax, 0x20(%rsp)
incl %ebx
movq 0x8(%rsp), %rax
movq %rax, 0x30(%rsp)
movl 0xf8(%rsp), %eax
movq %rax, 0x18(%rsp)
movl %r8d, 0x10(%rsp)
xorl %edx, %edx
xorl %r8d, %r8d
movl %r9d, %eax
jmp 0x65901
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, 0x10(%rsp)
movq %rsi, 0x28(%rsp)
xorl %edx, %edx
xorl %r8d, %r8d
movq 0x38(%rsp), %rax
jmp 0x65901
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, 0x10(%rsp)
movq %rcx, 0x28(%rsp)
xorl %edx, %edx
movl %esi, %r8d
jmp 0x65901
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, 0x10(%rsp)
movq %rsi, 0x28(%rsp)
movl %edi, %edx
jmp 0x658fe
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, 0x10(%rsp)
movq %rsi, 0x28(%rsp)
xorl %edx, %edx
xorl %r8d, %r8d
movl %edi, %ecx
movq %rcx, 0x8(%rsp)
movq 0x64e859(%rip), %r9     # 0x6b4168
movslq 0x50(%r15), %rcx
cmpl $0x0, 0x40(%rsp)
movq %r11, 0x68(%rsp)
movq %r9, 0x60(%rsp)
movl %ebx, 0x78(%rsp)
je 0x65c2b
movl %r14d, 0x74(%rsp)
movswq 0x2(%r9,%r11,4), %rsi
incq %rsi
imulq %rcx, %rsi
movswq (%r9,%r11,4), %rcx
addq %rsi, %rcx
movq 0x48(%r15), %rsi
leaq (%rsi,%rcx,4), %rsi
addq $0x4, %rsi
movq 0x18(%rsp), %rcx
addl %r12d, %ecx
movq %rcx, 0x88(%rsp)
movq 0x30(%rsp), %rdi
movl %edi, %ecx
subl %r12d, %ecx
movq %rcx, 0xa8(%rsp)
movq %rbp, %rcx
movq %r12, %rbp
addl %r12d, %edi
movl %edi, 0x4c(%rsp)
movl 0x64e725(%rip), %edi    # 0x6b40ac
movq 0x64e70a(%rip), %r9     # 0x6b4098
movslq 0x64e713(%rip), %rbx    # 0x6b40a8
movq 0x64e6f4(%rip), %r14    # 0x6b4090
movq %rcx, 0x90(%rsp)
movl %ecx, %ecx
xorl %r12d, %r12d
leaq 0x15b18(%rip), %r10     # 0x7b4c8
movq %r15, 0x98(%rsp)
movq 0x38(%rsp), %r11
addl %r12d, %r11d
movl %r11d, 0x5c(%rsp)
movq 0x28(%rsp), %r11
leal (%r12,%r11), %r11d
movl %r11d, 0x58(%rsp)
movq 0x20(%rsp), %r11
leal (%r12,%r11), %r11d
movl %r11d, 0x54(%rsp)
movl %r12d, %r15d
notl %r15d
movq 0x88(%rsp), %r11
leal (%r11,%r15), %r11d
movl %r11d, 0x84(%rsp)
movq 0x8(%rsp), %r11
movq %r12, 0xa0(%rsp)
addl %r12d, %r11d
movl %r11d, 0x50(%rsp)
movq 0x18(%rsp), %r11
addl %r15d, %r11d
movl %r11d, 0x80(%rsp)
movq 0x30(%rsp), %r11
addl %r15d, %r11d
movl %r11d, 0x7c(%rsp)
addl 0x4c(%rsp), %r15d
movq %r15, 0xb0(%rsp)
xorl %r12d, %r12d
cmpl $0x5, %r13d
ja 0x65b38
movl %r13d, %r11d
movslq (%r10,%r11,4), %r11
addq %r10, %r11
jmpq *%r11
cmpl 0x14(%rsp), %ebp
jae 0x65b11
movq 0x20(%rsp), %rax
addl %r12d, %eax
movq 0xb0(%rsp), %rdx
jmp 0x65b38
cmpl 0x14(%rsp), %ebp
jae 0x65add
movq 0x20(%rsp), %rax
addl %r12d, %eax
movl 0x84(%rsp), %r8d
jmp 0x65b38
cmpl 0x14(%rsp), %ebp
jae 0x65aed
movl %r12d, %r8d
notl %r8d
addl 0x18(%rsp), %r8d
movl 0x7c(%rsp), %edx
jmp 0x65b38
cmpl 0x14(%rsp), %ebp
jae 0x65b02
movq 0x28(%rsp), %rdx
leal (%rdx,%r12), %r8d
jmp 0x65ac7
cmpl 0x14(%rsp), %ebp
jae 0x65b20
movq 0x38(%rsp), %rax
addl %r12d, %eax
movl 0x50(%rsp), %edx
jmp 0x65b38
cmpl 0x14(%rsp), %ebp
jae 0x65b2b
movq 0x38(%rsp), %rax
addl %r12d, %eax
jmp 0x65b0a
movl %r12d, %r8d
notl %r8d
addl 0x88(%rsp), %r8d
jmp 0x65b1a
movq 0xa8(%rsp), %rdx
addl %r12d, %edx
movl 0x80(%rsp), %r8d
jmp 0x65b38
movq 0x8(%rsp), %rdx
addl %r12d, %edx
movl 0x58(%rsp), %r8d
jmp 0x65b38
movl %r12d, %edx
notl %edx
addl 0x4c(%rsp), %edx
movl 0x54(%rsp), %eax
jmp 0x65b38
movq 0x8(%rsp), %rax
leal (%rax,%r12), %edx
jmp 0x65b34
movq 0x28(%rsp), %rax
leal (%rax,%r12), %r8d
movl 0x5c(%rsp), %eax
movl %edi, %r11d
imull %edx, %r11d
movl 0x64e52a(%rip), %r15d   # 0x6b4070
imull %r8d, %r15d
addl %eax, %r11d
addl %r15d, %r11d
movslq %r11d, %r15
imulq $0x343fd, %r15, %r15    # imm = 0x343FD
andq %rbx, %r15
movl (%r9,%r15,4), %r13d
movl $0x808080, %r15d        # imm = 0x808080
testl %r13d, %r13d
js 0x65b88
movl %r13d, %r13d
leaq (%r13,%r13,2), %r13
leaq (%r14,%r13,4), %r13
cmpl %r11d, (%r13)
je 0x65b84
movl 0x8(%r13), %r13d
jmp 0x65b67
movl 0x4(%r13), %r15d
movl %r15d, (%rsi,%r12,4)
incq %r12
cmpq %rcx, %r12
movl 0x108(%rsp), %r13d
jne 0x65a3d
movq 0x98(%rsp), %r15
movslq 0x50(%r15), %r11
movq 0xa0(%rsp), %r12
incl %r12d
leaq (%rsi,%r11,4), %rsi
cmpl 0x40(%rsp), %r12d
jne 0x659b8
movq 0x40(%rsp), %rax
negl %eax
movl $0x1, %edx
movl 0x74(%rsp), %r14d
movq 0x68(%rsp), %r11
movq 0x60(%rsp), %r9
movq 0x48(%r15), %rsi
movswl 0x2(%r9,%r11,4), %edi
addl %edx, %edi
movslq 0x50(%r15), %r8
movslq %edi, %rdi
imulq %r8, %rdi
movswq (%r9,%r11,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 0x65be1
movl 0x50(%r15), %ecx
movq %rbp, %r12
movq 0x90(%rsp), %rbp
movq 0x48(%r15), %rax
movswl 0x2(%r9,%r11,4), %edx
movl %ecx, %esi
imull %edx, %esi
movswl (%r9,%r11,4), %r8d
addl %r8d, %esi
movslq %esi, %rsi
leaq (%rax,%rsi,4), %rdi
incl %edx
imull %ecx, %edx
addl %r8d, %edx
movslq %edx, %rcx
leaq (%rax,%rcx,4), %rsi
leal 0x8(,%rbp,4), %eax
movslq %eax, %rbx
movq %rbx, %rdx
callq 0x60c0
movq 0x48(%r15), %rax
movq 0x68(%rsp), %rcx
movq 0x60(%rsp), %rdx
movswl 0x2(%rdx,%rcx,4), %ecx
movq 0x40(%rsp), %rsi
leal (%rsi,%rcx), %edx
addl %esi, %ecx
incl %ecx
movl 0x50(%r15), %esi
imull %esi, %ecx
movq 0x68(%rsp), %rdi
movq 0x60(%rsp), %r8
movswl (%r8,%rdi,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 %rbx, %rdx
callq 0x60c0
movq 0x60(%rsp), %r8
movq 0x68(%rsp), %rsi
movq 0x20(%r15), %rax
movslq 0x28(%r15), %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 %r14w, 0x14(%rax)
movl 0x10(%rsp), %edi
movw %di, 0x16(%rax)
movl 0x78(%rsp), %r9d
movw %r9w, 0x18(%rax)
xorl %ecx, %ecx
movzwl (%r8,%rsi,4), %edx
incl %edx
movw %dx, 0x6(%rax,%rcx)
movzwl 0x2(%r8,%rsi,4), %edx
incl %edx
movw %dx, 0x8(%rax,%rcx)
addq $0xa, %rcx
cmpq $0x1e, %rcx
jne 0x65d26
cmpl 0x14(%rsp), %r12d
jae 0x65d66
addw 0x12(%rax), %r12w
movw %r12w, 0x12(%rax)
movl %r12d, %ecx
movzwl 0x10(%rax), %edx
movl %edx, %r12d
jmp 0x65d74
addw 0x10(%rax), %r12w
movw %r12w, 0x10(%rax)
movzwl 0x12(%rax), %ecx
addw 0x1a(%rax), %bp
movw %bp, 0x1a(%rax)
movq 0x40(%rsp), %rdx
addw 0x1c(%rax), %dx
movw %dx, 0x1c(%rax)
addw 0x6(%rax), %bp
subl %r12d, %ebp
movw %bp, 0x24(%rax)
addw 0x8(%rax), %dx
subl %ecx, %edx
movw %dx, 0x26(%rax)
movq 0x8(%rsp), %rcx
subl 0x30(%rsp), %ecx
addl %ecx, %r14d
movw %r14w, 0x1e(%rax)
movq 0x28(%rsp), %rcx
subl 0x18(%rsp), %ecx
addl %ecx, %edi
movw %di, 0x20(%rax)
movq 0x38(%rsp), %rcx
subl 0x20(%rsp), %ecx
addl %ecx, %r9d
movw %r9w, 0x22(%rax)
movslq %r13d, %rcx
cmpl $0x0, 0x2c(%r15,%rcx,4)
movl 0x28(%r15), %eax
jns 0x65de3
movl %eax, 0x2c(%r15,%rcx,4)
incl %eax
movl %eax, 0x28(%r15)
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq