// File: 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:
subq $0x28, %rsp
leaq 0x837f0d(%rip), %rax    # 0x8864a8
movq (%rax), %rax
movl (%rax), %eax
movl %eax, 0x24(%rsp)
movslq 0x24(%rsp), %rdi
shlq $0x2, %rdi
callq 0x4430
movq %rax, 0x55215df(%rip)   # 0x556fb98
movl $0x0, 0x20(%rsp)
movl 0x20(%rsp), %eax
cmpl 0x24(%rsp), %eax
jge 0x4e5f1
movq 0x55215c6(%rip), %rax   # 0x556fb98
movslq 0x20(%rsp), %rcx
movss 0x1ba6d(%rip), %xmm0    # 0x6a04c
movss %xmm0, (%rax,%rcx,4)
movl 0x20(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x20(%rsp)
jmp 0x4e5c1
movl $0x0, 0x1c(%rsp)
movl 0x1c(%rsp), %eax
leaq 0x2025e30(%rip), %rcx   # 0x2074434
cmpl (%rcx), %eax
jge 0x4e78f
movslq 0x1c(%rsp), %rcx
leaq 0x2025e28(%rip), %rax   # 0x2074440
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rdi
leaq 0x1bf27(%rip), %rsi     # 0x6a557
callq 0x7d50
movq %rax, %rdi
leaq 0x20b33(%rip), %rsi     # 0x6f172
callq 0x4480
cmpl $0x0, %eax
je 0x4e64e
jmp 0x4e77f
movl $0x3, %edi
leaq 0x20b27(%rip), %rsi     # 0x6f181
movb $0x0, %al
callq 0xbbf0
movl $0x0, 0x20(%rsp)
movl 0x20(%rsp), %eax
cmpl 0x24(%rsp), %eax
jge 0x4e77d
leaq 0x837e2a(%rip), %rax    # 0x8864a8
movq (%rax), %rax
leaq 0x837e20(%rip), %rcx    # 0x8864a8
movq (%rcx), %rcx
movslq 0x20(%rsp), %rdx
movslq 0x4(%rcx,%rdx,4), %rcx
addq %rcx, %rax
movq %rax, (%rsp)
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x8(%rsp)
cmpq $0x0, 0x8(%rsp)
je 0x4e76b
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rsp), %rsi
callq 0x4350
cmpl $0x0, %eax
je 0x4e6d2
jmp 0x4e759
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rdi
leaq 0x22ed2(%rip), %rsi     # 0x715b4
callq 0x4350
cmpl $0x0, %eax
jne 0x4e6ee
jmp 0x4e759
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x43e0
movaps %xmm0, %xmm1
xorps %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jb 0x4e70a
jmp 0x4e759
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x43e0
cvtsd2ss %xmm0, %xmm0
movq 0x5521475(%rip), %rax   # 0x556fb98
movslq 0x20(%rsp), %rcx
movss %xmm0, (%rax,%rcx,4)
movq (%rsp), %rdx
movq 0x5521460(%rip), %rax   # 0x556fb98
movslq 0x20(%rsp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movl $0x3, %edi
leaq 0x20a50(%rip), %rsi     # 0x6f1a2
movb $0x1, %al
callq 0xbbf0
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x8(%rsp)
jmp 0x4e6aa
jmp 0x4e76d
movl 0x20(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x20(%rsp)
jmp 0x4e669
jmp 0x4e77f
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0x4e5f9
addq $0x28, %rsp
retq
nopw %cs:(%rax,%rax)