// File: /workspace/github_cpp_makefile_star2_O1/arisKoutsou[P]oopproj/./src/livings/Hero.cpp
// Function: Hero::handleCastSpellCase(std::__cxx11::list<Monster*, std::allocator<Monster*>>&)
bool Hero :: handleCastSpellCase(list<Monster*>& monsters) {
  if (spells.empty()) {
    cout << endl << "You have no spells equiped";
    return false;
  }
  Monster* monsterToAttack;
  if (monsters.size() == 1) {
    monsterToAttack = *monsters.begin();

    this->castSpell(monsterToAttack);

    cout << endl
	 << "Attacking the only monster here: "
 	 << monsterToAttack->getName() << endl;

    if (monsterToAttack->getHealthPower() == 0) {
      monsters.remove(monsterToAttack);
      delete monsterToAttack;
    }
    return true;

  } else {

    monsterToAttack = NULL;
    cout << endl
	 << "Please enter the name of the monster you want to attack"
	 << endl << endl << "> ";
    list<Monster*> :: const_iterator it = monsters.begin();
       
    string name;
    getline(cin, name);       
    for (it = monsters.begin(); it != monsters.end(); ++it) {
      if ((*it)->getName() == name) {
	monsterToAttack = (*it);
	break;
      }
    }

    if (monsterToAttack != NULL) {
      this->castSpell(monsterToAttack);
      cout << endl << "Casting Spell on " << monsterToAttack->getName() << endl;
      
      if (monsterToAttack->getHealthPower() == 0) {
	monsters.remove(monsterToAttack);
	delete monsterToAttack;
      }
      return true;
    } else {

      cout << endl << "There is no such Monster here..." << endl;
    }

  }

  return false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
leaq 0x60(%rdi), %rax
cmpq %rax, 0x60(%rdi)
je 0x16ffe
movq %rsi, %rbx
movq %rdi, %r14
cmpq $0x1, 0x10(%rsi)
jne 0x17047
movq (%rbx), %rax
movq 0x10(%rax), %rsi
movq %rsi, (%rsp)
movq %r14, %rdi
callq 0x160d4
movq 0xe07b(%rip), %r14      # 0x24fc0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4270
movsbl %al, %esi
movq %r14, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x41b0
movq %rax, %r14
leaq 0x52e0(%rip), %rsi      # 0x1c256
movl $0x21, %edx
movq %rax, %rdi
callq 0x42f0
movq (%rsp), %rdi
callq 0x18694
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq %r14, %rdi
callq 0x42f0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4270
movsbl %al, %esi
movq %r14, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x41b0
movq (%rsp), %rdi
callq 0x18688
movb $0x1, %bpl
testl %eax, %eax
jne 0x172c5
movq %rsp, %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1857e
movq (%r14), %rdi
testq %rdi, %rdi
je 0x172c5
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x172c5
movq 0xdfbb(%rip), %rbx      # 0x24fc0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4270
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x41b0
leaq 0x52b1(%rip), %rsi      # 0x1c2e4
movl $0x1a, %edx
movq %rax, %rdi
callq 0x42f0
xorl %ebp, %ebp
jmp 0x172c5
xorl %r13d, %r13d
movq %r13, (%rsp)
movq 0xdf6b(%rip), %r15      # 0x24fc0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x4270
movsbl %al, %esi
movq %r15, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x41b0
movq %rax, %r12
leaq 0x51f2(%rip), %rsi      # 0x1c278
movl $0x37, %edx
movq %rax, %rdi
callq 0x42f0
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x4270
movsbl %al, %esi
movq %r12, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x41b0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x4270
movsbl %al, %esi
movq %r12, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x41b0
leaq 0x3f80(%rip), %rsi      # 0x1b06c
movl $0x2, %edx
movq %rax, %rdi
callq 0x42f0
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
movq %r13, -0x8(%r12)
movb $0x0, (%r12)
movq 0xdebc(%rip), %rdi      # 0x24fd0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x4270
movsbl %al, %edx
movq 0xdea1(%rip), %rdi      # 0x24fd0
leaq 0x8(%rsp), %rsi
callq 0x4460
movq (%rbx), %r13
cmpq %rbx, %r13
je 0x17179
movq 0x10(%r13), %rdi
callq 0x18694
movq 0x8(%rax), %rdx
cmpq 0x10(%rsp), %rdx
jne 0x1716b
testq %rdx, %rdx
je 0x17171
movq 0x8(%rsp), %rsi
movq (%rax), %rdi
callq 0x42b0
testl %eax, %eax
je 0x17171
movq (%r13), %r13
jmp 0x1713c
movq 0x10(%r13), %rax
movq %rax, (%rsp)
movq (%rsp), %rsi
testq %rsi, %rsi
setne %bpl
je 0x17245
movq %r14, %rdi
callq 0x160d4
movq (%r15), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0x4270
movsbl %al, %esi
movq 0xde10(%rip), %rdi      # 0x24fc0
callq 0x4040
movq %rax, %rdi
callq 0x41b0
movq %rax, %r14
leaq 0x5138(%rip), %rsi      # 0x1c2ff
movl $0x11, %edx
movq %rax, %rdi
callq 0x42f0
movq (%rsp), %rdi
callq 0x18694
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq %r14, %rdi
callq 0x42f0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4270
movsbl %al, %esi
movq %r14, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x41b0
movq (%rsp), %rdi
callq 0x18688
testl %eax, %eax
jne 0x172ae
movq %rsp, %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1857e
movq (%r14), %rdi
testq %rdi, %rdi
je 0x172ae
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x172ae
movq (%r15), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0x4270
movsbl %al, %esi
movq 0xdd5d(%rip), %rdi      # 0x24fc0
callq 0x4040
movq %rax, %rdi
callq 0x41b0
movq %rax, %rbx
leaq 0x5049(%rip), %rsi      # 0x1c2c3
movl $0x20, %edx
movq %rax, %rdi
callq 0x42f0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4270
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x41b0
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x172c5
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42a0
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x172d8
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x172f2
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42a0
movq %rbx, %rdi
callq 0x4430