// File: /workspace/github_cpp_makefile_star2_O3/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 $0x18, %rsp
movq %rsi, -0x30(%rbp)
movq %rdi, %rbx
movq (%rdi), %r13
cmpq %rdi, %r13
je 0xa65d
leaq 0x48(%rbx), %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
leal -0x1(%rax), %r14d
incl %eax
movl %eax, -0x40(%rbp)
movq 0x10(%r13), %rdi
callq 0x48cc
movl %eax, %r12d
testl %eax, %eax
jle 0xa613
movl $0x18, %edi
callq 0x3180
movq 0x10(%r13), %rcx
movq %rcx, 0x10(%rax)
movq %rax, %rdi
movq -0x38(%rbp), %rsi
callq 0x3050
incq 0x58(%rbx)
cmpl -0x30(%rbp), %r12d
sete %al
cmpl %r14d, %r12d
sete %cl
orb %al, %cl
cmpl -0x40(%rbp), %r12d
sete %al
orb %cl, %al
cmpb $0x1, %al
jne 0xa654
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 %rbx, %r13
jne 0xa5e1
leaq 0x18(%rbx), %r15
movq 0x18(%rbx), %r13
cmpq %r15, %r13
je 0xa6dd
movq -0x30(%rbp), %rax
leal -0x1(%rax), %r14d
leal 0x1(%rax), %r12d
movl %r14d, -0x40(%rbp)
movl %r12d, -0x38(%rbp)
movq 0x10(%r13), %rdi
callq 0x48cc
cmpl -0x30(%rbp), %eax
sete %cl
cmpl %r14d, %eax
sete %dl
orb %cl, %dl
cmpl %r12d, %eax
sete %al
orb %dl, %al
cmpb $0x1, %al
jne 0xa6d4
movq 0x10(%r13), %r12
movq %r15, %r14
movq 0x48(%rbx), %r15
movl $0x18, %edi
callq 0x3180
movq %r12, 0x10(%rax)
movl -0x38(%rbp), %r12d
movq %rax, %rdi
movq %r15, %rsi
movq %r14, %r15
movl -0x40(%rbp), %r14d
callq 0x3050
incq 0x58(%rbx)
movq (%r13), %r13
cmpq %r15, %r13
jne 0xa67e
leaq 0x30(%rbx), %r14
movq 0x30(%rbx), %r13
cmpq %r14, %r13
je 0xa75d
movq -0x30(%rbp), %rax
leal -0x1(%rax), %r15d
leal 0x1(%rax), %r12d
movq %r14, -0x40(%rbp)
movl %r12d, -0x38(%rbp)
movq 0x10(%r13), %rdi
callq 0x48cc
cmpl -0x30(%rbp), %eax
sete %cl
cmpl %r15d, %eax
sete %dl
orb %cl, %dl
cmpl %r12d, %eax
sete %al
orb %dl, %al
cmpb $0x1, %al
jne 0xa754
movq 0x10(%r13), %r12
movl %r15d, %r14d
movq 0x48(%rbx), %r15
movl $0x18, %edi
callq 0x3180
movq %r12, 0x10(%rax)
movl -0x38(%rbp), %r12d
movq %rax, %rdi
movq %r15, %rsi
movl %r14d, %r15d
movq -0x40(%rbp), %r14
callq 0x3050
incq 0x58(%rbx)
movq (%r13), %r13
cmpq %r14, %r13
jne 0xa6fe
movq 0x58(%rbx), %rax
cmpq $0x4, %rax
jb 0xa793
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 0xa767
jmp 0xa798
testq %rax, %rax
je 0xa7a7
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x9822(%rip), %rbx      # 0x13fd0
leaq 0x433a(%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 $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3100
nop