// File: /workspace/github_cpp_makefile_star2_O3/FreeSlave[P]vhlt/hlrad/vismatrix.cpp
// Function: MakeScalesVismatrix()
void            MakeScalesVismatrix()
{
    char            transferfile[_MAX_PATH];

    hlassume(g_num_patches < MAX_VISMATRIX_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))
    {
        // determine visibility between g_patches
        BuildVisMatrix();
        g_CheckVisBit = CheckVisBitVismatrix;

#ifdef HLRAD_HULLU
	#ifdef HLRAD_TRANSPARENCY_CPP
        CreateFinalTransparencyArrays("custom shadow array");
	#else
        if((s_max_transparency_count*sizeof(transparency_t))>=(1024 * 1024))
        	Log("%-20s: %5.1f megs\n", "custom shadow array", (s_max_transparency_count*sizeof(transparency_t)) / (1024 * 1024.0));
        else if(s_transparency_count)
        	Log("%-20s: %5.1f kilos\n", "custom shadow array", (s_max_transparency_count*sizeof(transparency_t)) / 1024.0);
	#endif
#endif

#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
        FreeVisMatrix();
#ifdef HLRAD_HULLU
	#ifdef HLRAD_TRANSPARENCY_CPP
        FreeTransparencyArrays();
	#endif
#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 %r13
pushq %r12
pushq %rbx
subq $0x1000, %rsp           # imm = 0x1000
leaq 0x54031cd(%rip), %r15   # 0x54379e8
xorl %edi, %edi
cmpl $0xffff, (%r15)         # imm = 0xFFFF
setb %dil
movl $0x1b, %esi
callq 0xa6ed
leaq 0x41c5(%rip), %rdx      # 0x389fe
leaq 0x12b10(%rip), %rcx     # 0x47350
movq %rsp, %rdi
movl $0x1000, %esi           # imm = 0x1000
xorl %eax, %eax
callq 0x8817
leaq 0x54c51aa(%rip), %r12   # 0x54f9a00
cmpb $0x1, (%r12)
jne 0x34870
movl (%r15), %esi
movq %rsp, %rdi
callq 0x33e18
testb %al, %al
jne 0x349e6
movl (%r15), %ebx
incl %ebx
imull %ebx, %ebx
shrl $0x4, %ebx
incl %ebx
cvtsi2sd %ebx, %xmm0
mulsd 0x4087(%rip), %xmm0     # 0x38910
leaq 0xa2fc(%rip), %rdi      # 0x3eb8c
leaq 0xa308(%rip), %rsi      # 0x3eb9f
movb $0x1, %al
callq 0x9c46
movq %rbx, %rdi
callq 0x491c
movq %rax, 0x66c5283(%rip)   # 0x66f9b30
testq %rax, %rax
jne 0x348d8
leaq 0xa664(%rip), %rdi      # 0x3ef1d
xorl %eax, %eax
callq 0x9c46
xorl %edi, %edi
cmpq $0x0, 0x66c5266(%rip)   # 0x66f9b30
setne %dil
movl $0x1, %esi
callq 0xa6ed
leaq 0xa212(%rip), %rdi      # 0x3eaf1
callq 0x9d92
leaq 0x6dd4(%rip), %rbx      # 0x3b6bf
movq %rbx, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0x9c46
leaq 0x13b71(%rip), %rax     # 0x48470
movl 0x34(%rax), %edi
leaq 0x13b1b(%rip), %r13     # 0x48424
movzbl (%r13), %esi
leaq 0x1b1(%rip), %rdx       # 0x34ac6
callq 0xb356
leaq 0xd6(%rip), %rax        # 0x349f7
leaq 0x66c5210(%rip), %rcx   # 0x66f9b38
movq %rax, (%rcx)
leaq 0xa18e(%rip), %rdi      # 0x3eac0
callq 0x34348
leaq 0x54c50eb(%rip), %rax   # 0x54f9a29
leaq 0x71f7(%rip), %rcx      # 0x3bb3c
leaq 0x71ff(%rip), %rdi      # 0x3bb4b
cmpb $0x0, (%rax)
cmovneq %rcx, %rdi
leaq 0x789(%rip), %r14       # 0x350e3
cmovneq 0x1261e(%rip), %r14     # 0x46f80
callq 0x9d92
movq %rbx, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0x9c46
movl (%r15), %edi
movzbl (%r13), %esi
movq %r14, %rdx
callq 0xb356
movq 0x66c51a5(%rip), %rdi   # 0x66f9b30
testq %rdi, %rdi
je 0x349b4
callq 0x4941
testb %al, %al
je 0x349a6
movq $0x0, 0x66c518c(%rip) # 0x66f9b30
jmp 0x349b4
leaq 0xa5d5(%rip), %rdi      # 0x3ef82
xorl %eax, %eax
callq 0xa2a6
callq 0x344e0
cmpb $0x1, (%r12)
jne 0x349cd
movl (%r15), %esi
movq %rsp, %rdi
callq 0x33c7c
jmp 0x349d5
movq %rsp, %rdi
callq 0x4160
callq 0x36392
leaq 0x7176(%rip), %rdi      # 0x3bb57
callq 0x346ee
addq $0x1000, %rsp           # imm = 0x1000
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq