// File: /workspace/github_cpp_makefile_star2_O1/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
movslq %esi, %r13
movslq %edi, %r15
leaq (%r15,%r13,4), %rcx
leaq 0x2b636(%rip), %rax     # 0x43bd0
cmpb $0x0, (%rax,%rcx)
jne 0x18823
movl %edx, %r12d
movl %esi, %ebx
movq %rdi, -0x38(%rbp)
movq %r13, %rcx
shlq $0x2, %rcx
addq %r15, %rcx
movb $0x1, (%rax,%rcx)
testb %r12b, %r12b
setne %al
testb %r13b, %r13b
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
cmpb $0x3, %r13b
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 0x18646
callq 0x41d0
movabsq $-0x3333333333333333, %rcx # imm = 0xCCCCCCCCCCCCCCCD
imulq %rax, %rcx
movabsq $0x1999999999999999, %rax # imm = 0x1999999999999999
addq %rcx, %rax
movabsq $0x3333333333333332, %rcx # imm = 0x3333333333333332
xorl %edx, %edx
cmpq %rcx, %rax
seta %dl
leaq (%rdx,%rdx,4), %r14
addq $0x2, %r14
jmp 0x1864c
movl $0x2, %r14d
callq 0x41d0
cqto
idivq %r14
leaq 0x1d5(%rip), %r14       # 0x18832
leal -0x1(%rdx), %eax
cmpl $0x5, %eax
movq %r15, -0x50(%rbp)
movq %r13, -0x48(%rbp)
ja 0x1873e
leaq 0x14504(%rip), %rcx     # 0x2cb7c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpb $-0x1, %r12b
je 0x186ea
movq %rdx, -0x40(%rbp)
movzbl %r12b, %r15d
callq 0x41d0
testb $0x1, %al
jne 0x186f2
leal -0x1(%r15), %eax
andl $0x3, %eax
leaq 0x2739a(%rip), %rcx     # 0x3fa40
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 0x18716
cmpb $-0x1, %r12b
je 0x18730
movsbq %r12b, %rax
leaq 0x2736c(%rip), %rcx     # 0x3fa40
movq (%rcx,%rax,8), %r14
jmp 0x18737
xorl %eax, %eax
testb $0x1, %r12b
jne 0x18721
movb %al, -0x29(%rbp)
movb %al, -0x2b(%rbp)
jmp 0x1873e
movw $0x0, -0x2a(%rbp)
jmp 0x1873e
movsbq %r12b, %rax
leaq 0x27343(%rip), %rcx     # 0x3fa40
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 -0x40(%rbp), %rdx
jmp 0x1873e
movb %al, -0x2a(%rbp)
movb %al, -0x2c(%rbp)
leaq 0x11a(%rip), %r14       # 0x18848
jmp 0x1873e
leaq 0xfb(%rip), %r14        # 0x18832
movl $0x0, -0x2c(%rbp)
leaq (%rdx,%rdx,8), %rax
leaq 0x14577(%rip), %r15     # 0x2ccc0
addq %rax, %r15
leal (%rbx,%rbx,2), %eax
movq -0x38(%rbp), %rcx
leal (%rcx,%rcx,2), %ecx
cltq
leaq (%rax,%rax), %rdx
shlq $0x4, %rax
subq %rdx, %rax
movslq %ecx, %rcx
addq %rax, %rcx
leaq 0x2b390(%rip), %rax     # 0x43b00
leaq (%rcx,%rax), %r12
addq $0xf, %r12
xorl %eax, %eax
movq %rax, -0x38(%rbp)
movsbl %al, %ebx
xorl %r13d, %r13d
movsbl %r13b, %edi
movl %ebx, %esi
movq %r15, %rdx
callq *%r14
movb %al, (%r12,%r13)
incq %r13
cmpq $0x3, %r13
jne 0x18784
movq -0x38(%rbp), %rax
incq %rax
addq $0xe, %r12
cmpq $0x3, %rax
jne 0x1877a
cmpb $0x1, -0x2c(%rbp)
movq -0x50(%rbp), %r15
movsbl %r15b, %r14d
movq -0x48(%rbp), %r12
jne 0x187d5
leal -0x1(%r12), %eax
movsbl %al, %esi
movl %r14d, %edi
movl $0x2, %edx
callq 0x18578
cmpb $0x1, -0x2b(%rbp)
movsbl %r12b, %ebx
jne 0x187f2
leal 0x1(%r15), %eax
movsbl %al, %edi
movl %ebx, %esi
movl $0x3, %edx
callq 0x18578
cmpb $0x1, -0x2a(%rbp)
jne 0x1880a
leal 0x1(%r12), %eax
movsbl %al, %esi
movl %r14d, %edi
xorl %edx, %edx
callq 0x18578
cmpb $0x1, -0x29(%rbp)
jne 0x18823
leal -0x1(%r15), %eax
movsbl %al, %edi
movl %ebx, %esi
movl $0x1, %edx
callq 0x18578
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq