// File: /workspace/github_cpp_makefile_star2_O2/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 0x54c9f63(%rip), %rax   # 0x54f6a3d
cmpb $0x1, (%rax)
jne 0x2cc94
leaq 0xcd90(%rip), %rsi      # 0x3987a
leaq 0x1786f(%rip), %rdx     # 0x44360
leaq 0x20(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x40a0
leaq 0x983f(%rip), %rdi      # 0x36346
movq %rbx, %rsi
xorl %eax, %eax
callq 0x8790
leaq 0xc1e4(%rip), %rsi      # 0x38cfc
movq %rbx, %rdi
callq 0x4370
testq %rax, %rax
je 0x2cc86
movq %rax, %rbx
xorl %ecx, %ecx
leaq 0xcd5b(%rip), %r13      # 0x39890
leaq 0x981c(%rip), %r14      # 0x36358
leaq 0x1b808c1(%rip), %rax   # 0x1bad404
movslq (%rax), %rax
cmpq %rax, %rcx
jge 0x2cc75
movq %rcx, 0x18(%rsp)
imulq $0x110, %rcx, %r12      # imm = 0x110
leaq 0x55ca07e(%rip), %rax   # 0x55f6be0
cmpb $0x1, (%r12,%rax)
jne 0x2cc68
leaq 0x55ca06c(%rip), %rax   # 0x55f6be0
addq %rax, %r12
xorl %r15d, %r15d
movslq 0x104(%r12), %rax
movslq 0x100(%r12), %rcx
imulq %rax, %rcx
cmpq %rcx, %r15
jge 0x2cc68
movq 0x108(%r12), %rax
imulq $0x18, %r15, %rcx
cmpb $0x1, (%rax,%rcx)
jne 0x2cc60
addq %rcx, %rax
movss 0xc(%rax), %xmm0
movss 0x10(%rax), %xmm1
movss %xmm0, 0x14(%rsp)
leaq 0x54c9e79(%rip), %rcx   # 0x54f6a40
subss (%rcx), %xmm0
movss 0x14(%rax), %xmm2
movss %xmm1, 0x10(%rsp)
subss 0x4(%rcx), %xmm1
movss %xmm2, 0xc(%rsp)
subss 0x8(%rcx), %xmm2
mulss %xmm1, %xmm1
mulss %xmm0, %xmm0
addss %xmm1, %xmm0
mulss %xmm2, %xmm2
addss %xmm0, %xmm2
leaq 0x54c9e4b(%rip), %rax   # 0x54f6a4c
movss (%rax), %xmm0
mulss %xmm0, %xmm0
ucomiss %xmm2, %xmm0
jbe 0x2cc60
pushq $0x8
popq %rbp
cmpq $0xbc, %rbp
je 0x2cc60
movss -0x8(%rbp,%r13), %xmm0
addss 0x14(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movss -0x4(%rbp,%r13), %xmm1
addss 0x10(%rsp), %xmm1
cvtss2sd %xmm1, %xmm1
movss (%rbp,%r13), %xmm2
addss 0xc(%rsp), %xmm2
cvtss2sd %xmm2, %xmm2
movq %rbx, %rdi
movq %r14, %rsi
movb $0x3, %al
callq 0x4480
addq $0xc, %rbp
jmp 0x2cc11
incq %r15
jmp 0x2cb7a
movq 0x18(%rsp), %rcx
incq %rcx
jmp 0x2cb3c
movq %rbx, %rdi
callq 0x42d0
leaq 0x96de(%rip), %rdi      # 0x36362
jmp 0x2cc8d
leaq 0x96da(%rip), %rdi      # 0x36367
xorl %eax, %eax
callq 0x8790
leaq 0x1b80769(%rip), %rbx   # 0x1bad404
movl (%rbx), %eax
leaq 0x55ca044(%rip), %r14   # 0x55f6ce8
xorl %r15d, %r15d
movslq %eax, %rcx
cmpq %rcx, %r15
jge 0x2cd1d
cmpb $0x1, -0x108(%r14)
jne 0x2cd11
movq -0x88(%r14), %rdi
testq %rdi, %rdi
je 0x2cccb
movq (%rdi), %rax
callq *0x8(%rax)
andq $0x0, -0x88(%r14)
movq -0x68(%r14), %rdi
testq %rdi, %rdi
je 0x2cce2
movq (%rdi), %rax
callq *0x8(%rax)
andq $0x0, -0x68(%r14)
movq -0x48(%r14), %rdi
testq %rdi, %rdi
je 0x2ccf6
movq (%rdi), %rax
callq *0x8(%rax)
andq $0x0, -0x48(%r14)
movq (%r14), %rdi
callq 0x4380
andq $0x0, (%r14)
movb $0x0, -0x108(%r14)
movl (%rbx), %eax
incq %r15
addq $0x110, %r14            # imm = 0x110
jmp 0x2cca7
addq $0x1038, %rsp           # imm = 0x1038
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq