// File: FreeSlave[P]vhlt/hlbsp/brink.cpp
// Function: CollectBrinks_r(bclipnode_s*, int&, bbrink_t**)
void CollectBrinks_r (bclipnode_t *node, int &numbrinks, bbrink_t **brinks)
{
	if (node->isleaf)
	{
		btreeface_l::iterator fi;
		btreeedge_l::iterator ei;
		for (fi = node->treeleaf->faces->begin (); fi != node->treeleaf->faces->end (); fi++)
		{
			for (ei = fi->f->edges->begin (); ei != fi->f->edges->end (); ei++)
			{
				if (ei->e->tmp_tested)
				{
					continue;
				}
				ei->e->tmp_tested = true;
				if (!ei->e->infinite)
				{
					if (brinks != NULL)
					{
						brinks[numbrinks] = ei->e->brink;
						brinks[numbrinks]->edge = ei->e;
						for (int i = 0; i < brinks[numbrinks]->numnodes; i++)
						{
							bbrinknode_t *node = &(*brinks[numbrinks]->nodes)[i];
							if (node->isleaf && !node->clipnode->isleaf)
							{
								PrintOnce ("CollectBrinks_r: internal error: not leaf");
								hlassume (false, assume_first);
							}
						}
					}
					numbrinks++;
				}
			}
		}
	}
	else
	{
		CollectBrinks_r (node->children[0], numbrinks, brinks);
		CollectBrinks_r (node->children[1], numbrinks, brinks);
	}
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x60(%rsp)
movq %rsi, 0x58(%rsp)
movq %rdx, 0x50(%rsp)
movq 0x60(%rsp), %rax
testb $0x1, (%rax)
je 0x1698c
leaq 0x48(%rsp), %rdi
callq 0x19ef0
leaq 0x40(%rsp), %rdi
callq 0x19d60
movq 0x60(%rsp), %rax
movq 0x30(%rax), %rax
movq (%rax), %rdi
callq 0x19f10
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x60(%rsp), %rax
movq 0x30(%rax), %rax
movq (%rax), %rdi
callq 0x19f60
movq %rax, 0x30(%rsp)
leaq 0x48(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x19f40
testb $0x1, %al
jne 0x167e3
jmp 0x1698a
leaq 0x48(%rsp), %rdi
callq 0x19f90
movq (%rax), %rax
movq (%rax), %rdi
callq 0x19d80
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rax
movq %rax, 0x40(%rsp)
leaq 0x48(%rsp), %rdi
callq 0x19f90
movq (%rax), %rax
movq (%rax), %rdi
callq 0x19dd0
movq %rax, 0x20(%rsp)
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x19db0
testb $0x1, %al
jne 0x16839
jmp 0x16973
leaq 0x40(%rsp), %rdi
callq 0x19e00
movq (%rax), %rax
testb $0x1, 0x38(%rax)
je 0x16851
jmp 0x1695d
leaq 0x40(%rsp), %rdi
callq 0x19e00
movq (%rax), %rax
movb $0x1, 0x38(%rax)
leaq 0x40(%rsp), %rdi
callq 0x19e00
movq (%rax), %rax
testb $0x1, 0x20(%rax)
jne 0x1695b
cmpq $0x0, 0x50(%rsp)
je 0x1694f
leaq 0x40(%rsp), %rdi
callq 0x19e00
movq (%rax), %rax
movq 0x30(%rax), %rdx
movq 0x50(%rsp), %rax
movq 0x58(%rsp), %rcx
movslq (%rcx), %rcx
movq %rdx, (%rax,%rcx,8)
leaq 0x40(%rsp), %rdi
callq 0x19e00
movq (%rax), %rcx
movq 0x50(%rsp), %rax
movq 0x58(%rsp), %rdx
movslq (%rdx), %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, 0x58(%rax)
movl $0x0, 0x1c(%rsp)
movl 0x1c(%rsp), %eax
movq 0x50(%rsp), %rcx
movq 0x58(%rsp), %rdx
movslq (%rdx), %rdx
movq (%rcx,%rdx,8), %rcx
cmpl 0x48(%rcx), %eax
jge 0x1694d
movq 0x50(%rsp), %rax
movq 0x58(%rsp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq 0x50(%rax), %rdi
movslq 0x1c(%rsp), %rsi
callq 0x19c00
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
testb $0x1, (%rax)
je 0x1693e
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rax
testb $0x1, (%rax)
jne 0x1693e
leaq 0x23346(%rip), %rdi     # 0x39c74
movb $0x0, %al
callq 0xb840
xorl %esi, %esi
movl %esi, %edi
callq 0xbe90
jmp 0x16940
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0x168d1
jmp 0x1694f
movq 0x58(%rsp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x1695d
leaq 0x40(%rsp), %rdi
xorl %esi, %esi
callq 0x19e90
movq %rax, 0x8(%rsp)
jmp 0x16807
jmp 0x16975
leaq 0x48(%rsp), %rdi
xorl %esi, %esi
callq 0x1a020
movq %rax, (%rsp)
jmp 0x167b5
jmp 0x169bc
movq 0x60(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x58(%rsp), %rsi
movq 0x50(%rsp), %rdx
callq 0x16760
movq 0x60(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x58(%rsp), %rsi
movq 0x50(%rsp), %rdx
callq 0x16760
addq $0x68, %rsp
retq
nopw %cs:(%rax,%rax)