// File: malcolmyeh[P]CC3K/werewolf.cc
// Function: Werewolf::dealDamage[abi:cxx11](Character*)
std::string Werewolf::dealDamage(Character *opponent)
{

    double amount;
    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;
    }

    if (this->HP <= 30)
    {
        combatMsg = attacker + "'s unstoppable rage increases its damage by 3. ";
        this->Atk += 3;
    }
    else if (this-> HP <= 60)
    {
        combatMsg = attacker + "'s blinding rage increases its damage by 2. ";
        this->Atk += 2;
    }
    else if (this-> HP <= 90)
    {
        combatMsg = attacker + "'s rage increases its damage by 1. ";
        this->Atk += 1;
    }

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

    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 $0x210, %rsp            # imm = 0x210
movq %rdi, -0x200(%rbp)
movq %rdi, %rax
movq %rax, -0x1f8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x1f0(%rbp)
movb $0x0, -0x21(%rbp)
callq 0x4280
movq -0x1f0(%rbp), %rsi
addq $0x18, %rsi
leaq -0x48(%rbp), %rdi
callq 0x40e0
jmp 0x17692
movq -0x1f0(%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, -0x204(%rbp)
jmp 0x176b4
movq -0x1f0(%rbp), %rax
movl -0x204(%rbp), %ecx
movl %ecx, -0x5c(%rbp)
testb $0x1, 0x39(%rax)
je 0x17739
movq -0x1f0(%rbp), %rax
movb $0x0, 0x39(%rax)
leaq 0x71ca(%rip), %rdx      # 0x1e8a6
leaq -0x80(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0xdac0
jmp 0x176eb
movq -0x200(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x4220
leaq -0x80(%rbp), %rdi
callq 0x4130
movb $0x1, -0x21(%rbp)
movl $0x1, -0x84(%rbp)
jmp 0x17b12
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x17b4a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x17b23
callq 0x4090
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x17796
leaq 0x7162(%rip), %rdx      # 0x1e8b4
leaq -0xa8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0xdac0
jmp 0x17764
movq -0x200(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x4220
leaq -0xa8(%rbp), %rdi
callq 0x4130
movb $0x1, -0x21(%rbp)
movl $0x1, -0x84(%rbp)
jmp 0x17b12
movq -0x1f0(%rbp), %rax
cmpl $0x1e, 0x10(%rax)
jg 0x177f0
leaq 0x7428(%rip), %rdx      # 0x1ebd2
leaq -0xc8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0xdac0
jmp 0x177bc
movq -0x200(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x4220
leaq -0xc8(%rbp), %rdi
callq 0x4130
movq -0x1f0(%rbp), %rax
movl 0x8(%rax), %ecx
addl $0x3, %ecx
movl %ecx, 0x8(%rax)
jmp 0x178a0
movq -0x1f0(%rbp), %rax
cmpl $0x3c, 0x10(%rax)
jg 0x17847
leaq 0x73fe(%rip), %rdx      # 0x1ec02
leaq -0xe8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0xdac0
jmp 0x17816
movq -0x200(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x4220
leaq -0xe8(%rbp), %rdi
callq 0x4130
movq -0x1f0(%rbp), %rax
movl 0x8(%rax), %ecx
addl $0x2, %ecx
movl %ecx, 0x8(%rax)
jmp 0x1789e
movq -0x1f0(%rbp), %rax
cmpl $0x5a, 0x10(%rax)
jg 0x1789c
leaq 0x73d4(%rip), %rdx      # 0x1ec2f
leaq -0x108(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0xdac0
jmp 0x1786d
movq -0x200(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x4220
leaq -0x108(%rbp), %rdi
callq 0x4130
movq -0x1f0(%rbp), %rax
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x8(%rax)
jmp 0x1789e
jmp 0x178a0
cvtsi2sdl -0x5c(%rbp), %xmm1
movsd 0x6fbb(%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 0x178dc
leaq 0x6fe4(%rip), %rdx      # 0x1e8c7
leaq -0x1a8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0xdac0
jmp 0x178f5
cvttsd2si -0x20(%rbp), %esi
leaq -0x1c8(%rbp), %rdi
callq 0xdbe0
jmp 0x17908
leaq -0x188(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
leaq -0x1c8(%rbp), %rdx
callq 0x11d30
jmp 0x17924
leaq 0x6fa4(%rip), %rdx      # 0x1e8cf
leaq -0x168(%rbp), %rdi
leaq -0x188(%rbp), %rsi
callq 0xdb40
jmp 0x17940
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movl %eax, -0x208(%rbp)
jmp 0x17955
movl -0x208(%rbp), %esi
leaq -0x1e8(%rbp), %rdi
callq 0xdbe0
jmp 0x17969
leaq -0x148(%rbp), %rdi
leaq -0x168(%rbp), %rsi
leaq -0x1e8(%rbp), %rdx
callq 0x11d30
jmp 0x17985
leaq 0x7181(%rip), %rdx      # 0x1eb0d
leaq -0x128(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0xdb40
jmp 0x179a1
movq -0x200(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x4240
jmp 0x179b6
leaq -0x128(%rbp), %rdi
callq 0x4130
leaq -0x148(%rbp), %rdi
callq 0x4130
leaq -0x1e8(%rbp), %rdi
callq 0x4130
leaq -0x168(%rbp), %rdi
callq 0x4130
leaq -0x188(%rbp), %rdi
callq 0x4130
leaq -0x1c8(%rbp), %rdi
callq 0x4130
leaq -0x1a8(%rbp), %rdi
callq 0x4130
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movl %eax, -0x20c(%rbp)
jmp 0x17a1f
movl -0x20c(%rbp), %eax
cmpl $0x0, %eax
jne 0x17b04
movq -0x200(%rbp), %rdi
leaq 0x6ea8(%rip), %rsi      # 0x1e8e4
callq 0x41a0
jmp 0x17a43
jmp 0x17b04
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x17af6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x17aea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x17ade
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x17ad2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x17ac6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x17aba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x4130
leaq -0x148(%rbp), %rdi
callq 0x4130
leaq -0x1e8(%rbp), %rdi
callq 0x4130
leaq -0x168(%rbp), %rdi
callq 0x4130
leaq -0x188(%rbp), %rdi
callq 0x4130
leaq -0x1c8(%rbp), %rdi
callq 0x4130
leaq -0x1a8(%rbp), %rdi
callq 0x4130
jmp 0x17b23
movb $0x1, -0x21(%rbp)
movl $0x1, -0x84(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x4130
testb $0x1, -0x21(%rbp)
jne 0x17b3a
jmp 0x17b2e
leaq -0x48(%rbp), %rdi
callq 0x4130
jmp 0x17b4a
movq -0x200(%rbp), %rdi
callq 0x4130
movq -0x1f8(%rbp), %rax
addq $0x210, %rsp            # imm = 0x210
popq %rbp
retq
movq -0x200(%rbp), %rdi
callq 0x4130
movq -0x50(%rbp), %rdi
callq 0x42f0
nop