// File: /workspace/github_cpp_makefile_star2_O3/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 0x1a60(%rip), %rsi      # 0x4010
leaq 0x40(%rsp), %rdi
movl $0x10, %edx
callq 0x2040
movq 0x30(%rbx), %rsi
cmpq 0x38(%rbx), %rsi
je 0x25e1
movups 0x20(%rsp), %xmm0
movups 0x30(%rsp), %xmm1
movups %xmm1, 0x10(%rsi)
movups %xmm0, (%rsi)
addq $0x20, 0x30(%rbx)
jmp 0x25ef
leaq 0x28(%rbx), %rdi
leaq 0x20(%rsp), %rdx
callq 0x2290
movq %rbx, %rdi
callq 0x2300
movq 0x28(%rbx), %rdi
movq 0x30(%rbx), %rax
cmpq %rdi, %rax
je 0x263a
xorl %r15d, %r15d
movq %rsp, %r14
xorl %r12d, %r12d
addq %r15, %rdi
movq 0xc(%rbx), %rdx
movq %r14, %rsi
callq 0x2320
incq %r12
movq 0x28(%rbx), %rdi
movq 0x30(%rbx), %rax
movq %rax, %rcx
subq %rdi, %rcx
sarq $0x5, %rcx
addq $0x20, %r15
cmpq %rcx, %r12
jb 0x260d
cmpl $0x0, (%rbx)
jle 0x26ad
leaq 0x40(%rbx), %r14
xorl %r15d, %r15d
movabsq $-0x3333333333333333, %r12 # imm = 0xCCCCCCCCCCCCCCCD
callq 0x2070
cltq
movq (%rsp), %rcx
movq 0x8(%rsp), %rsi
subq %rcx, %rsi
sarq $0x2, %rsi
imulq %r12, %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 0x2695
movl 0x10(%rdx), %eax
movl %eax, 0x10(%rsi)
movups (%rdx), %xmm0
movups %xmm0, (%rsi)
addq $0x14, 0x48(%rbx)
jmp 0x269d
movq %r14, %rdi
callq 0x2180
incl %r15d
cmpl (%rbx), %r15d
jl 0x2650
movq 0x28(%rbx), %rdi
movq 0x30(%rbx), %rax
cmpq %rdi, %rax
je 0x26eb
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x10(%rdi,%r14), %rdi
callq 0x2210
movq 0x28(%rbx), %rax
movq 0x18(%rax,%r14), %rdi
callq 0x2210
incq %r15
movq 0x28(%rbx), %rdi
movq 0x30(%rbx), %rax
subq %rdi, %rax
sarq $0x5, %rax
addq $0x20, %r14
cmpq %rax, %r15
jb 0x26b8
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 0x27a1
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 0x274b
leaq 0x40(%rsp), %rdi
callq 0x22a0
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x27b9
callq 0x2210
movq 0x3810(%rip), %rax      # 0x5fd0
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 0x2802
jmp 0x2802
jmp 0x2802
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x2813
callq 0x2210
leaq 0x40(%rsp), %rdi
callq 0x22c0
movq %rbx, %rdi
callq 0x2350
nop