// File: 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:
subq $0x1138, %rsp           # imm = 0x1138
leaq 0x54cfb2f(%rip), %rax   # 0x552fa4d
testb $0x1, (%rax)
je 0x60226
leaq 0x120(%rsp), %rdi
leaq 0x119ac(%rip), %rsi     # 0x718e2
leaq 0x1d423(%rip), %rdx     # 0x7d360
movb $0x0, %al
callq 0x40a0
leaq 0x120(%rsp), %rsi
leaq 0xe477(%rip), %rdi      # 0x6e3ca
movb $0x0, %al
callq 0xb0d0
leaq 0x120(%rsp), %rdi
leaq 0x10e1a(%rip), %rsi     # 0x70d83
callq 0x4390
movq %rax, 0x118(%rsp)
cmpq $0x0, 0x118(%rsp)
je 0x60216
movl $0xf, 0x114(%rsp)
leaq 0x60(%rsp), %rdi
leaq 0x11974(%rip), %rsi     # 0x71910
movl $0xb4, %edx
callq 0x4280
movl $0x0, 0x5c(%rsp)
movl 0x5c(%rsp), %eax
leaq 0x1b8644b(%rip), %rcx   # 0x1be6404
cmpl (%rcx), %eax
jge 0x601f9
movslq 0x5c(%rsp), %rcx
leaq 0x55cfc23(%rip), %rax   # 0x562fbf0
imulq $0x110, %rcx, %rcx      # imm = 0x110
addq %rcx, %rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rax
testb $0x1, (%rax)
jne 0x5ffeb
jmp 0x601e9
movl $0x0, 0x58(%rsp)
movl 0x58(%rsp), %eax
movq 0x30(%rsp), %rcx
movl 0x104(%rcx), %ecx
movq 0x30(%rsp), %rdx
imull 0x100(%rdx), %ecx
cmpl %ecx, %eax
jge 0x601e7
movq 0x30(%rsp), %rax
movq 0x108(%rax), %rax
movslq 0x58(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
testb $0x1, (%rax)
jne 0x60038
jmp 0x601d7
movq 0x30(%rsp), %rax
movq 0x108(%rax), %rax
movslq 0x58(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movss 0xc(%rax), %xmm0
movss %xmm0, 0x48(%rsp)
movq 0x30(%rsp), %rax
movq 0x108(%rax), %rax
movslq 0x58(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movss 0x10(%rax), %xmm0
movss %xmm0, 0x4c(%rsp)
movq 0x30(%rsp), %rax
movq 0x108(%rax), %rax
movslq 0x58(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movss 0x14(%rax), %xmm0
movss %xmm0, 0x50(%rsp)
movss 0x48(%rsp), %xmm0
leaq 0x54cf9a2(%rip), %rax   # 0x552fa50
subss (%rax), %xmm0
movss %xmm0, 0x3c(%rsp)
movss 0x4c(%rsp), %xmm0
leaq 0x54cf98b(%rip), %rax   # 0x552fa50
subss 0x4(%rax), %xmm0
movss %xmm0, 0x40(%rsp)
movss 0x50(%rsp), %xmm0
leaq 0x54cf973(%rip), %rax   # 0x552fa50
subss 0x8(%rax), %xmm0
movss %xmm0, 0x44(%rsp)
movss 0x3c(%rsp), %xmm0
movss 0x3c(%rsp), %xmm2
movss 0x40(%rsp), %xmm1
mulss 0x40(%rsp), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss 0x44(%rsp), %xmm1
movss 0x44(%rsp), %xmm2
mulss %xmm2, %xmm1
addss %xmm0, %xmm1
leaq 0x54cf939(%rip), %rax   # 0x552fa5c
movss (%rax), %xmm0
leaq 0x54cf92e(%rip), %rax   # 0x552fa5c
mulss (%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x601d5
movl $0x0, 0x54(%rsp)
cmpl $0xf, 0x54(%rsp)
jge 0x601d3
movq 0x118(%rsp), %rdi
movss 0x48(%rsp), %xmm0
movslq 0x54(%rsp), %rcx
leaq 0x60(%rsp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
addss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movss 0x4c(%rsp), %xmm1
movslq 0x54(%rsp), %rcx
leaq 0x60(%rsp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
addss 0x4(%rax), %xmm1
cvtss2sd %xmm1, %xmm1
movss 0x50(%rsp), %xmm2
movslq 0x54(%rsp), %rcx
leaq 0x60(%rsp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
addss 0x8(%rax), %xmm2
cvtss2sd %xmm2, %xmm2
leaq 0xe220(%rip), %rsi      # 0x6e3dc
movb $0x3, %al
callq 0x44a0
movl 0x54(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x54(%rsp)
jmp 0x60143
jmp 0x601d5
jmp 0x601d7
movl 0x58(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x58(%rsp)
jmp 0x5fff3
jmp 0x601e9
movl 0x5c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5c(%rsp)
jmp 0x5ffae
movq 0x118(%rsp), %rdi
callq 0x4310
leaq 0xe1d9(%rip), %rdi      # 0x6e3e6
movb $0x0, %al
callq 0xb0d0
jmp 0x60224
leaq 0xe1ce(%rip), %rdi      # 0x6e3eb
movb $0x0, %al
callq 0xb0d0
jmp 0x60226
movl $0x0, 0x2c(%rsp)
movl 0x2c(%rsp), %eax
leaq 0x1b861cb(%rip), %rcx   # 0x1be6404
cmpl (%rcx), %eax
jge 0x6033b
movslq 0x2c(%rsp), %rcx
leaq 0x55cf9a3(%rip), %rax   # 0x562fbf0
imulq $0x110, %rcx, %rcx      # imm = 0x110
addq %rcx, %rax
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rax
testb $0x1, (%rax)
je 0x60329
movq 0x20(%rsp), %rax
movq 0x80(%rax), %rax
movq %rax, 0x18(%rsp)
cmpq $0x0, %rax
je 0x6028c
movq 0x18(%rsp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x20(%rsp), %rax
movq $0x0, 0x80(%rax)
movq 0x20(%rsp), %rax
movq 0xa0(%rax), %rax
movq %rax, 0x10(%rsp)
cmpq $0x0, %rax
je 0x602be
movq 0x10(%rsp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x20(%rsp), %rax
movq $0x0, 0xa0(%rax)
movq 0x20(%rsp), %rax
movq 0xc0(%rax), %rax
movq %rax, 0x8(%rsp)
cmpq $0x0, %rax
je 0x602f0
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x20(%rsp), %rax
movq $0x0, 0xc0(%rax)
movq 0x20(%rsp), %rax
movq 0x108(%rax), %rdi
callq 0x43a0
movq 0x20(%rsp), %rax
movq $0x0, 0x108(%rax)
movq 0x20(%rsp), %rax
movb $0x0, (%rax)
jmp 0x6032b
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0x6022e
addq $0x1138, %rsp           # imm = 0x1138
retq
nopw %cs:(%rax,%rax)