// File: Unreality3D[P]Unreality3D/indie-studio/source/MapGenerator/MgUtils.cpp
// Function: Leaf::split(Size)
bool	Leaf::split(Size roomMin)
{
  bool	splitB;

  if (leftChild != NULL && rightChild != NULL)
    return false;
  if (_size.x > _size.y)
    splitB = false;
  else
    splitB = true;
  int max = (splitB ? _size.y : _size.x) - (splitB ? roomMin.y : roomMin.x);
  if (max < (splitB ? roomMin.y : roomMin.x))
    return false;
  int splitPos = random_range((splitB ? roomMin.y : roomMin.x), max);
  if (splitB)
    {
      leftChild =  new Leaf(Size(_pos.x, _pos.y), Size(_size.x, splitPos));
      rightChild =  new Leaf(Size(_pos.x, _pos.y + splitPos), Size(_size.x, _size.y - splitPos));
    }
  else
    {
      leftChild =  new Leaf(Size(_pos.x, _pos.y), Size(splitPos, _size.y));
      rightChild =  new Leaf(Size(_pos.x + splitPos, _pos.y), Size(_size.x - splitPos, _size.y));
    }
  return true;
}

// Assembly:
subq $0xb8, %rsp
movq %rsi, 0xac(%rsp)
movq %rdi, 0xa0(%rsp)
movq 0xa0(%rsp), %rax
movq %rax, 0x38(%rsp)
cmpq $0x0, 0x10(%rax)
je 0xbd14
movq 0x38(%rsp), %rax
cmpq $0x0, 0x18(%rax)
je 0xbd14
movb $0x0, 0xb7(%rsp)
jmp 0xc05f
movq 0x38(%rsp), %rcx
movl 0x8(%rcx), %eax
cmpl 0xc(%rcx), %eax
jle 0xbd2b
movb $0x0, 0x9f(%rsp)
jmp 0xbd33
movb $0x1, 0x9f(%rsp)
testb $0x1, 0x9f(%rsp)
je 0xbd4b
movq 0x38(%rsp), %rax
movl 0xc(%rax), %eax
movl %eax, 0x34(%rsp)
jmp 0xbd57
movq 0x38(%rsp), %rax
movl 0x8(%rax), %eax
movl %eax, 0x34(%rsp)
movl 0x34(%rsp), %eax
movl %eax, 0x30(%rsp)
testb $0x1, 0x9f(%rsp)
je 0xbd76
movl 0xb0(%rsp), %eax
movl %eax, 0x2c(%rsp)
jmp 0xbd81
movl 0xac(%rsp), %eax
movl %eax, 0x2c(%rsp)
movl 0x30(%rsp), %eax
movl 0x2c(%rsp), %ecx
subl %ecx, %eax
movl %eax, 0x98(%rsp)
movl 0x98(%rsp), %eax
movl %eax, 0x28(%rsp)
testb $0x1, 0x9f(%rsp)
je 0xbdb4
movl 0xb0(%rsp), %eax
movl %eax, 0x24(%rsp)
jmp 0xbdbf
movl 0xac(%rsp), %eax
movl %eax, 0x24(%rsp)
movl 0x28(%rsp), %eax
movl 0x24(%rsp), %ecx
cmpl %ecx, %eax
jge 0xbdd8
movb $0x0, 0xb7(%rsp)
jmp 0xc05f
testb $0x1, 0x9f(%rsp)
je 0xbdef
movl 0xb0(%rsp), %eax
movl %eax, 0x20(%rsp)
jmp 0xbdfa
movl 0xac(%rsp), %eax
movl %eax, 0x20(%rsp)
movl 0x20(%rsp), %edi
movl 0x98(%rsp), %esi
callq 0x6570
movl %eax, 0x94(%rsp)
testb $0x1, 0x9f(%rsp)
je 0xbf46
movl $0x20, %edi
callq 0x65b0
movq %rax, %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x18(%rsp)
movl (%rax), %esi
movl 0x4(%rax), %edx
leaq 0x8c(%rsp), %rdi
callq 0x6990
jmp 0xbe4a
movq 0x38(%rsp), %rax
movl 0x8(%rax), %esi
movl 0x94(%rsp), %edx
leaq 0x74(%rsp), %rdi
callq 0x6990
jmp 0xbe65
movq 0x18(%rsp), %rdi
movq 0x8c(%rsp), %rsi
movq 0x74(%rsp), %rdx
callq 0x6210
jmp 0xbe7e
movq 0x38(%rsp), %rax
movq 0x18(%rsp), %rcx
movq %rcx, 0x10(%rax)
movl $0x20, %edi
callq 0x65b0
movq %rax, %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x10(%rsp)
movl (%rax), %esi
movl 0x4(%rax), %edx
movl 0x94(%rsp), %eax
addl %eax, %edx
leaq 0x6c(%rsp), %rdi
callq 0x6990
jmp 0xbebd
movq 0x38(%rsp), %rax
movl 0x8(%rax), %esi
movl 0xc(%rax), %edx
movl 0x94(%rsp), %eax
subl %eax, %edx
leaq 0x64(%rsp), %rdi
callq 0x6990
jmp 0xbedd
movq 0x10(%rsp), %rdi
movq 0x6c(%rsp), %rsi
movq 0x64(%rsp), %rdx
callq 0x6210
jmp 0xbef3
movq 0x38(%rsp), %rax
movq 0x10(%rsp), %rcx
movq %rcx, 0x18(%rax)
jmp 0xc057
movq 0x18(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x80(%rsp)
movl %eax, 0x7c(%rsp)
callq 0x6530
jmp 0xc070
movq 0x10(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x80(%rsp)
movl %eax, 0x7c(%rsp)
callq 0x6530
jmp 0xc070
movl $0x20, %edi
callq 0x65b0
movq %rax, %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x8(%rsp)
movl (%rax), %esi
movl 0x4(%rax), %edx
leaq 0x5c(%rsp), %rdi
callq 0x6990
jmp 0xbf6e
movq 0x38(%rsp), %rax
movl 0x94(%rsp), %esi
movl 0xc(%rax), %edx
leaq 0x54(%rsp), %rdi
callq 0x6990
jmp 0xbf89
movq 0x8(%rsp), %rdi
movq 0x5c(%rsp), %rsi
movq 0x54(%rsp), %rdx
callq 0x6210
jmp 0xbf9f
movq 0x38(%rsp), %rax
movq 0x8(%rsp), %rcx
movq %rcx, 0x10(%rax)
movl $0x20, %edi
callq 0x65b0
movq 0x38(%rsp), %rcx
movq %rax, (%rsp)
movl 0x94(%rsp), %eax
movl (%rcx), %esi
movl 0x4(%rcx), %edx
addl %eax, %esi
leaq 0x4c(%rsp), %rdi
callq 0x6990
jmp 0xbfda
movq 0x38(%rsp), %rcx
movl 0x94(%rsp), %eax
movl 0x8(%rcx), %esi
movl 0xc(%rcx), %edx
subl %eax, %esi
leaq 0x44(%rsp), %rdi
callq 0x6990
jmp 0xbffa
movq (%rsp), %rdi
movq 0x4c(%rsp), %rsi
movq 0x44(%rsp), %rdx
callq 0x6210
jmp 0xc00f
movq 0x38(%rsp), %rax
movq (%rsp), %rcx
movq %rcx, 0x18(%rax)
jmp 0xc057
movq 0x8(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x80(%rsp)
movl %eax, 0x7c(%rsp)
callq 0x6530
jmp 0xc070
movq (%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x80(%rsp)
movl %eax, 0x7c(%rsp)
callq 0x6530
jmp 0xc070
movb $0x1, 0xb7(%rsp)
movb 0xb7(%rsp), %al
andb $0x1, %al
addq $0xb8, %rsp
retq
movq 0x80(%rsp), %rdi
callq 0x6a10
nopl (%rax)