// File: kongrigoriou[P]Text-Based-RPG/src/Grid.cpp
// Function: Grid::get_monsters(int)
void Grid::get_monsters(int lvl){
    int maxlvl = 0;
    list <Monster*>::iterator it, it2, it3;
    for(it = Dragons.begin(); it != Dragons.end(); ++it){
        int mlvl = (*it)->get_level();
        if(mlvl > maxlvl){
            Monsters.push_back(*it);
        }
        if(mlvl == lvl || mlvl == lvl - 1 || mlvl == lvl + 1){
            insert_Monster(*it);
        }
    }

    for(it2 = Exoskeletons.begin(); it2 != Exoskeletons.end(); ++it2){
        int mlvl = (*it2)->get_level();
        if(mlvl == lvl || mlvl == lvl - 1 || mlvl == lvl + 1){
            insert_Monster(*it2);
        }
    }

       for(it3 = Spirits.begin(); it3 != Spirits.end(); ++it3){
        int mlvl = (*it3)->get_level();
        if(mlvl == lvl || mlvl == lvl - 1 || mlvl == lvl + 1){
            insert_Monster(*it3);
        }
    }

    if(Monsters.size() > 3)
        while(Monsters.size() > 3)
            Monsters.pop_back();
    else if(Monsters.size() == 0)
        cout << "Could not find monsters" << endl;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x78(%rbp)
movl $0x0, -0x10(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x117a0
leaq -0x20(%rbp), %rdi
callq 0x117a0
leaq -0x28(%rbp), %rdi
callq 0x117a0
movq -0x78(%rbp), %rdi
callq 0x117c0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x78(%rbp), %rdi
callq 0x11820
movq %rax, -0x38(%rbp)
leaq -0x18(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x117f0
testb $0x1, %al
jne 0xf334
jmp 0xf3b8
leaq -0x18(%rbp), %rdi
callq 0x11850
movq (%rax), %rdi
callq 0x4e20
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x10(%rbp), %eax
jle 0xf371
movq -0x78(%rbp), %rax
addq $0x48, %rax
movq %rax, -0x80(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x11850
movq -0x80(%rbp), %rdi
movq %rax, %rsi
callq 0x11870
movl -0x3c(%rbp), %eax
cmpl -0xc(%rbp), %eax
je 0xf393
movl -0x3c(%rbp), %eax
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
je 0xf393
movl -0x3c(%rbp), %eax
movl -0xc(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0xf3a8
leaq -0x18(%rbp), %rdi
callq 0x11850
movq -0x78(%rbp), %rdi
movq (%rax), %rsi
callq 0xf210
jmp 0xf3aa
leaq -0x18(%rbp), %rdi
callq 0x118b0
jmp 0xf311
movq -0x78(%rbp), %rdi
addq $0x18, %rdi
callq 0x117c0
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x78(%rbp), %rdi
addq $0x18, %rdi
callq 0x11820
movq %rax, -0x50(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x117f0
testb $0x1, %al
jne 0xf3f5
jmp 0xf44d
leaq -0x20(%rbp), %rdi
callq 0x11850
movq (%rax), %rdi
callq 0x4e20
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0xc(%rbp), %eax
je 0xf42b
movl -0x54(%rbp), %eax
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
je 0xf42b
movl -0x54(%rbp), %eax
movl -0xc(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0xf440
leaq -0x20(%rbp), %rdi
callq 0x11850
movq -0x78(%rbp), %rdi
movq (%rax), %rsi
callq 0xf210
jmp 0xf442
leaq -0x20(%rbp), %rdi
callq 0x118b0
jmp 0xf3d1
movq -0x78(%rbp), %rdi
addq $0x30, %rdi
callq 0x117c0
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x78(%rbp), %rdi
addq $0x30, %rdi
callq 0x11820
movq %rax, -0x68(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x117f0
testb $0x1, %al
jne 0xf48a
jmp 0xf4e2
leaq -0x28(%rbp), %rdi
callq 0x11850
movq (%rax), %rdi
callq 0x4e20
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
cmpl -0xc(%rbp), %eax
je 0xf4c0
movl -0x6c(%rbp), %eax
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
je 0xf4c0
movl -0x6c(%rbp), %eax
movl -0xc(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0xf4d5
leaq -0x28(%rbp), %rdi
callq 0x11850
movq -0x78(%rbp), %rdi
movq (%rax), %rsi
callq 0xf210
jmp 0xf4d7
leaq -0x28(%rbp), %rdi
callq 0x118b0
jmp 0xf466
movq -0x78(%rbp), %rdi
addq $0x48, %rdi
callq 0x118d0
cmpq $0x3, %rax
jbe 0xf51b
jmp 0xf4f7
movq -0x78(%rbp), %rdi
addq $0x48, %rdi
callq 0x118d0
cmpq $0x3, %rax
jbe 0xf519
movq -0x78(%rbp), %rdi
addq $0x48, %rdi
callq 0x11900
jmp 0xf4f7
jmp 0xf552
movq -0x78(%rbp), %rdi
addq $0x48, %rdi
callq 0x118d0
cmpq $0x0, %rax
jne 0xf550
movq 0xfa9b(%rip), %rdi      # 0x1efd0
leaq 0x65b5(%rip), %rsi      # 0x15af1
callq 0x31e0
movq %rax, %rdi
movq 0xfa75(%rip), %rsi      # 0x1efc0
callq 0x3210
jmp 0xf552
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax,%rax)