// File: /workspace/github_cpp_makefile_star2_O2/essarrdee[P]mutantaliens/mutantaliens.cpp
// Function: make_room(std::pair<int, int>, std::pair<int, int>)
void make_room(std::pair<int,int> centre, std::pair<int,int> size)
{
	int x=centre.first;int y=centre.second;int xsize=size.first;int ysize=size.second;
	std::vector<std::pair<int,int>> inner_walls;
	std::vector<std::pair<int,int>> outer_walls;
	for(int i=0;i<xsize+2;i++)
	{
		for(int j=0;j<ysize+2;j++)
		{
			if(i==0 || i == xsize+1 || j==0 || j==ysize+1)
			{
				if (map_terrain[i+x-xsize/2][j+y-ysize/2] == DIRT || map_terrain[i+x-xsize/2][j+y-ysize/2] == STREE || map_terrain[i+x-xsize/2][j+y-ysize/2] == BTREE)
				{
					map_terrain[i+x-xsize/2][j+y-ysize/2] = WALL;
					if(!is_corner_a(i,j,xsize+1,ysize+1))
					{ outer_walls.push_back(std::make_pair(i+x-xsize/2,j+y-ysize/2)); }
				}
			}
			else
			{
				if(map_terrain[i+x-xsize/2][j+y-ysize/2] != WALL && map_terrain[i+x-xsize/2][j+y-ysize/2] != DOOR && map_terrain[i+x-xsize/2][j+y-ysize/2] != TWINDOW)
				{
					map_terrain[i+x-xsize/2][j+y-ysize/2] = FLOOR;
				}
				else if(map_terrain[i+x-xsize/2][j+y-ysize/2] == DOOR && rand()%3 == 0)
				{
					map_terrain[i+x-xsize/2][j+y-ysize/2] = FLOOR;
				}
				else if(!is_corner_b(i+x-xsize/2,j+y-ysize/2))
				{
					inner_walls.push_back(std::make_pair(i+x-xsize/2,j+y-ysize/2));
				}
			}
		}
	}
	if(inner_walls.size()>0) // this should really be done with shuffle
	{
		int door_id = rand()%inner_walls.size();
		std::pair<int,int> inner_door_choice = inner_walls[door_id];
		map_access[inner_door_choice.first+1][inner_door_choice.second] = true;
		map_access[inner_door_choice.first-1][inner_door_choice.second] = true;
		map_access[inner_door_choice.first][inner_door_choice.second+1] = true;
		map_access[inner_door_choice.first][inner_door_choice.second-1] = true;
		map_terrain[inner_door_choice.first][inner_door_choice.second] = DOOR;
		if(inner_walls.size() > 2)
		{
			int w1_id = rand()%inner_walls.size();
			while(w1_id == door_id)
			{
				w1_id = rand()%inner_walls.size();
			}
			std::pair<int,int> w1_choice = inner_walls[w1_id];
			map_terrain[w1_choice.first][w1_choice.second] = TWINDOW;
			if(inner_walls.size() > 4)
			{
				int w2_id = rand()%inner_walls.size();
				while(w2_id == door_id || w2_id == w1_id)
				{
					w2_id = rand()%inner_walls.size();
				}
				std::pair<int,int> w2_choice = inner_walls[w2_id];
				map_terrain[w2_choice.first][w2_choice.second] = TWINDOW;
				}
		}
	}
	if(outer_walls.size()>0)
	{
		int door_id = rand()%outer_walls.size();
		std::pair<int,int> outer_door_choice = outer_walls[door_id];
		map_terrain[outer_door_choice.first][outer_door_choice.second] = DOOR;
		map_access[outer_door_choice.first+1][outer_door_choice.second] = true;
		map_access[outer_door_choice.first-1][outer_door_choice.second] = true;
		map_access[outer_door_choice.first][outer_door_choice.second+1] = true;
		map_access[outer_door_choice.first][outer_door_choice.second-1] = true;
		if(outer_walls.size() > 2)
		{
			int w1_id = rand()%outer_walls.size();
			while(w1_id == door_id)
			{
				w1_id = rand()%outer_walls.size();
			}
			std::pair<int,int> w1_choice = outer_walls[w1_id];
			map_terrain[w1_choice.first][w1_choice.second] = TWINDOW;
			if(outer_walls.size() > 4)
			{
				int w2_id = rand()%outer_walls.size();
				while(w2_id == door_id || w2_id == w1_id)
				{
					w2_id = rand()%outer_walls.size();
				}
				std::pair<int,int> w2_choice = outer_walls[w2_id];
				map_terrain[w2_choice.first][w2_choice.second] = TWINDOW;
				}
		}
	}

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
leaq 0x30(%rsp), %rax
andq $0x0, 0x10(%rax)
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
leaq 0x10(%rsp), %rax
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
pushq $-0x2
popq %rcx
movl %esi, %eax
cltd
idivl %ecx
addl %edi, %eax
movq %rax, 0x70(%rsp)
shrq $0x20, %rdi
movq %rsi, %rax
shrq $0x20, %rax
leal 0x2(%rax), %ebx
leal 0x1(%rsi), %r12d
leal 0x1(%rax), %edx
movq %rdx, 0x60(%rsp)
cltd
idivl %ecx
xorl %r14d, %r14d
testl %ebx, %ebx
cmovlel %r14d, %ebx
cmpl $-0x1, %esi
cmovgel %esi, %ecx
addl $0x2, %ecx
movq %rcx, 0x78(%rsp)
addl %edi, %eax
movq %rax, 0x68(%rsp)
cmpq 0x78(%rsp), %r14
je 0x9a82
testq %r14, %r14
sete %al
cmpq %r12, %r14
sete %dl
movq 0x70(%rsp), %rcx
addl %r14d, %ecx
movq %rcx, 0x50(%rsp)
movslq %ecx, %rcx
orb %al, %dl
movb %dl, 0xf(%rsp)
imulq $0x258, %rcx, %r13      # imm = 0x258
leaq 0x149ec(%rip), %rax     # 0x1e340
addq %rax, %r13
xorl %ebp, %ebp
cmpq %rbp, %rbx
je 0x9a7a
testq %r14, %r14
je 0x9983
cmpq %r12, %r14
sete %al
testq %rbp, %rbp
sete %cl
orb %al, %cl
cmpq %rbp, 0x60(%rsp)
sete %al
orb %cl, %al
cmpb $0x1, %al
jne 0x99ea
movq 0x68(%rsp), %rax
addq %rbp, %rax
movslq %eax, %rcx
cmpl $0x2, (%r13,%rcx,4)
ja 0x9a72
leaq (,%rcx,4), %rcx
addq %r13, %rcx
movl $0x4, (%rcx)
cmpb $0x0, 0xf(%rsp)
je 0x99c8
testq %rbp, %rbp
sete %cl
cmpq %rbp, 0x60(%rsp)
sete %dl
orb %cl, %dl
jne 0x9a72
shlq $0x20, %rax
addq 0x50(%rsp), %rax
movq %rax, 0x58(%rsp)
leaq 0x10(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x12216
jmp 0x9a72
movq 0x68(%rsp), %rax
leaq (%rax,%rbp), %r15
movslq %r15d, %rcx
movl (%r13,%rcx,4), %eax
cmpl $0x4, %eax
je 0x9a3c
leaq (,%rcx,4), %rcx
addq %r13, %rcx
cmpl $0x5, %eax
je 0x9a1d
cmpl $0xc, %eax
je 0x9a3c
movl $0x3, (%rcx)
jmp 0x9a72
movq %rcx, 0x80(%rsp)
callq 0x5080
cltd
pushq $0x3
popq %rcx
idivl %ecx
movq 0x80(%rsp), %rax
testl %edx, %edx
je 0x9a6c
movq 0x50(%rsp), %rdi
movl %r15d, %esi
callq 0x1113b
testb %al, %al
jne 0x9a72
shlq $0x20, %r15
addq 0x50(%rsp), %r15
movq %r15, 0x58(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x12216
jmp 0x9a72
movl $0x3, (%rax)
incq %rbp
jmp 0x9959
incq %r14
jmp 0x9919
movq 0x38(%rsp), %rax
cmpq 0x30(%rsp), %rax
je 0x9ba5
callq 0x5080
cltq
movq 0x30(%rsp), %rcx
movq 0x38(%rsp), %rsi
subq %rcx, %rsi
sarq $0x3, %rsi
xorl %edx, %edx
divq %rsi
movq %rdx, %rbx
movslq %ebx, %rax
movslq (%rcx,%rax,8), %rdx
movslq 0x4(%rcx,%rax,8), %rax
leaq 0x5bf1b(%rip), %rcx     # 0x659e0
imulq $0x96, %rdx, %rdi
addq %rcx, %rdi
movb $0x1, %cl
movb %cl, 0x96(%rax,%rdi)
movb %cl, -0x96(%rax,%rdi)
movb %cl, 0x1(%rax,%rdi)
movb %cl, -0x1(%rax,%rdi)
imulq $0x258, %rdx, %rcx      # imm = 0x258
leaq 0x1484b(%rip), %rdx     # 0x1e340
addq %rdx, %rcx
movl $0x5, (%rcx,%rax,4)
cmpq $0x3, %rsi
jb 0x9ba5
callq 0x5080
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rcx
cltq
subq %rsi, %rcx
movq %rcx, %rdi
sarq $0x3, %rdi
xorl %edx, %edx
divq %rdi
movq %rdx, %r14
cmpl %ebx, %r14d
je 0x9b09
movslq %r14d, %rax
movslq (%rsi,%rax,8), %rdx
movslq 0x4(%rsi,%rax,8), %rax
imulq $0x258, %rdx, %rdx      # imm = 0x258
leaq 0x147f5(%rip), %rsi     # 0x1e340
addq %rsi, %rdx
movl $0xc, (%rdx,%rax,4)
cmpq $0x21, %rcx
jb 0x9ba5
callq 0x5080
movq 0x30(%rsp), %rcx
movq 0x38(%rsp), %rsi
cltq
subq %rcx, %rsi
sarq $0x3, %rsi
xorl %edx, %edx
divq %rsi
cmpl %ebx, %edx
je 0x9b5b
cmpl %r14d, %edx
je 0x9b5b
movslq %edx, %rax
movslq (%rcx,%rax,8), %rdx
movslq 0x4(%rcx,%rax,8), %rax
imulq $0x258, %rdx, %rcx      # imm = 0x258
leaq 0x147a5(%rip), %rdx     # 0x1e340
addq %rdx, %rcx
movl $0xc, (%rcx,%rax,4)
movq 0x18(%rsp), %rax
cmpq 0x10(%rsp), %rax
je 0x9cc8
callq 0x5080
cltq
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %rsi
subq %rcx, %rsi
sarq $0x3, %rsi
xorl %edx, %edx
divq %rsi
movq %rdx, %rbx
movslq %ebx, %rax
movslq (%rcx,%rax,8), %rdx
movslq 0x4(%rcx,%rax,8), %rax
imulq $0x258, %rdx, %rcx      # imm = 0x258
leaq 0x14751(%rip), %rdi     # 0x1e340
addq %rdi, %rcx
movl $0x5, (%rcx,%rax,4)
leaq 0x5bde0(%rip), %rcx     # 0x659e0
imulq $0x96, %rdx, %rdx
addq %rcx, %rdx
movb $0x1, %cl
movb %cl, 0x96(%rax,%rdx)
movb %cl, -0x96(%rax,%rdx)
movb %cl, 0x1(%rax,%rdx)
movb %cl, -0x1(%rax,%rdx)
cmpq $0x3, %rsi
jb 0x9cc8
callq 0x5080
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rcx
cltq
subq %rsi, %rcx
movq %rcx, %rdi
sarq $0x3, %rdi
xorl %edx, %edx
divq %rdi
movq %rdx, %r14
cmpl %ebx, %r14d
je 0x9c2c
movslq %r14d, %rax
movslq (%rsi,%rax,8), %rdx
movslq 0x4(%rsi,%rax,8), %rax
imulq $0x258, %rdx, %rdx      # imm = 0x258
leaq 0x146d2(%rip), %rsi     # 0x1e340
addq %rsi, %rdx
movl $0xc, (%rdx,%rax,4)
cmpq $0x21, %rcx
jb 0x9cc8
callq 0x5080
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %rsi
cltq
subq %rcx, %rsi
sarq $0x3, %rsi
xorl %edx, %edx
divq %rsi
cmpl %ebx, %edx
je 0x9c7e
cmpl %r14d, %edx
je 0x9c7e
movslq %edx, %rax
movslq (%rcx,%rax,8), %rdx
movslq 0x4(%rcx,%rax,8), %rax
imulq $0x258, %rdx, %rcx      # imm = 0x258
leaq 0x14682(%rip), %rdx     # 0x1e340
addq %rcx, %rdx
movl $0xc, (%rdx,%rax,4)
leaq 0x10(%rsp), %rdi
callq 0x116cc
leaq 0x30(%rsp), %rdi
callq 0x116cc
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x9cf0
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x116cc
leaq 0x30(%rsp), %rdi
callq 0x116cc
movq %rbx, %rdi
callq 0x53c0