// File: malcolmyeh[P]CC3K/dragon.cc
// Function: Dragon::dealDamage[abi:cxx11](Character*)
std::string Dragon::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 (this->HP <= 50)
    {
        if (rand() % 2 == 0)
        {
            this->HP += 15;
            combatMsg += "Dragon's magical scales recovers 15 health (HP: " + std::to_string(this->HP) + "). ";
        }
    }

    if (rand() % 2 == 0)
    {
        combatMsg += attacker + "'s attack missed. ";
        return combatMsg;
    }


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

    if (rand() % 3 == 0)
    {
        amount *= 1.25;
        opponent->takeDamage((int)amount);
        combatMsg += attacker + " breathes fire, dealing " + std::to_string((int)amount) + " damage to you (HP: " + std::to_string(opponent->getHP()) + "). ";
    }
    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 $0x2f0, %rsp            # imm = 0x2F0
movq %rdi, -0x2e0(%rbp)
movq %rdi, %rax
movq %rax, -0x2d8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x2d0(%rbp)
movb $0x0, -0x21(%rbp)
callq 0x4280
movq -0x2d0(%rbp), %rsi
addq $0x18, %rsi
leaq -0x48(%rbp), %rdi
callq 0x40e0
jmp 0x18632
movq -0x2d0(%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, -0x2e4(%rbp)
jmp 0x18654
movq -0x2d0(%rbp), %rax
movl -0x2e4(%rbp), %ecx
movl %ecx, -0x5c(%rbp)
testb $0x1, 0x39(%rax)
je 0x186d9
movq -0x2d0(%rbp), %rax
movb $0x0, 0x39(%rax)
leaq 0x622a(%rip), %rdx      # 0x1e8a6
leaq -0x80(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0xdac0
jmp 0x1868b
movq -0x2e0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x4220
leaq -0x80(%rbp), %rdi
callq 0x4130
movb $0x1, -0x21(%rbp)
movl $0x1, -0x84(%rbp)
jmp 0x18d0d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x18d45
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x18d1e
movq -0x2d0(%rbp), %rax
cmpl $0x32, 0x10(%rax)
jg 0x187e7
callq 0x4090
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x187e5
movq -0x2d0(%rbp), %rax
movl 0x10(%rax), %ecx
addl $0xf, %ecx
movl %ecx, 0x10(%rax)
movl 0x10(%rax), %esi
leaq -0xe8(%rbp), %rdi
callq 0xdbe0
jmp 0x18721
leaq 0x6558(%rip), %rsi      # 0x1ec80
leaq -0xc8(%rbp), %rdi
leaq -0xe8(%rbp), %rdx
callq 0xdb90
jmp 0x1873d
leaq 0x63c9(%rip), %rdx      # 0x1eb0d
leaq -0xa8(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0xdb40
jmp 0x18759
movq -0x2e0(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x4240
jmp 0x1876e
leaq -0xa8(%rbp), %rdi
callq 0x4130
leaq -0xc8(%rbp), %rdi
callq 0x4130
leaq -0xe8(%rbp), %rdi
callq 0x4130
jmp 0x187e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x187d4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x187c8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x4130
leaq -0xc8(%rbp), %rdi
callq 0x4130
leaq -0xe8(%rbp), %rdi
callq 0x4130
jmp 0x18d1e
jmp 0x187e7
callq 0x4090
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x18863
leaq 0x60b4(%rip), %rdx      # 0x1e8b4
leaq -0x108(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0xdac0
jmp 0x18812
movq -0x2e0(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x4240
jmp 0x18827
leaq -0x108(%rbp), %rdi
callq 0x4130
movb $0x1, -0x21(%rbp)
movl $0x1, -0x84(%rbp)
jmp 0x18d0d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x4130
jmp 0x18d1e
cvtsi2sdl -0x5c(%rbp), %xmm0
movsd 0x5ff8(%rip), %xmm1     # 0x1e868
addsd %xmm0, %xmm1
movsd 0x5fec(%rip), %xmm0     # 0x1e868
divsd %xmm1, %xmm0
cvtsi2sdl -0x58(%rbp), %xmm1
mulsd %xmm1, %xmm0
callq 0x4050
movsd %xmm0, -0x20(%rbp)
callq 0x4090
movl $0x3, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x18ac5
movsd -0x20(%rbp), %xmm0
movsd 0x6212(%rip), %xmm1     # 0x1eac8
mulsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
movq -0x18(%rbp), %rdi
cvttsd2si -0x20(%rbp), %esi
movq (%rdi), %rax
movq 0x48(%rax), %rax
callq *%rax
jmp 0x188d3
leaq 0x63d7(%rip), %rdx      # 0x1ecb1
leaq -0x1a8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0xdac0
jmp 0x188ec
cvttsd2si -0x20(%rbp), %esi
leaq -0x1c8(%rbp), %rdi
callq 0xdbe0
jmp 0x188ff
leaq -0x188(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
leaq -0x1c8(%rbp), %rdx
callq 0x11d30
jmp 0x1891b
leaq 0x5fad(%rip), %rdx      # 0x1e8cf
leaq -0x168(%rbp), %rdi
leaq -0x188(%rbp), %rsi
callq 0xdb40
jmp 0x18937
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movl %eax, -0x2e8(%rbp)
jmp 0x1894c
movl -0x2e8(%rbp), %esi
leaq -0x1e8(%rbp), %rdi
callq 0xdbe0
jmp 0x18960
leaq -0x148(%rbp), %rdi
leaq -0x168(%rbp), %rsi
leaq -0x1e8(%rbp), %rdx
callq 0x11d30
jmp 0x1897c
leaq 0x618a(%rip), %rdx      # 0x1eb0d
leaq -0x128(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0xdb40
jmp 0x18998
movq -0x2e0(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x4240
jmp 0x189ad
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 0x18cc8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x18ab4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x18aa8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x18a9c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x18a90
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x18a84
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x18a78
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 0x18d1e
movq -0x18(%rbp), %rdi
cvttsd2si -0x20(%rbp), %esi
movq (%rdi), %rax
movq 0x48(%rax), %rax
callq *%rax
jmp 0x18ad9
leaq 0x5de7(%rip), %rdx      # 0x1e8c7
leaq -0x288(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0xdac0
jmp 0x18af2
cvttsd2si -0x20(%rbp), %esi
leaq -0x2a8(%rbp), %rdi
callq 0xdbe0
jmp 0x18b05
leaq -0x268(%rbp), %rdi
leaq -0x288(%rbp), %rsi
leaq -0x2a8(%rbp), %rdx
callq 0x11d30
jmp 0x18b21
leaq 0x5da7(%rip), %rdx      # 0x1e8cf
leaq -0x248(%rbp), %rdi
leaq -0x268(%rbp), %rsi
callq 0xdb40
jmp 0x18b3d
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movl %eax, -0x2ec(%rbp)
jmp 0x18b52
movl -0x2ec(%rbp), %esi
leaq -0x2c8(%rbp), %rdi
callq 0xdbe0
jmp 0x18b66
leaq -0x228(%rbp), %rdi
leaq -0x248(%rbp), %rsi
leaq -0x2c8(%rbp), %rdx
callq 0x11d30
jmp 0x18b82
leaq 0x5f84(%rip), %rdx      # 0x1eb0d
leaq -0x208(%rbp), %rdi
leaq -0x228(%rbp), %rsi
callq 0xdb40
jmp 0x18b9e
movq -0x2e0(%rbp), %rdi
leaq -0x208(%rbp), %rsi
callq 0x4240
jmp 0x18bb3
leaq -0x208(%rbp), %rdi
callq 0x4130
leaq -0x228(%rbp), %rdi
callq 0x4130
leaq -0x2c8(%rbp), %rdi
callq 0x4130
leaq -0x248(%rbp), %rdi
callq 0x4130
leaq -0x268(%rbp), %rdi
callq 0x4130
leaq -0x2a8(%rbp), %rdi
callq 0x4130
leaq -0x288(%rbp), %rdi
callq 0x4130
jmp 0x18cc8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x18cba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x18cae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x18ca2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x18c96
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x18c8a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x18c7e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x208(%rbp), %rdi
callq 0x4130
leaq -0x228(%rbp), %rdi
callq 0x4130
leaq -0x2c8(%rbp), %rdi
callq 0x4130
leaq -0x248(%rbp), %rdi
callq 0x4130
leaq -0x268(%rbp), %rdi
callq 0x4130
leaq -0x2a8(%rbp), %rdi
callq 0x4130
leaq -0x288(%rbp), %rdi
callq 0x4130
jmp 0x18d1e
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movl %eax, -0x2f0(%rbp)
jmp 0x18cdd
movl -0x2f0(%rbp), %eax
cmpl $0x0, %eax
jne 0x18cff
movq -0x2e0(%rbp), %rdi
leaq 0x5bee(%rip), %rsi      # 0x1e8e4
callq 0x41a0
jmp 0x18cfd
jmp 0x18cff
movb $0x1, -0x21(%rbp)
movl $0x1, -0x84(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x4130
testb $0x1, -0x21(%rbp)
jne 0x18d35
jmp 0x18d29
leaq -0x48(%rbp), %rdi
callq 0x4130
jmp 0x18d45
movq -0x2e0(%rbp), %rdi
callq 0x4130
movq -0x2d8(%rbp), %rax
addq $0x2f0, %rsp            # imm = 0x2F0
popq %rbp
retq
movq -0x2e0(%rbp), %rdi
callq 0x4130
movq -0x50(%rbp), %rdi
callq 0x42f0
nopw (%rax,%rax)