// File: malcolmyeh[P]CC3K/troll.cc
// Function: Troll::dealDamage[abi:cxx11](Character*)
std::string Troll::dealDamage(Character *opponent)
{
    double amount;
    double secondHit;

    std::string combatMsg;
    std::string attacker = this->race;

    int attack = this->Atk;
    int defense = opponent->getDef();
    if (this->stunned)
    {
        this->stunned = false;
        combatMsg = attacker + " is stunned. ";
        return combatMsg;
    }
    if (rand() % 2 == 0)
    {
        combatMsg = attacker + "'s attack missed. ";
        return combatMsg;
    }

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

    if (rand() % 3 == 0)
    {
        //double hits player
        combatMsg = attacker + " strikes you twice for " + std::to_string((int)amount) + " + " + std::to_string((int)secondHit) + " damage (HP: " + std::to_string(opponent->getHP()) + "). ";
        opponent->takeDamage((int)(amount + secondHit));
    }
    else if (rand() % 3 == 1)
    {
        //hurts itself with second hit
        combatMsg = attacker + " deals " + std::to_string((int)amount) + " damage to you (HP: " + std::to_string(opponent->getHP()) + "). ";
        combatMsg += attacker + " hurts itself in confusion for " + std::to_string((int)secondHit) + " damage. (HP: " + std::to_string(this->HP) + "). ";
        opponent->takeDamage((int)amount);
        this->takeDamage((int)secondHit);
    }
    else
    {
        opponent->takeDamage((int)amount);
        combatMsg = attacker + " deals " + std::to_string((int)amount) + " damage to you (HP: " + std::to_string(opponent->getHP()) + "). ";
    }

    if (opponent->getHP() == 0)
    {
        combatMsg += "You have been slain.";
    }

    return combatMsg;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4d0, %rsp            # imm = 0x4D0
movq %rdi, -0x4a8(%rbp)
movq %rdi, %rax
movq %rax, -0x4a0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x498(%rbp)
movb $0x0, -0x29(%rbp)
callq 0x4280
movq -0x498(%rbp), %rsi
addq $0x18, %rsi
leaq -0x50(%rbp), %rdi
callq 0x40e0
jmp 0x163b2
movq -0x498(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x60(%rbp)
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movl %eax, -0x4ac(%rbp)
jmp 0x163d4
movq -0x498(%rbp), %rax
movl -0x4ac(%rbp), %ecx
movl %ecx, -0x64(%rbp)
testb $0x1, 0x39(%rax)
je 0x16462
movq -0x498(%rbp), %rax
movb $0x0, 0x39(%rax)
leaq 0x84aa(%rip), %rdx      # 0x1e8a6
leaq -0x88(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xdac0
jmp 0x1640e
movq -0x4a8(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x4220
leaq -0x88(%rbp), %rdi
callq 0x4130
movb $0x1, -0x29(%rbp)
movl $0x1, -0x8c(%rbp)
jmp 0x16dfa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x16e32
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x16e0b
callq 0x4090
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x164bf
leaq 0x8439(%rip), %rdx      # 0x1e8b4
leaq -0xb0(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xdac0
jmp 0x1648d
movq -0x4a8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x4220
leaq -0xb0(%rbp), %rdi
callq 0x4130
movb $0x1, -0x29(%rbp)
movl $0x1, -0x8c(%rbp)
jmp 0x16dfa
cvtsi2sdl -0x64(%rbp), %xmm0
movsd 0x839c(%rip), %xmm1     # 0x1e868
addsd %xmm0, %xmm1
movsd 0x8390(%rip), %xmm0     # 0x1e868
divsd %xmm1, %xmm0
cvtsi2sdl -0x60(%rbp), %xmm1
mulsd %xmm1, %xmm0
callq 0x4050
movsd %xmm0, -0x20(%rbp)
movsd 0x8649(%rip), %xmm0     # 0x1eb40
mulsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
callq 0x4090
movl $0x3, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x167d8
leaq 0x8630(%rip), %rdx      # 0x1eb4e
leaq -0x190(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xdac0
jmp 0x16530
cvttsd2si -0x20(%rbp), %esi
leaq -0x1b0(%rbp), %rdi
callq 0xdbe0
jmp 0x16543
leaq -0x170(%rbp), %rdi
leaq -0x190(%rbp), %rsi
leaq -0x1b0(%rbp), %rdx
callq 0x11d30
jmp 0x1655f
leaq 0x8600(%rip), %rdx      # 0x1eb66
leaq -0x150(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0xdb40
jmp 0x1657b
cvttsd2si -0x28(%rbp), %esi
leaq -0x1d0(%rbp), %rdi
callq 0xdbe0
jmp 0x1658e
leaq -0x130(%rbp), %rdi
leaq -0x150(%rbp), %rsi
leaq -0x1d0(%rbp), %rdx
callq 0x11d30
jmp 0x165aa
leaq 0x8054(%rip), %rdx      # 0x1e605
leaq -0x110(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0xdb40
jmp 0x165c6
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movl %eax, -0x4b0(%rbp)
jmp 0x165db
movl -0x4b0(%rbp), %esi
leaq -0x1f0(%rbp), %rdi
callq 0xdbe0
jmp 0x165ef
leaq -0xf0(%rbp), %rdi
leaq -0x110(%rbp), %rsi
leaq -0x1f0(%rbp), %rdx
callq 0x11d30
jmp 0x1660b
leaq 0x84fb(%rip), %rdx      # 0x1eb0d
leaq -0xd0(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0xdb40
jmp 0x16627
movq -0x4a8(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
movq %rsi, -0x4b8(%rbp)
callq 0x4220
movq -0x4b8(%rbp), %rdi
callq 0x4130
leaq -0xf0(%rbp), %rdi
callq 0x4130
leaq -0x1f0(%rbp), %rdi
callq 0x4130
leaq -0x110(%rbp), %rdi
callq 0x4130
leaq -0x130(%rbp), %rdi
callq 0x4130
leaq -0x1d0(%rbp), %rdi
callq 0x4130
leaq -0x150(%rbp), %rdi
callq 0x4130
leaq -0x170(%rbp), %rdi
callq 0x4130
leaq -0x1b0(%rbp), %rdi
callq 0x4130
leaq -0x190(%rbp), %rdi
callq 0x4130
movq -0x18(%rbp), %rdi
movsd -0x20(%rbp), %xmm0
movsd -0x28(%rbp), %xmm1
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %esi
movq (%rdi), %rax
movq 0x48(%rax), %rax
callq *%rax
jmp 0x166da
jmp 0x16db5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x167c7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x167bb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x167af
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x167a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x16797
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x1678b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x1677f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x16773
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x4130
leaq -0x1f0(%rbp), %rdi
callq 0x4130
leaq -0x110(%rbp), %rdi
callq 0x4130
leaq -0x130(%rbp), %rdi
callq 0x4130
leaq -0x1d0(%rbp), %rdi
callq 0x4130
leaq -0x150(%rbp), %rdi
callq 0x4130
leaq -0x170(%rbp), %rdi
callq 0x4130
leaq -0x1b0(%rbp), %rdi
callq 0x4130
leaq -0x190(%rbp), %rdi
callq 0x4130
jmp 0x16e0b
callq 0x4090
movl $0x3, %ecx
cltd
idivl %ecx
cmpl $0x1, %edx
jne 0x16bcf
leaq 0x80d2(%rip), %rdx      # 0x1e8c7
leaq -0x290(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xdac0
jmp 0x16807
cvttsd2si -0x20(%rbp), %esi
leaq -0x2b0(%rbp), %rdi
callq 0xdbe0
jmp 0x1681a
leaq -0x270(%rbp), %rdi
leaq -0x290(%rbp), %rsi
leaq -0x2b0(%rbp), %rdx
callq 0x11d30
jmp 0x16836
leaq 0x8092(%rip), %rdx      # 0x1e8cf
leaq -0x250(%rbp), %rdi
leaq -0x270(%rbp), %rsi
callq 0xdb40
jmp 0x16852
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movl %eax, -0x4bc(%rbp)
jmp 0x16867
movl -0x4bc(%rbp), %esi
leaq -0x2d0(%rbp), %rdi
callq 0xdbe0
jmp 0x1687b
leaq -0x230(%rbp), %rdi
leaq -0x250(%rbp), %rsi
leaq -0x2d0(%rbp), %rdx
callq 0x11d30
jmp 0x16897
leaq 0x826f(%rip), %rdx      # 0x1eb0d
leaq -0x210(%rbp), %rdi
leaq -0x230(%rbp), %rsi
callq 0xdb40
jmp 0x168b3
movq -0x4a8(%rbp), %rdi
leaq -0x210(%rbp), %rsi
movq %rsi, -0x4c8(%rbp)
callq 0x4220
movq -0x4c8(%rbp), %rdi
callq 0x4130
leaq -0x230(%rbp), %rdi
callq 0x4130
leaq -0x2d0(%rbp), %rdi
callq 0x4130
leaq -0x250(%rbp), %rdi
callq 0x4130
leaq -0x270(%rbp), %rdi
callq 0x4130
leaq -0x2b0(%rbp), %rdi
callq 0x4130
leaq -0x290(%rbp), %rdi
callq 0x4130
leaq 0x8242(%rip), %rdx      # 0x1eb6a
leaq -0x370(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xdac0
jmp 0x1693a
cvttsd2si -0x28(%rbp), %esi
leaq -0x390(%rbp), %rdi
callq 0xdbe0
jmp 0x1694d
leaq -0x350(%rbp), %rdi
leaq -0x370(%rbp), %rsi
leaq -0x390(%rbp), %rdx
callq 0x11d30
jmp 0x16969
leaq 0x821a(%rip), %rdx      # 0x1eb8a
leaq -0x330(%rbp), %rdi
leaq -0x350(%rbp), %rsi
callq 0xdb40
jmp 0x16985
movq -0x498(%rbp), %rax
movl 0x10(%rax), %esi
leaq -0x3b0(%rbp), %rdi
callq 0xdbe0
jmp 0x1699d
leaq -0x310(%rbp), %rdi
leaq -0x330(%rbp), %rsi
leaq -0x3b0(%rbp), %rdx
callq 0x11d30
jmp 0x169b9
leaq 0x814d(%rip), %rdx      # 0x1eb0d
leaq -0x2f0(%rbp), %rdi
leaq -0x310(%rbp), %rsi
callq 0xdb40
jmp 0x169d5
movq -0x4a8(%rbp), %rdi
leaq -0x2f0(%rbp), %rsi
callq 0x4240
jmp 0x169ea
leaq -0x2f0(%rbp), %rdi
callq 0x4130
leaq -0x310(%rbp), %rdi
callq 0x4130
leaq -0x3b0(%rbp), %rdi
callq 0x4130
leaq -0x330(%rbp), %rdi
callq 0x4130
leaq -0x350(%rbp), %rdi
callq 0x4130
leaq -0x390(%rbp), %rdi
callq 0x4130
leaq -0x370(%rbp), %rdi
callq 0x4130
movq -0x18(%rbp), %rdi
cvttsd2si -0x20(%rbp), %esi
movq (%rdi), %rax
movq 0x48(%rax), %rax
callq *%rax
jmp 0x16a52
movq -0x498(%rbp), %rdi
cvttsd2si -0x28(%rbp), %esi
movq (%rdi), %rax
movq 0x48(%rax), %rax
callq *%rax
jmp 0x16a69
jmp 0x16db3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x16aff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x16af3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x16ae7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x16adb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x16acf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x4130
leaq -0x2d0(%rbp), %rdi
callq 0x4130
leaq -0x250(%rbp), %rdi
callq 0x4130
leaq -0x270(%rbp), %rdi
callq 0x4130
leaq -0x2b0(%rbp), %rdi
callq 0x4130
leaq -0x290(%rbp), %rdi
callq 0x4130
jmp 0x16e0b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x16bbe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x16bb2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x16ba6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x16b9a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x16b8e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x16b82
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x2f0(%rbp), %rdi
callq 0x4130
leaq -0x310(%rbp), %rdi
callq 0x4130
leaq -0x3b0(%rbp), %rdi
callq 0x4130
leaq -0x330(%rbp), %rdi
callq 0x4130
leaq -0x350(%rbp), %rdi
callq 0x4130
leaq -0x390(%rbp), %rdi
callq 0x4130
leaq -0x370(%rbp), %rdi
callq 0x4130
jmp 0x16e0b
movq -0x18(%rbp), %rdi
cvttsd2si -0x20(%rbp), %esi
movq (%rdi), %rax
movq 0x48(%rax), %rax
callq *%rax
jmp 0x16be3
leaq 0x7cdd(%rip), %rdx      # 0x1e8c7
leaq -0x450(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xdac0
jmp 0x16bfc
cvttsd2si -0x20(%rbp), %esi
leaq -0x470(%rbp), %rdi
callq 0xdbe0
jmp 0x16c0f
leaq -0x430(%rbp), %rdi
leaq -0x450(%rbp), %rsi
leaq -0x470(%rbp), %rdx
callq 0x11d30
jmp 0x16c2b
leaq 0x7c9d(%rip), %rdx      # 0x1e8cf
leaq -0x410(%rbp), %rdi
leaq -0x430(%rbp), %rsi
callq 0xdb40
jmp 0x16c47
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movl %eax, -0x4cc(%rbp)
jmp 0x16c5c
movl -0x4cc(%rbp), %esi
leaq -0x490(%rbp), %rdi
callq 0xdbe0
jmp 0x16c70
leaq -0x3f0(%rbp), %rdi
leaq -0x410(%rbp), %rsi
leaq -0x490(%rbp), %rdx
callq 0x11d30
jmp 0x16c8c
leaq 0x7e7a(%rip), %rdx      # 0x1eb0d
leaq -0x3d0(%rbp), %rdi
leaq -0x3f0(%rbp), %rsi
callq 0xdb40
jmp 0x16ca8
movq -0x4a8(%rbp), %rdi
leaq -0x3d0(%rbp), %rsi
callq 0x4220
leaq -0x3d0(%rbp), %rdi
callq 0x4130
leaq -0x3f0(%rbp), %rdi
callq 0x4130
leaq -0x490(%rbp), %rdi
callq 0x4130
leaq -0x410(%rbp), %rdi
callq 0x4130
leaq -0x430(%rbp), %rdi
callq 0x4130
leaq -0x470(%rbp), %rdi
callq 0x4130
leaq -0x450(%rbp), %rdi
callq 0x4130
jmp 0x16db3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x16da5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x16d99
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x16d8d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x16d81
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x16d75
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x3f0(%rbp), %rdi
callq 0x4130
leaq -0x490(%rbp), %rdi
callq 0x4130
leaq -0x410(%rbp), %rdi
callq 0x4130
leaq -0x430(%rbp), %rdi
callq 0x4130
leaq -0x470(%rbp), %rdi
callq 0x4130
leaq -0x450(%rbp), %rdi
callq 0x4130
jmp 0x16e0b
jmp 0x16db5
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movl %eax, -0x4d0(%rbp)
jmp 0x16dca
movl -0x4d0(%rbp), %eax
cmpl $0x0, %eax
jne 0x16dec
movq -0x4a8(%rbp), %rdi
leaq 0x7b01(%rip), %rsi      # 0x1e8e4
callq 0x41a0
jmp 0x16dea
jmp 0x16dec
movb $0x1, -0x29(%rbp)
movl $0x1, -0x8c(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x4130
testb $0x1, -0x29(%rbp)
jne 0x16e22
jmp 0x16e16
leaq -0x50(%rbp), %rdi
callq 0x4130
jmp 0x16e32
movq -0x4a8(%rbp), %rdi
callq 0x4130
movq -0x4a0(%rbp), %rax
addq $0x4d0, %rsp            # imm = 0x4D0
popq %rbp
retq
movq -0x4a8(%rbp), %rdi
callq 0x4130
movq -0x58(%rbp), %rdi
callq 0x42f0
nopw (%rax,%rax)