// File: malcolmyeh[P]CC3K/phoenix.cc
// Function: Phoenix::dealDamage[abi:cxx11](Character*)
std::string Phoenix::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;
    }
    amount = ceil((100.0 / (100.0 + defense)) * attack);

    if (rand() % 5 == 0)
    {
        //rebirth
        opponent->takeDamage((int)amount);
        combatMsg = attacker + " deals " + std::to_string((int)amount) + " damage to you (HP: " + std::to_string(opponent->getHP()) + "). ";
        combatMsg += "Phoenix consumes itself in fire and is reborn (HP: 50). ";
        this->HP = 50;
    }
    else if (rand() % 5 == 1 || rand() % 5 == 2)
    {
        //critical strike
        amount *= 1.25;
        opponent->takeDamage((int)amount);
        combatMsg = attacker + " unleashes its fire energy, 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 $0x380, %rsp            # imm = 0x380
movq %rdi, -0x360(%rbp)
movq %rdi, %rax
movq %rax, -0x358(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x350(%rbp)
movb $0x0, -0x21(%rbp)
callq 0x4280
movq -0x350(%rbp), %rsi
addq $0x18, %rsi
leaq -0x48(%rbp), %rdi
callq 0x40e0
jmp 0x15a62
movq -0x350(%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, -0x364(%rbp)
jmp 0x15a84
movq -0x350(%rbp), %rax
movl -0x364(%rbp), %ecx
movl %ecx, -0x5c(%rbp)
testb $0x1, 0x39(%rax)
je 0x15b09
movq -0x350(%rbp), %rax
movb $0x0, 0x39(%rax)
leaq 0x8dfa(%rip), %rdx      # 0x1e8a6
leaq -0x80(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0xdac0
jmp 0x15abb
movq -0x360(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x4220
leaq -0x80(%rbp), %rdi
callq 0x4130
movb $0x1, -0x21(%rbp)
movl $0x1, -0x84(%rbp)
jmp 0x1620d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x16245
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1621e
callq 0x4090
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x15b66
leaq 0x8d92(%rip), %rdx      # 0x1e8b4
leaq -0xa8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0xdac0
jmp 0x15b34
movq -0x360(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x4220
leaq -0xa8(%rbp), %rdi
callq 0x4130
movb $0x1, -0x21(%rbp)
movl $0x1, -0x84(%rbp)
jmp 0x1620d
cvtsi2sdl -0x5c(%rbp), %xmm0
movsd 0x8cf5(%rip), %xmm1     # 0x1e868
addsd %xmm0, %xmm1
movsd 0x8ce9(%rip), %xmm0     # 0x1e868
divsd %xmm1, %xmm0
cvtsi2sdl -0x58(%rbp), %xmm1
mulsd %xmm1, %xmm0
callq 0x4050
movsd %xmm0, -0x20(%rbp)
callq 0x4090
movl $0x5, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x15dbd
movq -0x18(%rbp), %rdi
cvttsd2si -0x20(%rbp), %esi
movq (%rdi), %rax
movq 0x48(%rax), %rax
callq *%rax
jmp 0x15bc0
leaq 0x8d00(%rip), %rdx      # 0x1e8c7
leaq -0x148(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0xdac0
jmp 0x15bd9
cvttsd2si -0x20(%rbp), %esi
leaq -0x168(%rbp), %rdi
callq 0xdbe0
jmp 0x15bec
leaq -0x128(%rbp), %rdi
leaq -0x148(%rbp), %rsi
leaq -0x168(%rbp), %rdx
callq 0x11d30
jmp 0x15c08
leaq 0x8cc0(%rip), %rdx      # 0x1e8cf
leaq -0x108(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0xdb40
jmp 0x15c24
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movl %eax, -0x368(%rbp)
jmp 0x15c39
movl -0x368(%rbp), %esi
leaq -0x188(%rbp), %rdi
callq 0xdbe0
jmp 0x15c4d
leaq -0xe8(%rbp), %rdi
leaq -0x108(%rbp), %rsi
leaq -0x188(%rbp), %rdx
callq 0x11d30
jmp 0x15c69
leaq 0x8e9d(%rip), %rdx      # 0x1eb0d
leaq -0xc8(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0xdb40
jmp 0x15c85
movq -0x360(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
movq %rsi, -0x370(%rbp)
callq 0x4220
movq -0x370(%rbp), %rdi
callq 0x4130
leaq -0xe8(%rbp), %rdi
callq 0x4130
leaq -0x188(%rbp), %rdi
callq 0x4130
leaq -0x108(%rbp), %rdi
callq 0x4130
leaq -0x128(%rbp), %rdi
callq 0x4130
leaq -0x168(%rbp), %rdi
callq 0x4130
leaq -0x148(%rbp), %rdi
callq 0x4130
movq -0x360(%rbp), %rdi
leaq 0x8dd7(%rip), %rsi      # 0x1ead8
callq 0x41a0
jmp 0x15d08
movq -0x350(%rbp), %rax
movl $0x32, 0x10(%rax)
jmp 0x161c8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x15dac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x15da0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x15d94
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x15d88
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x15d7c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x4130
leaq -0x188(%rbp), %rdi
callq 0x4130
leaq -0x108(%rbp), %rdi
callq 0x4130
leaq -0x128(%rbp), %rdi
callq 0x4130
leaq -0x168(%rbp), %rdi
callq 0x4130
leaq -0x148(%rbp), %rdi
callq 0x4130
jmp 0x1621e
callq 0x4090
movl $0x5, %ecx
cltd
idivl %ecx
cmpl $0x1, %edx
je 0x15de5
callq 0x4090
movl $0x5, %ecx
cltd
idivl %ecx
cmpl $0x2, %edx
jne 0x15fe2
movsd -0x20(%rbp), %xmm0
movsd 0x8cd6(%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 0x15e0f
leaq 0x8cfb(%rip), %rdx      # 0x1eb11
leaq -0x228(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0xdac0
jmp 0x15e28
cvttsd2si -0x20(%rbp), %esi
leaq -0x248(%rbp), %rdi
callq 0xdbe0
jmp 0x15e3b
leaq -0x208(%rbp), %rdi
leaq -0x228(%rbp), %rsi
leaq -0x248(%rbp), %rdx
callq 0x11d30
jmp 0x15e57
leaq 0x8a71(%rip), %rdx      # 0x1e8cf
leaq -0x1e8(%rbp), %rdi
leaq -0x208(%rbp), %rsi
callq 0xdb40
jmp 0x15e73
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movl %eax, -0x374(%rbp)
jmp 0x15e88
movl -0x374(%rbp), %esi
leaq -0x268(%rbp), %rdi
callq 0xdbe0
jmp 0x15e9c
leaq -0x1c8(%rbp), %rdi
leaq -0x1e8(%rbp), %rsi
leaq -0x268(%rbp), %rdx
callq 0x11d30
jmp 0x15eb8
leaq 0x8c4e(%rip), %rdx      # 0x1eb0d
leaq -0x1a8(%rbp), %rdi
leaq -0x1c8(%rbp), %rsi
callq 0xdb40
jmp 0x15ed4
movq -0x360(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x4220
leaq -0x1a8(%rbp), %rdi
callq 0x4130
leaq -0x1c8(%rbp), %rdi
callq 0x4130
leaq -0x268(%rbp), %rdi
callq 0x4130
leaq -0x1e8(%rbp), %rdi
callq 0x4130
leaq -0x208(%rbp), %rdi
callq 0x4130
leaq -0x248(%rbp), %rdi
callq 0x4130
leaq -0x228(%rbp), %rdi
callq 0x4130
jmp 0x161c6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x15fd1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x15fc5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x15fb9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x15fad
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x15fa1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x1c8(%rbp), %rdi
callq 0x4130
leaq -0x268(%rbp), %rdi
callq 0x4130
leaq -0x1e8(%rbp), %rdi
callq 0x4130
leaq -0x208(%rbp), %rdi
callq 0x4130
leaq -0x248(%rbp), %rdi
callq 0x4130
leaq -0x228(%rbp), %rdi
callq 0x4130
jmp 0x1621e
movq -0x18(%rbp), %rdi
cvttsd2si -0x20(%rbp), %esi
movq (%rdi), %rax
movq 0x48(%rax), %rax
callq *%rax
jmp 0x15ff6
leaq 0x88ca(%rip), %rdx      # 0x1e8c7
leaq -0x308(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0xdac0
jmp 0x1600f
cvttsd2si -0x20(%rbp), %esi
leaq -0x328(%rbp), %rdi
callq 0xdbe0
jmp 0x16022
leaq -0x2e8(%rbp), %rdi
leaq -0x308(%rbp), %rsi
leaq -0x328(%rbp), %rdx
callq 0x11d30
jmp 0x1603e
leaq 0x888a(%rip), %rdx      # 0x1e8cf
leaq -0x2c8(%rbp), %rdi
leaq -0x2e8(%rbp), %rsi
callq 0xdb40
jmp 0x1605a
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movl %eax, -0x378(%rbp)
jmp 0x1606f
movl -0x378(%rbp), %esi
leaq -0x348(%rbp), %rdi
callq 0xdbe0
jmp 0x16083
leaq -0x2a8(%rbp), %rdi
leaq -0x2c8(%rbp), %rsi
leaq -0x348(%rbp), %rdx
callq 0x11d30
jmp 0x1609f
leaq 0x8a67(%rip), %rdx      # 0x1eb0d
leaq -0x288(%rbp), %rdi
leaq -0x2a8(%rbp), %rsi
callq 0xdb40
jmp 0x160bb
movq -0x360(%rbp), %rdi
leaq -0x288(%rbp), %rsi
callq 0x4220
leaq -0x288(%rbp), %rdi
callq 0x4130
leaq -0x2a8(%rbp), %rdi
callq 0x4130
leaq -0x348(%rbp), %rdi
callq 0x4130
leaq -0x2c8(%rbp), %rdi
callq 0x4130
leaq -0x2e8(%rbp), %rdi
callq 0x4130
leaq -0x328(%rbp), %rdi
callq 0x4130
leaq -0x308(%rbp), %rdi
callq 0x4130
jmp 0x161c6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x161b8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x161ac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x161a0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x16194
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x16188
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x2a8(%rbp), %rdi
callq 0x4130
leaq -0x348(%rbp), %rdi
callq 0x4130
leaq -0x2c8(%rbp), %rdi
callq 0x4130
leaq -0x2e8(%rbp), %rdi
callq 0x4130
leaq -0x328(%rbp), %rdi
callq 0x4130
leaq -0x308(%rbp), %rdi
callq 0x4130
jmp 0x1621e
jmp 0x161c8
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movl %eax, -0x37c(%rbp)
jmp 0x161dd
movl -0x37c(%rbp), %eax
cmpl $0x0, %eax
jne 0x161ff
movq -0x360(%rbp), %rdi
leaq 0x86ee(%rip), %rsi      # 0x1e8e4
callq 0x41a0
jmp 0x161fd
jmp 0x161ff
movb $0x1, -0x21(%rbp)
movl $0x1, -0x84(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x4130
testb $0x1, -0x21(%rbp)
jne 0x16235
jmp 0x16229
leaq -0x48(%rbp), %rdi
callq 0x4130
jmp 0x16245
movq -0x360(%rbp), %rdi
callq 0x4130
movq -0x358(%rbp), %rax
addq $0x380, %rsp            # imm = 0x380
popq %rbp
retq
movq -0x360(%rbp), %rdi
callq 0x4130
movq -0x50(%rbp), %rdi
callq 0x42f0
nopw (%rax,%rax)