// File: malcolmyeh[P]CC3K/dwarf.cc
// Function: Dwarf::dealDamage[abi:cxx11](Character*)
std::string Dwarf::dealDamage(Character *opponent)
{
    double amount;
    std::string combatMsg;
    std::string defender = opponent->getRace();
    int attack = this->Atk;
    int defense = opponent->getDef();

    int chance = rand() % 40;

    if (chance == 0 || chance == 1)
    {
        //longsword
        this->increaseAtk(1);
        combatMsg += "You forged a Longsword. Atk increased by 1 (Atk: " + std::to_string(this->Atk) + "). ";
    }
    else if (chance == 2)
    {
        //broadsword
        this->increaseAtk(2);
        combatMsg += "You forged a Broadsword. Atk increased by 2 (Atk: " + std::to_string(this->Atk) + "). ";
    }
    else if (chance == 3 || chance == 4)
    {
        //light shield
        this->increaseDef(1);
        combatMsg += "You forged a Light Shield. Def increased by 1 (Def: " + std::to_string(this->Def) + "). ";
    }
    else if (chance == 5)
    {
        //heavy shield
        this->increaseDef(2);
        combatMsg += "You forged a Heavy Shield. Def increased by 2 (Def: " + std::to_string(this->Def) + "). ";
    }

    amount = ceil((100.0 / (100.0 + defense)) * attack);

    opponent->takeDamage((int)amount);

    combatMsg += "You deal " + std::to_string((int)amount) + " damage to " + defender + " (HP: " + std::to_string(opponent->getHP()) + "). ";

    if (opponent->getHP() == 0)
    {
        combatMsg += defender + " has been slain. You have earned " + std::to_string(opponent->getGold()) + " gold. ";
        this->updateGold(opponent->getGold());
    }


    return combatMsg;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x390, %rsp            # imm = 0x390
movq %rdi, -0x378(%rbp)
movq %rdi, %rax
movq %rax, -0x370(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x368(%rbp)
movb $0x0, -0x21(%rbp)
callq 0x4280
movq -0x18(%rbp), %rsi
movq (%rsi), %rax
movq 0x28(%rax), %rax
leaq -0x48(%rbp), %rdi
callq *%rax
jmp 0x148cf
movq -0x368(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x58(%rbp)
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movl %eax, -0x37c(%rbp)
jmp 0x148f1
movl -0x37c(%rbp), %eax
movl %eax, -0x5c(%rbp)
callq 0x4090
movl $0x28, %ecx
cltd
idivl %ecx
movl %edx, -0x60(%rbp)
cmpl $0x0, -0x60(%rbp)
je 0x1491a
cmpl $0x1, -0x60(%rbp)
jne 0x14a22
movq -0x368(%rbp), %rdi
movl $0x1, %esi
callq 0x11cd0
jmp 0x1492d
movq -0x368(%rbp), %rax
movl 0x8(%rax), %esi
leaq -0xc0(%rbp), %rdi
callq 0xdbe0
jmp 0x14945
leaq 0xa067(%rip), %rsi      # 0x1e9b3
leaq -0xa0(%rbp), %rdi
leaq -0xc0(%rbp), %rdx
callq 0xdb90
jmp 0x14961
leaq 0xa1a5(%rip), %rdx      # 0x1eb0d
leaq -0x80(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0xdb40
jmp 0x1497a
movq -0x378(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x4240
jmp 0x1498c
leaq -0x80(%rbp), %rdi
callq 0x4130
leaq -0xa0(%rbp), %rdi
callq 0x4130
leaq -0xc0(%rbp), %rdi
callq 0x4130
jmp 0x14d1f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x15142
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1511b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x14a11
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x14a05
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x4130
leaq -0xa0(%rbp), %rdi
callq 0x4130
leaq -0xc0(%rbp), %rdi
callq 0x4130
jmp 0x1511b
cmpl $0x2, -0x60(%rbp)
jne 0x14b1e
movq -0x368(%rbp), %rdi
movl $0x2, %esi
callq 0x11cd0
jmp 0x14a3f
movq -0x368(%rbp), %rax
movl 0x8(%rax), %esi
leaq -0x120(%rbp), %rdi
callq 0xdbe0
jmp 0x14a57
leaq 0x9f87(%rip), %rsi      # 0x1e9e5
leaq -0x100(%rbp), %rdi
leaq -0x120(%rbp), %rdx
callq 0xdb90
jmp 0x14a73
leaq 0xa093(%rip), %rdx      # 0x1eb0d
leaq -0xe0(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0xdb40
jmp 0x14a8f
movq -0x378(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x4240
jmp 0x14aa4
leaq -0xe0(%rbp), %rdi
callq 0x4130
leaq -0x100(%rbp), %rdi
callq 0x4130
leaq -0x120(%rbp), %rdi
callq 0x4130
jmp 0x14d1d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x14b0d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x14b01
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x4130
leaq -0x100(%rbp), %rdi
callq 0x4130
leaq -0x120(%rbp), %rdi
callq 0x4130
jmp 0x1511b
cmpl $0x3, -0x60(%rbp)
je 0x14b2e
cmpl $0x4, -0x60(%rbp)
jne 0x14c20
movq -0x368(%rbp), %rdi
movl $0x1, %esi
callq 0x11cf0
jmp 0x14b41
movq -0x368(%rbp), %rax
movl 0xc(%rax), %esi
leaq -0x180(%rbp), %rdi
callq 0xdbe0
jmp 0x14b59
leaq 0x9eb8(%rip), %rsi      # 0x1ea18
leaq -0x160(%rbp), %rdi
leaq -0x180(%rbp), %rdx
callq 0xdb90
jmp 0x14b75
leaq 0x9f91(%rip), %rdx      # 0x1eb0d
leaq -0x140(%rbp), %rdi
leaq -0x160(%rbp), %rsi
callq 0xdb40
jmp 0x14b91
movq -0x378(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x4240
jmp 0x14ba6
leaq -0x140(%rbp), %rdi
callq 0x4130
leaq -0x160(%rbp), %rdi
callq 0x4130
leaq -0x180(%rbp), %rdi
callq 0x4130
jmp 0x14d1b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x14c0f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x14c03
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x4130
leaq -0x160(%rbp), %rdi
callq 0x4130
leaq -0x180(%rbp), %rdi
callq 0x4130
jmp 0x1511b
cmpl $0x5, -0x60(%rbp)
jne 0x14d19
movq -0x368(%rbp), %rdi
movl $0x2, %esi
callq 0x11cf0
jmp 0x14c3d
movq -0x368(%rbp), %rax
movl 0xc(%rax), %esi
leaq -0x1e0(%rbp), %rdi
callq 0xdbe0
jmp 0x14c55
leaq 0x9df1(%rip), %rsi      # 0x1ea4d
leaq -0x1c0(%rbp), %rdi
leaq -0x1e0(%rbp), %rdx
callq 0xdb90
jmp 0x14c71
leaq 0x9e95(%rip), %rdx      # 0x1eb0d
leaq -0x1a0(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0xdb40
jmp 0x14c8d
movq -0x378(%rbp), %rdi
leaq -0x1a0(%rbp), %rsi
callq 0x4240
jmp 0x14ca2
leaq -0x1a0(%rbp), %rdi
callq 0x4130
leaq -0x1c0(%rbp), %rdi
callq 0x4130
leaq -0x1e0(%rbp), %rdi
callq 0x4130
jmp 0x14d19
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x14d08
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x14cfc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0x4130
leaq -0x1c0(%rbp), %rdi
callq 0x4130
leaq -0x1e0(%rbp), %rdi
callq 0x4130
jmp 0x1511b
jmp 0x14d1b
jmp 0x14d1d
jmp 0x14d1f
cvtsi2sdl -0x5c(%rbp), %xmm1
movsd 0x9b3c(%rip), %xmm0     # 0x1e868
addsd %xmm0, %xmm1
divsd %xmm1, %xmm0
cvtsi2sdl -0x58(%rbp), %xmm1
mulsd %xmm1, %xmm0
callq 0x4050
movsd %xmm0, -0x20(%rbp)
movq -0x18(%rbp), %rdi
cvttsd2si -0x20(%rbp), %esi
movq (%rdi), %rax
movq 0x48(%rax), %rax
callq *%rax
jmp 0x14d5b
cvttsd2si -0x20(%rbp), %esi
leaq -0x2c0(%rbp), %rdi
callq 0xdbe0
jmp 0x14d6e
leaq 0x9bb7(%rip), %rsi      # 0x1e92c
leaq -0x2a0(%rbp), %rdi
leaq -0x2c0(%rbp), %rdx
callq 0xdb90
jmp 0x14d8a
leaq 0x9adf(%rip), %rdx      # 0x1e870
leaq -0x280(%rbp), %rdi
leaq -0x2a0(%rbp), %rsi
callq 0xdb40
jmp 0x14da6
leaq -0x260(%rbp), %rdi
leaq -0x280(%rbp), %rsi
leaq -0x48(%rbp), %rdx
callq 0x11e00
jmp 0x14dbf
leaq 0x9dcc(%rip), %rdx      # 0x1eb92
leaq -0x240(%rbp), %rdi
leaq -0x260(%rbp), %rsi
callq 0xdb40
jmp 0x14ddb
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movl %eax, -0x380(%rbp)
jmp 0x14df0
movl -0x380(%rbp), %esi
leaq -0x2e0(%rbp), %rdi
callq 0xdbe0
jmp 0x14e04
leaq -0x220(%rbp), %rdi
leaq -0x240(%rbp), %rsi
leaq -0x2e0(%rbp), %rdx
callq 0x11d30
jmp 0x14e20
leaq 0x9ce6(%rip), %rdx      # 0x1eb0d
leaq -0x200(%rbp), %rdi
leaq -0x220(%rbp), %rsi
callq 0xdb40
jmp 0x14e3c
movq -0x378(%rbp), %rdi
leaq -0x200(%rbp), %rsi
callq 0x4240
jmp 0x14e51
leaq -0x200(%rbp), %rdi
callq 0x4130
leaq -0x220(%rbp), %rdi
callq 0x4130
leaq -0x2e0(%rbp), %rdi
callq 0x4130
leaq -0x240(%rbp), %rdi
callq 0x4130
leaq -0x260(%rbp), %rdi
callq 0x4130
leaq -0x280(%rbp), %rdi
callq 0x4130
leaq -0x2a0(%rbp), %rdi
callq 0x4130
leaq -0x2c0(%rbp), %rdi
callq 0x4130
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movl %eax, -0x384(%rbp)
jmp 0x14ec6
movl -0x384(%rbp), %eax
cmpl $0x0, %eax
jne 0x15106
leaq 0x99a0(%rip), %rdx      # 0x1e87c
leaq -0x340(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0xdac0
jmp 0x14eee
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
callq *%rax
movl %eax, -0x388(%rbp)
jmp 0x14f03
movl -0x388(%rbp), %esi
leaq -0x360(%rbp), %rdi
callq 0xdbe0
jmp 0x14f17
leaq -0x320(%rbp), %rdi
leaq -0x340(%rbp), %rsi
leaq -0x360(%rbp), %rdx
callq 0x11d30
jmp 0x14f33
leaq 0x937c(%rip), %rdx      # 0x1e2b6
leaq -0x300(%rbp), %rdi
leaq -0x320(%rbp), %rsi
callq 0xdb40
jmp 0x14f4f
movq -0x378(%rbp), %rdi
leaq -0x300(%rbp), %rsi
callq 0x4240
jmp 0x14f64
leaq -0x300(%rbp), %rdi
callq 0x4130
leaq -0x320(%rbp), %rdi
callq 0x4130
leaq -0x360(%rbp), %rdi
callq 0x4130
leaq -0x340(%rbp), %rdi
callq 0x4130
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
callq *%rax
movl %eax, -0x38c(%rbp)
jmp 0x14fa9
movl -0x38c(%rbp), %esi
movq -0x368(%rbp), %rdi
movq (%rdi), %rax
movq (%rax), %rax
callq *%rax
jmp 0x14fc0
jmp 0x15106
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x15090
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x15084
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x15078
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1506c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x15060
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x15054
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x15048
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x200(%rbp), %rdi
callq 0x4130
leaq -0x220(%rbp), %rdi
callq 0x4130
leaq -0x2e0(%rbp), %rdi
callq 0x4130
leaq -0x240(%rbp), %rdi
callq 0x4130
leaq -0x260(%rbp), %rdi
callq 0x4130
leaq -0x280(%rbp), %rdi
callq 0x4130
leaq -0x2a0(%rbp), %rdi
callq 0x4130
leaq -0x2c0(%rbp), %rdi
callq 0x4130
jmp 0x1511b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x150f8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x150ec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x150e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x300(%rbp), %rdi
callq 0x4130
leaq -0x320(%rbp), %rdi
callq 0x4130
leaq -0x360(%rbp), %rdi
callq 0x4130
leaq -0x340(%rbp), %rdi
callq 0x4130
jmp 0x1511b
movb $0x1, -0x21(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x4130
testb $0x1, -0x21(%rbp)
jne 0x15132
jmp 0x15126
leaq -0x48(%rbp), %rdi
callq 0x4130
jmp 0x15142
movq -0x378(%rbp), %rdi
callq 0x4130
movq -0x370(%rbp), %rax
addq $0x390, %rsp            # imm = 0x390
popq %rbp
retq
movq -0x378(%rbp), %rdi
callq 0x4130
movq -0x50(%rbp), %rdi
callq 0x42f0
nopw (%rax,%rax)