// File: /workspace/github_cpp_makefile_star2_O3/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 0x1705b
movq %rsi, %rbx
movq %rdi, %r14
cmpq $0x1, 0x10(%rsi)
jne 0x170a4
movq (%rbx), %rax
movq 0x10(%rax), %r15
movq %r15, (%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x16132
movq 0xe01c(%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 0x5291(%rip), %rsi      # 0x1c266
movl $0x21, %edx
movq %rax, %rdi
callq 0x42f0
movq %r15, %rdi
callq 0x186fc
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 %r15, %rdi
callq 0x186f0
movb $0x1, %bpl
testl %eax, %eax
jne 0x17324
movq %rsp, %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x185e6
movq (%r14), %rdi
testq %rdi, %rdi
je 0x17324
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x17324
movq 0xdf5e(%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 0x5264(%rip), %rsi      # 0x1c2f4
movl $0x1a, %edx
movq %rax, %rdi
callq 0x42f0
xorl %ebp, %ebp
jmp 0x17324
xorl %r13d, %r13d
movq %r13, (%rsp)
movq 0xdf0e(%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 0x51a5(%rip), %rsi      # 0x1c288
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 0x3f23(%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 0xde5f(%rip), %rdi      # 0x24fd0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x4270
movsbl %al, %edx
movq 0xde44(%rip), %rdi      # 0x24fd0
leaq 0x8(%rsp), %rsi
callq 0x4460
movq (%rbx), %r13
cmpq %rbx, %r13
je 0x171ce
movq 0x10(%r13), %rdi
callq 0x186fc
movq 0x8(%rax), %rdx
cmpq 0x10(%rsp), %rdx
jne 0x171c8
testq %rdx, %rdx
je 0x171d4
movq 0x8(%rsp), %rsi
movq (%rax), %rdi
callq 0x42b0
testl %eax, %eax
je 0x171d4
movq (%r13), %r13
jmp 0x17199
movq (%rsp), %rsi
jmp 0x171dc
movq 0x10(%r13), %rsi
movq %rsi, (%rsp)
testq %rsi, %rsi
setne %bpl
je 0x172a4
movq %r14, %rdi
callq 0x16132
movq (%r15), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0x4270
movsbl %al, %esi
movq 0xddb1(%rip), %rdi      # 0x24fc0
callq 0x4040
movq %rax, %rdi
callq 0x41b0
movq %rax, %r14
leaq 0x50e9(%rip), %rsi      # 0x1c30f
movl $0x11, %edx
movq %rax, %rdi
callq 0x42f0
movq (%rsp), %rdi
callq 0x186fc
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 0x186f0
testl %eax, %eax
jne 0x1730d
movq %rsp, %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x185e6
movq (%r14), %rdi
testq %rdi, %rdi
je 0x1730d
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x1730d
movq (%r15), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0x4270
movsbl %al, %esi
movq 0xdcfe(%rip), %rdi      # 0x24fc0
callq 0x4040
movq %rax, %rdi
callq 0x41b0
movq %rax, %rbx
leaq 0x4ffa(%rip), %rsi      # 0x1c2d3
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 0x17324
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 0x17337
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x17351
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42a0
movq %rbx, %rdi
callq 0x4430
nop