// File: /workspace/github_cpp_makefile_star2_O2/lotuskip[P]yuxtapa/server/map.cpp
// Function: (anonymous namespace)::room_recur(char, char, char)
void room_recur(const char rx, const char ry, const char dir)
{
	if(rooms[ry*ROOM_NUM+rx])
		return;
	rooms[ry*ROOM_NUM+rx] = true;
	// See where we can branch from here:
	bool branches[4] = {  (dir != 0 && ry != 0) /*N*/,
		(dir != 1 && rx != ROOM_NUM-1) /*E*/,
		(dir != 2 && ry != ROOM_NUM-1) /*S*/,
		(dir != 3 && rx != 0) /*W*/ };
	char (*rot_func)(const char, const char, const char*) = &rot_0;
	// Make a random kind of room here:
	char room_type; // index to the 'roomcell' table
	// First room (dir == -1) must not be a corridor only, and we favour
	// the non-corridors otherwise, too:
	if(dir == -1 || !(random()%5))
		room_type = random()%2; // 0 or 1 is okay
	else
		room_type = random()%7;
	switch(room_type)
	{
	case 1: case 6: /* #..  #.#  rotate these similarly
			         * #..  #..
			         * ###  ###  */
		if(dir != -1)
		{
			if(random()%2) // dir enters from the top
			{
				rot_func = rot_fs[dir];
				branches[(dir+2)%4] = branches[(dir+3)%4] = false;
			}
			else // dir enters from the side
			{
				rot_func = rot_fs[(dir+3)%4];
				branches[(dir+1)%4] = branches[(dir+2)%4] = false;
			}
		}
		else
			branches[2] = branches[3] = false;
		break;
	case 4: /* #.#  can branch only one way
			 * #.#
			 * ### */
		if(dir != -1)
			rot_func = rot_fs[dir];
		branches[0] = branches[1] = branches[2] = branches[3] = false;
		break;
	case 3: /* #.# can branch N / S
			 * #.#
			 * #.# */
		if(dir%2)
		{
			rot_func = rot_90;
			branches[0] = branches[2] = false;
		}
		else
			branches[1] = branches[3] = false;
		break;
	// default: (Others can branch any way and don't need rotation.)
	}

	// Put the room in place:
	char x, y;
	for(y = 0; y < ROOM_SIZE; ++y)
	{
		for(x = 0; x < ROOM_SIZE; ++x)
			house[(ry*ROOM_SIZE+1+y)*MAX_HS+rx*ROOM_SIZE+1+x]
				= rot_func(x, y, roomcell[room_type]);
	}

	// Branch where-ever we can:
	if(branches[0]) room_recur(rx, ry-1, 2);
	if(branches[1]) room_recur(rx+1, ry, 3);
	if(branches[2]) room_recur(rx, ry+1, 0);
	if(branches[3]) room_recur(rx-1, ry, 1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edx, %r12d
movslq %esi, %rdx
movslq %edi, %r15
leaq (%r15,%rdx,4), %rcx
leaq 0x2d550(%rip), %rax     # 0x40bc0
cmpb $0x0, (%rax,%rcx)
jne 0x138c3
movl %esi, %ebx
movl %edi, %r13d
movq %rdx, %rcx
shlq $0x2, %rcx
addq %r15, %rcx
movb $0x1, (%rax,%rcx)
testb %r12b, %r12b
setne %al
testb %dl, %dl
setne %cl
andb %al, %cl
movb %cl, -0x2c(%rbp)
cmpb $0x1, %r12b
setne %al
cmpb $0x3, %r15b
setne %cl
andb %al, %cl
movb %cl, -0x2b(%rbp)
cmpb $0x2, %r12b
setne %al
movq %rdx, -0x40(%rbp)
cmpb $0x3, %dl
setne %cl
andb %al, %cl
movb %cl, -0x2a(%rbp)
cmpb $0x3, %r12b
setne %al
testb %r15b, %r15b
setne %cl
andb %al, %cl
movb %cl, -0x29(%rbp)
cmpb $-0x1, %r12b
je 0x136fd
callq 0x41e0
pushq $0x5
popq %rcx
cqto
idivq %rcx
xorl %eax, %eax
testq %rdx, %rdx
setne %al
leaq (%rax,%rax,4), %r14
addq $0x2, %r14
jmp 0x13701
pushq $0x2
popq %r14
callq 0x41e0
cqto
idivq %r14
leaq 0x1c0(%rip), %r14       # 0x138d2
leal -0x1(%rdx), %eax
cmpl $0x5, %eax
movq %r15, -0x48(%rbp)
ja 0x137eb
leaq 0x13483(%rip), %rcx     # 0x26bac
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpb $-0x1, %r12b
je 0x1379b
movq %rdx, -0x38(%rbp)
movzbl %r12b, %r15d
callq 0x41e0
testb $0x1, %al
jne 0x137a2
leal -0x1(%r15), %eax
andl $0x3, %eax
leaq 0x292f9(%rip), %rcx     # 0x3ca50
movq (%rcx,%rax,8), %r14
movl %r15d, %eax
andl $0x3, %eax
xorq $0x2, %rax
xorl %ecx, %ecx
movb %cl, -0x2c(%rbp,%rax)
incl %r15d
andl $0x3, %r15d
jmp 0x137c6
cmpb $-0x1, %r12b
je 0x137e0
movsbq %r12b, %rax
leaq 0x292cb(%rip), %rcx     # 0x3ca50
movq (%rcx,%rax,8), %r14
jmp 0x137e7
xorl %eax, %eax
testb $0x1, %r12b
jne 0x137d1
movb %al, -0x29(%rbp)
movb %al, -0x2b(%rbp)
jmp 0x137eb
andw $0x0, -0x2a(%rbp)
jmp 0x137eb
movsbq %r12b, %rax
leaq 0x292a3(%rip), %rcx     # 0x3ca50
movq (%rcx,%rax,8), %r14
leal -0x1(%r15), %eax
andl $0x3, %eax
xorl %ecx, %ecx
movb %cl, -0x2c(%rbp,%rax)
andl $0x3, %r15d
xorq $0x2, %r15
movb %cl, -0x2c(%rbp,%r15)
movq -0x38(%rbp), %rdx
jmp 0x137eb
movb %al, -0x2a(%rbp)
movb %al, -0x2c(%rbp)
leaq 0x10a(%rip), %r14       # 0x138e8
jmp 0x137eb
leaq 0xeb(%rip), %r14        # 0x138d2
andl $0x0, -0x2c(%rbp)
leaq (%rdx,%rdx,8), %rax
leaq 0x134fa(%rip), %r15     # 0x26cf0
addq %rax, %r15
leal (%rbx,%rbx,2), %eax
leal (%r13,%r13,2), %ecx
cltq
imulq $0xe, %rax, %rax
movslq %ecx, %rcx
addq %rax, %rcx
leaq 0x2d2dc(%rip), %rax     # 0x40af0
leaq (%rcx,%rax), %r12
addq $0xf, %r12
xorl %eax, %eax
cmpq $0x3, %rax
je 0x13856
movq %rax, -0x38(%rbp)
movsbl %al, %ebx
xorl %r13d, %r13d
cmpq $0x3, %r13
je 0x13849
movsbl %r13b, %edi
movl %ebx, %esi
movq %r15, %rdx
callq *%r14
movb %al, (%r12,%r13)
incq %r13
jmp 0x1382e
movq -0x38(%rbp), %rax
incq %rax
addq $0xe, %r12
jmp 0x1381e
cmpb $0x1, -0x2c(%rbp)
movq -0x48(%rbp), %r15
movsbl %r15b, %r14d
jne 0x13878
movq -0x40(%rbp), %rax
decl %eax
movsbl %al, %esi
pushq $0x2
popq %rdx
movl %r14d, %edi
callq 0x1364b
cmpb $0x1, -0x2b(%rbp)
movsbl -0x40(%rbp), %ebx
jne 0x13893
leal 0x1(%r15), %eax
movsbl %al, %edi
pushq $0x3
popq %rdx
movl %ebx, %esi
callq 0x1364b
cmpb $0x1, -0x2a(%rbp)
jne 0x138ac
movq -0x40(%rbp), %rax
incl %eax
movsbl %al, %esi
movl %r14d, %edi
xorl %edx, %edx
callq 0x1364b
cmpb $0x1, -0x29(%rbp)
jne 0x138c3
leal -0x1(%r15), %eax
movsbl %al, %edi
pushq $0x1
popq %rdx
movl %ebx, %esi
callq 0x1364b
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq