// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rdi, %rbx
leaq 0x10(%rdi), %rax
movq %rax, (%rdi)
andq $0x0, 0x8(%rdi)
movq %rdx, %r14
movq %rsi, %r15
movb $0x0, 0x10(%rdi)
addq $0x18, %rsi
leaq -0x68(%rbp), %rdi
callq 0x4200
movl 0x8(%r15), %r13d
movq (%r14), %rax
movq %r14, %rdi
callq *0x10(%rax)
cmpb $0x1, 0x39(%r15)
jne 0xc7c3
movb $0x0, 0x39(%r15)
leaq 0x4172(%rip), %rdx      # 0x10926
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x848f
jmp 0xc7e3
movl %eax, %r12d
callq 0x4070
testb $0x1, %al
jne 0xc818
leaq 0x415e(%rip), %rdx      # 0x10934
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x848f
leaq -0x48(%rbp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x41d0
movq %r14, %rdi
callq 0x40e0
leaq -0x68(%rbp), %rdi
callq 0x40e0
movq %rbx, %rax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x10(%r15), %eax
cmpl $0x1e, %eax
jg 0xc84e
leaq 0x44a1(%rip), %rdx      # 0x10cc9
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x848f
leaq -0x48(%rbp), %rsi
movq %rbx, %rdi
callq 0x41d0
leaq -0x48(%rbp), %rdi
callq 0x40e0
pushq $0x3
jmp 0xc8b0
cmpl $0x3c, %eax
ja 0xc880
leaq 0x449f(%rip), %rdx      # 0x10cf9
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x848f
leaq -0x48(%rbp), %rsi
movq %rbx, %rdi
callq 0x41d0
leaq -0x48(%rbp), %rdi
callq 0x40e0
pushq $0x2
jmp 0xc8b0
cmpl $0x5a, %eax
ja 0xc8b5
leaq 0x449a(%rip), %rdx      # 0x10d26
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x848f
leaq -0x48(%rbp), %rsi
movq %rbx, %rdi
callq 0x41d0
leaq -0x48(%rbp), %rdi
callq 0x40e0
pushq $0x1
popq %rax
addl %eax, 0x8(%r15)
cvtsi2sd %r12d, %xmm0
movsd 0x4026(%rip), %xmm1     # 0x108e8
addsd %xmm1, %xmm0
divsd %xmm0, %xmm1
cvtsi2sd %r13d, %xmm0
mulsd %xmm1, %xmm0
callq 0x4030
cvttsd2si %xmm0, %r15d
movq (%r14), %rax
movq %r14, %rdi
movl %r15d, %esi
callq *0x48(%rax)
leaq 0x4057(%rip), %rdx      # 0x10947
leaq -0xc8(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x848f
leaq -0xa8(%rbp), %rdi
movl %r15d, %esi
callq 0x851e
leaq -0xe8(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
leaq -0xa8(%rbp), %rdx
callq 0x9190
leaq 0x401f(%rip), %rdx      # 0x1094f
leaq -0x108(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x84c7
movq (%r14), %rax
movq %r14, %rdi
callq *0x18(%rax)
leaq -0x88(%rbp), %rdi
movl %eax, %esi
callq 0x851e
leaq -0x128(%rbp), %rdi
leaq -0x108(%rbp), %rsi
leaq -0x88(%rbp), %rdx
callq 0x9190
leaq 0x424a(%rip), %rdx      # 0x10bc5
leaq -0x48(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x84c7
leaq -0x48(%rbp), %rsi
movq %rbx, %rdi
callq 0x42b0
leaq -0x48(%rbp), %rdi
callq 0x40e0
leaq -0x128(%rbp), %rdi
callq 0x40e0
leaq -0x88(%rbp), %rdi
callq 0x40e0
leaq -0x108(%rbp), %rdi
callq 0x40e0
leaq -0xe8(%rbp), %rdi
callq 0x40e0
leaq -0xa8(%rbp), %rdi
callq 0x40e0
leaq -0xc8(%rbp), %rdi
callq 0x40e0
movq (%r14), %rax
movq %r14, %rdi
callq *0x18(%rax)
testl %eax, %eax
jne 0xc7fa
leaq 0x3f64(%rip), %rsi      # 0x10964
movq %rbx, %rdi
callq 0x4290
jmp 0xc7fa
jmp 0xca98
jmp 0xca98
jmp 0xca98
movq %rax, %r14
leaq -0x48(%rbp), %rdi
callq 0x40e0
jmp 0xca2a
movq %rax, %r14
leaq -0x128(%rbp), %rdi
callq 0x40e0
jmp 0xca3b
movq %rax, %r14
leaq -0x88(%rbp), %rdi
callq 0x40e0
jmp 0xca5f
movq %rax, %r14
jmp 0xca6b
movq %rax, %r14
jmp 0xca77
movq %rax, %r14
jmp 0xca83
jmp 0xca98
jmp 0xca98
movq %rax, %r14
leaq -0x108(%rbp), %rdi
callq 0x40e0
leaq -0xe8(%rbp), %rdi
callq 0x40e0
leaq -0xa8(%rbp), %rdi
callq 0x40e0
leaq -0xc8(%rbp), %rdi
callq 0x40e0
jmp 0xca9b
jmp 0xca98
movq %rax, %r14
jmp 0xcaa4
movq %rax, %r14
leaq -0x68(%rbp), %rdi
callq 0x40e0
movq %rbx, %rdi
callq 0x40e0
movq %r14, %rdi
callq 0x4280