// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/hlbsp/outside.cpp
// Function: RecursiveFillOutside(node_s*, bool)
static bool     RecursiveFillOutside(node_t* l, const bool fill)
{
    portal_t*       p;
    int             s;

    if ((l->contents == CONTENTS_SOLID) || (l->contents == CONTENTS_SKY) 
#ifdef ZHLT_DETAIL
        || (l->contents == CONTENTS_DETAIL)
#endif
        )
	{
        /*if (l->contents != CONTENTS_SOLID)
            Log("RecursiveFillOutside::l->contents == %i \n", l->contents);*/

        return false;
    }

    if (l->valid == valid)
    {
        return false;
    }

    if (l->occupied)
    {
        hit_occupied = l->occupied;
        backdraw = 1000;
        return true;
    }

    l->valid = valid;

    // fill it and it's neighbors
    if (fill)
    {
#ifdef ZHLT_DETAILBRUSH
		FillLeaf (l);
#else
        l->contents = CONTENTS_SOLID;
        l->planenum = -1;
#endif
    }
    outleafs++;

    for (p = l->portals; p;)
    {
        s = (p->nodes[0] == l);

        if (RecursiveFillOutside(p->nodes[s], fill))
        {                                                  // leaked, so stop filling
            if (backdraw-- > 0)
            {
                MarkLeakTrail(p);
            }
            return true;
        }
        p = p->next[!s];
    }

    return false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x70, %rsp
movl 0xa0(%rdi), %eax
orl $0x4, %eax
cmpl $-0x2, %eax
jne 0x1174b
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x70, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rdi, %rbx
movl 0x20bc198(%rip), %eax   # 0x20cd8ec
cmpl %eax, 0xbc(%rdi)
je 0x1173a
movl 0xc0(%rbx), %ecx
testl %ecx, %ecx
je 0x1177a
movl %ecx, 0x20bc19c(%rip)   # 0x20cd908
movl $0x3e8, 0x20bc1a2(%rip) # imm = 0x3E8
movb $0x1, %bl
jmp 0x1173c
movl %esi, %ebp
movl %eax, 0xbc(%rbx)
testb %bpl, %bpl
je 0x1178f
movq %rbx, %rdi
callq 0x11b47
incl 0x20bc153(%rip)         # 0x20cd8e8
leaq 0xb0(%rbx), %rax
movzbl %bpl, %ebp
movq (%rax), %r14
testq %r14, %r14
je 0x1173a
movq 0x48(%r14), %r15
xorl %eax, %eax
cmpq %rbx, %r15
sete %al
movq 0x48(%r14,%rax,8), %rdi
movl %ebp, %esi
callq 0x11720
testb %al, %al
jne 0x117d6
xorl %eax, %eax
cmpq %rbx, %r15
setne %al
leaq (%r14,%rax,8), %rax
addq $0x58, %rax
jmp 0x117a0
movl 0x20bc13c(%rip), %eax   # 0x20cd918
leal -0x1(%rax), %ecx
movl %ecx, 0x20bc133(%rip)   # 0x20cd918
movb $0x1, %bl
testl %eax, %eax
jle 0x1173c
movq 0x20bc0fa(%rip), %rax   # 0x20cd8f0
movq %r14, 0x20bc0f3(%rip)   # 0x20cd8f0
testq %rax, %rax
je 0x1173c
movq 0x68(%rax), %rdi
leaq 0x10(%rsp), %r15
movq %r15, %rsi
callq 0xa53c
movq 0x68(%r14), %rdi
leaq 0x50(%rsp), %r12
movq %r12, %rsi
callq 0xa53c
movq 0x20bc0d1(%rip), %rdi   # 0x20cd900
movsd (%r15), %xmm0
movsd 0x8(%r15), %xmm1
movsd 0x10(%r15), %xmm2
movsd (%r12), %xmm3
movsd 0x8(%r12), %xmm4
movsd 0x10(%r12), %xmm5
leaq 0xd99a(%rip), %rsi      # 0x1f1f5
movb $0x6, %al
callq 0x4450
movq 0x20bc08f(%rip), %rdi   # 0x20cd8f8
movsd (%r15), %xmm0
movsd 0x8(%r15), %xmm1
movsd 0x10(%r15), %xmm2
leaq 0xd97f(%rip), %r14      # 0x1f200
movq %r14, %rsi
movb $0x3, %al
callq 0x4450
movapd (%r12), %xmm0
subpd (%r15), %xmm0
leaq 0x30(%rsp), %rdi
movsd 0x10(%r12), %xmm1
subsd 0x10(%r15), %xmm1
movapd %xmm0, (%rdi)
movsd %xmm1, 0x10(%rdi)
movapd %xmm0, %xmm2
mulpd %xmm0, %xmm2
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
mulsd %xmm0, %xmm0
addsd %xmm2, %xmm0
mulsd %xmm1, %xmm1
addsd %xmm0, %xmm1
sqrtsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xc(%rsp)
callq 0xc073
movss 0xc(%rsp), %xmm0
ucomiss 0xd4db(%rip), %xmm0     # 0x1edc8
jbe 0x1173c
movss %xmm0, 0xc(%rsp)
movq 0x20bbff8(%rip), %rdi   # 0x20cd8f8
movsd 0x10(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movsd 0x20(%rsp), %xmm2
movq %r14, %rsi
movb $0x3, %al
callq 0x4450
xorl %eax, %eax
cmpq $0x3, %rax
je 0x1193f
movsd 0x30(%rsp,%rax,8), %xmm0
addsd %xmm0, %xmm0
addsd 0x10(%rsp,%rax,8), %xmm0
movsd %xmm0, 0x10(%rsp,%rax,8)
incq %rax
jmp 0x1191e
movss 0xc(%rsp), %xmm0
addss 0xd47f(%rip), %xmm0     # 0x1edcc
jmp 0x118e6