// File: malcolmyeh[P]CC3K/enemy.cc
// Function: Enemy::dealDamage[abi:cxx11](Character*)
std::string Enemy::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);

    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 $0x1c0, %rsp            # imm = 0x1C0
movq %rdi, -0x1a0(%rbp)
movq %rdi, %rax
movq %rax, -0x198(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x190(%rbp)
movb $0x0, -0x21(%rbp)
callq 0x4280
movq -0x190(%rbp), %rsi
addq $0x18, %rsi
leaq -0x48(%rbp), %rdi
callq 0x40e0
jmp 0x12502
movq -0x190(%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, -0x1a4(%rbp)
jmp 0x12524
movq -0x190(%rbp), %rax
movl -0x1a4(%rbp), %ecx
movl %ecx, -0x5c(%rbp)
testb $0x1, 0x39(%rax)
je 0x125a9
movq -0x190(%rbp), %rax
movb $0x0, 0x39(%rax)
leaq 0xc35a(%rip), %rdx      # 0x1e8a6
leaq -0x80(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0xdac0
jmp 0x1255b
movq -0x1a0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x4220
leaq -0x80(%rbp), %rdi
callq 0x4130
movb $0x1, -0x21(%rbp)
movl $0x1, -0x84(%rbp)
jmp 0x12860
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x12898
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x12871
callq 0x4090
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x12606
leaq 0xc2f2(%rip), %rdx      # 0x1e8b4
leaq -0xa8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0xdac0
jmp 0x125d4
movq -0x1a0(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x4220
leaq -0xa8(%rbp), %rdi
callq 0x4130
movb $0x1, -0x21(%rbp)
movl $0x1, -0x84(%rbp)
jmp 0x12860
cvtsi2sdl -0x5c(%rbp), %xmm1
movsd 0xc255(%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 0x12642
leaq 0xc27e(%rip), %rdx      # 0x1e8c7
leaq -0x148(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0xdac0
jmp 0x1265b
cvttsd2si -0x20(%rbp), %esi
leaq -0x168(%rbp), %rdi
callq 0xdbe0
jmp 0x1266e
leaq -0x128(%rbp), %rdi
leaq -0x148(%rbp), %rsi
leaq -0x168(%rbp), %rdx
callq 0x11d30
jmp 0x1268a
leaq 0xc23e(%rip), %rdx      # 0x1e8cf
leaq -0x108(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0xdb40
jmp 0x126a6
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movl %eax, -0x1a8(%rbp)
jmp 0x126bb
movl -0x1a8(%rbp), %esi
leaq -0x188(%rbp), %rdi
callq 0xdbe0
jmp 0x126cf
leaq -0xe8(%rbp), %rdi
leaq -0x108(%rbp), %rsi
leaq -0x188(%rbp), %rdx
callq 0x11d30
jmp 0x126eb
leaq 0xc41b(%rip), %rdx      # 0x1eb0d
leaq -0xc8(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0xdb40
jmp 0x12707
movq -0x1a0(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
movq %rsi, -0x1b8(%rbp)
callq 0x4220
movq -0x1b8(%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 -0x18(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movl %eax, -0x1ac(%rbp)
jmp 0x1278a
movl -0x1ac(%rbp), %eax
cmpl $0x0, %eax
jne 0x12852
movq -0x1a0(%rbp), %rdi
leaq 0xc13d(%rip), %rsi      # 0x1e8e4
callq 0x41a0
jmp 0x127ae
jmp 0x12852
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x12844
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x12838
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1282c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x12820
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x12814
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 0x12871
movb $0x1, -0x21(%rbp)
movl $0x1, -0x84(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x4130
testb $0x1, -0x21(%rbp)
jne 0x12888
jmp 0x1287c
leaq -0x48(%rbp), %rdi
callq 0x4130
jmp 0x12898
movq -0x1a0(%rbp), %rdi
callq 0x4130
movq -0x198(%rbp), %rax
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbp
retq
movq -0x1a0(%rbp), %rdi
callq 0x4130
movq -0x50(%rbp), %rdi
callq 0x42f0
nopl (%rax)