// File: /workspace/github_c_makefile_star2_O1/ajpaulson[P]srogue11/passages.c
// Function: do_passages
void do_passages()
{
	struct rdes *r1, *r2;
	int i, j;
	int roomcount;
	static struct rdes {
		bool conn[MAXROOMS];		/* possible to connect to room i */
		bool isconn[MAXROOMS];		/* connection was made to room i */
		bool	ingraph;			/* this room in graph already? */
	} rdes[MAXROOMS] = {
		{{ 0, 1, 0, 1, 0, 0, 0, 0, 0 },{ 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 },
		{{ 1, 0, 1, 0, 1, 0, 0, 0, 0 },{ 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 },
		{{ 0, 1, 0, 0, 0, 1, 0, 0, 0 },{ 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 },
		{{ 1, 0, 0, 0, 1, 0, 1, 0, 0 },{ 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 },
		{{ 0, 1, 0, 1, 0, 1, 0, 1, 0 },{ 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 },
		{{ 0, 0, 1, 0, 1, 0, 0, 0, 1 },{ 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 },
		{{ 0, 0, 0, 1, 0, 0, 0, 1, 0 },{ 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 },
		{{ 0, 0, 0, 0, 1, 0, 1, 0, 1 },{ 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 },
		{{ 0, 0, 0, 0, 0, 1, 0, 1, 0 },{ 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 },
	};

	/*
	 * reinitialize room graph description
	 */
	for (r1 = rdes; r1 < &rdes[MAXROOMS]; r1++) {
		for (j = 0; j < MAXROOMS; j++)
			r1->isconn[j] = FALSE;
		r1->ingraph = FALSE;
	}

	/*
	 * starting with one room, connect it to a random adjacent room and
	 * then pick a new room to start with.
	 */
	roomcount = 1;
	r1 = &rdes[rnd(MAXROOMS)];
	r1->ingraph = TRUE;
	do {
		/*
		 * find a room to connect with
		 */
		j = 0;
		for (i = 0; i < MAXROOMS; i++)
			if (r1->conn[i] && !rdes[i].ingraph && rnd(++j) == 0)
				r2 = &rdes[i];
		/*
		 * if no adjacent rooms are outside the graph, pick a new room
		 * to look from
		 */
		if (j == 0) {
			do {
				r1 = &rdes[rnd(MAXROOMS)];
			} until (r1->ingraph);
		}
		/*
		 * otherwise, connect new room to the graph, and draw a tunnel
		 * to it
		 */
		else {
			r2->ingraph = TRUE;
			i = r1 - rdes;
			j = r2 - rdes;
			conn(i, j);
			r1->isconn[j] = TRUE;
			r2->isconn[i] = TRUE;
			roomcount++;
		}
	} while (roomcount < MAXROOMS);

	/*
	 * attempt to add passages to the graph a random number of times so
	 * that there isn't just one unique passage through it.
	 */
	for (roomcount = rnd(5); roomcount > 0; roomcount--) {
		r1 = &rdes[rnd(MAXROOMS)];	/* a random room to look from */
		/*
		 * find an adjacent room not already connected
		 */
		j = 0;
		for (i = 0; i < MAXROOMS; i++)
			if (r1->conn[i] && !r1->isconn[i] && rnd(++j) == 0)
				r2 = &rdes[i];
		/*
		 * if there is one, connect it and look for the next added
		 * passage
		 */
		if (j != 0) {
			i = r1 - rdes;
			j = r2 - rdes;
			conn(i, j);
			r1->isconn[j] = TRUE;
			r2->isconn[i] = TRUE;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl $0x12, %eax
leaq 0x1c655(%rip), %r15     # 0x2d400
movq $0x0, -0x9(%rax,%r15)
movw $0x0, -0x1(%rax,%r15)
addq $0x13, %rax
cmpq $0xbd, %rax
jne 0x10dab
movl $0x9, %edi
xorl %eax, %eax
callq 0xc72d
cltq
leaq (%rax,%rax,8), %rcx
leaq (%rax,%rcx,2), %rax
leaq (%r15,%rax), %rbx
movb $0x1, 0x12(%r15,%rax)
movl $0x1, %ebp
movl %ebp, (%rsp)
movq %r15, %r12
xorl %ebp, %ebp
xorl %r14d, %r14d
cmpb $0x1, (%rbx,%rbp)
jne 0x10e19
cmpb $0x0, 0x12(%r12)
jne 0x10e19
incl %r14d
movl %r14d, %edi
xorl %eax, %eax
callq 0xc72d
testl %eax, %eax
cmoveq %r12, %r13
incq %rbp
addq $0x13, %r12
cmpq $0x9, %rbp
jne 0x10df8
testl %r14d, %r14d
je 0x10e72
movb $0x1, %bpl
movb %bpl, 0x12(%r13)
movq %rbx, %r12
subq %r15, %r12
movabsq $-0x79435e50d79435e5, %rax # imm = 0x86BCA1AF286BCA1B
imulq %rax, %r12
movq %r13, %r14
subq %r15, %r14
imulq %rax, %r14
movl %r12d, %edi
movl %r14d, %esi
callq 0x10f61
movslq %r14d, %rax
movb %bpl, 0x9(%rbx,%rax)
movslq %r12d, %rax
movb %bpl, 0x9(%r13,%rax)
movl (%rsp), %ebp
incl %ebp
jmp 0x10e96
movl (%rsp), %ebp
movl $0x9, %edi
xorl %eax, %eax
callq 0xc72d
cltq
leaq (%rax,%rax,8), %rcx
leaq (%rax,%rcx,2), %rbx
cmpb $0x0, 0x12(%r15,%rbx)
je 0x10e75
addq %r15, %rbx
cmpl $0x9, %ebp
jl 0x10ded
movl $0x5, %edi
xorl %eax, %eax
callq 0xc72d
testl %eax, %eax
jle 0x10f52
movq %rax, (%rsp)
movl $0x9, %edi
xorl %eax, %eax
callq 0xc72d
movslq %eax, %r14
leaq (%r14,%r14,8), %rax
leaq (%r14,%rax,2), %r12
leaq 0x1c52b(%rip), %r15     # 0x2d400
addq %r15, %r12
xorl %ebx, %ebx
xorl %ebp, %ebp
cmpb $0x1, (%r12,%rbx)
jne 0x10efc
cmpb $0x0, 0x9(%r12,%rbx)
jne 0x10efc
incl %ebp
movl %ebp, %edi
xorl %eax, %eax
callq 0xc72d
testl %eax, %eax
cmoveq %r15, %r13
incq %rbx
addq $0x13, %r15
cmpq $0x9, %rbx
jne 0x10edc
testl %ebp, %ebp
je 0x10f42
movq %r13, %r15
leaq 0x1c4e9(%rip), %rax     # 0x2d400
subq %rax, %r15
movabsq $-0x79435e50d79435e5, %rax # imm = 0x86BCA1AF286BCA1B
imulq %rax, %r15
movl %r14d, %edi
movl %r15d, %esi
callq 0x10f61
movslq %r15d, %rax
movb $0x1, %cl
movb %cl, 0x9(%r12,%rax)
movb %cl, 0x9(%r13,%r14)
movq (%rsp), %rcx
leal -0x1(%rcx), %eax
cmpl $0x1, %ecx
jg 0x10eb3
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq