// File: /workspace/github_cpp_makefile_star2_O3/arisKoutsou[P]oopproj/./src/livings/Hero.cpp
// Function: Hero::equip(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
bool Hero :: equip(const string& name) {
  Item* itemToEquip = inventory.getItemByName(name);

  if (itemToEquip != NULL) {
    string kind = itemToEquip->kindOf();

    if (kind == "Weapon") {
      Weapon* weaponToEquip = static_cast<Weapon*>(itemToEquip);
      this->equipWeapon(weaponToEquip);
    } else if (kind == "Armor") {
      Armor* armorToEquip = static_cast<Armor*>(itemToEquip);
      this->equipArmor(armorToEquip);

    } else if (kind == "Potion") {
      cout << endl << "You can't equip a potion" << endl;
      return false;
    }
    this->inventory.removeItem(itemToEquip);
    return true;
  }

  Spell* spellToEquip = inventory.getSpellByName(name);

  if (spellToEquip != NULL) {
    this->equipSpell(spellToEquip);
    this->inventory.removeSpell(spellToEquip);
    return true;
  }

  cout << endl << "There's no such item or spell in your inventory" << endl;
  return false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rsi, %r12
movq %rdi, %r15
leaq 0xc0(%rdi), %rbx
movq %rbx, %rdi
callq 0xed62
testq %rax, %rax
je 0x1497a
movq %rax, %r14
movq (%rax), %rax
movq %rsp, %r12
movq %r12, %rdi
movq %r14, %rsi
callq *0x18(%rax)
leaq 0x72e7(%rip), %rsi      # 0x1bbb2
movq %r12, %rdi
callq 0x40d0
testl %eax, %eax
je 0x149ab
leaq 0x72d7(%rip), %rsi      # 0x1bbb9
movq %rsp, %rdi
callq 0x40d0
testl %eax, %eax
je 0x149b8
leaq 0x763e(%rip), %rsi      # 0x1bf37
movq %rsp, %rdi
callq 0x40d0
testl %eax, %eax
jne 0x149cd
movq 0x106b0(%rip), %rdi     # 0x24fc0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x4270
movsbl %al, %esi
movq 0x10695(%rip), %rdi     # 0x24fc0
callq 0x4040
movq %rax, %rdi
callq 0x41b0
movq %rax, %rbx
leaq 0x7574(%rip), %rsi      # 0x1beb6
movl $0x18, %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
xorl %ebp, %ebp
jmp 0x149db
movq %rbx, %rdi
movq %r12, %rsi
callq 0xee00
testq %rax, %rax
je 0x149f8
movq %rax, %r14
movq %r15, %rdi
movq %rax, %rsi
callq 0x14d1e
movq %rbx, %rdi
movq %r14, %rsi
callq 0xecee
movb $0x1, %bpl
jmp 0x14a66
movq %r15, %rdi
movq %r14, %rsi
callq 0x14aa0
jmp 0x149cd
movq 0x58(%r15), %rsi
testq %rsi, %rsi
je 0x149c9
movq %rbx, %rdi
callq 0xea7c
movq %r14, 0x58(%r15)
movb $0x1, %bpl
movq %rbx, %rdi
movq %r14, %rsi
callq 0xec80
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x14a66
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x14a66
movq 0x105c1(%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
movq %rax, %rbx
leaq 0x749f(%rip), %rsi      # 0x1becf
movl $0x2f, %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
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x14a79
jmp 0x14a79
movq %rax, %rbx
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x14a97
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x42a0
movq %rbx, %rdi
callq 0x4430
nop