// File: /workspace/github_c_makefile_star2_O1/ajpaulson[P]srogue11/new_leve.c
// Function: new_level
void new_level(int ltype)
{
	char ch;
	struct coord traploc;
	struct room *rp;

	if (level > max_level)
		max_level = level;

	wclear(cw);
	wclear(mw);
	clear();

	isfight = FALSE;
	levtype = ltype;

	free_list(mlist);			/* free monster list */

	if (levtype == POSTLEV)
		do_post();
	else {
		lev_mon();			/* fill in monster list */

		if (levtype == MAZELEV)
			do_maze();
		else {				/* normal levels */
			do_rooms();		/* Draw rooms */
			do_passages();		/* Draw passages */
		}
		no_food++;
		put_things();			/* Place objects (if any) */
	}
	/*
	 * Place the staircase down.
	 */
	stairs = *rnd_pos(&rooms[rnd_room()]);
	mvaddch(stairs.y, stairs.x, STAIRS);
	ntraps = 0;

	if (levtype == NORMLEV)
	{
		struct trap *trp, *maxtrp;

		/* Place the traps for normal levels only */

		if (rnd(10) < level)
		{
			ntraps = rnd(level / 4) + 1;

			if (ntraps > MAXTRAPS)
				ntraps = MAXTRAPS;

			maxtrp = &traps[ntraps];
			for (trp = &traps[0]; trp < maxtrp; trp++)
			{
again:
				switch(rnd(TYPETRAPS + 1))
				{
					case 0:
						if (rnd(100) > 25)
							goto again;
						else
							ch = POST;

					when 1: ch = TRAPDOOR;
					when 2: ch = BEARTRAP;
					when 3: ch = SLEEPTRAP;
					when 4: ch = ARROWTRAP;
					when 5: ch = TELTRAP;
					when 6: ch = DARTTRAP;
					when 7: ch = MAZETRAP;
					when 8:
					case 9:
						if (rnd(100) > 80)
							goto again;
						else
							ch = POOL;
				}
				trp->tr_flags = 0;
				traploc = *rnd_pos(&rooms[rnd_room()]);
				mvaddch(traploc.y,traploc.x,ch);
				trp->tr_type = ch;
				trp->tr_pos = traploc;

				if (ch == POOL || ch == POST)
					trp->tr_flags |= ISFOUND;

				if (ch==TELTRAP && rnd(100)<20 && trp<maxtrp-1)
				{
					struct coord newloc;

					newloc = *rnd_pos(&rooms[rnd_room()]);
					trp->tr_goto = newloc;
					trp++;
					trp->tr_goto = traploc;
					trp->tr_type = TELTRAP;
					trp->tr_pos = newloc;
					mvaddch(newloc.y, newloc.x, TELTRAP);
				}
				else
					trp->tr_goto = rndspot;
			}
		}
	}
	do
	{
		rp = &rooms[rnd_room()];
		hero = *rnd_pos(rp);
	} while(levtype==MAZELEV&&DISTANCE(hero.y,hero.x,stairs.y,stairs.x)<10);

	player.t_room = rp;
	player.t_oldch = mvinch(hero.y, hero.x);
	light(&hero);
	mvwaddch(cw,hero.y,hero.x,PLAYER);
	nochange = FALSE;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edi, %ebx
leaq 0x1ac81(%rip), %r14     # 0x2a2f0
movl (%r14), %eax
leaq 0x1ac83(%rip), %rcx     # 0x2a2fc
cmpl (%rcx), %eax
jle 0xf67f
movl %eax, (%rcx)
leaq 0x2135a(%rip), %rax     # 0x309e0
movq (%rax), %rdi
callq 0x6120
leaq 0x2135b(%rip), %rax     # 0x309f0
movq (%rax), %rdi
callq 0x6120
movq 0x1a88c(%rip), %r15     # 0x29f30
movq (%r15), %rdi
callq 0x6120
leaq 0x1e1e5(%rip), %rax     # 0x2d898
movb $0x0, (%rax)
leaq 0x1e1a7(%rip), %r12     # 0x2d864
movl %ebx, (%r12)
leaq 0x1e178(%rip), %rdi     # 0x2d840
callq 0xbe53
cmpl $0x1, (%r12)
jne 0xf6dd
xorl %eax, %eax
callq 0x1bae4
jmp 0xf710
xorl %eax, %eax
callq 0xd63b
cmpl $0x2, (%r12)
jne 0xf6f4
xorl %eax, %eax
callq 0x1c1fa
jmp 0xf702
xorl %eax, %eax
callq 0x13a94
xorl %eax, %eax
callq 0x10d94
leaq 0x1e177(%rip), %rax     # 0x2d880
incl (%rax)
callq 0xfa87
callq 0xfa3f
cltq
imulq $0x68, %rax, %rdi
addq 0x1a7ee(%rip), %rdi     # 0x29f10
callq 0x14063
movq (%rax), %rdx
leaq 0x20d3b(%rip), %r13     # 0x3046c
movq %rdx, (%r13)
movq (%r15), %rdi
movl 0x4(%r13), %esi
callq 0x6490
cmpl $-0x1, %eax
je 0xf753
movq (%r15), %rdi
movl $0x25, %esi
callq 0x64c0
leaq 0x1e70e(%rip), %rbx     # 0x2de68
movl $0x0, (%rbx)
cmpl $0x0, (%r12)
jne 0xf96b
movl $0xa, %edi
xorl %eax, %eax
callq 0xc72d
movl (%r14), %ecx
cmpl %ecx, %eax
jge 0xf96b
leal 0x3(%rcx), %edi
testl %ecx, %ecx
cmovnsl %ecx, %edi
sarl $0x2, %edi
xorl %eax, %eax
callq 0xc72d
cmpl $0x9, %eax
movl $0x9, %ecx
cmovll %eax, %ecx
incl %ecx
movl %ecx, (%rbx)
testl %eax, %eax
js 0xf96b
movslq %ecx, %rax
leaq (%rax,%rax,2), %rax
shlq $0x3, %rax
addq 0x1a803(%rip), %rax     # 0x29fc0
movq %rax, 0x10(%rsp)
addq $-0x18, %rax
movq %rax, 0x8(%rsp)
leaq 0x1e59e(%rip), %r12     # 0x2dd70
leaq 0x11be3(%rip), %r15     # 0x213bc
movl $0xa, %edi
xorl %eax, %eax
callq 0xc72d
cmpl $0x9, %eax
ja 0xf842
movl %eax, %eax
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
movl $0x64, %edi
xorl %eax, %eax
callq 0xc72d
cmpl $0x50, %eax
jg 0xf7d9
movb $0x22, %r14b
jmp 0xf842
movl $0x64, %edi
xorl %eax, %eax
callq 0xc72d
cmpl $0x19, %eax
jg 0xf7d9
movb $0x5e, %r14b
jmp 0xf842
movb $0x7d, %r14b
jmp 0xf842
movb $0x7e, %r14b
jmp 0xf842
movb $0x7b, %r14b
jmp 0xf842
movb $0x24, %r14b
jmp 0xf842
movb $0x3e, %r14b
jmp 0xf842
movb $0x60, %r14b
jmp 0xf842
movb $0x5c, %r14b
movl $0x0, 0x10(%r12)
callq 0xfa3f
cltq
imulq $0x68, %rax, %rdi
addq 0x1a6b3(%rip), %rdi     # 0x29f10
callq 0x14063
movl (%rax), %ebx
movl 0x4(%rax), %ebp
movq 0x1a6c2(%rip), %r13     # 0x29f30
movq (%r13), %rdi
movl %ebp, %esi
movl %ebx, %edx
callq 0x6490
cmpl $-0x1, %eax
je 0xf88d
movq (%r13), %rdi
movsbl %r14b, %esi
callq 0x64c0
movb %r14b, 0x14(%r12)
movl %ebx, (%r12)
movl %ebp, 0x4(%r12)
cmpb $0x22, %r14b
je 0xf8b3
movzbl %r14b, %eax
cmpl $0x7e, %eax
je 0xf8c3
cmpl $0x5e, %eax
jne 0xf946
orb $0x8, 0x10(%r12)
cmpb $0x7e, %r14b
jne 0xf946
movl $0x64, %edi
xorl %eax, %eax
callq 0xc72d
cmpl $0x13, %eax
jg 0xf946
cmpq 0x8(%rsp), %r12
jae 0xf946
callq 0xfa3f
cltq
imulq $0x68, %rax, %rdi
addq 0x1a623(%rip), %rdi     # 0x29f10
callq 0x14063
movl (%rax), %edx
movl 0x4(%rax), %esi
movl %edx, 0x8(%r12)
movl %esi, 0xc(%r12)
leaq 0x18(%r12), %r13
movl %ebx, 0x20(%r12)
movl %ebp, 0x24(%r12)
movb $0x7e, 0x2c(%r12)
movl %edx, 0x18(%r12)
movl %esi, 0x1c(%r12)
movq 0x1a609(%rip), %rbx     # 0x29f30
movq (%rbx), %rdi
callq 0x6490
cmpl $-0x1, %eax
je 0xf941
movq (%rbx), %rdi
movl $0x7e, %esi
callq 0x64c0
movq %r13, %r12
jmp 0xf955
leaq 0x1aa63(%rip), %rax     # 0x2a3b0
movq (%rax), %rax
movq %rax, 0x8(%r12)
leaq 0x20b10(%rip), %r13     # 0x3046c
addq $0x18, %r12
cmpq 0x10(%rsp), %r12
jb 0xf7d9
leaq 0x1df3e(%rip), %r15     # 0x2d8b0
leaq 0x1e2e7(%rip), %r14     # 0x2dc60
leaq 0x1dee4(%rip), %r12     # 0x2d864
callq 0xfa3f
cltq
imulq $0x68, %rax, %rbx
addq %r15, %rbx
movq %rbx, %rdi
callq 0x14063
movq (%rax), %rax
movq %rax, 0x50(%r14)
cmpl $0x2, (%r12)
jne 0xf9c1
movl (%r13), %eax
movl 0x4(%r13), %ecx
subl 0x50(%r14), %eax
subl 0x54(%r14), %ecx
imull %eax, %eax
imull %ecx, %ecx
addl %eax, %ecx
cmpl $0xa, %ecx
jb 0xf980
movq %rbx, 0x70(%r14)
movq 0x1a564(%rip), %rbx     # 0x29f30
movq (%rbx), %rdi
movl 0x50(%r14), %edx
movl 0x54(%r14), %esi
callq 0x6490
cmpl $-0x1, %eax
je 0xf9eb
movq (%rbx), %rdi
callq 0x6330
jmp 0xf9ed
movb $-0x1, %al
leaq 0x20fec(%rip), %rbx     # 0x309e0
movb %al, 0x8f(%r14)
leaq 0x50(%r14), %rdi
callq 0xecbc
movq (%rbx), %rdi
movl 0x50(%r14), %edx
movl 0x54(%r14), %esi
callq 0x6490
cmpl $-0x1, %eax
je 0xfa26
movq (%rbx), %rdi
movl $0x40, %esi
callq 0x64c0
leaq 0x1de76(%rip), %rax     # 0x2d8a3
movb $0x0, (%rax)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq