// File: /workspace/github_c_makefile_star2_O1/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 0x1ddaf(%rip), %rdi     # 0x2d848
callq 0xbe53
leaq 0x1a84b(%rip), %rax     # 0x2a2f0
movl (%rax), %eax
leaq 0x1a84e(%rip), %rcx     # 0x2a2fc
cmpl (%rcx), %eax
jl 0xfcfd
leaq 0x1dda7(%rip), %r15     # 0x2d864
xorl %r12d, %r12d
movl $0x64, %edi
xorl %eax, %eax
callq 0xc72d
cmpl $0x27, %eax
jg 0xfb6f
xorl %edi, %edi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x1b715
movq %rax, %r14
leaq 0x1dd58(%rip), %rdi     # 0x2d848
movq %rax, %rsi
callq 0xbe2d
movq 0x10(%r14), %r13
movl $0x1f5, %ebp            # imm = 0x1F5
callq 0xfa3f
movslq %eax, %r14
decl %ebp
je 0xfb2c
imulq $0x68, %r14, %rdi
addq 0x1a3f8(%rip), %rdi     # 0x29f10
movl $0x4, %esi
callq 0x13e74
testl %eax, %eax
je 0xfb2c
cmpl $0x2, (%r15)
jne 0xfb01
imulq $0x68, %r14, %rdi
addq 0x1a3d9(%rip), %rdi     # 0x29f10
callq 0x14063
movl (%rax), %ebp
movl 0x4(%rax), %r14d
movq 0x1a3e7(%rip), %rbx     # 0x29f30
movq (%rbx), %rdi
movl %r14d, %esi
movl %ebp, %edx
callq 0x6490
cmpl $-0x1, %eax
je 0xfb67
movq (%rbx), %rdi
movl 0x20(%r13), %esi
callq 0x64c0
movl %ebp, (%r13)
movl %r14d, 0x4(%r13)
incl %r12d
cmpl $0x9, %r12d
jne 0xfac0
leaq 0x1a76d(%rip), %rax     # 0x2a2f0
cmpl $0x23, (%rax)
jl 0xfc14
leaq 0x1dd0e(%rip), %rax     # 0x2d8a1
cmpb $0x0, (%rax)
jne 0xfc14
movl $0x64, %edi
xorl %eax, %eax
callq 0xc72d
cmpl $0x45, %eax
jg 0xfc14
xorl %edi, %edi
movl $0x2c, %esi
xorl %edx, %edx
callq 0x1b715
movq %rax, %rbx
leaq 0x1dc87(%rip), %rdi     # 0x2d848
movq %rax, %rsi
callq 0xbe2d
movq 0x10(%rbx), %r14
callq 0xfa3f
cltq
imulq $0x68, %rax, %rdi
addq 0x1a331(%rip), %rdi     # 0x29f10
callq 0x14063
movl (%rax), %ebx
movl 0x4(%rax), %ebp
movq 0x1a340(%rip), %r15     # 0x29f30
movq (%r15), %rdi
movl %ebp, %esi
movl %ebx, %edx
callq 0x6490
cmpl $-0x1, %eax
je 0xfc0d
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 0x1a2eb(%rip), %r14     # 0x29f10
movl $0x4, %esi
movq %r14, %rdi
callq 0x13e74
testl %eax, %eax
je 0xfcec
leaq 0x1a6af(%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 0xc72d
cmpl $-0x6, %eax
jl 0xfcec
movl %eax, %r15d
addl $0x5, %r15d
movl $0x1, %edi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x1b715
movq 0x10(%rax), %rbx
cmpl $0x3a, 0x20(%rbx)
jne 0xfc97
movq %rax, %rdi
callq 0xbe93
jmp 0xfc6f
leaq 0x1dbaa(%rip), %rdi     # 0x2d848
movq %rax, %rsi
callq 0xbe2d
movq %r14, %rdi
callq 0x14063
movl (%rax), %ebp
movl 0x4(%rax), %r12d
movq 0x1a275(%rip), %r13     # 0x29f30
movq (%r13), %rdi
movl %r12d, %esi
movl %ebp, %edx
callq 0x6490
cmpl $-0x1, %eax
je 0xfcda
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 0xfc6f
movq (%rsp), %rax
incq %rax
cmpq $0x9, %rax
jne 0xfc16
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop