// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, -0x38(%rbp)
movq (%rdi), %r13
movq %rdi, -0x30(%rbp)
cmpq %rdi, %r13
je 0xa5b9
movq -0x30(%rbp), %rax
addq $0x48, %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
leal -0x1(%rax), %r14d
incl %eax
movl %eax, -0x48(%rbp)
movq -0x30(%rbp), %rbx
movq 0x10(%r13), %rdi
callq 0x48c8
movl %eax, %r12d
testl %eax, %eax
jle 0xa56a
movl $0x18, %edi
callq 0x3180
movq 0x10(%r13), %rcx
movq %rcx, 0x10(%rax)
movq %rax, %rdi
movq -0x40(%rbp), %rsi
callq 0x3050
movq -0x30(%rbp), %rax
incq 0x58(%rax)
cmpl -0x38(%rbp), %r12d
sete %al
cmpl %r14d, %r12d
sete %cl
orb %al, %cl
cmpl -0x48(%rbp), %r12d
sete %al
orb %cl, %al
cmpb $0x1, %al
jne 0xa5ab
movq 0x10(%r13), %r15
movq 0x48(%rbx), %r12
movl $0x18, %edi
callq 0x3180
movq %r15, 0x10(%rax)
movq %rax, %rdi
movq %r12, %rsi
callq 0x3050
incq 0x58(%rbx)
movq (%r13), %r13
cmpq -0x30(%rbp), %r13
jne 0xa534
movq -0x30(%rbp), %rax
leaq 0x18(%rax), %r15
movq 0x18(%rax), %r13
cmpq %r15, %r13
je 0xa641
movq -0x38(%rbp), %rax
leal -0x1(%rax), %r14d
leal 0x1(%rax), %r12d
movl %r14d, -0x48(%rbp)
movl %r12d, -0x40(%rbp)
movq -0x30(%rbp), %rbx
movq 0x10(%r13), %rdi
callq 0x48c8
cmpl -0x38(%rbp), %eax
sete %cl
cmpl %r14d, %eax
sete %dl
orb %cl, %dl
cmpl %r12d, %eax
sete %al
orb %dl, %al
cmpb $0x1, %al
jne 0xa638
movq 0x10(%r13), %r12
movq %r15, %r14
movq 0x48(%rbx), %r15
movl $0x18, %edi
callq 0x3180
movq %r12, 0x10(%rax)
movl -0x40(%rbp), %r12d
movq %rax, %rdi
movq %r15, %rsi
movq %r14, %r15
movl -0x48(%rbp), %r14d
callq 0x3050
incq 0x58(%rbx)
movq (%r13), %r13
cmpq %r15, %r13
jne 0xa5e2
movq -0x30(%rbp), %rax
leaq 0x30(%rax), %r14
movq 0x30(%rax), %r13
cmpq %r14, %r13
je 0xa6c5
movq -0x38(%rbp), %rax
leal -0x1(%rax), %r15d
leal 0x1(%rax), %ebx
movq %r14, -0x48(%rbp)
movl %ebx, -0x40(%rbp)
movq 0x10(%r13), %rdi
callq 0x48c8
cmpl -0x38(%rbp), %eax
sete %cl
cmpl %r15d, %eax
sete %dl
orb %cl, %dl
cmpl %ebx, %eax
sete %al
orb %dl, %al
cmpb $0x1, %al
jne 0xa6bc
movq 0x10(%r13), %r12
movl %r15d, %r14d
movq -0x30(%rbp), %rbx
movq 0x48(%rbx), %r15
movl $0x18, %edi
callq 0x3180
movq %r12, 0x10(%rax)
movq %rax, %rdi
movq %r15, %rsi
movl %r14d, %r15d
movq -0x48(%rbp), %r14
callq 0x3050
incq 0x58(%rbx)
movl -0x40(%rbp), %ebx
movq (%r13), %r13
cmpq %r14, %r13
jne 0xa664
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rax
cmpq $0x4, %rax
jb 0xa711
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rax
cmpq $0x4, %rax
jb 0xa716
movq -0x30(%rbp), %rbx
movq 0x50(%rbx), %r14
decq %rax
movq %rax, 0x58(%rbx)
movq %r14, %rdi
callq 0x3200
movl $0x18, %esi
movq %r14, %rdi
callq 0x3190
movq 0x58(%rbx), %rax
cmpq $0x3, %rax
ja 0xa6e5
jmp 0xa716
testq %rax, %rax
je 0xa725
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x98a4(%rip), %rbx      # 0x13fd0
leaq 0x43bc(%rip), %rsi      # 0xeaef
movl $0x17, %edx
movq %rbx, %rdi
callq 0x31c0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3100
nop