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

    int chance = rand() % 40;

    if (chance == 0 || chance == 1)
    {
        //longsword
        this->increaseAtk(1);
        combatMsg += "You forged a Longsword. Atk increased by 1 (Atk: " + std::to_string(this->Atk) + "). ";
    }
    else if (chance == 2)
    {
        //broadsword
        this->increaseAtk(2);
        combatMsg += "You forged a Broadsword. Atk increased by 2 (Atk: " + std::to_string(this->Atk) + "). ";
    }
    else if (chance == 3 || chance == 4)
    {
        //light shield
        this->increaseDef(1);
        combatMsg += "You forged a Light Shield. Def increased by 1 (Def: " + std::to_string(this->Def) + "). ";
    }
    else if (chance == 5)
    {
        //heavy shield
        this->increaseDef(2);
        combatMsg += "You forged a Heavy Shield. Def increased by 2 (Def: " + std::to_string(this->Def) + "). ";
    }

    amount = ceil((100.0 / (100.0 + defense)) * attack);

    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 -0xc8(%rbp), %rdi
movq %rdx, %rsi
callq *0x28(%rax)
movl 0x8(%r14), %r13d
movq (%r15), %rax
movq %r15, %rdi
callq *0x10(%rax)
movl %eax, %r12d
callq 0x4070
pushq $0x28
popq %rcx
cltd
idivl %ecx
cmpl $0x1, %edx
ja 0xaaf6
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x9172
movl 0x8(%r14), %esi
leaq -0x48(%rbp), %rdi
callq 0x851e
leaq 0x5f75(%rip), %rsi      # 0x10a33
leaq -0x68(%rbp), %rdi
leaq -0x48(%rbp), %rdx
callq 0x84f0
leaq 0x60f3(%rip), %rdx      # 0x10bc5
leaq -0x88(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x84c7
leaq -0x88(%rbp), %rsi
movq %rbx, %rdi
callq 0x42b0
jmp 0xac05
cmpl $0x2, %edx
jne 0xab52
pushq $0x2
popq %rsi
movq %r14, %rdi
callq 0x9172
movl 0x8(%r14), %esi
leaq -0x48(%rbp), %rdi
callq 0x851e
leaq 0x5f4b(%rip), %rsi      # 0x10a65
leaq -0x68(%rbp), %rdi
leaq -0x48(%rbp), %rdx
callq 0x84f0
leaq 0x6097(%rip), %rdx      # 0x10bc5
leaq -0x88(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x84c7
leaq -0x88(%rbp), %rsi
movq %rbx, %rdi
callq 0x42b0
jmp 0xac05
leal -0x3(%rdx), %eax
cmpl $0x1, %eax
ja 0xabae
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x917c
movl 0xc(%r14), %esi
leaq -0x48(%rbp), %rdi
callq 0x851e
leaq 0x5f1f(%rip), %rsi      # 0x10a98
leaq -0x68(%rbp), %rdi
leaq -0x48(%rbp), %rdx
callq 0x84f0
leaq 0x6038(%rip), %rdx      # 0x10bc5
leaq -0x88(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x84c7
leaq -0x88(%rbp), %rsi
movq %rbx, %rdi
callq 0x42b0
jmp 0xac05
cmpl $0x5, %edx
jne 0xac23
pushq $0x2
popq %rsi
movq %r14, %rdi
callq 0x917c
movl 0xc(%r14), %esi
leaq -0x48(%rbp), %rdi
callq 0x851e
leaq 0x5efb(%rip), %rsi      # 0x10acd
leaq -0x68(%rbp), %rdi
leaq -0x48(%rbp), %rdx
callq 0x84f0
leaq 0x5fdf(%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 0x5cb8(%rip), %xmm1     # 0x108e8
addsd %xmm1, %xmm0
divsd %xmm0, %xmm1
cvtsi2sd %r13d, %xmm0
mulsd %xmm1, %xmm0
callq 0x4030
cvttsd2si %xmm0, %r12d
movq (%r15), %rax
movq %r15, %rdi
movl %r12d, %esi
callq *0x48(%rax)
leaq -0x108(%rbp), %rdi
movl %r12d, %esi
callq 0x851e
leaq 0x5d3f(%rip), %rsi      # 0x109ac
leaq -0x128(%rbp), %rdi
leaq -0x108(%rbp), %rdx
callq 0x84f0
leaq 0x5c69(%rip), %rdx      # 0x108f0
leaq -0x148(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x84c7
leaq -0xa8(%rbp), %rdi
leaq -0x148(%rbp), %rsi
leaq -0xc8(%rbp), %rdx
callq 0x9201
leaq 0x5fa7(%rip), %rdx      # 0x10c62
leaq -0x48(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x84c7
movq (%r15), %rax
movq %r15, %rdi
callq *0x18(%rax)
leaq -0xe8(%rbp), %rdi
movl %eax, %esi
callq 0x851e
leaq -0x68(%rbp), %rdi
leaq -0x48(%rbp), %rsi
leaq -0xe8(%rbp), %rdx
callq 0x9190
leaq 0x5ec8(%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 -0xe8(%rbp), %rdi
callq 0x40e0
leaq -0x48(%rbp), %rdi
callq 0x40e0
leaq -0xa8(%rbp), %rdi
callq 0x40e0
leaq -0x148(%rbp), %rdi
callq 0x40e0
leaq -0x128(%rbp), %rdi
callq 0x40e0
leaq -0x108(%rbp), %rdi
callq 0x40e0
movq (%r15), %rax
movq %r15, %rdi
callq *0x18(%rax)
testl %eax, %eax
jne 0xae2c
leaq 0x5b6e(%rip), %rdx      # 0x108fc
leaq -0x48(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x848f
movq (%r15), %rax
movq %r15, %rdi
callq *0x20(%rax)
leaq -0xa8(%rbp), %rdi
movl %eax, %esi
callq 0x851e
leaq -0x68(%rbp), %rdi
leaq -0x48(%rbp), %rsi
leaq -0xa8(%rbp), %rdx
callq 0x9190
leaq 0x5566(%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 -0xa8(%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 -0xc8(%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
jmp 0xae9e
jmp 0xaeaf
jmp 0xaec4
jmp 0xaf5b
jmp 0xae9e
jmp 0xaeaf
jmp 0xaec4
jmp 0xaf5b
jmp 0xae9e
jmp 0xaeaf
jmp 0xaec4
jmp 0xaf5b
movq %rax, %r14
leaq -0x88(%rbp), %rdi
callq 0x40e0
jmp 0xae82
movq %rax, %r14
leaq -0x68(%rbp), %rdi
callq 0x40e0
jmp 0xae90
movq %rax, %r14
leaq -0xa8(%rbp), %rdi
jmp 0xaeb6
jmp 0xaf5b
movq %rax, %r14
leaq -0x88(%rbp), %rdi
callq 0x40e0
jmp 0xaeb2
movq %rax, %r14
leaq -0x68(%rbp), %rdi
callq 0x40e0
jmp 0xaec7
jmp 0xaec4
jmp 0xaf5b
movq %rax, %r14
leaq -0x48(%rbp), %rdi
jmp 0xaf54
movq %rax, %r14
leaq -0x88(%rbp), %rdi
callq 0x40e0
jmp 0xaee4
movq %rax, %r14
leaq -0x68(%rbp), %rdi
callq 0x40e0
jmp 0xaef2
movq %rax, %r14
leaq -0xe8(%rbp), %rdi
callq 0x40e0
jmp 0xaf20
movq %rax, %r14
jmp 0xaf29
movq %rax, %r14
jmp 0xaf35
movq %rax, %r14
jmp 0xaf41
movq %rax, %r14
jmp 0xaf4d
jmp 0xaf5b
jmp 0xaf5b
movq %rax, %r14
jmp 0xaf6a
movq %rax, %r14
leaq -0x48(%rbp), %rdi
callq 0x40e0
leaq -0xa8(%rbp), %rdi
callq 0x40e0
leaq -0x148(%rbp), %rdi
callq 0x40e0
leaq -0x128(%rbp), %rdi
callq 0x40e0
leaq -0x108(%rbp), %rdi
callq 0x40e0
jmp 0xaf5e
movq %rax, %r14
leaq -0xc8(%rbp), %rdi
callq 0x40e0
movq %rbx, %rdi
callq 0x40e0
movq %r14, %rdi
callq 0x4280
nop