// File: 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
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x98(%rbp)
addq $0x60, %rdi
callq 0x17ad0
testb $0x1, %al
jne 0x26ecd
jmp 0x26ef8
movq 0x190ec(%rip), %rdi     # 0x3ffc0
movq 0x190c5(%rip), %rsi     # 0x3ffa0
callq 0x5330
movq %rax, %rdi
leaq 0x83d2(%rip), %rsi      # 0x2f2bc
callq 0x52f0
movb $0x0, -0x1(%rbp)
jmp 0x27293
movq -0x18(%rbp), %rdi
callq 0x133a0
cmpq $0x1, %rax
jne 0x26fcc
movq -0x18(%rbp), %rdi
callq 0x13410
movq %rax, -0x28(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x13600
movq -0x98(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rsi
callq 0x25e80
movq 0x19081(%rip), %rdi     # 0x3ffc0
movq 0x1905a(%rip), %rsi     # 0x3ffa0
callq 0x5330
movq %rax, %rdi
leaq 0x82d9(%rip), %rsi      # 0x2f22e
callq 0x52f0
movq %rax, -0xa0(%rbp)
movq -0x20(%rbp), %rdi
callq 0x29900
movq -0xa0(%rbp), %rdi
movq %rax, %rsi
callq 0x52a0
movq %rax, %rdi
movq 0x1901d(%rip), %rsi     # 0x3ffa0
callq 0x5330
movq -0x20(%rbp), %rdi
callq 0x298a0
cmpl $0x0, %eax
jne 0x26fc3
movq -0x18(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x28a70
movq -0x20(%rbp), %rax
movq %rax, -0xa8(%rbp)
cmpq $0x0, %rax
je 0x26fc1
movq -0xa8(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x26fc3
movb $0x1, -0x1(%rbp)
jmp 0x27293
movq $0x0, -0x20(%rbp)
movq 0x18fe5(%rip), %rdi     # 0x3ffc0
movq 0x18fbe(%rip), %rsi     # 0x3ffa0
movq %rsi, -0xb8(%rbp)
callq 0x5330
movq %rax, %rdi
leaq 0x8258(%rip), %rsi      # 0x2f250
callq 0x52f0
movq -0xb8(%rbp), %rsi
movq %rax, %rdi
callq 0x5330
movq -0xb8(%rbp), %rsi
movq %rax, %rdi
callq 0x5330
movq %rax, %rdi
leaq 0x7017(%rip), %rsi      # 0x2e03c
callq 0x52f0
movq -0x18(%rbp), %rdi
callq 0x13410
movq %rax, -0x38(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x13440
leaq -0x58(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
callq 0x5460
movq -0xb0(%rbp), %rsi
movq 0x18f76(%rip), %rdi     # 0x3ffd8
callq 0x5070
jmp 0x27069
movq -0x18(%rbp), %rdi
callq 0x13410
movq %rax, -0x78(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x13440
movq -0x70(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rdi
callq 0x135a0
movq %rax, -0x88(%rbp)
leaq -0x80(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x13440
leaq -0x30(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x13570
testb $0x1, %al
jne 0x270be
jmp 0x2712a
leaq -0x30(%rbp), %rdi
callq 0x13480
movq (%rax), %rdi
callq 0x29900
movq %rax, -0xc0(%rbp)
jmp 0x270d8
movq -0xc0(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x7e80
testb $0x1, %al
jne 0x270ee
jmp 0x2711a
leaq -0x30(%rbp), %rdi
callq 0x13480
movq (%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x2712a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x55d0
jmp 0x272a1
jmp 0x2711c
leaq -0x30(%rbp), %rdi
callq 0x13460
jmp 0x2708b
cmpq $0x0, -0x20(%rbp)
je 0x2721d
movq -0x98(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x25e80
jmp 0x27147
movq 0x18e72(%rip), %rdi     # 0x3ffc0
movq 0x18e4b(%rip), %rsi     # 0x3ffa0
callq 0x5330
movq %rax, -0xc8(%rbp)
jmp 0x27163
movq -0xc8(%rbp), %rdi
leaq 0x8166(%rip), %rsi      # 0x2f2d7
callq 0x52f0
movq %rax, -0xd0(%rbp)
jmp 0x2717f
movq -0x20(%rbp), %rdi
callq 0x29900
movq %rax, -0xd8(%rbp)
jmp 0x27191
movq -0xd8(%rbp), %rsi
movq -0xd0(%rbp), %rdi
callq 0x52a0
movq %rax, -0xe0(%rbp)
jmp 0x271ad
movq -0xe0(%rbp), %rdi
movq 0x18de5(%rip), %rsi     # 0x3ffa0
callq 0x5330
jmp 0x271c2
movq -0x20(%rbp), %rdi
callq 0x298a0
movl %eax, -0xe4(%rbp)
jmp 0x271d3
movl -0xe4(%rbp), %eax
cmpl $0x0, %eax
jne 0x2720d
movq -0x18(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x28a70
jmp 0x271ed
movq -0x20(%rbp), %rax
movq %rax, -0xf0(%rbp)
cmpq $0x0, %rax
je 0x2720b
movq -0xf0(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x2720d
movb $0x1, -0x1(%rbp)
movl $0x1, -0x8c(%rbp)
jmp 0x27276
movq 0x18d9c(%rip), %rdi     # 0x3ffc0
movq 0x18d75(%rip), %rsi     # 0x3ffa0
callq 0x5330
movq %rax, -0xf8(%rbp)
jmp 0x27239
movq -0xf8(%rbp), %rdi
leaq 0x8054(%rip), %rsi      # 0x2f29b
callq 0x52f0
movq %rax, -0x100(%rbp)
jmp 0x27255
movq -0x100(%rbp), %rdi
movq 0x18d3d(%rip), %rsi     # 0x3ffa0
callq 0x5330
jmp 0x2726a
jmp 0x2726c
movl $0x0, -0x8c(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x55d0
movl -0x8c(%rbp), %eax
testl %eax, %eax
je 0x2728d
jmp 0x2728b
jmp 0x27293
jmp 0x2728f
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
movq -0x60(%rbp), %rdi
callq 0x5550
nopw (%rax,%rax)