// File: /workspace/github_cpp_makefile_star2_O2/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 0x3380
movq 0x4(%rbx), %rax
andq $0x0, 0x20(%rsp)
movq %rax, 0x28(%rsp)
xorps %xmm0, %xmm0
andq $0x0, 0x10(%rsp)
movups %xmm0, 0x30(%rsp)
movaps %xmm0, (%rsp)
movl 0x1c(%rbx), %edi
cmpl $-0x1, %edi
jne 0x35de
xorl %edi, %edi
callq 0x3200
movq %rax, %rdi
callq 0x3220
leaq 0x1a26(%rip), %rsi      # 0x5010
leaq 0x40(%rsp), %rdi
pushq $0x10
popq %rdx
callq 0x3030
leaq 0x28(%rbx), %r14
leaq 0x20(%rsp), %rsi
movq %r14, %rdi
callq 0x33e0
movq %rbx, %rdi
callq 0x3370
xorl %r12d, %r12d
movq %rsp, %r15
xorl %r13d, %r13d
movq 0x28(%rbx), %rdi
movq 0x30(%rbx), %rax
subq %rdi, %rax
sarq $0x5, %rax
cmpq %rax, %r13
jae 0x3645
addq %r12, %rdi
movq 0xc(%rbx), %rdx
movq %r15, %rsi
callq 0x33a0
incq %r13
addq $0x20, %r12
jmp 0x3619
leaq 0x40(%rbx), %r15
xorl %r12d, %r12d
pushq $0x14
popq %r13
cmpl (%rbx), %r12d
jge 0x368d
callq 0x3080
movslq %eax, %rcx
movq (%rsp), %rdi
movq 0x8(%rsp), %rax
subq %rdi, %rax
cqto
idivq %r13
movq %rax, %rsi
movq %rcx, %rax
xorl %edx, %edx
divq %rsi
imulq $0x14, %rdx, %rsi
addq %rdi, %rsi
movq %r15, %rdi
callq 0x3330
incl %r12d
jmp 0x3650
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0x28(%rbx), %rax
movq 0x30(%rbx), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
cmpq %rcx, %r12
jae 0x36c7
movq 0x10(%rax,%r15), %rdi
callq 0x3210
movq (%r14), %rax
movq 0x18(%rax,%r15), %rdi
callq 0x3210
incq %r12
addq $0x20, %r15
jmp 0x3693
movq %rbx, %rdi
callq 0x33c0
movq %rbx, %rdi
callq 0x31b0
movq %rbx, %rdi
callq 0x3420
movq %rbx, %rdi
callq 0x31f0
movq %rbx, %rdi
callq 0x3150
movq %rbx, %rdi
callq 0x3130
movq %rbx, %rdi
callq 0x3110
movq %rbx, %rdi
callq 0x3280
movq %rbx, %rdi
callq 0x3170
xorl %r15d, %r15d
leaq 0x40(%rsp), %r14
xorl %r12d, %r12d
movq 0x58(%rbx), %rsi
movq 0x60(%rbx), %rax
subq %rsi, %rax
sarq $0x5, %rax
cmpq %rax, %r12
jae 0x374a
addq %r15, %rsi
movq %r14, %rdi
callq 0x31e0
movq %rax, %rdi
callq 0x3100
incq %r12
addq $0x20, %r15
jmp 0x371a
leaq 0x40(%rsp), %rdi
callq 0x32f0
movq %rsp, %rdi
callq 0x30a0
leaq 0x40(%rsp), %rdi
callq 0x3310
addq $0x240, %rsp            # imm = 0x240
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
jmp 0x377d
jmp 0x377d
jmp 0x377d
movq %rax, %rbx
movq %rsp, %rdi
callq 0x30a0
leaq 0x40(%rsp), %rdi
callq 0x3310
movq %rbx, %rdi
callq 0x33d0