// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %rdi, %rbx
leaq 0x10(%rdi), %rax
movq %rax, (%rdi)
andq $0x0, 0x8(%rdi)
movq %rdx, %r15
movq %rsi, %r14
movb $0x0, 0x10(%rdi)
movq (%rdx), %rax
leaq -0x150(%rbp), %rdi
movq %rdx, %rsi
callq *0x28(%rax)
movl 0x8(%r14), %r13d
movq (%r15), %rax
movq %r15, %rdi
callq *0x10(%rax)
movl %eax, %r12d
cmpl $0x22, 0x10(%r14)
jg 0xa4b7
callq 0x4070
testb $0x1, %al
jne 0xa4b7
pushq $0xf
popq %rsi
movq %r14, %rdi
callq 0x9152
movl 0x10(%r14), %esi
leaq -0x48(%rbp), %rdi
callq 0x851e
leaq 0x656b(%rip), %rsi      # 0x109d1
leaq -0x68(%rbp), %rdi
leaq -0x48(%rbp), %rdx
callq 0x84f0
leaq 0x674b(%rip), %rdx      # 0x10bc5
leaq -0x88(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x84c7
leaq -0x88(%rbp), %rsi
movq %rbx, %rdi
callq 0x42b0
leaq -0x88(%rbp), %rdi
callq 0x40e0
leaq -0x68(%rbp), %rdi
callq 0x40e0
leaq -0x48(%rbp), %rdi
callq 0x40e0
cvtsi2sd %r12d, %xmm0
movsd 0x6424(%rip), %xmm1     # 0x108e8
addsd %xmm1, %xmm0
divsd %xmm0, %xmm1
cvtsi2sd %r13d, %xmm0
mulsd %xmm1, %xmm0
callq 0x4030
movsd %xmm0, -0x90(%rbp)
callq 0x4070
pushq $0xa
popq %rcx
cltd
idivl %ecx
testl %edx, %edx
je 0xa5d4
cvttsd2si -0x90(%rbp), %r12d
movq (%r15), %rax
movq %r15, %rdi
movl %r12d, %esi
callq *0x48(%rax)
leaq -0xf0(%rbp), %rdi
movl %r12d, %esi
callq 0x851e
leaq 0x648c(%rip), %rsi      # 0x109ac
leaq -0x110(%rbp), %rdi
leaq -0xf0(%rbp), %rdx
callq 0x84f0
leaq 0x63b6(%rip), %rdx      # 0x108f0
leaq -0x130(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x84c7
leaq -0xb0(%rbp), %rdi
leaq -0x130(%rbp), %rsi
leaq -0x150(%rbp), %rdx
callq 0x9201
leaq 0x66f4(%rip), %rdx      # 0x10c62
leaq -0x48(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x84c7
movq (%r15), %rax
movq %r15, %rdi
callq *0x18(%rax)
leaq -0xd0(%rbp), %rdi
movl %eax, %esi
callq 0x851e
leaq -0x68(%rbp), %rdi
leaq -0x48(%rbp), %rsi
leaq -0xd0(%rbp), %rdx
callq 0x9190
leaq 0x6615(%rip), %rdx      # 0x10bc5
leaq -0x88(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x84c7
leaq -0x88(%rbp), %rsi
movq %rbx, %rdi
callq 0x42b0
jmp 0xa6b6
movq %r15, %rdi
callq 0x8db6
cvttsd2si -0x90(%rbp), %r12d
movq (%r15), %rax
movq %r15, %rdi
movl %r12d, %esi
callq *0x48(%rax)
leaq -0xf0(%rbp), %rdi
movl %r12d, %esi
callq 0x851e
leaq 0x63ef(%rip), %rsi      # 0x109f6
leaq -0x110(%rbp), %rdi
leaq -0xf0(%rbp), %rdx
callq 0x84f0
leaq 0x62cf(%rip), %rdx      # 0x108f0
leaq -0x130(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x84c7
leaq -0xb0(%rbp), %rdi
leaq -0x130(%rbp), %rsi
leaq -0x150(%rbp), %rdx
callq 0x9201
leaq 0x660d(%rip), %rdx      # 0x10c62
leaq -0x48(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x84c7
movq (%r15), %rax
movq %r15, %rdi
callq *0x18(%rax)
leaq -0xd0(%rbp), %rdi
movl %eax, %esi
callq 0x851e
leaq -0x68(%rbp), %rdi
leaq -0x48(%rbp), %rsi
leaq -0xd0(%rbp), %rdx
callq 0x9190
leaq 0x637b(%rip), %rdx      # 0x10a12
leaq -0x88(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x84c7
leaq -0x88(%rbp), %rsi
movq %rbx, %rdi
callq 0x42b0
leaq -0x88(%rbp), %rdi
callq 0x40e0
leaq -0x68(%rbp), %rdi
callq 0x40e0
leaq -0xd0(%rbp), %rdi
callq 0x40e0
leaq -0x48(%rbp), %rdi
callq 0x40e0
leaq -0xb0(%rbp), %rdi
callq 0x40e0
leaq -0x130(%rbp), %rdi
callq 0x40e0
leaq -0x110(%rbp), %rdi
callq 0x40e0
leaq -0xf0(%rbp), %rdi
callq 0x40e0
movq (%r15), %rax
movq %r15, %rdi
callq *0x18(%rax)
testl %eax, %eax
jne 0xa7c6
leaq 0x61d4(%rip), %rdx      # 0x108fc
leaq -0x48(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x848f
movq (%r15), %rax
movq %r15, %rdi
callq *0x20(%rax)
leaq -0xb0(%rbp), %rdi
movl %eax, %esi
callq 0x851e
leaq -0x68(%rbp), %rdi
leaq -0x48(%rbp), %rsi
leaq -0xb0(%rbp), %rdx
callq 0x9190
leaq 0x5bcc(%rip), %rdx      # 0x10336
leaq -0x88(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x84c7
leaq -0x88(%rbp), %rsi
movq %rbx, %rdi
callq 0x42b0
leaq -0x88(%rbp), %rdi
callq 0x40e0
leaq -0x68(%rbp), %rdi
callq 0x40e0
leaq -0xb0(%rbp), %rdi
callq 0x40e0
leaq -0x48(%rbp), %rdi
callq 0x40e0
movq (%r15), %rax
movq %r15, %rdi
callq *0x20(%rax)
movq (%r14), %rcx
movq %r14, %rdi
movl %eax, %esi
callq *(%rcx)
leaq -0x150(%rbp), %rdi
callq 0x40e0
movq %rbx, %rax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
leaq -0x88(%rbp), %rdi
callq 0x40e0
jmp 0xa7fb
movq %rax, %r14
leaq -0x68(%rbp), %rdi
jmp 0xa834
jmp 0xa899
jmp 0xa8e7
movq %rax, %r14
leaq -0x88(%rbp), %rdi
callq 0x40e0
jmp 0xa81f
movq %rax, %r14
leaq -0x68(%rbp), %rdi
callq 0x40e0
jmp 0xa82d
movq %rax, %r14
leaq -0xb0(%rbp), %rdi
callq 0x40e0
jmp 0xa89c
jmp 0xa8e7
jmp 0xa853
jmp 0xa864
jmp 0xa872
jmp 0xa883
jmp 0xa888
jmp 0xa88d
jmp 0xa892
jmp 0xa8e7
movq %rax, %r14
leaq -0x88(%rbp), %rdi
callq 0x40e0
jmp 0xa867
movq %rax, %r14
leaq -0x68(%rbp), %rdi
callq 0x40e0
jmp 0xa875
movq %rax, %r14
leaq -0xd0(%rbp), %rdi
callq 0x40e0
jmp 0xa8ac
movq %rax, %r14
jmp 0xa8b5
movq %rax, %r14
jmp 0xa8c1
movq %rax, %r14
jmp 0xa8cd
movq %rax, %r14
jmp 0xa8d9
jmp 0xa8e7
movq %rax, %r14
leaq -0x48(%rbp), %rdi
jmp 0xa8e0
jmp 0xa8a9
movq %rax, %r14
jmp 0xa8f6
movq %rax, %r14
leaq -0x48(%rbp), %rdi
callq 0x40e0
leaq -0xb0(%rbp), %rdi
callq 0x40e0
leaq -0x130(%rbp), %rdi
callq 0x40e0
leaq -0x110(%rbp), %rdi
callq 0x40e0
leaq -0xf0(%rbp), %rdi
callq 0x40e0
jmp 0xa8ea
movq %rax, %r14
leaq -0x150(%rbp), %rdi
callq 0x40e0
movq %rbx, %rdi
callq 0x40e0
movq %r14, %rdi
callq 0x4280
nop