// File: malcolmyeh[P]CC3K/vampire.cc
// Function: Vampire::dealDamage[abi:cxx11](Character*)
std::string Vampire::dealDamage(Character *opponent)
{
    double amount;
    double lifesteal;

    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);
    lifesteal = ceil(amount * 0.25);

    opponent->takeDamage((int)amount);

    this->HP += ((int)lifesteal);
    if (this->HP > 50){
        this->HP = 50;
    }

    combatMsg = attacker + " deals " + std::to_string((int)amount) + " damage to you (HP: " + std::to_string(opponent->getHP()) + "). ";
    combatMsg += "Vampire lifesteals for " + std::to_string((int)lifesteal) + " HP (HP: " + std::to_string(this->HP) + "). ";
    if (opponent->getHP() == 0)
    {
        combatMsg += "You have been slain.";
    }

    return combatMsg;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x280, %rsp            # imm = 0x280
movq %rdi, -0x268(%rbp)
movq %rdi, %rax
movq %rax, -0x260(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x258(%rbp)
movb $0x0, -0x29(%rbp)
callq 0x4280
movq -0x258(%rbp), %rsi
addq $0x18, %rsi
leaq -0x50(%rbp), %rdi
callq 0x40e0
jmp 0x16fa2
movq -0x258(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x60(%rbp)
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movl %eax, -0x26c(%rbp)
jmp 0x16fc4
movq -0x258(%rbp), %rax
movl -0x26c(%rbp), %ecx
movl %ecx, -0x64(%rbp)
testb $0x1, 0x39(%rax)
je 0x17052
movq -0x258(%rbp), %rax
movb $0x0, 0x39(%rax)
leaq 0x78ba(%rip), %rdx      # 0x1e8a6
leaq -0x88(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xdac0
jmp 0x16ffe
movq -0x268(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x4220
leaq -0x88(%rbp), %rdi
callq 0x4130
movb $0x1, -0x29(%rbp)
movl $0x1, -0x8c(%rbp)
jmp 0x174e4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x1751c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x174f5
callq 0x4090
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x170af
leaq 0x7849(%rip), %rdx      # 0x1e8b4
leaq -0xb0(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xdac0
jmp 0x1707d
movq -0x268(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x4220
leaq -0xb0(%rbp), %rdi
callq 0x4130
movb $0x1, -0x29(%rbp)
movl $0x1, -0x8c(%rbp)
jmp 0x174e4
cvtsi2sdl -0x64(%rbp), %xmm1
movsd 0x77ac(%rip), %xmm0     # 0x1e868
addsd %xmm0, %xmm1
divsd %xmm1, %xmm0
cvtsi2sdl -0x60(%rbp), %xmm1
mulsd %xmm1, %xmm0
callq 0x4050
movsd %xmm0, -0x20(%rbp)
movsd -0x20(%rbp), %xmm0
movsd 0x7834(%rip), %xmm1     # 0x1e918
mulsd %xmm1, %xmm0
callq 0x4050
movsd %xmm0, -0x28(%rbp)
movq -0x18(%rbp), %rdi
cvttsd2si -0x20(%rbp), %esi
movq (%rdi), %rax
movq 0x48(%rax), %rax
callq *%rax
jmp 0x17106
movq -0x258(%rbp), %rax
cvttsd2si -0x28(%rbp), %ecx
addl 0x10(%rax), %ecx
movl %ecx, 0x10(%rax)
cmpl $0x32, 0x10(%rax)
jle 0x1712c
movq -0x258(%rbp), %rax
movl $0x32, 0x10(%rax)
leaq 0x7794(%rip), %rdx      # 0x1e8c7
leaq -0x150(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xdac0
jmp 0x17145
cvttsd2si -0x20(%rbp), %esi
leaq -0x170(%rbp), %rdi
callq 0xdbe0
jmp 0x17158
leaq -0x130(%rbp), %rdi
leaq -0x150(%rbp), %rsi
leaq -0x170(%rbp), %rdx
callq 0x11d30
jmp 0x17174
leaq 0x7754(%rip), %rdx      # 0x1e8cf
leaq -0x110(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0xdb40
jmp 0x17190
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movl %eax, -0x270(%rbp)
jmp 0x171a5
movl -0x270(%rbp), %esi
leaq -0x190(%rbp), %rdi
callq 0xdbe0
jmp 0x171b9
leaq -0xf0(%rbp), %rdi
leaq -0x110(%rbp), %rsi
leaq -0x190(%rbp), %rdx
callq 0x11d30
jmp 0x171d5
leaq 0x7931(%rip), %rdx      # 0x1eb0d
leaq -0xd0(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0xdb40
jmp 0x171f1
movq -0x268(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
movq %rsi, -0x278(%rbp)
callq 0x4220
movq -0x278(%rbp), %rdi
callq 0x4130
leaq -0xf0(%rbp), %rdi
callq 0x4130
leaq -0x190(%rbp), %rdi
callq 0x4130
leaq -0x110(%rbp), %rdi
callq 0x4130
leaq -0x130(%rbp), %rdi
callq 0x4130
leaq -0x170(%rbp), %rdi
callq 0x4130
leaq -0x150(%rbp), %rdi
callq 0x4130
cvttsd2si -0x28(%rbp), %esi
leaq -0x230(%rbp), %rdi
callq 0xdbe0
jmp 0x17272
leaq 0x792f(%rip), %rsi      # 0x1eba8
leaq -0x210(%rbp), %rdi
leaq -0x230(%rbp), %rdx
callq 0xdb90
jmp 0x1728e
leaq 0x72c3(%rip), %rdx      # 0x1e558
leaq -0x1f0(%rbp), %rdi
leaq -0x210(%rbp), %rsi
callq 0xdb40
jmp 0x172aa
movq -0x258(%rbp), %rax
movl 0x10(%rax), %esi
leaq -0x250(%rbp), %rdi
callq 0xdbe0
jmp 0x172c2
leaq -0x1d0(%rbp), %rdi
leaq -0x1f0(%rbp), %rsi
leaq -0x250(%rbp), %rdx
callq 0x11d30
jmp 0x172de
leaq 0x7828(%rip), %rdx      # 0x1eb0d
leaq -0x1b0(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
callq 0xdb40
jmp 0x172fa
movq -0x268(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
callq 0x4240
jmp 0x1730f
leaq -0x1b0(%rbp), %rdi
callq 0x4130
leaq -0x1d0(%rbp), %rdi
callq 0x4130
leaq -0x250(%rbp), %rdi
callq 0x4130
leaq -0x1f0(%rbp), %rdi
callq 0x4130
leaq -0x210(%rbp), %rdi
callq 0x4130
leaq -0x230(%rbp), %rdi
callq 0x4130
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movl %eax, -0x27c(%rbp)
jmp 0x1736c
movl -0x27c(%rbp), %eax
cmpl $0x0, %eax
jne 0x174d6
movq -0x268(%rbp), %rdi
leaq 0x755b(%rip), %rsi      # 0x1e8e4
callq 0x41a0
jmp 0x17390
jmp 0x174d6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x17426
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x1741a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x1740e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x17402
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x173f6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x4130
leaq -0x190(%rbp), %rdi
callq 0x4130
leaq -0x110(%rbp), %rdi
callq 0x4130
leaq -0x130(%rbp), %rdi
callq 0x4130
leaq -0x170(%rbp), %rdi
callq 0x4130
leaq -0x150(%rbp), %rdi
callq 0x4130
jmp 0x174f5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x174c8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x174bc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x174b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x174a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x17498
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x4130
leaq -0x1d0(%rbp), %rdi
callq 0x4130
leaq -0x250(%rbp), %rdi
callq 0x4130
leaq -0x1f0(%rbp), %rdi
callq 0x4130
leaq -0x210(%rbp), %rdi
callq 0x4130
leaq -0x230(%rbp), %rdi
callq 0x4130
jmp 0x174f5
movb $0x1, -0x29(%rbp)
movl $0x1, -0x8c(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x4130
testb $0x1, -0x29(%rbp)
jne 0x1750c
jmp 0x17500
leaq -0x50(%rbp), %rdi
callq 0x4130
jmp 0x1751c
movq -0x268(%rbp), %rdi
callq 0x4130
movq -0x260(%rbp), %rax
addq $0x280, %rsp            # imm = 0x280
popq %rbp
retq
movq -0x268(%rbp), %rdi
callq 0x4130
movq -0x58(%rbp), %rdi
callq 0x42f0
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)