// File: malcolmyeh[P]CC3K/floor.cc
// Function: Floor::initNext(char, int, int, int, int, bool)
void Floor::initNext(char type, int HP, int gold, int Atk, int Def, bool hasBarrier) {
	int id;
	int dragons = 0;
	srand(time(NULL));
	generateChamber();

	id = rand() % 5 + 1;
	Chamber *c = chambers.at(id - 1);
	Posn p;
	do {
		p = c->getPosition();
	} while (!(this->displayGrid[p.y][p.x] == '.'));
	if (type == 'h') {
	 	this->player = new Human(HP, gold, p, Atk, Def, hasBarrier);
	} else if (type == 'o') {
		this->player = new Orc(HP, gold, p, Atk, Def, hasBarrier);
	} else if (type == 'e') {
		this->player = new Elf(HP, gold, p, Atk, Def, hasBarrier);
	} else if (type == 'd') {
		this->player = new Dwarf(HP, gold, p, Atk, Def, hasBarrier);
	}
	displayGrid[p.y][p.x] = '@';

	generateStair(id);
	generateItems(dragons);
	generateEnemies(dragons);
	assignCompass();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movb 0x10(%rbp), %al
movq %rdi, -0x8(%rbp)
movb %sil, -0x9(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movl %r8d, -0x18(%rbp)
movl %r9d, -0x1c(%rbp)
andb $0x1, %al
movb %al, -0x1d(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x78(%rbp)
movl $0x0, -0x28(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x4190
movl %eax, %edi
callq 0x41b0
movq -0x78(%rbp), %rdi
callq 0x6a60
callq 0x4090
movq -0x78(%rbp), %rdi
movl $0x5, %ecx
cltd
idivl %ecx
addl $0x1, %edx
movl %edx, -0x24(%rbp)
addq $0x808, %rdi            # imm = 0x808
movl -0x24(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0xd590
movq (%rax), %rax
movq %rax, -0x30(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x54a0
movq -0x30(%rbp), %rdi
callq 0x57d0
movq %rax, -0x40(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x5470
movq -0x78(%rbp), %rax
addq $0x820, %rax            # imm = 0x820
movslq -0x34(%rbp), %rcx
imulq $0x4f, %rcx, %rcx
addq %rcx, %rax
movslq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2e, %eax
sete %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x7f4d
movsbl -0x9(%rbp), %eax
cmpl $0x68, %eax
jne 0x8010
movl $0x50, %edi
callq 0x41d0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x80(%rbp)
movl -0x10(%rbp), %esi
movl -0x14(%rbp), %edx
movq -0x38(%rbp), %rax
movq %rax, -0x48(%rbp)
movl -0x18(%rbp), %r8d
movl -0x1c(%rbp), %r9d
movq -0x48(%rbp), %rcx
movzbl -0x1d(%rbp), %r10d
andl $0x1, %r10d
movq %rsp, %rax
movl %r10d, (%rax)
callq 0x129f0
jmp 0x7fdd
movq -0x78(%rbp), %rax
movq -0x80(%rbp), %rcx
movq %rcx, 0xfe0(%rax)
jmp 0x81b3
movq -0x80(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0x50, %esi
callq 0x41e0
jmp 0x8206
movsbl -0x9(%rbp), %eax
cmpl $0x6f, %eax
jne 0x809d
movl $0x50, %edi
callq 0x41d0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x88(%rbp)
movl -0x10(%rbp), %esi
movl -0x14(%rbp), %edx
movq -0x38(%rbp), %rax
movq %rax, -0x60(%rbp)
movl -0x18(%rbp), %r8d
movl -0x1c(%rbp), %r9d
movq -0x60(%rbp), %rcx
movzbl -0x1d(%rbp), %r10d
andl $0x1, %r10d
movq %rsp, %rax
movl %r10d, (%rax)
callq 0x12c60
jmp 0x8064
movq -0x78(%rbp), %rax
movq -0x88(%rbp), %rcx
movq %rcx, 0xfe0(%rax)
jmp 0x81b1
movq -0x88(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0x50, %esi
callq 0x41e0
jmp 0x8206
movsbl -0x9(%rbp), %eax
cmpl $0x65, %eax
jne 0x812a
movl $0x50, %edi
callq 0x41d0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x90(%rbp)
movl -0x10(%rbp), %esi
movl -0x14(%rbp), %edx
movq -0x38(%rbp), %rax
movq %rax, -0x68(%rbp)
movl -0x18(%rbp), %r8d
movl -0x1c(%rbp), %r9d
movq -0x68(%rbp), %rcx
movzbl -0x1d(%rbp), %r10d
andl $0x1, %r10d
movq %rsp, %rax
movl %r10d, (%rax)
callq 0x13d50
jmp 0x80f1
movq -0x78(%rbp), %rax
movq -0x90(%rbp), %rcx
movq %rcx, 0xfe0(%rax)
jmp 0x81af
movq -0x90(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0x50, %esi
callq 0x41e0
jmp 0x8206
movsbl -0x9(%rbp), %eax
cmpl $0x64, %eax
jne 0x81ad
movl $0x50, %edi
callq 0x41d0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x98(%rbp)
movl -0x10(%rbp), %esi
movl -0x14(%rbp), %edx
movq -0x38(%rbp), %rax
movq %rax, -0x70(%rbp)
movl -0x18(%rbp), %r8d
movl -0x1c(%rbp), %r9d
movq -0x70(%rbp), %rcx
movzbl -0x1d(%rbp), %r10d
andl $0x1, %r10d
movq %rsp, %rax
movl %r10d, (%rax)
callq 0x14770
jmp 0x817a
movq -0x78(%rbp), %rax
movq -0x98(%rbp), %rcx
movq %rcx, 0xfe0(%rax)
jmp 0x81ad
movq -0x98(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0x50, %esi
callq 0x41e0
jmp 0x8206
jmp 0x81af
jmp 0x81b1
jmp 0x81b3
movq -0x78(%rbp), %rdi
movq %rdi, %rax
addq $0x820, %rax            # imm = 0x820
movslq -0x34(%rbp), %rcx
imulq $0x4f, %rcx, %rcx
addq %rcx, %rax
movslq -0x38(%rbp), %rcx
movb $0x40, (%rax,%rcx)
movl -0x24(%rbp), %esi
callq 0x6d90
movq -0x78(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x6e90
movq -0x78(%rbp), %rdi
movl -0x28(%rbp), %esi
callq 0x7ac0
movq -0x78(%rbp), %rdi
callq 0x7e50
addq $0xa0, %rsp
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x42f0
nop