// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/hlrad/qradutil.cpp
// Function: FreePositionMaps()
void FreePositionMaps ()
{
#ifdef HLRAD_DEBUG_DRAWPOINTS
	if (g_drawsample)
	{
		char name[_MAX_PATH+20];
		sprintf (name, "%s_positions.pts", g_Mapname);
		Log ("Writing '%s' ...\n", name);
		FILE *f;
		f = fopen(name, "w");
		if (f)
		{
			const int pos_count = 15;
			const vec3_t pos[pos_count] = {{0,0,0},{1,0,0},{0,1,0},{-1,0,0},{0,-1,0},{1,0,0},{0,0,1},{-1,0,0},{0,0,-1},{0,-1,0},{0,0,1},{0,1,0},{0,0,-1},{1,0,0},{0,0,0}};
			int i, j, k;
			vec3_t v, dist;
			for (i = 0; i < g_numfaces; ++i)
			{
				positionmap_t *map = &g_face_positions[i];
				if (!map->valid)
				{
					continue;
				}
				for (j = 0; j < map->h * map->w; ++j)
				{
					if (!map->grid[j].valid)
					{
						continue;
					}
					VectorCopy (map->grid[j].pos, v);
					VectorSubtract (v, g_drawsample_origin, dist);
					if (DotProduct (dist, dist) < g_drawsample_radius * g_drawsample_radius)
					{
						for (k = 0; k < pos_count; ++k)
							fprintf (f, "%g %g %g\n", v[0]+pos[k][0], v[1]+pos[k][1], v[2]+pos[k][2]);
					}
				}
			}
			fclose(f);
			Log ("OK.\n");
		}
		else
			Log ("Error.\n");
	}
#endif
	for (int facenum = 0; facenum < g_numfaces; facenum++)
	{
		positionmap_t *map = &g_face_positions[facenum];
		if (map->valid)
		{
			delete map->facewinding;
			map->facewinding = NULL;
			delete map->facewindingwithoffset;
			map->facewindingwithoffset = NULL;
			delete map->texwinding;
			map->texwinding = NULL;
			free (map->grid);
			map->grid = NULL;
			map->valid = false;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1038, %rsp           # imm = 0x1038
leaq 0x54c9049(%rip), %rax   # 0x54faa2d
cmpb $0x1, (%rax)
jne 0x31bd4
leaq 0xdfc6(%rip), %rsi      # 0x3f9ba
leaq 0x16955(%rip), %rdx     # 0x48350
leaq 0x20(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x40a0
leaq 0xa9f5(%rip), %rdi      # 0x3c406
movq %rbx, %rsi
xorl %eax, %eax
callq 0x9d2e
leaq 0xd3dd(%rip), %rsi      # 0x3edff
movq %rbx, %rdi
callq 0x4370
testq %rax, %rax
je 0x31bc6
movq %rax, %rbx
leaq 0x1b7f9b7(%rip), %rax   # 0x1bb13f4
cmpl $0x0, (%rax)
jle 0x31bb5
xorl %ecx, %ecx
leaq 0xdf81(%rip), %r13      # 0x3f9d0
leaq 0xa9c2(%rip), %r14      # 0x3c418
movq %rcx, 0x18(%rsp)
imulq $0x110, %rcx, %r15      # imm = 0x110
leaq 0x55c9167(%rip), %rax   # 0x55fabd0
cmpb $0x1, (%r15,%rax)
jne 0x31b9a
leaq 0x55c9155(%rip), %rax   # 0x55fabd0
addq %rax, %r15
movl 0x100(%r15), %eax
imull 0x104(%r15), %eax
testl %eax, %eax
jle 0x31b9a
xorl %ebp, %ebp
movq 0x108(%r15), %rax
leaq (,%rbp,2), %rcx
addq %rbp, %rcx
cmpb $0x1, (%rax,%rcx,8)
jne 0x31b7c
leaq (%rax,%rcx,8), %rax
movss 0xc(%rax), %xmm3
movss 0x10(%rax), %xmm4
movaps %xmm3, %xmm0
leaq 0x54c8f65(%rip), %rcx   # 0x54faa30
subss (%rcx), %xmm0
movss 0x14(%rax), %xmm5
movaps %xmm4, %xmm1
subss 0x4(%rcx), %xmm1
movaps %xmm5, %xmm2
subss 0x8(%rcx), %xmm2
mulss %xmm1, %xmm1
mulss %xmm0, %xmm0
addss %xmm1, %xmm0
mulss %xmm2, %xmm2
addss %xmm0, %xmm2
leaq 0x54c8f3d(%rip), %rax   # 0x54faa3c
movss (%rax), %xmm0
mulss %xmm0, %xmm0
ucomiss %xmm2, %xmm0
jbe 0x31b7c
movl $0x8, %r12d
movss %xmm3, 0x14(%rsp)
movss %xmm4, 0x10(%rsp)
movss %xmm5, 0xc(%rsp)
movss -0x8(%r12,%r13), %xmm0
addss %xmm3, %xmm0
cvtss2sd %xmm0, %xmm0
movss -0x4(%r12,%r13), %xmm1
addss %xmm4, %xmm1
cvtss2sd %xmm1, %xmm1
movss (%r12,%r13), %xmm2
addss %xmm5, %xmm2
cvtss2sd %xmm2, %xmm2
movq %rbx, %rdi
movq %r14, %rsi
movb $0x3, %al
callq 0x4460
movss 0xc(%rsp), %xmm5
movss 0x10(%rsp), %xmm4
movss 0x14(%rsp), %xmm3
addq $0xc, %r12
cmpq $0xbc, %r12
jne 0x31b24
incq %rbp
movslq 0x104(%r15), %rax
movslq 0x100(%r15), %rcx
imulq %rax, %rcx
cmpq %rcx, %rbp
jl 0x31a97
movq 0x18(%rsp), %rcx
incq %rcx
leaq 0x1b7f84b(%rip), %rax   # 0x1bb13f4
movslq (%rax), %rax
cmpq %rax, %rcx
jl 0x31a56
movq %rbx, %rdi
callq 0x42e0
leaq 0xa85e(%rip), %rdi      # 0x3c422
jmp 0x31bcd
leaq 0xa85a(%rip), %rdi      # 0x3c427
xorl %eax, %eax
callq 0x9d2e
leaq 0x1b7f819(%rip), %rbx   # 0x1bb13f4
cmpl $0x0, (%rbx)
jle 0x31c67
leaq 0x55c90ed(%rip), %r14   # 0x55facd8
xorl %r15d, %r15d
xorl %r12d, %r12d
cmpb $0x1, -0x108(%r14)
jne 0x31c55
movq -0x88(%r14), %rdi
testq %rdi, %rdi
je 0x31c0d
movq (%rdi), %rax
callq *0x8(%rax)
movq $0x0, -0x88(%r14)
movq -0x68(%r14), %rdi
testq %rdi, %rdi
je 0x31c27
movq (%rdi), %rax
callq *0x8(%rax)
movq $0x0, -0x68(%r14)
movq -0x48(%r14), %rdi
testq %rdi, %rdi
je 0x31c3e
movq (%rdi), %rax
callq *0x8(%rax)
movq %r15, -0x48(%r14)
movq (%r14), %rdi
callq 0x4380
movq %r15, (%r14)
movb $0x0, -0x108(%r14)
incq %r12
movslq (%rbx), %rax
addq $0x110, %r14            # imm = 0x110
cmpq %rax, %r12
jl 0x31bf1
addq $0x1038, %rsp           # imm = 0x1038
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq