// File: /workspace/github_cpp_makefile_star2_O3/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 0x54c90d3(%rip), %rax   # 0x54f9a2d
cmpb $0x1, (%rax)
jne 0x30b6b
leaq 0xdfd0(%rip), %rsi      # 0x3e93a
leaq 0x169df(%rip), %rdx     # 0x47350
leaq 0x20(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x40a0
leaq 0xa9ff(%rip), %rdi      # 0x3b386
movq %rbx, %rsi
xorl %eax, %eax
callq 0x9c46
leaq 0xd3e4(%rip), %rsi      # 0x3dd7c
movq %rbx, %rdi
callq 0x4360
testq %rax, %rax
je 0x30b5d
movq %rax, %rbx
leaq 0x1b7fa41(%rip), %rax   # 0x1bb03f4
movl (%rax), %edx
testl %edx, %edx
jle 0x30b4c
xorl %edi, %edi
leaq 0x55c920a(%rip), %r8    # 0x55f9bd0
leaq 0x54c9063(%rip), %r9    # 0x54f9a30
leaq 0x54c9068(%rip), %r10   # 0x54f9a3c
leaq 0xdf75(%rip), %r13      # 0x3e950
leaq 0xa9b6(%rip), %r14      # 0x3b398
imulq $0x110, %rdi, %r15      # imm = 0x110
cmpb $0x1, (%r15,%r8)
jne 0x30b3d
addq %r8, %r15
movl 0x100(%r15), %eax
movl 0x104(%r15), %ecx
movl %eax, %esi
imull %ecx, %esi
testl %esi, %esi
jle 0x30b3d
movq %rdi, 0x18(%rsp)
xorl %ebp, %ebp
movq 0x108(%r15), %rdx
leaq (,%rbp,2), %rsi
addq %rbp, %rsi
cmpb $0x1, (%rdx,%rsi,8)
jne 0x30b14
leaq (%rdx,%rsi,8), %rdx
movss 0xc(%rdx), %xmm3
movss 0x10(%rdx), %xmm4
movaps %xmm3, %xmm0
subss (%r9), %xmm0
movss 0x14(%rdx), %xmm5
movaps %xmm4, %xmm1
subss 0x4(%r9), %xmm1
movaps %xmm5, %xmm2
subss 0x8(%r9), %xmm2
mulss %xmm1, %xmm1
mulss %xmm0, %xmm0
addss %xmm1, %xmm0
mulss %xmm2, %xmm2
addss %xmm0, %xmm2
movss (%r10), %xmm0
mulss %xmm0, %xmm0
ucomiss %xmm2, %xmm0
jbe 0x30b14
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 0x4450
movss 0xc(%rsp), %xmm5
movss 0x10(%rsp), %xmm4
movss 0x14(%rsp), %xmm3
addq $0xc, %r12
cmpq $0xbc, %r12
jne 0x30aa0
movl 0x100(%r15), %eax
movl 0x104(%r15), %ecx
leaq 0x54c8f23(%rip), %r9    # 0x54f9a30
leaq 0x54c8f28(%rip), %r10   # 0x54f9a3c
incq %rbp
movl %eax, %edx
imull %ecx, %edx
movslq %edx, %rdx
cmpq %rdx, %rbp
jl 0x30a19
leaq 0x1b7f8c5(%rip), %rax   # 0x1bb03f4
movl (%rax), %edx
movq 0x18(%rsp), %rdi
leaq 0x55c9093(%rip), %r8    # 0x55f9bd0
incq %rdi
movslq %edx, %rax
cmpq %rax, %rdi
jl 0x309e2
movq %rbx, %rdi
callq 0x42d0
leaq 0xa847(%rip), %rdi      # 0x3b3a2
jmp 0x30b64
leaq 0xa843(%rip), %rdi      # 0x3b3a7
xorl %eax, %eax
callq 0x9c46
leaq 0x1b7f882(%rip), %rbx   # 0x1bb03f4
movl (%rbx), %eax
testl %eax, %eax
jle 0x30c01
leaq 0x55c9155(%rip), %r14   # 0x55f9cd8
xorl %r15d, %r15d
xorl %r12d, %r12d
cmpb $0x1, -0x108(%r14)
jne 0x30bef
movq -0x88(%r14), %rdi
testq %rdi, %rdi
je 0x30ba5
movq (%rdi), %rax
callq *0x8(%rax)
movq $0x0, -0x88(%r14)
movq -0x68(%r14), %rdi
testq %rdi, %rdi
je 0x30bbf
movq (%rdi), %rax
callq *0x8(%rax)
movq $0x0, -0x68(%r14)
movq -0x48(%r14), %rdi
testq %rdi, %rdi
je 0x30bd6
movq (%rdi), %rax
callq *0x8(%rax)
movq %r15, -0x48(%r14)
movq (%r14), %rdi
callq 0x4370
movq %r15, (%r14)
movb $0x0, -0x108(%r14)
movl (%rbx), %eax
incq %r12
movslq %eax, %rcx
addq $0x110, %r14            # imm = 0x110
cmpq %rcx, %r12
jl 0x30b89
addq $0x1038, %rsp           # imm = 0x1038
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq