// File: /workspace/github_cpp_makefile_star2_O1/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 0xed2e
testq %rax, %rax
je 0x1490e
movq %rax, %r14
movq (%rax), %rax
movq %rsp, %r12
movq %r12, %rdi
movq %r14, %rsi
callq *0x18(%rax)
leaq 0x7353(%rip), %rsi      # 0x1bbb2
movq %r12, %rdi
callq 0x40d0
testl %eax, %eax
je 0x1493f
leaq 0x7343(%rip), %rsi      # 0x1bbb9
movq %rsp, %rdi
callq 0x40d0
testl %eax, %eax
je 0x1494c
leaq 0x769a(%rip), %rsi      # 0x1bf27
movq %rsp, %rdi
callq 0x40d0
testl %eax, %eax
jne 0x14961
movq 0x1071c(%rip), %rdi     # 0x24fc0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x4270
movsbl %al, %esi
movq 0x10701(%rip), %rdi     # 0x24fc0
callq 0x4040
movq %rax, %rdi
callq 0x41b0
movq %rax, %rbx
leaq 0x75d0(%rip), %rsi      # 0x1bea6
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 0x1496f
movq %rbx, %rdi
movq %r12, %rsi
callq 0xedc4
testq %rax, %rax
je 0x1498c
movq %rax, %r14
movq %r15, %rdi
movq %rax, %rsi
callq 0x14cb2
movq %rbx, %rdi
movq %r14, %rsi
callq 0xecba
movb $0x1, %bpl
jmp 0x149fa
movq %r15, %rdi
movq %r14, %rsi
callq 0x14a34
jmp 0x14961
movq 0x58(%r15), %rsi
testq %rsi, %rsi
je 0x1495d
movq %rbx, %rdi
callq 0xea48
movq %r14, 0x58(%r15)
movb $0x1, %bpl
movq %rbx, %rdi
movq %r14, %rsi
callq 0xec4c
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x149fa
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x149fa
movq 0x1062d(%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 0x74fb(%rip), %rsi      # 0x1bebf
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 0x14a0d
jmp 0x14a0d
movq %rax, %rbx
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x14a2b
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x42a0
movq %rbx, %rdi
callq 0x4430
nop