// File: malcolmyeh[P]CC3K/elf.cc
// Function: Elf::dealDamage[abi:cxx11](Character*)
std::string Elf::dealDamage(Character *opponent)
{
    double amount;
    std::string combatMsg;
    std::string defender = opponent->getRace();
    int attack = this->Atk;
    int defense = opponent->getDef();

    if (this->HP < 35)
    {
        if (rand() % 2 == 0)
        {
            this->heal(15); 
            combatMsg += "Elven magic restored 15 health (HP: " + std::to_string(this->HP) + "). ";
        }
    }
    amount = ceil((100.0 / (100.0 + defense)) * attack);

    if (rand() % 10 == 0)
    {
        opponent->getStunned();
        opponent->takeDamage((int)amount);
        combatMsg += "You cast Shockwave dealing " + std::to_string((int)amount) + " damage to " + defender + " (HP: " + std::to_string(opponent->getHP()) + ") and stunning them. ";
    }
    else
    {
        opponent->takeDamage((int)amount);
        combatMsg += "You deal " + std::to_string((int)amount) + " damage to " + defender + " (HP: " + std::to_string(opponent->getHP()) + "). ";
    }
    if (opponent->getHP() == 0)
    {
        combatMsg += defender + " has been slain. You have earned " + std::to_string(opponent->getGold()) + " gold. ";
        this->updateGold(opponent->getGold());
    }

    return combatMsg;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x370, %rsp            # imm = 0x370
movq %rdi, -0x358(%rbp)
movq %rdi, %rax
movq %rax, -0x350(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x348(%rbp)
movb $0x0, -0x21(%rbp)
callq 0x4280
movq -0x18(%rbp), %rsi
movq (%rsi), %rax
movq 0x28(%rax), %rax
leaq -0x48(%rbp), %rdi
callq *%rax
jmp 0x13eaf
movq -0x348(%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, -0x35c(%rbp)
jmp 0x13ed1
movq -0x348(%rbp), %rax
movl -0x35c(%rbp), %ecx
movl %ecx, -0x5c(%rbp)
cmpl $0x23, 0x10(%rax)
jge 0x14008
callq 0x4090
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x14006
movq -0x348(%rbp), %rdi
movl $0xf, %esi
callq 0x11c80
jmp 0x13f14
movq -0x348(%rbp), %rax
movl 0x10(%rax), %esi
leaq -0xc0(%rbp), %rdi
callq 0xdbe0
jmp 0x13f2c
leaq 0xaa1e(%rip), %rsi      # 0x1e951
leaq -0xa0(%rbp), %rdi
leaq -0xc0(%rbp), %rdx
callq 0xdb90
jmp 0x13f48
leaq 0xabbe(%rip), %rdx      # 0x1eb0d
leaq -0x80(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0xdb40
jmp 0x13f61
movq -0x358(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x4240
jmp 0x13f73
leaq -0x80(%rbp), %rdi
callq 0x4130
leaq -0xa0(%rbp), %rdi
callq 0x4130
leaq -0xc0(%rbp), %rdi
callq 0x4130
jmp 0x14006
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x146a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1467d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x13ff5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x13fe9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x4130
leaq -0xa0(%rbp), %rdi
callq 0x4130
leaq -0xc0(%rbp), %rdi
callq 0x4130
jmp 0x1467d
jmp 0x14008
cvtsi2sdl -0x5c(%rbp), %xmm0
movsd 0xa853(%rip), %xmm1     # 0x1e868
addsd %xmm0, %xmm1
movsd 0xa847(%rip), %xmm0     # 0x1e868
divsd %xmm1, %xmm0
cvtsi2sdl -0x58(%rbp), %xmm1
mulsd %xmm1, %xmm0
callq 0x4050
movsd %xmm0, -0x20(%rbp)
callq 0x4090
movl $0xa, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x142a4
movq -0x18(%rbp), %rdi
callq 0x11690
jmp 0x14059
movq -0x18(%rbp), %rdi
cvttsd2si -0x20(%rbp), %esi
movq (%rdi), %rax
movq 0x48(%rax), %rax
callq *%rax
jmp 0x1406d
cvttsd2si -0x20(%rbp), %esi
leaq -0x1a0(%rbp), %rdi
callq 0xdbe0
jmp 0x14080
leaq 0xa8ef(%rip), %rsi      # 0x1e976
leaq -0x180(%rbp), %rdi
leaq -0x1a0(%rbp), %rdx
callq 0xdb90
jmp 0x1409c
leaq 0xa7cd(%rip), %rdx      # 0x1e870
leaq -0x160(%rbp), %rdi
leaq -0x180(%rbp), %rsi
callq 0xdb40
jmp 0x140b8
leaq -0x140(%rbp), %rdi
leaq -0x160(%rbp), %rsi
leaq -0x48(%rbp), %rdx
callq 0x11e00
jmp 0x140d1
leaq 0xaaba(%rip), %rdx      # 0x1eb92
leaq -0x120(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0xdb40
jmp 0x140ed
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movl %eax, -0x360(%rbp)
jmp 0x14102
movl -0x360(%rbp), %esi
leaq -0x1c0(%rbp), %rdi
callq 0xdbe0
jmp 0x14116
leaq -0x100(%rbp), %rdi
leaq -0x120(%rbp), %rsi
leaq -0x1c0(%rbp), %rdx
callq 0x11d30
jmp 0x14132
leaq 0xa859(%rip), %rdx      # 0x1e992
leaq -0xe0(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0xdb40
jmp 0x1414e
movq -0x358(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x4240
jmp 0x14163
leaq -0xe0(%rbp), %rdi
callq 0x4130
leaq -0x100(%rbp), %rdi
callq 0x4130
leaq -0x1c0(%rbp), %rdi
callq 0x4130
leaq -0x120(%rbp), %rdi
callq 0x4130
leaq -0x140(%rbp), %rdi
callq 0x4130
leaq -0x160(%rbp), %rdi
callq 0x4130
leaq -0x180(%rbp), %rdi
callq 0x4130
leaq -0x1a0(%rbp), %rdi
callq 0x4130
jmp 0x144ef
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x14293
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x14287
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1427b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1426f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x14263
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x14257
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1424b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x4130
leaq -0x100(%rbp), %rdi
callq 0x4130
leaq -0x1c0(%rbp), %rdi
callq 0x4130
leaq -0x120(%rbp), %rdi
callq 0x4130
leaq -0x140(%rbp), %rdi
callq 0x4130
leaq -0x160(%rbp), %rdi
callq 0x4130
leaq -0x180(%rbp), %rdi
callq 0x4130
leaq -0x1a0(%rbp), %rdi
callq 0x4130
jmp 0x1467d
movq -0x18(%rbp), %rdi
cvttsd2si -0x20(%rbp), %esi
movq (%rdi), %rax
movq 0x48(%rax), %rax
callq *%rax
jmp 0x142b8
cvttsd2si -0x20(%rbp), %esi
leaq -0x2a0(%rbp), %rdi
callq 0xdbe0
jmp 0x142cb
leaq 0xa65a(%rip), %rsi      # 0x1e92c
leaq -0x280(%rbp), %rdi
leaq -0x2a0(%rbp), %rdx
callq 0xdb90
jmp 0x142e7
leaq 0xa582(%rip), %rdx      # 0x1e870
leaq -0x260(%rbp), %rdi
leaq -0x280(%rbp), %rsi
callq 0xdb40
jmp 0x14303
leaq -0x240(%rbp), %rdi
leaq -0x260(%rbp), %rsi
leaq -0x48(%rbp), %rdx
callq 0x11e00
jmp 0x1431c
leaq 0xa86f(%rip), %rdx      # 0x1eb92
leaq -0x220(%rbp), %rdi
leaq -0x240(%rbp), %rsi
callq 0xdb40
jmp 0x14338
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movl %eax, -0x364(%rbp)
jmp 0x1434d
movl -0x364(%rbp), %esi
leaq -0x2c0(%rbp), %rdi
callq 0xdbe0
jmp 0x14361
leaq -0x200(%rbp), %rdi
leaq -0x220(%rbp), %rsi
leaq -0x2c0(%rbp), %rdx
callq 0x11d30
jmp 0x1437d
leaq 0xa789(%rip), %rdx      # 0x1eb0d
leaq -0x1e0(%rbp), %rdi
leaq -0x200(%rbp), %rsi
callq 0xdb40
jmp 0x14399
movq -0x358(%rbp), %rdi
leaq -0x1e0(%rbp), %rsi
callq 0x4240
jmp 0x143ae
leaq -0x1e0(%rbp), %rdi
callq 0x4130
leaq -0x200(%rbp), %rdi
callq 0x4130
leaq -0x2c0(%rbp), %rdi
callq 0x4130
leaq -0x220(%rbp), %rdi
callq 0x4130
leaq -0x240(%rbp), %rdi
callq 0x4130
leaq -0x260(%rbp), %rdi
callq 0x4130
leaq -0x280(%rbp), %rdi
callq 0x4130
leaq -0x2a0(%rbp), %rdi
callq 0x4130
jmp 0x144ef
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x144de
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x144d2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x144c6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x144ba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x144ae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x144a2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x14496
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x1e0(%rbp), %rdi
callq 0x4130
leaq -0x200(%rbp), %rdi
callq 0x4130
leaq -0x2c0(%rbp), %rdi
callq 0x4130
leaq -0x220(%rbp), %rdi
callq 0x4130
leaq -0x240(%rbp), %rdi
callq 0x4130
leaq -0x260(%rbp), %rdi
callq 0x4130
leaq -0x280(%rbp), %rdi
callq 0x4130
leaq -0x2a0(%rbp), %rdi
callq 0x4130
jmp 0x1467d
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movl %eax, -0x368(%rbp)
jmp 0x14504
movl -0x368(%rbp), %eax
cmpl $0x0, %eax
jne 0x14668
leaq 0xa362(%rip), %rdx      # 0x1e87c
leaq -0x320(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0xdac0
jmp 0x1452c
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
callq *%rax
movl %eax, -0x36c(%rbp)
jmp 0x14541
movl -0x36c(%rbp), %esi
leaq -0x340(%rbp), %rdi
callq 0xdbe0
jmp 0x14555
leaq -0x300(%rbp), %rdi
leaq -0x320(%rbp), %rsi
leaq -0x340(%rbp), %rdx
callq 0x11d30
jmp 0x14571
leaq 0x9d3e(%rip), %rdx      # 0x1e2b6
leaq -0x2e0(%rbp), %rdi
leaq -0x300(%rbp), %rsi
callq 0xdb40
jmp 0x1458d
movq -0x358(%rbp), %rdi
leaq -0x2e0(%rbp), %rsi
callq 0x4240
jmp 0x145a2
leaq -0x2e0(%rbp), %rdi
callq 0x4130
leaq -0x300(%rbp), %rdi
callq 0x4130
leaq -0x340(%rbp), %rdi
callq 0x4130
leaq -0x320(%rbp), %rdi
callq 0x4130
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
callq *%rax
movl %eax, -0x370(%rbp)
jmp 0x145e7
movl -0x370(%rbp), %esi
movq -0x348(%rbp), %rdi
movq (%rdi), %rax
movq (%rax), %rax
callq *%rax
jmp 0x145fe
jmp 0x14668
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1465a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1464e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x14642
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x2e0(%rbp), %rdi
callq 0x4130
leaq -0x300(%rbp), %rdi
callq 0x4130
leaq -0x340(%rbp), %rdi
callq 0x4130
leaq -0x320(%rbp), %rdi
callq 0x4130
jmp 0x1467d
movb $0x1, -0x21(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x4130
testb $0x1, -0x21(%rbp)
jne 0x14694
jmp 0x14688
leaq -0x48(%rbp), %rdi
callq 0x4130
jmp 0x146a4
movq -0x358(%rbp), %rdi
callq 0x4130
movq -0x350(%rbp), %rax
addq $0x370, %rsp            # imm = 0x370
popq %rbp
retq
movq -0x358(%rbp), %rdi
callq 0x4130
movq -0x50(%rbp), %rdi
callq 0x42f0
nopl (%rax)