LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/hlrad/lightmap.cpp
// Function: ScaleDirectLights()
void ScaleDirectLights ()
{
	int facenum;
	dface_t *f;
	facelight_t *fl;
	int i;
	int k;
	sample_t *samp;

	for (facenum = 0; facenum < g_numfaces; facenum++)
	{
		f = &g_dfaces[facenum];

		if (g_texinfo[f->texinfo].flags & TEX_SPECIAL)
		{
			continue;
		}

		fl = &facelight[facenum];

		for (k = 0; k < MAXLIGHTMAPS && f->styles[k] != 255; k++)
		{
			for (i = 0; i < fl->numsamples; i++)
			{
				samp = &fl->samples[k][i];
				VectorScale (samp->light, g_direct_scale, samp->light);
	#ifdef ZHLT_XASH
				VectorScale (samp->light_direction, g_direct_scale, samp->light_direction);
	#endif
			}
		}
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
xorl %eax, %eax
leaq 0x1b8f646(%rip), %rcx   # 0x1bad404
leaq 0x1b8f64b(%rip), %rdx   # 0x1bad410
leaq 0x118f634(%rip), %rsi   # 0x11ad400
leaq 0x4f50bed(%rip), %rdi   # 0x4f6e9c0
leaq 0x275f6(%rip), %r8      # 0x453d0
xorl %r9d, %r9d
movslq (%rcx), %r10
cmpq %r10, %r9
jge 0x1de80
imulq $0x14, %r9, %r10
movswq 0xa(%rdx,%r10), %r11
imulq $0x28, %r11, %r11
testb $0x1, 0x24(%rsi,%r11)
jne 0x1de78
addq %rdx, %r10
imulq $0x28, %r9, %r11
addq %rdi, %r11
xorl %ebx, %ebx
cmpq $0x4, %rbx
je 0x1de78
cmpb $-0x1, 0xc(%r10,%rbx)
je 0x1de78
movl (%r11), %r14d
testl %r14d, %r14d
cmovlel %eax, %r14d
imulq $0x1c, %r14, %r14
xorl %r15d, %r15d
cmpq %r15, %r14
je 0x1de73
movq 0x8(%r11,%rbx,8), %r12
movss 0xc(%r12,%r15), %xmm0
movss 0x10(%r12,%r15), %xmm1
mulss (%r8), %xmm0
movss %xmm0, 0xc(%r12,%r15)
mulss (%r8), %xmm1
movss %xmm1, 0x10(%r12,%r15)
movss 0x14(%r12,%r15), %xmm0
mulss (%r8), %xmm0
movss %xmm0, 0x14(%r12,%r15)
addq $0x1c, %r15
jmp 0x1de2a
incq %rbx
jmp 0x1de0b
incq %r9
jmp 0x1dddd
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/hlrad/loadtextures.cpp
// Function: AddWadFolder(char const*)
void AddWadFolder (const char *path)
{
	waddir_t *waddir;
	waddir = (waddir_t *)malloc (sizeof (waddir_t));
	hlassume (waddir != NULL, assume_NoMemory);
	{
		waddir_t **pos;
		for (pos = &g_waddirs; *pos; pos = &(*pos)->next)
			;
		waddir->next = *pos;
		*pos = waddir;
	}
	safe_snprintf (waddir->path, _MAX_PATH, "%s", path);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0x1008, %edi           # imm = 0x1008
callq 0x4420
movq %rax, %r14
xorl %edi, %edi
testq %rax, %rax
setne %dil
pushq $0x1
popq %rsi
callq 0x92cb
leaq 0x52500e8(%rip), %rcx   # 0x526e9c0
movq %rcx, %rax
movq (%rcx), %rcx
testq %rcx, %rcx
jne 0x1e8d8
andq $0x0, (%r14)
movq %r14, (%rax)
addq $0x8, %r14
leaq 0x17d0c(%rip), %rdx     # 0x36601
movl $0x1000, %esi           # imm = 0x1000
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x767f
// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/hlrad/loadtextures.cpp
// Function: TryOpenWadFiles()
void TryOpenWadFiles ()
{
	if (!g_wadfiles_opened)
	{
		g_wadfiles_opened = true;
#ifdef ZHLT_NOWADDIR
		char filename[_MAX_PATH];
		safe_snprintf(filename, _MAX_PATH, "%s.wa_", g_Mapname);
	   if (q_exists (filename))
	   {
		OpenWadFile (filename, true);
	   }
	   else
	   {
		Warning ("Couldn't open %s", filename);
#endif
		Log ("Opening wad files from directories:\n");
		if (!g_waddirs)
		{
			Warning ("No wad directories have been set.");
		}
		else
		{
			waddir_t *dir;
			for (dir = g_waddirs; dir; dir = dir->next)
			{
				Log ("  %s\n", dir->path);
			}
		}
		const char *value = ValueForKey (&g_entities[0], "wad");
		char path[MAX_VAL];
		int i, j;
		for (i = 0, j = 0; i < strlen(value) + 1; i++)
		{
			if (value[i] == ';' || value[i] == '\0')
			{
				path[j] = '\0';
				if (path[0])
				{
					char name[MAX_VAL];
					ExtractFile (path, name);
					DefaultExtension (name, ".wad");
					OpenWadFile (name);
				}
				j = 0;
			}
			else
			{
				path[j] = value[i];
				j++;
			}
		}
#ifdef ZHLT_NOWADDIR
	   }
#endif
		CheckFatal ();
	}
}

// Assembly:
cmpb $0x0, 0x524fd81(%rip)   # 0x526e9d0
jne 0x1ecc0
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3008, %rsp           # imm = 0x3008
movb $0x1, 0x524fd67(%rip)   # 0x526e9d0
leaq 0x14d48(%rip), %rdx     # 0x339b8
leaq 0x256e9(%rip), %rcx     # 0x44360
leaq 0x1000(%rsp), %rbx
movl $0x1000, %esi           # imm = 0x1000
movq %rbx, %rdi
xorl %eax, %eax
callq 0x767f
movq %rbx, %rdi
callq 0x82be
testb %al, %al
je 0x1ecc1
leaq 0x1000(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x1e90e
callq 0x8b1c
addq $0x3008, %rsp           # imm = 0x3008
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x178b4(%rip), %rdi     # 0x3657c
leaq 0x1000(%rsp), %rsi
xorl %eax, %eax
callq 0x8ea5
leaq 0x17960(%rip), %rdi     # 0x3663e
xorl %eax, %eax
callq 0x8790
movq 0x524fcd4(%rip), %r14   # 0x526e9c0
testq %r14, %r14
je 0x1ed10
leaq 0x1798d(%rip), %rbx     # 0x36685
testq %r14, %r14
je 0x1ed1e
leaq 0x8(%r14), %rsi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x8790
movq (%r14), %r14
jmp 0x1ecf8
leaq 0x1794c(%rip), %rdi     # 0x36663
xorl %eax, %eax
callq 0x8ea5
leaq 0x201c71b(%rip), %rdi   # 0x203b440
leaq 0x17960(%rip), %rsi     # 0x3668c
callq 0x6929
movq %rax, %rbx
xorl %r13d, %r13d
movq %rsp, %r14
leaq 0x2000(%rsp), %r15
leaq 0x17942(%rip), %r12     # 0x3668b
xorl %ebp, %ebp
movq %rbx, %rdi
callq 0x4150
incq %rax
cmpq %r13, %rax
jbe 0x1ecaa
movzbl (%rbx,%r13), %eax
movslq %ebp, %rbp
cmpl $0x3b, %eax
je 0x1ed70
testl %eax, %eax
jne 0x1ed9e
movb $0x0, (%rsp,%rbp)
cmpb $0x0, (%rsp)
je 0x1eda5
movq %r14, %rdi
movq %r15, %rsi
callq 0x7556
movq %r15, %rdi
movq %r12, %rsi
callq 0x7471
xorl %ebp, %ebp
movq %r15, %rdi
xorl %esi, %esi
callq 0x1e90e
jmp 0x1eda7
movb %al, (%rsp,%rbp)
incl %ebp
jmp 0x1eda7
xorl %ebp, %ebp
incq %r13
jmp 0x1ed4b
// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/hlrad/loadtextures.cpp
// Function: TryCloseWadFiles()
void TryCloseWadFiles ()
{
	if (g_wadfiles_opened)
	{
		g_wadfiles_opened = false;
		wadfile_t *wadfile, *next;
		for (wadfile = g_wadfiles; wadfile; wadfile = next)
		{
			next = wadfile->next;
			free (wadfile->lumpinfos);
			fclose (wadfile->file);
			free (wadfile);
		}
		g_wadfiles = NULL;
	}
}

// Assembly:
cmpb $0x1, 0x524fc1d(%rip)   # 0x526e9d0
jne 0x1ee03
pushq %r14
pushq %rbx
pushq %rax
movb $0x0, 0x524fc10(%rip)   # 0x526e9d0
movq 0x524fc01(%rip), %rbx   # 0x526e9c8
testq %rbx, %rbx
je 0x1edf4
movq (%rbx), %r14
movq 0x1018(%rbx), %rdi
callq 0x4380
movq 0x1008(%rbx), %rdi
callq 0x42d0
movq %rbx, %rdi
callq 0x4380
movq %r14, %rbx
jmp 0x1edc7
andq $0x0, 0x524fbcc(%rip)   # 0x526e9c8
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/hlrad/loadtextures.cpp
// Function: DefaultTexture(radtexture_t*, char const*)
void DefaultTexture (radtexture_t *tex, const char *name)
{
	int i;
	tex->width = 16;
	tex->height = 16;
	strcpy (tex->name, name);
	tex->name[16 - 1] = '\0';
	tex->canvas = (byte *)malloc (tex->width * tex->height);
	hlassume (tex->canvas != NULL, assume_NoMemory);
	for (i = 0; i < 256; i++)
	{
		VectorFill (tex->palette[i], 0x80);
	}
	for (i = 0; i < tex->width * tex->height; i++)
	{
		tex->canvas[i] = 0x00;
	}
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movabsq $0x1000000010, %rax     # imm = 0x1000000010
movq %rax, 0x10(%rdi)
callq 0x42a0
movb $0x0, 0xf(%rbx)
movslq 0x10(%rbx), %rax
movslq 0x14(%rbx), %rdi
imulq %rax, %rdi
callq 0x4420
movq %rax, 0x18(%rbx)
xorl %edi, %edi
testq %rax, %rax
setne %dil
pushq $0x1
popq %rsi
callq 0x92cb
pushq $0x22
popq %rax
cmpq $0x322, %rax            # imm = 0x322
je 0x1ee61
movw $0x8080, -0x2(%rbx,%rax) # imm = 0x8080
movb $-0x80, (%rbx,%rax)
addq $0x3, %rax
jmp 0x1ee48
xorl %eax, %eax
movslq 0x10(%rbx), %rcx
movslq 0x14(%rbx), %rdx
imulq %rcx, %rdx
cmpq %rdx, %rax
jge 0x1ee81
movq 0x18(%rbx), %rcx
movb $0x0, (%rcx,%rax)
incq %rax
jmp 0x1ee63
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/hlrad/loadtextures.cpp
// Function: NewTextures_PushTexture(int, void*)
void NewTextures_PushTexture (int size, void *data)
{
	if (g_newtextures_num >= RADTEXTURES_MAX)
	{
		Error ("the number of textures created by hlrad has exceeded its internal limit(%d).", (int)RADTEXTURES_MAX);
	}
	g_newtextures_data[g_newtextures_num] = (byte *)malloc (size);
	hlassume (g_newtextures_data[g_newtextures_num] != NULL, assume_NoMemory);
	memcpy (g_newtextures_data[g_newtextures_num], data, size);
	g_newtextures_size[g_newtextures_num] = size;
	g_newtextures_num++;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %rbx
movl %edi, %ebp
movl 0x524f447(%rip), %r15d  # 0x526e9d4
cmpl $0x800, %r15d           # imm = 0x800
jl 0x1f5b0
leaq 0x17328(%rip), %rdi     # 0x368c5
movl $0x800, %esi            # imm = 0x800
xorl %eax, %eax
callq 0x8b2f
movl 0x524f424(%rip), %r15d  # 0x526e9d4
movslq %ebp, %r14
movq %r14, %rdi
callq 0x4420
movslq %r15d, %rcx
leaq 0x524f41b(%rip), %r15   # 0x526e9e0
movq %rax, (%r15,%rcx,8)
xorl %edi, %edi
testq %rax, %rax
setne %dil
pushq $0x1
popq %rsi
callq 0x92cb
movslq 0x524f3f3(%rip), %r12   # 0x526e9d4
movq (%r15,%r12,8), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x4240
leaq 0x52533e9(%rip), %rax   # 0x52729e0
movl %r14d, (%rax,%r12,4)
leal 0x1(%r12), %eax
movl %eax, 0x524f3ce(%rip)   # 0x526e9d4
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/hlrad/loadtextures.cpp
// Function: GetLightInt(dface_t*, int const*, int, int, float (&) [3])
static void GetLightInt (dface_t *face, const int texsize[2], int ix, int iy, vec3_t &light)
{
	ix = qmax (0, qmin (ix, texsize[0]));
	iy = qmax (0, qmin (iy, texsize[1]));
	VectorClear (light);
	if (face->lightofs < 0)
	{
		return;
	}
	for (int k = 0; k < MAXLIGHTMAPS && face->styles[k] != 255; k++)
	{
		byte *samples = &g_dlightdata[face->lightofs + k * (texsize[0] + 1) * (texsize[1] + 1) * 3];
		if (face->styles[k] == 0)
		{
			VectorAdd (light, &samples[(iy * (texsize[0] + 1) + ix) * 3], light);
		}
	}
}

// Assembly:
movl (%rsi), %eax
cmpl %edx, %eax
cmovll %eax, %edx
xorl %eax, %eax
testl %edx, %edx
cmovlel %eax, %edx
movl 0x4(%rsi), %r9d
cmpl %ecx, %r9d
cmovll %r9d, %ecx
testl %ecx, %ecx
cmovlel %eax, %ecx
andl $0x0, 0x8(%r8)
andq $0x0, (%r8)
cmpl $0x0, 0x10(%rdi)
js 0x212ef
pushq %rbp
pushq %r14
pushq %rbx
leaq 0xc(%rdi), %rax
xorps %xmm0, %xmm0
xorl %r9d, %r9d
leaq 0x82c26e(%rip), %r10    # 0x84d498
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
cmpq $0xc, %r9
je 0x212eb
movzbl (%rax), %r11d
testl %r11d, %r11d
je 0x21255
cmpl $0xff, %r11d
jne 0x212df
jmp 0x212eb
movslq 0x10(%rdi), %rbx
movl (%rsi), %ebp
movl 0x4(%rsi), %r11d
incl %ebp
incl %r11d
movl %r9d, %r14d
imull %ebp, %r14d
imull %r11d, %r14d
movslq %r14d, %r11
addq %rbx, %r11
addq (%r10), %r11
imull %ecx, %ebp
addl %edx, %ebp
movslq %ebp, %rbx
leaq (%rbx,%rbx,2), %rbx
movzbl (%r11,%rbx), %ebx
cvtsi2ss %ebx, %xmm3
addss %xmm3, %xmm2
movss %xmm2, (%r8)
movl (%rsi), %ebx
incl %ebx
imull %ecx, %ebx
addl %edx, %ebx
movslq %ebx, %rbx
leaq (%rbx,%rbx,2), %rbx
movzbl 0x1(%r11,%rbx), %ebx
cvtsi2ss %ebx, %xmm3
addss %xmm3, %xmm1
movss %xmm1, 0x4(%r8)
movl (%rsi), %ebx
incl %ebx
imull %ecx, %ebx
addl %edx, %ebx
movslq %ebx, %rbx
leaq (%rbx,%rbx,2), %rbx
movzbl 0x2(%r11,%rbx), %r11d
cvtsi2ss %r11d, %xmm3
addss %xmm3, %xmm0
movss %xmm0, 0x8(%r8)
addq $0x3, %r9
incq %rax
jmp 0x21230
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/hlrad/loadtextures.cpp
// Function: CQ_MapPoint_r(int*, int*, cq_searchnode_s*, unsigned char const (*) [3], unsigned char const*, int)
static void CQ_MapPoint_r (int *bestdist, int *best,
					cq_searchnode_t *node, const unsigned char (*colors)[CQ_DIM],
					const unsigned char point[CQ_DIM], int searchradius)
{
	while (!node->isleafnode)
	{
		int dist = point[node->planeaxis] - node->planedist;
		if (dist <= -searchradius)
		{
			node = node->childrennode[0];
		}
		else if (dist >= searchradius - 1)
		{
			node = node->childrennode[1];
		}
		else
		{
			CQ_MapPoint_r (bestdist, best, node->childrennode[0], colors, point, searchradius);
			CQ_MapPoint_r (bestdist, best, node->childrennode[1], colors, point, searchradius);
			return;
		}
	}
	int dist = 0;
	for (int k = 0; k < CQ_DIM; k++)
	{
		dist += (colors[node->result][k] - point[k]) * (colors[node->result][k] - point[k]);
	}
	if (dist <= *bestdist)
	{
		if (dist < *bestdist || node->result < *best)
		{
			*bestdist = dist;
			*best = node->result;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, %r12
movq %rcx, %r14
movq %rdx, %rbx
movq %rsi, (%rsp)
movq %rdi, 0x8(%rsp)
movl %r9d, %ebp
negl %ebp
movq %r9, 0x10(%rsp)
leal -0x1(%r9), %r13d
pushq $0x8
popq %r15
pushq $0x10
popq %rdx
cmpb $0x1, (%rbx)
je 0x216b0
movslq 0x18(%rbx), %rax
movzbl (%r12,%rax), %eax
subl 0x1c(%rbx), %eax
movq %r15, %r8
cmpl %ebp, %eax
jle 0x216a8
movq %rdx, %r8
cmpl %r13d, %eax
jge 0x216a8
movq 0x8(%rbx), %rdx
movq 0x8(%rsp), %rdi
movq (%rsp), %rsi
movq %r14, %rcx
movq %r12, %r8
movq 0x10(%rsp), %r9
callq 0x2162d
pushq $0x10
popq %rdx
addq $0x10, %rbx
jmp 0x216ab
addq %r8, %rbx
movq (%rbx), %rbx
jmp 0x21662
movslq 0x20(%rbx), %rax
leaq (%rax,%rax,2), %rdx
addq %rdx, %r14
xorl %edx, %edx
xorl %r8d, %r8d
cmpq $0x3, %rdx
je 0x216dd
movzbl (%r14,%rdx), %esi
movzbl (%r12,%rdx), %edi
subl %edi, %esi
imull %esi, %esi
addl %esi, %r8d
incq %rdx
jmp 0x216c0
movq 0x8(%rsp), %rdx
cmpl (%rdx), %r8d
jg 0x21702
jl 0x216f1
movq (%rsp), %rdx
cmpl (%rdx), %eax
jge 0x21702
movq 0x8(%rsp), %rax
movl %r8d, (%rax)
movl 0x20(%rbx), %eax
movq (%rsp), %rcx
movl %eax, (%rcx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/hlrad/loadtextures.cpp
// Function: double CQ_DotProduct<double>(double const*, double const*)
inline T CQ_DotProduct (const T a[CQ_DIM], const T b[CQ_DIM])
{
	T dot = (T)0;
	for (int x = 0; x < CQ_DIM; x++)
	{
		dot += a[x] * b[x];
	}
	return dot;
}

// Assembly:
xorpd %xmm0, %xmm0
xorl %eax, %eax
cmpq $0x3, %rax
je 0x217c8
movsd (%rdi,%rax,8), %xmm1
mulsd (%rsi,%rax,8), %xmm1
addsd %xmm1, %xmm0
incq %rax
jmp 0x217af
retq
// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/hlrad/mathutil.cpp
// Function: point_in_winding(Winding const&, dplane_t const&, float const*, float)
bool            point_in_winding(const Winding& w, const dplane_t& plane, const vec_t* const point, vec_t epsilon/* = 0.0*/)
{
	int				numpoints;
	int				x;
	vec3_t			delta;
	vec3_t			normal;
	vec_t			dist;

	numpoints = w.m_NumPoints;

	for (x = 0; x < numpoints; x++)
	{
		VectorSubtract (w.m_Points[(x+ 1) % numpoints], w.m_Points[x], delta);
		CrossProduct (delta, plane.normal, normal);
		dist = DotProduct (point, normal) - DotProduct (w.m_Points[x], normal);

		if (dist < 0.0
			&& (epsilon == 0.0 || dist * dist > epsilon * epsilon * DotProduct (normal, normal)))
		{
			return false;
		}
	}

	return true;
}

// Assembly:
movq %rdx, %rcx
movslq 0x8(%rdi), %r8
movq 0x10(%rdi), %rdi
movss 0x8(%rsi), %xmm1
movss (%rsi), %xmm2
movss 0x4(%rsi), %xmm3
movaps %xmm0, %xmm4
mulss %xmm0, %xmm4
xorl %esi, %esi
testl %r8d, %r8d
movl $0x0, %r9d
cmovgl %r8d, %r9d
leaq 0x8(%rdi), %r10
xorps %xmm5, %xmm5
cmpq %rsi, %r9
je 0x21932
leal 0x1(%rsi), %eax
cltd
idivl %r8d
imulq $0xc, %rdx, %rax
movss (%rdi,%rax), %xmm6
movss 0x4(%rdi,%rax), %xmm7
movss -0x8(%r10), %xmm10
movss -0x4(%r10), %xmm11
subss %xmm10, %xmm6
subss %xmm11, %xmm7
movss 0x8(%rdi,%rax), %xmm8
movss (%r10), %xmm9
subss %xmm9, %xmm8
movaps %xmm3, %xmm12
mulss %xmm8, %xmm12
movaps %xmm2, %xmm13
mulss %xmm7, %xmm13
mulss %xmm1, %xmm7
subss %xmm12, %xmm7
movaps %xmm1, %xmm12
mulss %xmm6, %xmm12
mulss %xmm2, %xmm8
subss %xmm12, %xmm8
mulss %xmm3, %xmm6
subss %xmm13, %xmm6
movaps %xmm8, %xmm12
shufps $0x0, %xmm8, %xmm12     # xmm12 = xmm12[0,0],xmm8[0,0]
movss (%rcx), %xmm13
movss 0x4(%rcx), %xmm14
movss 0x8(%rcx), %xmm15
unpcklps %xmm11, %xmm14          # xmm14 = xmm14[0],xmm11[0],xmm14[1],xmm11[1]
mulps %xmm12, %xmm14
unpcklps %xmm10, %xmm13          # xmm13 = xmm13[0],xmm10[0],xmm13[1],xmm10[1]
movaps %xmm7, %xmm10
shufps $0x0, %xmm7, %xmm10     # xmm10 = xmm10[0,0],xmm7[0,0]
mulps %xmm13, %xmm10
addps %xmm14, %xmm10
unpcklps %xmm9, %xmm15           # xmm15 = xmm15[0],xmm9[0],xmm15[1],xmm9[1]
movaps %xmm6, %xmm9
shufps $0x0, %xmm6, %xmm9      # xmm9 = xmm9[0,0],xmm6[0,0]
mulps %xmm15, %xmm9
addps %xmm10, %xmm9
movaps %xmm9, %xmm10
shufps $0x55, %xmm9, %xmm10    # xmm10 = xmm10[1,1],xmm9[1,1]
subps %xmm10, %xmm9
ucomiss %xmm9, %xmm5
jbe 0x21926
ucomiss %xmm5, %xmm0
jne 0x21901
jnp 0x21932
mulss %xmm9, %xmm9
mulss %xmm8, %xmm8
mulss %xmm7, %xmm7
addss %xmm8, %xmm7
mulss %xmm6, %xmm6
addss %xmm7, %xmm6
mulss %xmm4, %xmm6
ucomiss %xmm6, %xmm9
ja 0x21932
addq $0xc, %r10
incq %rsi
jmp 0x2181e
cmpq %r8, %rsi
setge %al
retq
// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/hlrad/mathutil.cpp
// Function: point_in_winding_noedge(Winding const&, dplane_t const&, float const*, float)
bool            point_in_winding_noedge(const Winding& w, const dplane_t& plane, const vec_t* const point, vec_t width)
{
	int				numpoints;
	int				x;
	vec3_t			delta;
	vec3_t			normal;
	vec_t			dist;

	numpoints = w.m_NumPoints;

	for (x = 0; x < numpoints; x++)
	{
		VectorSubtract (w.m_Points[(x+ 1) % numpoints], w.m_Points[x], delta);
		CrossProduct (delta, plane.normal, normal);
		dist = DotProduct (point, normal) - DotProduct (w.m_Points[x], normal);

		if (dist < 0.0 || dist * dist <= width * width * DotProduct (normal, normal))
		{
			return false;
		}
	}

	return true;
}

// Assembly:
movq %rdx, %rcx
movslq 0x8(%rdi), %r8
movq 0x10(%rdi), %rdi
movss 0x8(%rsi), %xmm1
movss (%rsi), %xmm2
movss 0x4(%rsi), %xmm3
mulss %xmm0, %xmm0
xorl %eax, %eax
testl %r8d, %r8d
movl $0x0, %esi
cmovgl %r8d, %esi
leaq 0x8(%rdi), %r9
xorps %xmm4, %xmm4
movq %rax, %r10
cmpq %rax, %rsi
je 0x21a78
leal 0x1(%r10), %eax
cltd
idivl %r8d
imulq $0xc, %rdx, %rax
movss (%rdi,%rax), %xmm5
movss 0x4(%rdi,%rax), %xmm6
movss -0x8(%r9), %xmm9
movss -0x4(%r9), %xmm10
subss %xmm9, %xmm5
subss %xmm10, %xmm6
movss 0x8(%rdi,%rax), %xmm7
movss (%r9), %xmm8
subss %xmm8, %xmm7
movaps %xmm3, %xmm11
mulss %xmm7, %xmm11
movaps %xmm2, %xmm12
mulss %xmm6, %xmm12
mulss %xmm1, %xmm6
subss %xmm11, %xmm6
movaps %xmm1, %xmm11
mulss %xmm5, %xmm11
mulss %xmm2, %xmm7
subss %xmm11, %xmm7
mulss %xmm3, %xmm5
subss %xmm12, %xmm5
movaps %xmm7, %xmm11
shufps $0x0, %xmm7, %xmm11     # xmm11 = xmm11[0,0],xmm7[0,0]
movss (%rcx), %xmm12
movss 0x4(%rcx), %xmm13
movss 0x8(%rcx), %xmm14
unpcklps %xmm10, %xmm13          # xmm13 = xmm13[0],xmm10[0],xmm13[1],xmm10[1]
mulps %xmm11, %xmm13
unpcklps %xmm9, %xmm12           # xmm12 = xmm12[0],xmm9[0],xmm12[1],xmm9[1]
movaps %xmm6, %xmm9
shufps $0x0, %xmm6, %xmm9      # xmm9 = xmm9[0,0],xmm6[0,0]
mulps %xmm12, %xmm9
addps %xmm13, %xmm9
unpcklps %xmm8, %xmm14           # xmm14 = xmm14[0],xmm8[0],xmm14[1],xmm8[1]
movaps %xmm5, %xmm8
shufps $0x0, %xmm5, %xmm8      # xmm8 = xmm8[0,0],xmm5[0,0]
mulps %xmm14, %xmm8
addps %xmm9, %xmm8
movaps %xmm8, %xmm9
shufps $0x55, %xmm8, %xmm9     # xmm9 = xmm9[1,1],xmm8[1,1]
subps %xmm9, %xmm8
ucomiss %xmm8, %xmm4
ja 0x21a78
mulss %xmm8, %xmm8
mulss %xmm7, %xmm7
mulss %xmm6, %xmm6
addss %xmm7, %xmm6
mulss %xmm5, %xmm5
addss %xmm6, %xmm5
mulss %xmm0, %xmm5
addq $0xc, %r9
leaq 0x1(%r10), %rax
ucomiss %xmm8, %xmm5
jb 0x2196b
cmpq %r8, %r10
setge %al
retq
// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/hlrad/mathutil.cpp
// Function: intersect_linesegment_plane(dplane_t const*, float const*, float const*, float*)
bool			intersect_linesegment_plane(const dplane_t* const plane, const vec_t* const p1, const vec_t* const p2, vec3_t point)
{
	vec_t			part1;
	vec_t			part2;
	int				i;
	part1 = DotProduct (p1, plane->normal) - plane->dist;
	part2 = DotProduct (p2, plane->normal) - plane->dist;
	if (part1 * part2 > 0 || part1 == part2)
		return false;
	for (i=0; i<3; ++i)
		point[i] = (part1 * p2[i] - part2 * p1[i]) / (part1 - part2);
	return true;
}

// Assembly:
movss (%rdi), %xmm1
movss 0x4(%rdi), %xmm2
movss 0x8(%rdi), %xmm0
movss 0xc(%rdi), %xmm3
shufps $0x0, %xmm2, %xmm2      # xmm2 = xmm2[0,0,0,0]
movss (%rdx), %xmm4
movss 0x4(%rdx), %xmm5
movss 0x8(%rdx), %xmm6
movss (%rsi), %xmm7
unpcklps %xmm4, %xmm7            # xmm7 = xmm7[0],xmm4[0],xmm7[1],xmm4[1]
movss 0x4(%rsi), %xmm4
unpcklps %xmm5, %xmm4            # xmm4 = xmm4[0],xmm5[0],xmm4[1],xmm5[1]
mulps %xmm2, %xmm4
movss 0x8(%rsi), %xmm2
unpcklps %xmm6, %xmm2            # xmm2 = xmm2[0],xmm6[0],xmm2[1],xmm6[1]
shufps $0x0, %xmm1, %xmm1      # xmm1 = xmm1[0,0,0,0]
mulps %xmm7, %xmm1
addps %xmm4, %xmm1
shufps $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0]
mulps %xmm2, %xmm0
addps %xmm1, %xmm0
shufps $0x0, %xmm3, %xmm3      # xmm3 = xmm3[0,0,0,0]
subps %xmm3, %xmm0
movaps %xmm0, %xmm2
shufps $0x55, %xmm0, %xmm2     # xmm2 = xmm2[1,1],xmm0[1,1]
movaps %xmm0, %xmm1
mulss %xmm2, %xmm1
movaps %xmm0, %xmm3
cmpneqps %xmm2, %xmm3
xorps %xmm4, %xmm4
cmpnltps %xmm1, %xmm4
andps %xmm3, %xmm4
movd %xmm4, %eax
testb $0x1, %al
je 0x222bf
movaps 0x13007(%rip), %xmm1    # 0x35290
xorps %xmm2, %xmm1
movaps %xmm0, %xmm3
subss %xmm2, %xmm3
xorl %edi, %edi
cmpq $0x3, %rdi
je 0x222bf
movss (%rsi,%rdi,4), %xmm2
mulss %xmm1, %xmm2
movss (%rdx,%rdi,4), %xmm4
mulss %xmm0, %xmm4
addss %xmm2, %xmm4
divss %xmm3, %xmm4
movss %xmm4, (%rcx,%rdi,4)
incq %rdi
jmp 0x22295
andb $0x1, %al
retq
// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/hlrad/mathutil.cpp
// Function: plane_from_points(float const*, float const*, float const*, dplane_t*)
void            plane_from_points(const vec3_t p1, const vec3_t p2, const vec3_t p3, dplane_t* plane)
{
    vec3_t          delta1;
    vec3_t          delta2;
    vec3_t          normal;

    VectorSubtract(p3, p2, delta1);
    VectorSubtract(p1, p2, delta2);
    CrossProduct(delta1, delta2, normal);
    VectorNormalize(normal);
    plane->dist = DotProduct(normal, p1);
    VectorCopy(normal, plane->normal);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rcx, %rbx
movq %rdi, %r14
movss (%rdx), %xmm0
movss (%rsi), %xmm2
subss %xmm2, %xmm0
movss 0x4(%rdi), %xmm3
movsd 0x4(%rdx), %xmm1
movsd 0x4(%rsi), %xmm4
subps %xmm4, %xmm1
subss %xmm4, %xmm3
movss (%rdi), %xmm5
movss 0x8(%rdi), %xmm6
unpcklps %xmm5, %xmm6            # xmm6 = xmm6[0],xmm5[0],xmm6[1],xmm5[1]
shufps $0xd4, %xmm4, %xmm2     # xmm2 = xmm2[0,1],xmm4[1,3]
shufps $0x52, %xmm4, %xmm2     # xmm2 = xmm2[2,0],xmm4[1,1]
subps %xmm2, %xmm6
movaps %xmm0, %xmm2
shufps $0xd4, %xmm1, %xmm2     # xmm2 = xmm2[0,1],xmm1[1,3]
shufps $0x52, %xmm1, %xmm2     # xmm2 = xmm2[2,0],xmm1[1,1]
mulss %xmm3, %xmm0
unpcklps %xmm6, %xmm3            # xmm3 = xmm3[0],xmm6[0],xmm3[1],xmm6[1]
mulps %xmm2, %xmm3
movaps %xmm1, %xmm2
mulps %xmm6, %xmm2
subps %xmm3, %xmm2
movq %rsp, %r15
movlps %xmm2, (%r15)
shufps $0x55, %xmm6, %xmm6     # xmm6 = xmm6[1,1,1,1]
mulss %xmm1, %xmm6
subss %xmm6, %xmm0
movss %xmm0, 0x8(%r15)
movq %r15, %rdi
callq 0xc021
movss 0x8(%r15), %xmm0
movsd (%r15), %xmm1
movaps %xmm1, %xmm2
shufps $0x55, %xmm1, %xmm2     # xmm2 = xmm2[1,1],xmm1[1,1]
mulss 0x4(%r14), %xmm2
movss (%r14), %xmm3
mulss %xmm1, %xmm3
addss %xmm2, %xmm3
movss 0x8(%r14), %xmm2
mulss %xmm0, %xmm2
addss %xmm3, %xmm2
movss %xmm2, 0xc(%rbx)
movsd %xmm1, (%rbx)
movss %xmm0, 0x8(%rbx)
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/hlrad/mathutil.cpp
// Function: LineSegmentIntersectsBounds_r(float const*, float const*, float const*, float const*, int)
bool LineSegmentIntersectsBounds_r (const vec_t* p1, const vec_t* p2, const vec_t* mins, const vec_t* maxs, int d)
{
	vec_t lmin, lmax;
	const vec_t* tmp;
	vec3_t x1, x2;
	int i;
	d--;
	if (p2[d]<p1[d])
		tmp=p1, p1=p2, p2=tmp;
	if (p2[d]<mins[d] || p1[d]>maxs[d])
		return false;
	if (d==0)
		return true;
	lmin = p1[d]>=mins[d]? 0 : (mins[d]-p1[d])/(p2[d]-p1[d]);
	lmax = p2[d]<=maxs[d]? 1 : (p2[d]-maxs[d])/(p2[d]-p1[d]);
	for (i=0; i<d; ++i)
	{
		x1[i]=(1-lmin)*p1[i]+lmin*p2[i];
		x2[i]=(1-lmax)*p2[i]+lmax*p2[i];
	}
	return LineSegmentIntersectsBounds_r (x1, x2, mins, maxs, d);
}

// Assembly:
movslq %r8d, %r8
movss -0x4(%rdi,%r8,4), %xmm0
ucomiss -0x4(%rsi,%r8,4), %xmm0
movq %rsi, %rax
cmovaq %rdi, %rax
cmovaq %rsi, %rdi
movss -0x4(%rax,%r8,4), %xmm0
movss -0x4(%rdx,%r8,4), %xmm1
ucomiss %xmm0, %xmm1
ja 0x223d6
decq %r8
movss (%rdi,%r8,4), %xmm3
movss (%rcx,%r8,4), %xmm2
ucomiss %xmm2, %xmm3
jbe 0x223d9
xorl %eax, %eax
retq
testl %r8d, %r8d
je 0x2248a
subq $0x18, %rsp
movaps %xmm1, %xmm4
subss %xmm3, %xmm4
movaps %xmm0, %xmm5
subss %xmm3, %xmm5
divss %xmm5, %xmm4
cmpnless %xmm3, %xmm1
andps %xmm4, %xmm1
movaps %xmm0, %xmm3
subss %xmm2, %xmm3
divss %xmm5, %xmm3
cmpnless %xmm2, %xmm0
andps %xmm0, %xmm3
movss 0xfc49(%rip), %xmm2     # 0x32064
andnps %xmm2, %xmm0
orps %xmm3, %xmm0
movaps %xmm2, %xmm3
subss %xmm1, %xmm3
subss %xmm0, %xmm2
xorl %esi, %esi
testl %r8d, %r8d
movl $0x0, %r9d
cmovgl %r8d, %r9d
cmpq %rsi, %r9
je 0x22478
movss (%rax,%rsi,4), %xmm4
movaps %xmm1, %xmm5
mulss %xmm4, %xmm5
movss (%rdi,%rsi,4), %xmm6
mulss %xmm3, %xmm6
addss %xmm5, %xmm6
movss %xmm6, 0xc(%rsp,%rsi,4)
movaps %xmm0, %xmm5
mulss %xmm4, %xmm5
mulss %xmm2, %xmm4
addss %xmm5, %xmm4
movss %xmm4, (%rsp,%rsi,4)
incq %rsi
jmp 0x2243b
leaq 0xc(%rsp), %rdi
movq %rsp, %rsi
callq 0x22394
addq $0x18, %rsp
retq
movb $0x1, %al
retq
// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/hlrad/nomatrix.cpp
// Function: MakeScalesNoVismatrix()
void            MakeScalesNoVismatrix()
{
    char            transferfile[_MAX_PATH];

    hlassume(g_num_patches < MAX_PATCHES, assume_MAX_PATCHES);

#ifdef ZHLT_DEFAULTEXTENSION_FIX
	safe_snprintf(transferfile, _MAX_PATH, "%s.inc", g_Mapname);
#else
    safe_strncpy(transferfile, g_source, _MAX_PATH);
    StripExtension(transferfile);
    DefaultExtension(transferfile, ".inc");
#endif

    if (!g_incremental || !readtransfers(transferfile, g_num_patches))
    {
        g_CheckVisBit = CheckVisBitNoVismatrix;
#ifndef HLRAD_HULLU
        NamedRunThreadsOn(g_num_patches, g_estimate, MakeScales);
#else
	if(g_rgb_transfers)
		{NamedRunThreadsOn(g_num_patches, g_estimate, MakeRGBScales);}
	else
		{NamedRunThreadsOn(g_num_patches, g_estimate, MakeScales);}
#endif

#ifndef HLRAD_NOSWAP
        // invert the transfers for gather vs scatter
#ifndef HLRAD_HULLU
        NamedRunThreadsOnIndividual(g_num_patches, g_estimate, SwapTransfers);
#else
	if(g_rgb_transfers)
		{NamedRunThreadsOnIndividual(g_num_patches, g_estimate, SwapRGBTransfers);}
	else
		{NamedRunThreadsOnIndividual(g_num_patches, g_estimate, SwapTransfers);}
#endif
#endif /*HLRAD_NOSWAP*/
        if (g_incremental)
        {
            writetransfers(transferfile, g_num_patches);
        }
        else
        {
            unlink(transferfile);
        }
        DumpTransfersMemoryUsage();
#ifdef HLRAD_OPAQUE_STYLE_BOUNCE
		CreateFinalStyleArrays ("dynamic shadow array");
#endif
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x1000, %rsp           # imm = 0x1000
leaq 0x541181e(%rip), %r14   # 0x54349f8
xorl %edi, %edi
cmpl $0xffff0, (%r14)        # imm = 0xFFFF0
setb %dil
pushq $0x1b
popq %rsi
callq 0x92cb
leaq 0x10768(%rip), %rdx     # 0x3395e
leaq 0x21163(%rip), %rcx     # 0x44360
movq %rsp, %rdi
movl $0x1000, %esi           # imm = 0x1000
xorl %eax, %eax
callq 0x767f
leaq 0x54d37fd(%rip), %r15   # 0x54f6a10
cmpb $0x1, (%r15)
jne 0x2322c
movl (%r14), %esi
movq %rsp, %rdi
callq 0x2f9ba
testb %al, %al
jne 0x232bf
leaq 0x99(%rip), %rax        # 0x232cc
leaq 0x66d390e(%rip), %rcx   # 0x66f6b48
movq %rax, (%rcx)
leaq 0x54d37f5(%rip), %rax   # 0x54f6a39
leaq 0x138b5(%rip), %rcx     # 0x36b00
leaq 0x138bd(%rip), %rdi     # 0x36b0f
cmpb $0x0, (%rax)
cmovneq %rcx, %rdi
leaq 0xd853(%rip), %rbx      # 0x30ab3
cmovneq 0x20d18(%rip), %rbx     # 0x43f80
callq 0x893a
leaq 0x13413(%rip), %rdi     # 0x36687
movq %rax, %rsi
xorl %eax, %eax
callq 0x8790
movl (%r14), %edi
leaq 0x221ac(%rip), %rax     # 0x45434
movzbl (%rax), %esi
movq %rbx, %rdx
callq 0x9e41
cmpb $0x1, (%r15)
jne 0x232a6
movl (%r14), %esi
movq %rsp, %rdi
callq 0x2f838
jmp 0x232ae
movq %rsp, %rdi
callq 0x4170
callq 0x31ab2
leaq 0x13861(%rip), %rdi     # 0x36b1b
callq 0x3018f
addq $0x1000, %rsp           # imm = 0x1000
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/hlrad/qrad.cpp
// Function: ReadCustomChopValue()
void ReadCustomChopValue()
{
	int num;
	int i, k;
	entity_t *mapent;
	epair_t *ep;

	num = ((dmiptexlump_t *)g_dtexdata)->nummiptex;
	chopscales = (vec_t *)malloc (num * sizeof(vec_t));
	for (i = 0; i < num; i++)
	{
		chopscales[i] = 1.0;
	}
	for (k = 0; k < g_numentities; k++)
	{
		mapent = &g_entities[k];
		if (strcmp(ValueForKey(mapent, "classname"), "info_chopscale"))
			continue;
		Developer (DEVELOPER_LEVEL_MESSAGE, "info_chopscale entity detected.\n");
		for (i = 0; i < num; i++)
		{
			const char *texname = ((miptex_t*)(g_dtexdata+((dmiptexlump_t*)g_dtexdata)->dataofs[i]))->name;
			for (ep = mapent->epairs; ep; ep = ep->next)
			{
				if (strcasecmp (ep->key, texname))
					continue;
				if (!strcasecmp (ep->key, "origin"))
					continue;
				if (atof (ep->value) <= 0)
					continue;
				chopscales[i] = atof (ep->value);
				Developer (DEVELOPER_LEVEL_MESSAGE, "info_chopscale: %s = %f\n", texname, chopscales[i]);
			}
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
leaq 0x82981c(%rip), %rax    # 0x84d4a8
movq (%rax), %rax
movslq (%rax), %rbx
movq %rbx, %rdi
shlq $0x2, %rdi
callq 0x4420
movq %rax, 0x5512ee3(%rip)   # 0x5536b88
xorl %eax, %eax
testl %ebx, %ebx
movl $0x0, %ecx
cmovgl %ebx, %ecx
movq %rcx, 0x8(%rsp)
cmpq %rax, 0x8(%rsp)
je 0x23cd0
movq 0x5512ec4(%rip), %rcx   # 0x5536b88
movl $0x3f800000, (%rcx,%rax,4) # imm = 0x3F800000
incq %rax
jmp 0x23cb6
leaq 0x15856(%rip), %r12     # 0x3952d
leaq 0x1343d(%rip), %r13     # 0x3711b
xorl %ecx, %ecx
leaq 0x201774d(%rip), %rax   # 0x203b434
movslq (%rax), %rax
cmpq %rax, %rcx
jge 0x23ddf
movq %rcx, 0x10(%rsp)
movq %rcx, %rdi
shlq $0x5, %rdi
addq 0x202ca(%rip), %rdi     # 0x43fd0
movq %rdi, (%rsp)
leaq 0xe85a(%rip), %rsi      # 0x3256b
callq 0x6929
movq %rax, %rdi
leaq 0x133cb(%rip), %rsi     # 0x370eb
callq 0x4460
testl %eax, %eax
je 0x23d33
movq 0x10(%rsp), %rcx
incq %rcx
jmp 0x23ce0
pushq $0x3
popq %rdi
leaq 0x133bd(%rip), %rsi     # 0x370fa
xorl %eax, %eax
callq 0x9045
addq $0x18, (%rsp)
xorl %r15d, %r15d
cmpq 0x8(%rsp), %r15
je 0x23d29
leaq 0x82974e(%rip), %rax    # 0x84d4a8
movq (%rax), %rax
movslq 0x4(%rax,%r15,4), %rbx
addq %rax, %rbx
movq (%rsp), %rbp
movq (%rbp), %rbp
testq %rbp, %rbp
je 0x23dd7
movq 0x8(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4320
testl %eax, %eax
jne 0x23d69
movq %r14, %rdi
movq %r12, %rsi
callq 0x4320
testl %eax, %eax
je 0x23d69
movq 0x10(%rbp), %rdi
callq 0x43c0
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
jae 0x23d69
cvtsd2ss %xmm0, %xmm0
movq 0x5512dd6(%rip), %rax   # 0x5536b88
movss %xmm0, (%rax,%r15,4)
movq 0x5512dc9(%rip), %rax   # 0x5536b88
cvtss2sd (%rax,%r15,4), %xmm0
pushq $0x3
popq %rdi
movq %r13, %rsi
movq %rbx, %rdx
movb $0x1, %al
callq 0x9045
jmp 0x23d69
incq %r15
jmp 0x23d4c
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/hlrad/qrad.cpp
// Function: ReadCustomSmoothValue()
void ReadCustomSmoothValue()
{
	int num;
	int i, k;
	entity_t *mapent;
	epair_t *ep;

	num = ((dmiptexlump_t *)g_dtexdata)->nummiptex;
	g_smoothvalues = (vec_t *)malloc (num * sizeof(vec_t));
	for (i = 0; i < num; i++)
	{
		g_smoothvalues[i] = g_smoothing_threshold;
	}
	for (k = 0; k < g_numentities; k++)
	{
		mapent = &g_entities[k];
		if (strcmp(ValueForKey(mapent, "classname"), "info_smoothvalue"))
			continue;
		Developer (DEVELOPER_LEVEL_MESSAGE, "info_smoothvalue entity detected.\n");
		for (i = 0; i < num; i++)
		{
			const char *texname = ((miptex_t*)(g_dtexdata+((dmiptexlump_t*)g_dtexdata)->dataofs[i]))->name;
			for (ep = mapent->epairs; ep; ep = ep->next)
			{
				if (strcasecmp (ep->key, texname))
					continue;
				if (!strcasecmp (ep->key, "origin"))
					continue;
				g_smoothvalues[i] = cos(atof (ep->value) * (Q_PI / 180.0));
				Developer (DEVELOPER_LEVEL_MESSAGE, "info_smoothvalue: %s = %f\n", texname, atof (ep->value));
			}
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
leaq 0x829674(%rip), %rax    # 0x84d4a8
movq (%rax), %rax
movslq (%rax), %rbx
movq %rbx, %rdi
shlq $0x2, %rdi
callq 0x4420
movq %rax, 0x5512d43(%rip)   # 0x5536b90
xorl %eax, %eax
testl %ebx, %ebx
movl $0x0, %ecx
cmovgl %ebx, %ecx
movq %rcx, 0x8(%rsp)
cmpq %rax, 0x8(%rsp)
je 0x23e7e
movss 0x54d2ba7(%rip), %xmm0  # 0x54f6a14
movq 0x5512d1c(%rip), %rcx   # 0x5536b90
movss %xmm0, (%rcx,%rax,4)
incq %rax
jmp 0x23e5e
leaq 0x156a8(%rip), %r12     # 0x3952d
leaq 0x132dc(%rip), %r13     # 0x37168
xorl %ecx, %ecx
leaq 0x201759f(%rip), %rax   # 0x203b434
movslq (%rax), %rax
cmpq %rax, %rcx
jge 0x23f8c
movq %rcx, 0x10(%rsp)
movq %rcx, %rdi
shlq $0x5, %rdi
addq 0x2011c(%rip), %rdi     # 0x43fd0
movq %rdi, (%rsp)
leaq 0xe6ac(%rip), %rsi      # 0x3256b
callq 0x6929
movq %rax, %rdi
leaq 0x13266(%rip), %rsi     # 0x37134
callq 0x4460
testl %eax, %eax
je 0x23ee1
movq 0x10(%rsp), %rcx
incq %rcx
jmp 0x23e8e
pushq $0x3
popq %rdi
leaq 0x1325a(%rip), %rsi     # 0x37145
xorl %eax, %eax
callq 0x9045
addq $0x18, (%rsp)
xorl %r15d, %r15d
cmpq 0x8(%rsp), %r15
je 0x23ed7
leaq 0x8295a0(%rip), %rax    # 0x84d4a8
movq (%rax), %rax
movslq 0x4(%rax,%r15,4), %rbx
addq %rax, %rbx
movq (%rsp), %rbp
movq (%rbp), %rbp
testq %rbp, %rbp
je 0x23f84
movq 0x8(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4320
testl %eax, %eax
jne 0x23f17
movq %r14, %rdi
movq %r12, %rsi
callq 0x4320
testl %eax, %eax
je 0x23f17
movq 0x10(%rbp), %rdi
callq 0x43c0
mulsd 0x116ad(%rip), %xmm0    # 0x35600
callq 0x4600
cvtsd2ss %xmm0, %xmm0
movq 0x5512c2d(%rip), %rax   # 0x5536b90
movss %xmm0, (%rax,%r15,4)
movq 0x10(%rbp), %rdi
callq 0x43c0
pushq $0x3
popq %rdi
movq %r13, %rsi
movq %rbx, %rdx
movb $0x1, %al
callq 0x9045
jmp 0x23f17
incq %r15
jmp 0x23efa
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/hlrad/qrad.cpp
// Function: MakeParents(int, int)
static void     MakeParents(const int nodenum, const int parent)
{
    int             i;
    int             j;
    dnode_t*        node;

    nodeparents[nodenum] = parent;
    node = g_dnodes + nodenum;

    for (i = 0; i < 2; i++)
    {
        j = node->children[i];
        if (j < 0)
        {
            leafparents[-j - 1] = nodenum;
        }
        else
        {
            MakeParents(j, nodenum);
        }
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movl %edi, %ebx
movl %edi, %eax
leaq 0x54ece1d(%rip), %rcx   # 0x5516b60
movl %esi, (%rcx,%rax,4)
imulq $0x18, %rax, %rax
leaq 0x10c36bf(%rip), %rcx   # 0x10ed410
leaq (%rax,%rcx), %r14
addq $0x4, %r14
xorl %r15d, %r15d
leaq 0x54cce1d(%rip), %r12   # 0x54f6b80
cmpq $0x2, %r15
je 0x29d86
movswl (%r14,%r15,2), %edi
testl %edi, %edi
js 0x29d7b
movl %ebx, %esi
callq 0x29d30
jmp 0x29d81
notl %edi
movl %ebx, (%r12,%rdi,4)
incq %r15
jmp 0x29d63
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/hlrad/qrad.cpp
// Function: UpdateEmitterInfo(patch_s*)
static void		UpdateEmitterInfo (patch_t *patch)
{
#if ACCURATEBOUNCE_DEFAULT_SKYLEVEL + 3 > SKYLEVELMAX
#error "please raise SKYLEVELMAX"
#endif
	const vec_t *origin = patch->origin;
	const Winding *winding = patch->winding;
	vec_t radius = ON_EPSILON;
	for (int x = 0; x < winding->m_NumPoints; x++)
	{
		vec3_t delta;
		vec_t dist;
		VectorSubtract (winding->m_Points[x], origin, delta);
		dist = VectorLength (delta);
		if (dist > radius)
		{
			radius = dist;
		}
	}
	int skylevel = ACCURATEBOUNCE_DEFAULT_SKYLEVEL;
	vec_t area = winding->getArea ();
	vec_t size = 0.8f;
	if (area < size * radius * radius) // the shape is too thin
	{
		skylevel++;
		size *= 0.25f;
		if (area < size * radius * radius)
		{
			skylevel++;
			size *= 0.25f;
			if (area < size * radius * radius)
			{
				// stop here
				radius = sqrt (area / size);
				// just decrease the range to limit the use of the new method. because when the area is small, the new method becomes randomized and unstable.
			}
		}
	}
	patch->emitter_range = ACCURATEBOUNCE_THRESHOLD * radius;
	if (g_noemitterrange)
	{
		patch->emitter_range = 0.0;
	}
	patch->emitter_skylevel = skylevel;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x28(%rdi), %rdi
movl 0x8(%rdi), %eax
imulq $0xc, %rax, %rax
movss 0xb68e(%rip), %xmm3     # 0x359c4
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0x2a38c
movq 0x10(%rdi), %rdx
movss 0x8(%rdx,%rcx), %xmm0
subss 0x10(%rbx), %xmm0
movsd (%rdx,%rcx), %xmm1
movsd 0x8(%rbx), %xmm2
subps %xmm2, %xmm1
mulps %xmm1, %xmm1
cvtps2pd %xmm1, %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
mulss %xmm0, %xmm0
cvtss2sd %xmm0, %xmm0
addsd %xmm2, %xmm0
sqrtsd %xmm0, %xmm0
cvtsd2ss %xmm0, %xmm0
maxss %xmm3, %xmm0
addq $0xc, %rcx
movaps %xmm0, %xmm3
jmp 0x2a338
movss %xmm3, 0x4(%rsp)
callq 0xa378
movss 0x4(%rsp), %xmm2
movss 0xb283(%rip), %xmm1     # 0x35628
mulss %xmm2, %xmm1
mulss %xmm2, %xmm1
ucomiss %xmm0, %xmm1
jbe 0x2a3f5
movss 0xb636(%rip), %xmm1     # 0x359f0
mulss %xmm2, %xmm1
mulss %xmm2, %xmm1
ucomiss %xmm0, %xmm1
jbe 0x2a3f9
movss 0xc7d5(%rip), %xmm1     # 0x36ba4
mulss %xmm2, %xmm1
mulss %xmm2, %xmm1
pushq $0x7
popq %rbp
ucomiss %xmm0, %xmm1
jbe 0x2a3fc
divss 0xc7bd(%rip), %xmm0     # 0x36ba4
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jb 0x2a422
sqrtss %xmm0, %xmm2
jmp 0x2a3fc
pushq $0x5
jmp 0x2a3fb
pushq $0x6
popq %rbp
cmpb $0x0, 0x54cc775(%rip)   # 0x54f6b78
xorps %xmm0, %xmm0
jne 0x2a413
mulss 0xc6e0(%rip), %xmm2     # 0x36af0
movaps %xmm2, %xmm0
movss %xmm0, 0x1c(%rbx)
movl %ebp, 0x20(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
callq 0x45c0
movaps %xmm0, %xmm2
jmp 0x2a3fc
// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/hlrad/qradutil.cpp
// Function: PointInLeaf_Worst_r(int, float const*)
dleaf_t*		PointInLeaf_Worst_r(int nodenum, const vec3_t point)
{
	vec_t			dist;
	dnode_t*		node;
	dplane_t*		plane;

	while (nodenum >= 0)
	{
		node = &g_dnodes[nodenum];
		plane = &g_dplanes[node->planenum];
		dist = DotProduct(point, plane->normal) - plane->dist;
		if (dist > HUNT_WALL_EPSILON)
		{
			nodenum = node->children[0];
		}
		else if (dist < -HUNT_WALL_EPSILON)
		{
			nodenum = node->children[1];
		}
		else
		{
			dleaf_t* result[2];
			result[0] = PointInLeaf_Worst_r(node->children[0], point);
			result[1] = PointInLeaf_Worst_r(node->children[1], point);
			if (result[0] == g_dleafs || result[0]->contents == CONTENTS_SOLID)
				return result[0];
			if (result[1] == g_dleafs || result[1]->contents == CONTENTS_SOLID)
				return result[1];
			if (result[0]->contents == CONTENTS_SKY)
				return result[0];
			if (result[1]->contents == CONTENTS_SKY)
				return result[1];
#ifdef HLRAD_WATERBLOCKLIGHT
			if (result[0]->contents == result[1]->contents)
				return result[0];
			return g_dleafs;
#else
			return result[0];
#endif
		}
	}

	return &g_dleafs[-nodenum - 1];
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
leaq 0x10c2005(%rip), %rax   # 0x10ed410
leaq 0xb01fee(%rip), %rcx    # 0xb2d400
pushq $0x4
popq %rdx
movsd 0xe3db(%rip), %xmm0     # 0x397f8
pushq $0x6
popq %rsi
movsd 0xe3d8(%rip), %xmm1     # 0x39800
testl %edi, %edi
js 0x2b48c
movl %edi, %edi
imulq $0x18, %rdi, %rdi
movslq (%rax,%rdi), %r8
imulq $0x14, %r8, %r8
movss (%rbx), %xmm2
movss 0x4(%rbx), %xmm3
mulss 0x4(%rcx,%r8), %xmm3
mulss (%rcx,%r8), %xmm2
addss %xmm3, %xmm2
movss 0x8(%rbx), %xmm3
mulss 0x8(%rcx,%r8), %xmm3
leaq (%rax,%rdi), %r15
addss %xmm2, %xmm3
subss 0xc(%rcx,%r8), %xmm3
cvtss2sd %xmm3, %xmm2
ucomisd %xmm0, %xmm2
movq %rdx, %rdi
ja 0x2b485
ucomisd %xmm2, %xmm1
movq %rsi, %rdi
jbe 0x2b4a2
movswl (%r15,%rdi), %edi
jmp 0x2b428
notl %edi
imulq $0x1c, %rdi, %rcx
addq 0x18abf(%rip), %rcx     # 0x43f58
movq %rcx, %rax
popq %rbx
popq %r14
popq %r15
retq
movswl 0x4(%r15), %edi
movq %rbx, %rsi
callq 0x2b3fc
movq %rax, %r14
movswl 0x6(%r15), %edi
movq %rbx, %rsi
callq 0x2b3fc
leaq 0xa2200a(%rip), %rcx    # 0xa4d4d0
cmpq %rcx, %r14
je 0x2b499
movl (%r14), %edx
cmpl $-0x2, %edx
jne 0x2b4d8
movq %r14, %rcx
jmp 0x2b499
leaq 0xa21ff1(%rip), %rcx    # 0xa4d4d0
cmpq %rcx, %rax
je 0x2b499
movl (%rax), %esi
cmpl $-0x2, %esi
jne 0x2b4f0
movq %rax, %rcx
jmp 0x2b499
cmpl $-0x6, %edx
je 0x2b4d3
movq %rax, %rcx
cmpl $-0x6, %esi
je 0x2b499
cmpl %esi, %edx
je 0x2b4d3
leaq 0xa21fc8(%rip), %r14    # 0xa4d4d0
jmp 0x2b4d3
// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/hlrad/qradutil.cpp
// Function: PointInLeaf(float const*)
dleaf_t*        PointInLeaf(const vec3_t point)
{
    int             nodenum;
    vec_t           dist;
    dnode_t*        node;
    dplane_t*       plane;

    nodenum = 0;
    while (nodenum >= 0)
    {
        node = &g_dnodes[nodenum];
        plane = &g_dplanes[node->planenum];
        dist = DotProduct(point, plane->normal) - plane->dist;
        if (dist >= 0.0)
        {
            nodenum = node->children[0];
        }
        else
        {
            nodenum = node->children[1];
        }
    }

    return &g_dleafs[-nodenum - 1];
}

// Assembly:
movss (%rdi), %xmm0
movss 0x4(%rdi), %xmm1
movss 0x8(%rdi), %xmm2
xorl %edx, %edx
leaq 0x10c1ee5(%rip), %rax   # 0x10ed410
leaq 0xb01ece(%rip), %rcx    # 0xb2d400
xorps %xmm3, %xmm3
testl %edx, %edx
js 0x2b585
movl %edx, %edx
imulq $0x18, %rdx, %rdx
leaq (%rax,%rdx), %rsi
movslq (%rax,%rdx), %rdx
imulq $0x14, %rdx, %rdx
movss 0x4(%rcx,%rdx), %xmm4
mulss %xmm1, %xmm4
movss (%rcx,%rdx), %xmm5
mulss %xmm0, %xmm5
addss %xmm4, %xmm5
movss 0x8(%rcx,%rdx), %xmm4
mulss %xmm2, %xmm4
addss %xmm5, %xmm4
subss 0xc(%rcx,%rdx), %xmm4
xorl %edx, %edx
ucomiss %xmm3, %xmm4
setb %dl
movswl 0x4(%rsi,%rdx,2), %edx
jmp 0x2b535
notl %edx
imulq $0x1c, %rdx, %rax
addq 0x189c6(%rip), %rax     # 0x43f58
retq
// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/hlrad/qradutil.cpp
// Function: MakeBackplanes()
void            MakeBackplanes()
{
    int             i;

    for (i = 0; i < g_numplanes; i++)
    {
        backplanes[i].dist = -g_dplanes[i].dist;
        VectorSubtract(vec3_origin, g_dplanes[i].normal, backplanes[i].normal);
    }
}

// Assembly:
leaq 0xb01dbc(%rip), %rax    # 0xb2d3f4
movslq (%rax), %rax
leaq 0x86ee(%rip), %rcx      # 0x33d30
movsd (%rcx), %xmm0
movss 0x8(%rcx), %xmm1
pushq $0xc
popq %rcx
xorl %edx, %edx
leaq 0xb01da9(%rip), %rsi    # 0xb2d400
movaps 0x9c32(%rip), %xmm2     # 0x35290
leaq 0x552b57b(%rip), %rdi   # 0x5556be0
cmpq %rax, %rdx
jge 0x2b6a0
movss (%rsi,%rcx), %xmm3
xorps %xmm2, %xmm3
movss %xmm3, (%rcx,%rdi)
movsd -0xc(%rsi,%rcx), %xmm3
movaps %xmm0, %xmm4
subps %xmm3, %xmm4
movaps %xmm1, %xmm3
subss -0x4(%rsi,%rcx), %xmm3
movlps %xmm4, -0xc(%rcx,%rdi)
movss %xmm3, -0x4(%rcx,%rdi)
incq %rdx
addq $0x14, %rcx
jmp 0x2b665
retq
// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/hlrad/qradutil.cpp
// Function: getPlaneFromFace(dface_t const*)
const dplane_t* getPlaneFromFace(const dface_t* const face)
{
    if (!face)
    {
        Error("getPlaneFromFace() face was NULL\n");
    }

    if (face->side)
    {
        return &backplanes[face->planenum];
    }
    else
    {
        return &g_dplanes[face->planenum];
    }
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
testq %rdi, %rdi
jne 0x2b6b8
leaq 0xe1a7(%rip), %rdi      # 0x39858
xorl %eax, %eax
callq 0x8b2f
movzwl (%rbx), %eax
imulq $0x14, %rax, %rcx
cmpw $0x0, 0x2(%rbx)
jne 0x2b6cf
leaq 0xb01d33(%rip), %rax    # 0xb2d400
jmp 0x2b6d6
leaq 0x552b50a(%rip), %rax   # 0x5556be0
addq %rcx, %rax
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/hlrad/qradutil.cpp
// Function: getAdjustedPlaneFromFaceNumber(unsigned int, dplane_t*)
void getAdjustedPlaneFromFaceNumber(unsigned int faceNumber, dplane_t* plane)
{
    dface_t*        face = &g_dfaces[faceNumber];
    const vec_t*    face_offset = g_face_offset[faceNumber];

    plane->type = (planetypes)0;
    
    if (face->side)
    {
        vec_t dist;

        VectorCopy(backplanes[face->planenum].normal, plane->normal);
        dist = DotProduct(plane->normal, face_offset);
        plane->dist = backplanes[face->planenum].dist + dist;
    }
    else
    {
        vec_t dist;

        VectorCopy(g_dplanes[face->planenum].normal, plane->normal);
        dist = DotProduct(plane->normal, face_offset);
        plane->dist = g_dplanes[face->planenum].dist + dist;
    }
}

// Assembly:
movl %edi, %ecx
imulq $0x14, %rcx, %rdi
leaq 0x1b81d28(%rip), %r8    # 0x1bad410
leaq (%r8,%rdi), %rax
imulq $0xc, %rcx, %rcx
andl $0x0, 0x10(%rsi)
movzwl (%r8,%rdi), %edx
addq 0x18878(%rip), %rcx     # 0x43f78
cmpw $0x0, 0x2(%r8,%rdi)
je 0x2b767
imulq $0x14, %rdx, %rdx
leaq 0x552b4cc(%rip), %rdi   # 0x5556be0
movss (%rdx,%rdi), %xmm1
movss %xmm1, (%rsi)
movzwl (%rax), %edx
imulq $0x14, %rdx, %rdx
movss 0x4(%rdx,%rdi), %xmm2
movss %xmm2, 0x4(%rsi)
movzwl (%rax), %edx
imulq $0x14, %rdx, %rdx
movss 0x8(%rdx,%rdi), %xmm0
movss %xmm0, 0x8(%rsi)
mulss 0x4(%rcx), %xmm2
mulss (%rcx), %xmm1
addss %xmm2, %xmm1
mulss 0x8(%rcx), %xmm0
addss %xmm1, %xmm0
movzwl (%rax), %eax
imulq $0x14, %rax, %rax
addq %rdi, %rax
addq $0xc, %rax
jmp 0x2b7c3
imulq $0x14, %rdx, %rdx
leaq 0xb01c8e(%rip), %rdi    # 0xb2d400
movss (%rdi,%rdx), %xmm1
movss %xmm1, (%rsi)
movzwl (%rax), %edx
imulq $0x14, %rdx, %rdx
movss 0x4(%rdi,%rdx), %xmm2
movss %xmm2, 0x4(%rsi)
movzwl (%rax), %edx
imulq $0x14, %rdx, %rdx
movss 0x8(%rdi,%rdx), %xmm0
movss %xmm0, 0x8(%rsi)
mulss 0x4(%rcx), %xmm2
mulss (%rcx), %xmm1
addss %xmm2, %xmm1
mulss 0x8(%rcx), %xmm0
addss %xmm1, %xmm0
movzwl (%rax), %eax
imulq $0x14, %rax, %rax
addq %rdi, %rax
addq $0xc, %rax
addss (%rax), %xmm0
movss %xmm0, 0xc(%rsi)
retq
// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/hlrad/qradutil.cpp
// Function: ApplyMatrix(matrix_t const&, float const*, float (&) [3])
void ApplyMatrix (const matrix_t &m, const vec3_t in, vec3_t &out)
{
	int i;

	hlassume (&in[0] != &out[0], assume_first);
	VectorCopy (m.v[3], out);
	for (i = 0; i < 3; i++)
	{
		VectorMA (out, in[i], m.v[i], out);
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
xorl %edi, %edi
cmpq %rdx, %rsi
setne %dil
xorl %r12d, %r12d
xorl %esi, %esi
callq 0x92cb
movss 0x24(%r15), %xmm0
movss %xmm0, (%rbx)
movss 0x28(%r15), %xmm1
movss %xmm1, 0x4(%rbx)
movss 0x2c(%r15), %xmm2
movss %xmm2, 0x8(%rbx)
addq $0x8, %r15
cmpq $0x3, %r12
je 0x2bc31
movss (%r14,%r12,4), %xmm3
mulss -0x8(%r15), %xmm3
addss %xmm3, %xmm0
movss %xmm0, (%rbx)
movss (%r14,%r12,4), %xmm3
mulss -0x4(%r15), %xmm3
addss %xmm3, %xmm1
movss %xmm1, 0x4(%rbx)
movss (%r14,%r12,4), %xmm3
mulss (%r15), %xmm3
addss %xmm3, %xmm2
movss %xmm2, 0x8(%rbx)
incq %r12
addq $0xc, %r15
jmp 0x2bbe5
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq