// File: /workspace/github_c_makefile_star2_O3/ajpaulson[P]srogue11/new_leve.c
// Function: put_things
int put_things()
{
	int i, cnt, rm;
	struct linked_list *item;
	struct object *cur;
	struct coord tp;

	/* Throw away stuff left on the previous level (if anything) */

	free_list(lvl_obj);

	/* The only way to get new stuff is to go down into the dungeon. */

	if (goingup())
		return 0;

	/* Do MAXOBJ attempts to put things on a level */

	for (i = 0; i < MAXOBJ; i++)
	{
		if (rnd(100) < 40)
		{
			item = new_thing(FALSE, ANYTHING);
			attach(lvl_obj, item);
			cur = OBJPTR(item);
			cnt = 0;
			do {
				/* skip treasure rooms */
				rm = rnd_room();
				if (++cnt > 500)
					break;
			} while(rf_on(&rooms[rm],ISTREAS) && levtype!=MAZELEV);

			tp = *rnd_pos(&rooms[rm]);
			mvaddch(tp.y, tp.x, cur->o_type);
			cur->o_pos = tp;
		}
	}
	/*
	 * If he is really deep in the dungeon and he hasn't found the
	 * amulet yet, put it somewhere on the ground
	 */
	if (level >= AMLEVEL && !amulet && rnd(100) < 70)
	{
		item = new_thing(FALSE, AMULET, 0);
		attach(lvl_obj, item);
		cur = OBJPTR(item);
		rm = rnd_room();
		tp = *rnd_pos(&rooms[rm]);
		mvaddch(tp.y, tp.x, cur->o_type);
		cur->o_pos = tp;
	}

	for (i = 0; i < MAXROOMS; i++)		/* loop through all */
	{
		if (rf_on(&rooms[i],ISTREAS))	/* treasure rooms */
		{
			int numthgs, isfood;

			numthgs = rnd(level / 3) + 6;
			while (numthgs-- >= 0)
			{
				isfood = TRUE;
				do {
					item = new_thing(TRUE, ANYTHING);
					cur = OBJPTR(item);

					/* dont create food for */
					if (cur->o_type == FOOD)
						discard(item);

					/* treasure rooms */
					else
						isfood = FALSE;

				} while (isfood);

				attach(lvl_obj, item);
				tp = *rnd_pos(&rooms[i]);
				mvaddch(tp.y, tp.x, cur->o_type);
				cur->o_pos = tp;
			}
		}
	}
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0x1dedb(%rip), %rdi     # 0x2d848
callq 0xbd9a
leaq 0x1a977(%rip), %rax     # 0x2a2f0
movl (%rax), %eax
leaq 0x1a97a(%rip), %rcx     # 0x2a2fc
cmpl (%rcx), %eax
jl 0xfbd1
leaq 0x1ded3(%rip), %r15     # 0x2d864
xorl %r12d, %r12d
movl $0x64, %edi
xorl %eax, %eax
callq 0xc674
cmpl $0x27, %eax
jg 0xfa43
xorl %edi, %edi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x1b640
movq %rax, %r14
leaq 0x1de84(%rip), %rdi     # 0x2d848
movq %rax, %rsi
callq 0xbd73
movq 0x10(%r14), %r13
movl $0x1f5, %ebp            # imm = 0x1F5
callq 0xf913
movslq %eax, %r14
decl %ebp
je 0xfa00
imulq $0x68, %r14, %rdi
addq 0x1a524(%rip), %rdi     # 0x29f10
movl $0x4, %esi
callq 0x13d18
testl %eax, %eax
je 0xfa00
cmpl $0x2, (%r15)
jne 0xf9d5
imulq $0x68, %r14, %rdi
addq 0x1a505(%rip), %rdi     # 0x29f10
callq 0x13f09
movl (%rax), %ebp
movl 0x4(%rax), %r14d
movq 0x1a513(%rip), %rbx     # 0x29f30
movq (%rbx), %rdi
movl %r14d, %esi
movl %ebp, %edx
callq 0x6490
cmpl $-0x1, %eax
je 0xfa3b
movq (%rbx), %rdi
movl 0x20(%r13), %esi
callq 0x64c0
movl %ebp, (%r13)
movl %r14d, 0x4(%r13)
incl %r12d
cmpl $0x9, %r12d
jne 0xf994
leaq 0x1a899(%rip), %rax     # 0x2a2f0
cmpl $0x23, (%rax)
jl 0xfae8
leaq 0x1de3a(%rip), %rax     # 0x2d8a1
cmpb $0x0, (%rax)
jne 0xfae8
movl $0x64, %edi
xorl %eax, %eax
callq 0xc674
cmpl $0x45, %eax
jg 0xfae8
xorl %edi, %edi
movl $0x2c, %esi
xorl %edx, %edx
callq 0x1b640
movq %rax, %rbx
leaq 0x1ddb3(%rip), %rdi     # 0x2d848
movq %rax, %rsi
callq 0xbd73
movq 0x10(%rbx), %r14
callq 0xf913
cltq
imulq $0x68, %rax, %rdi
addq 0x1a45d(%rip), %rdi     # 0x29f10
callq 0x13f09
movl (%rax), %ebx
movl 0x4(%rax), %ebp
movq 0x1a46c(%rip), %r15     # 0x29f30
movq (%r15), %rdi
movl %ebp, %esi
movl %ebx, %edx
callq 0x6490
cmpl $-0x1, %eax
je 0xfae1
movq (%r15), %rdi
movl 0x20(%r14), %esi
callq 0x64c0
movl %ebx, (%r14)
movl %ebp, 0x4(%r14)
xorl %eax, %eax
movq %rax, (%rsp)
imulq $0x68, %rax, %r14
addq 0x1a417(%rip), %r14     # 0x29f10
movl $0x4, %esi
movq %r14, %rdi
callq 0x13d18
testl %eax, %eax
je 0xfbc0
leaq 0x1a7db(%rip), %rax     # 0x2a2f0
movslq (%rax), %rax
imulq $0x55555556, %rax, %rdi # imm = 0x55555556
movq %rdi, %rax
shrq $0x3f, %rax
shrq $0x20, %rdi
addl %eax, %edi
xorl %eax, %eax
callq 0xc674
cmpl $-0x6, %eax
jl 0xfbc0
movl %eax, %r15d
addl $0x5, %r15d
movl $0x1, %edi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x1b640
movq 0x10(%rax), %rbx
cmpl $0x3a, 0x20(%rbx)
jne 0xfb6b
movq %rax, %rdi
callq 0xbdda
jmp 0xfb43
leaq 0x1dcd6(%rip), %rdi     # 0x2d848
movq %rax, %rsi
callq 0xbd73
movq %r14, %rdi
callq 0x13f09
movl (%rax), %ebp
movl 0x4(%rax), %r12d
movq 0x1a3a1(%rip), %r13     # 0x29f30
movq (%r13), %rdi
movl %r12d, %esi
movl %ebp, %edx
callq 0x6490
cmpl $-0x1, %eax
je 0xfbae
movq (%r13), %rdi
movl 0x20(%rbx), %esi
callq 0x64c0
movl %ebp, (%rbx)
movl %r12d, 0x4(%rbx)
leal -0x1(%r15), %eax
testl %r15d, %r15d
movl %eax, %r15d
jns 0xfb43
movq (%rsp), %rax
incq %rax
cmpq $0x9, %rax
jne 0xfaea
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop