// File: /workspace/github_cpp_makefile_star2_O2/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
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 -0x130(%rbp), %rdi
callq 0x4200
movl 0x8(%r15), %r13d
movq (%r14), %rax
movq %r14, %rdi
callq *0x10(%rax)
cmpb $0x1, 0x39(%r15)
jne 0xb59c
movb $0x0, 0x39(%r15)
leaq 0x539f(%rip), %rdx      # 0x10926
leaq -0x110(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x848f
jmp 0xb5c2
movl %eax, %r12d
callq 0x4070
testb $0x1, %al
jne 0xb5fd
leaq 0x5385(%rip), %rdx      # 0x10934
leaq -0x110(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x848f
leaq -0x110(%rbp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x41d0
movq %r14, %rdi
callq 0x40e0
leaq -0x130(%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
cvtsi2sd %r12d, %xmm0
movsd 0x52de(%rip), %xmm1     # 0x108e8
addsd %xmm1, %xmm0
divsd %xmm0, %xmm1
cvtsi2sd %r13d, %xmm0
mulsd %xmm1, %xmm0
callq 0x4030
movsd %xmm0, -0x30(%rbp)
callq 0x4070
pushq $0x5
popq %r12
cltd
idivl %r12d
testl %edx, %edx
je 0xb719
callq 0x4070
cltd
idivl %r12d
cmpl $0x1, %edx
je 0xb65a
callq 0x4070
cltd
idivl %r12d
cmpl $0x2, %edx
jne 0xb83f
movsd -0x30(%rbp), %xmm0
mulsd 0x5519(%rip), %xmm0     # 0x10b80
cvttsd2si %xmm0, %r15d
movq (%r14), %rax
movq %r14, %rdi
movl %r15d, %esi
callq *0x48(%rax)
leaq 0x554a(%rip), %rdx      # 0x10bc9
leaq -0x90(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x848f
leaq -0x70(%rbp), %rdi
movl %r15d, %esi
callq 0x851e
leaq -0xb0(%rbp), %rdi
leaq -0x90(%rbp), %rsi
leaq -0x70(%rbp), %rdx
callq 0x9190
leaq 0x5293(%rip), %rdx      # 0x1094f
leaq -0xd0(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x84c7
movq (%r14), %rax
movq %r14, %rdi
callq *0x18(%rax)
leaq -0x50(%rbp), %rdi
movl %eax, %esi
callq 0x851e
leaq -0xf0(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x9190
leaq 0x54c4(%rip), %rdx      # 0x10bc5
leaq -0x110(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x84c7
jmp 0xb8ed
cvttsd2si -0x30(%rbp), %r12d
movq (%r14), %rax
movq %r14, %rdi
movl %r12d, %esi
callq *0x48(%rax)
leaq 0x5215(%rip), %rdx      # 0x10947
leaq -0x90(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x848f
leaq -0x70(%rbp), %rdi
movl %r12d, %esi
callq 0x851e
leaq -0xb0(%rbp), %rdi
leaq -0x90(%rbp), %rsi
leaq -0x70(%rbp), %rdx
callq 0x9190
leaq 0x51e0(%rip), %rdx      # 0x1094f
leaq -0xd0(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x84c7
movq (%r14), %rax
movq %r14, %rdi
callq *0x18(%rax)
leaq -0x50(%rbp), %rdi
movl %eax, %esi
callq 0x851e
leaq -0xf0(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x9190
leaq 0x5411(%rip), %rdx      # 0x10bc5
leaq -0x110(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x84c7
leaq -0x110(%rbp), %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x41d0
movq %r12, %rdi
callq 0x40e0
leaq -0xf0(%rbp), %rdi
callq 0x40e0
leaq -0x50(%rbp), %rdi
callq 0x40e0
leaq -0xd0(%rbp), %rdi
callq 0x40e0
leaq -0xb0(%rbp), %rdi
callq 0x40e0
leaq -0x70(%rbp), %rdi
callq 0x40e0
leaq -0x90(%rbp), %rdi
callq 0x40e0
leaq 0x5366(%rip), %rsi      # 0x10b90
movq %rbx, %rdi
callq 0x4290
movl $0x32, 0x10(%r15)
jmp 0xb949
cvttsd2si -0x30(%rbp), %r15d
movq (%r14), %rax
movq %r14, %rdi
movl %r15d, %esi
callq *0x48(%rax)
leaq 0x50ef(%rip), %rdx      # 0x10947
leaq -0x90(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x848f
leaq -0x70(%rbp), %rdi
movl %r15d, %esi
callq 0x851e
leaq -0xb0(%rbp), %rdi
leaq -0x90(%rbp), %rsi
leaq -0x70(%rbp), %rdx
callq 0x9190
leaq 0x50ba(%rip), %rdx      # 0x1094f
leaq -0xd0(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x84c7
movq (%r14), %rax
movq %r14, %rdi
callq *0x18(%rax)
leaq -0x50(%rbp), %rdi
movl %eax, %esi
callq 0x851e
leaq -0xf0(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x9190
leaq 0x52eb(%rip), %rdx      # 0x10bc5
leaq -0x110(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x84c7
leaq -0x110(%rbp), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x41d0
movq %r15, %rdi
callq 0x40e0
leaq -0xf0(%rbp), %rdi
callq 0x40e0
leaq -0x50(%rbp), %rdi
callq 0x40e0
leaq -0xd0(%rbp), %rdi
callq 0x40e0
leaq -0xb0(%rbp), %rdi
callq 0x40e0
leaq -0x70(%rbp), %rdi
callq 0x40e0
leaq -0x90(%rbp), %rdi
callq 0x40e0
movq (%r14), %rax
movq %r14, %rdi
callq *0x18(%rax)
testl %eax, %eax
jne 0xb5dc
leaq 0x5003(%rip), %rsi      # 0x10964
movq %rbx, %rdi
callq 0x4290
jmp 0xb5dc
jmp 0xb988
jmp 0xb999
jmp 0xb9a7
jmp 0xb9ac
jmp 0xb9b1
jmp 0xb9f5
jmp 0xb9ba
jmp 0xb988
jmp 0xb999
jmp 0xb9a7
jmp 0xb9ac
jmp 0xb9b1
jmp 0xb9f5
movq %rax, %r14
leaq -0xf0(%rbp), %rdi
callq 0x40e0
jmp 0xb99c
movq %rax, %r14
leaq -0x50(%rbp), %rdi
callq 0x40e0
jmp 0xb9bd
movq %rax, %r14
jmp 0xb9c9
movq %rax, %r14
jmp 0xb9d5
movq %rax, %r14
jmp 0xb9de
jmp 0xb9f5
jmp 0xb9ba
movq %rax, %r14
leaq -0xd0(%rbp), %rdi
callq 0x40e0
leaq -0xb0(%rbp), %rdi
callq 0x40e0
leaq -0x70(%rbp), %rdi
callq 0x40e0
leaq -0x90(%rbp), %rdi
callq 0x40e0
jmp 0xb9f8
jmp 0xb9f5
jmp 0xb9f5
movq %rax, %r14
jmp 0xba04
movq %rax, %r14
leaq -0x130(%rbp), %rdi
callq 0x40e0
movq %rbx, %rdi
callq 0x40e0
movq %r14, %rdi
callq 0x4280