// File: /workspace/github_cpp_makefile_star2_O1/Unreality3D[P]Unreality3D/indie-studio/source/MapGenerator/MapGenerator.cpp
// Function: Map::generate_map()
void				Map::generate_map()
{
  std::ofstream			debug;
  Leaf				_root = Leaf(Size(0, 0), Size(map_size.x, map_size.y));
  std::vector<Rooms>		tmpRooms;

  if (_seed != -1)
    srand(_seed);
  else
    srand(time(NULL));
  debug.open("map.txt");
  _leafs.push_back(_root);
  split();
  for(size_t i = 0; i < _leafs.size();i++)
    _leafs[i].create_rooms(tmpRooms, room_max_size);
  for (int i = 0; i < room_nbr;i++)
    _rooms.push_back(tmpRooms[rand() % tmpRooms.size()]);
  for(size_t i = 0; i < _leafs.size();i++)
    {
      delete(_leafs[i].leftChild);
      delete(_leafs[i].rightChild);
    }
  blank_map();
  draw_rooms();
  draw_better_walls();
  draw_hallways();
  draw_hallways_walls();
  draw_angles();
  add_misc();
  draw_rooms_pattern();
  draw_in_out();
  for (size_t i = 0; i < _map.size() ; i++)
    debug << _map[i] << std::endl;
  debug.close();
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x240, %rsp            # imm = 0x240
movq %rdi, %rbx
leaq 0x40(%rsp), %rdi
callq 0x2310
movq 0x4(%rbx), %rax
xorl %ecx, %ecx
movq %rcx, 0x20(%rsp)
movq %rax, 0x28(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rsp)
movq %rcx, 0x10(%rsp)
movaps %xmm0, (%rsp)
movl 0x1c(%rbx), %edi
cmpl $-0x1, %edi
jne 0x25a4
xorl %edi, %edi
callq 0x2200
movq %rax, %rdi
callq 0x2220
leaq 0x2a60(%rip), %rsi      # 0x5010
leaq 0x40(%rsp), %rdi
movl $0x10, %edx
callq 0x2040
leaq 0x28(%rbx), %r14
movq 0x30(%rbx), %rsi
cmpq 0x38(%rbx), %rsi
je 0x25e5
movups 0x20(%rsp), %xmm0
movups 0x30(%rsp), %xmm1
movups %xmm1, 0x10(%rsi)
movups %xmm0, (%rsi)
addq $0x20, 0x30(%rbx)
jmp 0x25f2
leaq 0x20(%rsp), %rdx
movq %r14, %rdi
callq 0x2290
movq %rbx, %rdi
callq 0x2300
movq 0x28(%rbx), %rdi
cmpq %rdi, 0x30(%rbx)
je 0x2637
xorl %r12d, %r12d
movq %rsp, %r15
xorl %r13d, %r13d
addq %r12, %rdi
movq 0xc(%rbx), %rdx
movq %r15, %rsi
callq 0x2320
incq %r13
movq 0x28(%rbx), %rdi
movq 0x30(%rbx), %rax
subq %rdi, %rax
sarq $0x5, %rax
addq $0x20, %r12
cmpq %rax, %r13
jb 0x260d
cmpl $0x0, (%rbx)
jle 0x26a2
leaq 0x40(%rbx), %r15
xorl %r12d, %r12d
movabsq $-0x3333333333333333, %r13 # imm = 0xCCCCCCCCCCCCCCCD
callq 0x2070
cltq
movq (%rsp), %rcx
movq 0x8(%rsp), %rsi
subq %rcx, %rsi
sarq $0x2, %rsi
imulq %r13, %rsi
xorl %edx, %edx
divq %rsi
leaq (%rdx,%rdx,4), %rax
leaq (%rcx,%rax,4), %rdx
movq 0x48(%rbx), %rsi
cmpq 0x50(%rbx), %rsi
je 0x2692
movl 0x10(%rdx), %eax
movl %eax, 0x10(%rsi)
movups (%rdx), %xmm0
movups %xmm0, (%rsi)
addq $0x14, 0x48(%rbx)
jmp 0x269a
movq %r15, %rdi
callq 0x2180
incl %r12d
cmpl (%rbx), %r12d
jl 0x264d
movq 0x28(%rbx), %rax
cmpq %rax, 0x30(%rbx)
je 0x26ee
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0x10(%rax,%r15), %rdi
testq %rdi, %rdi
je 0x26c1
callq 0x2210
movq (%r14), %rax
movq 0x18(%rax,%r15), %rdi
testq %rdi, %rdi
je 0x26d3
callq 0x2210
incq %r12
movq 0x28(%rbx), %rax
movq 0x30(%rbx), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
addq $0x20, %r15
cmpq %rcx, %r12
jb 0x26b2
movq %rbx, %rdi
callq 0x2340
movq %rbx, %rdi
callq 0x21a0
movq %rbx, %rdi
callq 0x2380
movq %rbx, %rdi
callq 0x21f0
movq %rbx, %rdi
callq 0x2120
movq %rbx, %rdi
callq 0x2100
movq %rbx, %rdi
callq 0x20e0
movq %rbx, %rdi
callq 0x2260
movq %rbx, %rdi
callq 0x2160
movq 0x58(%rbx), %rax
cmpq %rax, 0x60(%rbx)
je 0x27a4
movl $0x8, %r12d
xorl %r13d, %r13d
leaq 0x40(%rsp), %r14
movq -0x8(%rax,%r12), %rsi
movq (%rax,%r12), %rdx
movq %r14, %rdi
callq 0x2270
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2230
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2140
incq %r13
movq 0x58(%rbx), %rax
movq 0x60(%rbx), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
addq $0x20, %r12
cmpq %rcx, %r13
jb 0x274e
leaq 0x40(%rsp), %rdi
callq 0x22a0
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x27bc
callq 0x2210
movq 0x480d(%rip), %rax      # 0x6fd0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x48(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x40(%rsp,%rcx)
callq 0x21d0
leaq 0x138(%rsp), %rdi
callq 0x20a0
addq $0x240, %rsp            # imm = 0x240
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
jmp 0x2805
jmp 0x2805
jmp 0x2805
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x2816
callq 0x2210
leaq 0x40(%rsp), %rdi
callq 0x22c0
movq %rbx, %rdi
callq 0x2350