// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x20, %rsp
leaq 0x21201(%rip), %rax     # 0x36400
movq %rax, -0x8(%rbp)
leaq 0x211f6(%rip), %rax     # 0x36400
addq $0xab, %rax
cmpq %rax, -0x8(%rbp)
jae 0x15251
movl $0x0, -0x18(%rbp)
cmpl $0x9, -0x18(%rbp)
jge 0x1523b
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movb $0x0, 0x9(%rax,%rcx)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x1521d
movq -0x8(%rbp), %rax
movb $0x0, 0x12(%rax)
movq -0x8(%rbp), %rax
addq $0x13, %rax
movq %rax, -0x8(%rbp)
jmp 0x15203
movl $0x1, -0x1c(%rbp)
movl $0x9, %edi
movb $0x0, %al
callq 0xef20
movslq %eax, %rcx
leaq 0x21192(%rip), %rax     # 0x36400
imulq $0x13, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
movb $0x1, 0x12(%rax)
movl $0x0, -0x18(%rbp)
movl $0x0, -0x14(%rbp)
cmpl $0x9, -0x14(%rbp)
jge 0x152f3
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
testb $0x1, (%rax,%rcx)
je 0x152e6
movslq -0x14(%rbp), %rcx
leaq 0x21152(%rip), %rax     # 0x36400
imulq $0x13, %rcx, %rcx
addq %rcx, %rax
testb $0x1, 0x12(%rax)
jne 0x152e6
movl -0x18(%rbp), %edi
addl $0x1, %edi
movl %edi, -0x18(%rbp)
movb $0x0, %al
callq 0xef20
cmpl $0x0, %eax
jne 0x152e6
movslq -0x14(%rbp), %rcx
leaq 0x21125(%rip), %rax     # 0x36400
imulq $0x13, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
jmp 0x152e8
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1528f
cmpl $0x0, -0x18(%rbp)
jne 0x1532b
jmp 0x152fb
movl $0x9, %edi
movb $0x0, %al
callq 0xef20
movslq %eax, %rcx
leaq 0x210ef(%rip), %rax     # 0x36400
imulq $0x13, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
movb 0x12(%rax), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x152fb
jmp 0x15397
movq -0x10(%rbp), %rax
movb $0x1, 0x12(%rax)
movq -0x8(%rbp), %rax
leaq 0x210c2(%rip), %rcx     # 0x36400
subq %rcx, %rax
movl $0x13, %ecx
cqto
idivq %rcx
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
leaq 0x210a7(%rip), %rcx     # 0x36400
subq %rcx, %rax
movl $0x13, %ecx
cqto
idivq %rcx
movl %eax, -0x18(%rbp)
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
callq 0x154c0
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movb $0x1, 0x9(%rax,%rcx)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movb $0x1, 0x9(%rax,%rcx)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x15399
cmpl $0x9, -0x1c(%rbp)
jl 0x15281
movl $0x5, %edi
movb $0x0, %al
callq 0xef20
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jle 0x154b7
movl $0x9, %edi
movb $0x0, %al
callq 0xef20
movslq %eax, %rcx
leaq 0x2102e(%rip), %rax     # 0x36400
imulq $0x13, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x8(%rbp)
movl $0x0, -0x18(%rbp)
movl $0x0, -0x14(%rbp)
cmpl $0x9, -0x14(%rbp)
jge 0x15446
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
testb $0x1, (%rax,%rcx)
je 0x15439
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
testb $0x1, 0x9(%rax,%rcx)
jne 0x15439
movl -0x18(%rbp), %edi
addl $0x1, %edi
movl %edi, -0x18(%rbp)
movb $0x0, %al
callq 0xef20
cmpl $0x0, %eax
jne 0x15439
movslq -0x14(%rbp), %rcx
leaq 0x20fd2(%rip), %rax     # 0x36400
imulq $0x13, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
jmp 0x1543b
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x153eb
cmpl $0x0, -0x18(%rbp)
je 0x154a7
movq -0x8(%rbp), %rax
leaq 0x20fa9(%rip), %rcx     # 0x36400
subq %rcx, %rax
movl $0x13, %ecx
cqto
idivq %rcx
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
leaq 0x20f8e(%rip), %rcx     # 0x36400
subq %rcx, %rax
movl $0x13, %ecx
cqto
idivq %rcx
movl %eax, -0x18(%rbp)
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
callq 0x154c0
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movb $0x1, 0x9(%rax,%rcx)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movb $0x1, 0x9(%rax,%rcx)
jmp 0x154a9
movl -0x1c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x153b2
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)