// File: /workspace/github_c_makefile_star2_O2/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
subq $0x18, %rsp
leaq 0x1e89d(%rip), %rdi     # 0x2d838
callq 0xb83c
leaq 0x1b339(%rip), %rax     # 0x2a2e0
movl (%rax), %eax
leaq 0x1b33c(%rip), %rcx     # 0x2a2ec
cmpl (%rcx), %eax
jge 0xefc5
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x64
popq %rbp
pushq $0x4
popq %r15
leaq 0x1e881(%rip), %r14     # 0x2d854
xorl %ebx, %ebx
cmpl $0x9, %ebx
je 0xf098
movl %ebp, %edi
xorl %eax, %eax
callq 0xc004
cmpl $0x27, %eax
jg 0xf091
xorl %edi, %edi
pushq $-0x1
popq %rdx
movl %edx, %esi
callq 0x19c8f
movq %rax, %r12
leaq 0x1e832(%rip), %rdi     # 0x2d838
movq %rax, %rsi
callq 0xb81b
movq 0x10(%r12), %rbp
movl $0x1f5, %r12d           # imm = 0x1F5
callq 0xef36
movslq %eax, %r13
decl %r12d
je 0xf043
imulq $0x68, %r13, %rdi
addq 0x1aedf(%rip), %rdi     # 0x29f10
movq %r15, %rsi
callq 0x12f50
testl %eax, %eax
je 0xf043
cmpl $0x2, (%r14)
jne 0xf019
imulq $0x68, %r13, %rdi
addq 0x1aec2(%rip), %rdi     # 0x29f10
callq 0x1310e
movl (%rax), %r12d
movl 0x4(%rax), %r13d
movq 0x1aed7(%rip), %rax     # 0x29f38
movq (%rax), %rdi
movl %r13d, %esi
movl %r12d, %edx
callq 0x6470
cmpl $-0x1, %eax
je 0xf086
movq 0x1aebd(%rip), %rax     # 0x29f38
movq (%rax), %rdi
movl 0x20(%rbp), %esi
callq 0x64a0
movl %r12d, (%rbp)
movl %r13d, 0x4(%rbp)
pushq $0x64
popq %rbp
incl %ebx
jmp 0xefd5
leaq 0x1b241(%rip), %rax     # 0x2a2e0
cmpl $0x23, (%rax)
jl 0xf12c
leaq 0x1e7e2(%rip), %rax     # 0x2d891
cmpb $0x0, (%rax)
jne 0xf12c
pushq $0x64
popq %rdi
xorl %eax, %eax
callq 0xc004
cmpl $0x45, %eax
jg 0xf12c
pushq $0x2c
popq %rsi
xorl %edi, %edi
xorl %edx, %edx
callq 0x19c8f
movq %rax, %rbx
leaq 0x1e75f(%rip), %rdi     # 0x2d838
movq %rax, %rsi
callq 0xb81b
movq 0x10(%rbx), %r14
callq 0xef36
cltq
imulq $0x68, %rax, %rdi
addq 0x1ae19(%rip), %rdi     # 0x29f10
callq 0x1310e
movl (%rax), %ebx
movl 0x4(%rax), %ebp
movq 0x1ae30(%rip), %r15     # 0x29f38
movq (%r15), %rdi
movl %ebp, %esi
movl %ebx, %edx
callq 0x6470
cmpl $-0x1, %eax
je 0xf125
movq (%r15), %rdi
movl 0x20(%r14), %esi
callq 0x64a0
movl %ebx, (%r14)
movl %ebp, 0x4(%r14)
pushq $0x1
popq %rbp
pushq $-0x1
popq %r14
xorl %eax, %eax
cmpq $0x9, %rax
je 0xefb4
movq %rax, 0x8(%rsp)
imulq $0x68, %rax, %rdi
addq 0x1adc1(%rip), %rdi     # 0x29f10
movq %rdi, 0x10(%rsp)
pushq $0x4
popq %rsi
callq 0x12f50
testl %eax, %eax
je 0xf209
leaq 0x1b175(%rip), %rax     # 0x2a2e0
movl (%rax), %eax
cltd
pushq $0x3
popq %rcx
idivl %ecx
movl %eax, %edi
xorl %eax, %eax
callq 0xc004
addl $0x6, %eax
testl %eax, %eax
js 0xf209
decl %eax
movl %eax, 0x4(%rsp)
movl %ebp, %edi
movl %r14d, %esi
movl %r14d, %edx
callq 0x19c8f
movq 0x10(%rax), %r12
cmpl $0x3a, 0x20(%r12)
jne 0xf1b0
movq %rax, %rdi
callq 0xb857
jmp 0xf18d
leaq 0x1e681(%rip), %rdi     # 0x2d838
movq %rax, %rsi
callq 0xb81b
movq 0x10(%rsp), %rdi
callq 0x1310e
movl (%rax), %ebx
movl 0x4(%rax), %r15d
movq 0x1ad62(%rip), %r13     # 0x29f38
movq (%r13), %rdi
movl %r15d, %esi
movl %ebx, %edx
callq 0x6470
cmpl $-0x1, %eax
je 0xf1f7
movq (%r13), %rdi
movl 0x20(%r12), %esi
callq 0x64a0
movl %ebx, (%r12)
movl %r15d, 0x4(%r12)
movl 0x4(%rsp), %eax
jmp 0xf17f
movq 0x8(%rsp), %rax
incq %rax
jmp 0xf135
nop