// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/hlrad/sparse.cpp
// Function: MakeScalesSparseVismatrix()
void            MakeScalesSparseVismatrix()
{
    char            transferfile[_MAX_PATH];

    hlassume(g_num_patches < MAX_SPARSE_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();
        DumpVismatrixInfo();
        g_CheckVisBit = CheckVisBitSparse;

#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);
        }
        // release visibility matrix
        DumpTransfersMemoryUsage();
#ifdef HLRAD_OPAQUE_STYLE_BOUNCE
		CreateFinalStyleArrays ("dynamic shadow array");
#endif
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x1000, %rsp           # imm = 0x1000
leaq 0x5406486(%rip), %r14   # 0x54389e8
xorl %edi, %edi
cmpl $0xffff0, (%r14)        # imm = 0xFFFF0
setb %dil
movl $0x1b, %esi
callq 0xa7c9
leaq 0x747e(%rip), %rdx      # 0x399fe
leaq 0x15dc9(%rip), %rcx     # 0x48350
movq %rsp, %rdi
movl $0x1000, %esi           # imm = 0x1000
xorl %eax, %eax
callq 0x88fb
leaq 0x54c8463(%rip), %r15   # 0x54faa00
cmpb $0x1, (%r15)
jne 0x325b6
movl (%r14), %esi
movq %rsp, %rdi
callq 0x34e98
testb %al, %al
jne 0x32792
movl (%r14), %edi
shlq $0x4, %rdi
callq 0x492c
movq %rax, 0x66c84f7(%rip)   # 0x66faac0
testq %rax, %rax
jne 0x325f4
leaq 0xd57f(%rip), %rdi      # 0x3fb54
xorl %eax, %eax
callq 0x9d2e
xorl %edi, %edi
cmpq $0x0, 0x66c84da(%rip)   # 0x66faac0
setne %dil
movl $0x1, %esi
callq 0xa7c9
leaq 0xd576(%rip), %rdi      # 0x3fb71
callq 0x9e7a
leaq 0xa178(%rip), %rdi      # 0x3c77f
movq %rax, %rsi
xorl %eax, %eax
callq 0x9d2e
leaq 0x16e58(%rip), %rax     # 0x49470
movl 0x34(%rax), %edi
leaq 0x16e02(%rip), %r12     # 0x49424
movzbl (%r12), %esi
leaq 0x2a0(%rip), %rdx       # 0x328ce
callq 0xb446
movl (%r14), %ecx
movq %rcx, %rax
shlq $0x4, %rax
testq %rcx, %rcx
je 0x3265e
movq 0x66c8477(%rip), %rcx   # 0x66faac0
leaq (%rcx,%rax), %rdx
movslq 0x8(%rcx), %rsi
leaq (%rax,%rsi,4), %rax
addq $0x10, %rcx
cmpq %rdx, %rcx
jb 0x3264d
movq %rax, %xmm1
punpckldq 0xd4b5(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0xd4bd(%rip), %xmm1     # 0x3fb30
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x7289(%rip), %xmm0     # 0x39910
leaq 0xd57e(%rip), %rdi      # 0x3fc0c
leaq 0xd58a(%rip), %rsi      # 0x3fc1f
movb $0x1, %al
callq 0x9d2e
leaq 0xff(%rip), %rax        # 0x327a2
leaq 0x66c848e(%rip), %rcx   # 0x66fab38
movq %rax, (%rcx)
leaq 0xd48c(%rip), %rdi      # 0x3fb40
callq 0x35430
leaq 0x54c8369(%rip), %rax   # 0x54faa29
leaq 0xa535(%rip), %rcx      # 0x3cbfc
leaq 0xa53d(%rip), %rdi      # 0x3cc0b
cmpb $0x0, (%rax)
cmovneq %rcx, %rdi
leaq 0x3b43(%rip), %rbx      # 0x3621f
cmovneq 0x1589c(%rip), %rbx     # 0x47f80
callq 0x9e7a
leaq 0xa08f(%rip), %rdi      # 0x3c77f
movq %rax, %rsi
xorl %eax, %eax
callq 0x9d2e
movl (%r14), %edi
movzbl (%r12), %esi
movq %rbx, %rdx
callq 0xb446
movq 0x66c83af(%rip), %rbx   # 0x66faac0
testq %rbx, %rbx
je 0x32761
cmpl $0x0, (%r14)
je 0x32736
xorl %ebp, %ebp
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x3272b
callq 0x4380
incl %ebp
addq $0x10, %rbx
cmpl (%r14), %ebp
jb 0x3271e
movq 0x66c8383(%rip), %rdi   # 0x66faac0
callq 0x4951
testb %al, %al
je 0x32753
movq $0x0, 0x66c836f(%rip) # 0x66faac0
jmp 0x32761
leaq 0xd51b(%rip), %rdi      # 0x3fc75
xorl %eax, %eax
callq 0xa38e
callq 0x355ca
cmpb $0x1, (%r15)
jne 0x32779
movl (%r14), %esi
movq %rsp, %rdi
callq 0x34cfc
jmp 0x32781
movq %rsp, %rdi
callq 0x4160
callq 0x374fd
leaq 0xa48a(%rip), %rdi      # 0x3cc17
callq 0x357db
addq $0x1000, %rsp           # imm = 0x1000
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq