// File: /workspace/github_c_makefile_star2_O0/Ziddykins[P]Dawn/src/monsters.c
// Function: slay_monster
void slay_monster(char const *username, int global, int amount) { //username -> MAX_NICK_LENGTH
    char out[MAX_MESSAGE_BUFFER];
    int pindex = get_pindex(username);

    if (global && dawn->global_monster.active) {
        if (amount < 1 || amount >= MAX_SLAY_GOLD) {
            sprintf(out, "PRIVMSG %s :Please enter an amount in between 1 - %d gold\r\n", dawn->active_room,
                    MAX_SLAY_GOLD);
            add_msg(out, strlen(out));
            return;
        }

        if (dawn->players[pindex].gold >= amount) {
            dawn->players[pindex].gold -= amount;
            dawn->global_monster.slay_cost -= amount;
            sprintf(out, "PRIVMSG %s :%s has contributed %d towards the cost of hiring a warrior to slay "
                            "the monster. %d gold still has to be raised!\r\n", dawn->active_room, username, amount,
                    dawn->global_monster.slay_cost);
        } else {
            sprintf(out, "PRIVMSG %s :%s, you do not have that much gold\r\n", dawn->active_room, username);
        }

        add_msg(out, strlen(out));

        if (dawn->global_monster.slay_cost <= 0) {
            sprintf(out, "PRIVMSG %s :The people have raised enough money to rid their town of the horrid monster "
                    "and hire a warrior to come dispose of the entity. In no time, a warrior rides into town "
                            "and slices the monster in half with one precise strike. Well that was easy...\r\n",
                    dawn->active_room);
            dawn->global_monster.active = 0;
            dawn->global_monster.slay_cost = dawn->global_monster.gold;
            dawn->global_monster.hp = dawn->global_monster.mhp;
            dawn->global_monster.type = DEFMON;
            add_msg(out, strlen(out));
        }
    } else {
        pindex = get_pindex(username);
        if (!dawn->players[pindex].personal_monster.active) return;
        if (dawn->players[pindex].gold >= 150) {
            dawn->players[pindex].gold -= 150;
            sprintf(out, "PRIVMSG %s :%s has paid a true warrior to dispose of the monster which "
                    "they couldn't handle. [Gold -150]\r\n", dawn->active_room, username);
            dawn->players[pindex].personal_monster.hp = dawn->players[pindex].personal_monster.mhp;
            dawn->players[pindex].personal_monster.active = 0;
            dawn->players[pindex].personal_monster.type = DEFMON;
        } else {
            sprintf(out, "PRIVMSG %s :%s, you don't have enough gold to pay a true warrior to dispose "
                    "of this monster [cost: 150 gold]\r\n", dawn->active_room, username);
        }
        add_msg(out, strlen(out));
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1d0, %rsp            # imm = 0x1D0
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq -0x8(%rbp), %rdi
callq 0x13ba0
movl %eax, -0x1a4(%rbp)
cmpl $0x0, -0xc(%rbp)
je 0x1172a
leaq 0x175ab(%rip), %rax     # 0x28a70
movq (%rax), %rax
cmpl $0x0, 0xf2e64(%rax)
je 0x1172a
cmpl $0x1, -0x10(%rbp)
jl 0x114e4
cmpl $0x7fffffff, -0x10(%rbp) # imm = 0x7FFFFFFF
jl 0x1153d
leaq -0x1a0(%rbp), %rdi
leaq 0x1757e(%rip), %rax     # 0x28a70
movq (%rax), %rdx
addq $0x100, %rdx            # imm = 0x100
leaq 0xe377(%rip), %rsi      # 0x1f87a
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movb $0x0, %al
callq 0x2050
leaq -0x1a0(%rbp), %rax
movq %rax, -0x1b0(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0x20c0
movq -0x1b0(%rbp), %rdi
movq %rax, %rsi
callq 0x12840
jmp 0x118f3
leaq 0x1752c(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x1a4(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
movq 0x2648(%rax), %rax
movslq -0x10(%rbp), %rcx
cmpq %rcx, %rax
jl 0x11604
movslq -0x10(%rbp), %rdx
leaq 0x174f3(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x1a4(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
movq 0x2648(%rax), %rcx
subq %rdx, %rcx
movq %rcx, 0x2648(%rax)
movl -0x10(%rbp), %edx
leaq 0x174be(%rip), %rax     # 0x28a70
movq (%rax), %rax
movl 0xf2e68(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0xf2e68(%rax)
leaq -0x1a0(%rbp), %rdi
leaq 0x1749f(%rip), %rax     # 0x28a70
movq (%rax), %rdx
addq $0x100, %rdx            # imm = 0x100
movq -0x8(%rbp), %rcx
movl -0x10(%rbp), %r8d
leaq 0x17486(%rip), %rax     # 0x28a70
movq (%rax), %rax
movl 0xf2e68(%rax), %r9d
leaq 0xe2bb(%rip), %rsi      # 0x1f8b6
movb $0x0, %al
callq 0x2050
jmp 0x1162e
leaq -0x1a0(%rbp), %rdi
leaq 0x1745e(%rip), %rax     # 0x28a70
movq (%rax), %rdx
addq $0x100, %rdx            # imm = 0x100
movq -0x8(%rbp), %rcx
leaq 0xe30d(%rip), %rsi      # 0x1f934
movb $0x0, %al
callq 0x2050
leaq -0x1a0(%rbp), %rax
movq %rax, -0x1b8(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0x20c0
movq -0x1b8(%rbp), %rdi
movq %rax, %rsi
callq 0x12840
leaq 0x17412(%rip), %rax     # 0x28a70
movq (%rax), %rax
cmpl $0x0, 0xf2e68(%rax)
jg 0x11725
leaq -0x1a0(%rbp), %rdi
leaq 0x173f4(%rip), %rax     # 0x28a70
movq (%rax), %rdx
addq $0x100, %rdx            # imm = 0x100
leaq 0xe2d8(%rip), %rsi      # 0x1f965
movb $0x0, %al
callq 0x2050
leaq 0x173d5(%rip), %rax     # 0x28a70
movq (%rax), %rax
movl $0x0, 0xf2e64(%rax)
leaq 0x173c1(%rip), %rax     # 0x28a70
movq (%rax), %rax
movl 0xf2e58(%rax), %ecx
leaq 0x173b1(%rip), %rax     # 0x28a70
movq (%rax), %rax
movl %ecx, 0xf2e68(%rax)
leaq 0x173a1(%rip), %rax     # 0x28a70
movq (%rax), %rax
movl 0xf2e44(%rax), %ecx
leaq 0x17391(%rip), %rax     # 0x28a70
movq (%rax), %rax
movl %ecx, 0xf2e40(%rax)
leaq 0x17381(%rip), %rax     # 0x28a70
movq (%rax), %rax
movl $0x5, 0xf2e70(%rax)
leaq -0x1a0(%rbp), %rax
movq %rax, -0x1c0(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0x20c0
movq -0x1c0(%rbp), %rdi
movq %rax, %rsi
callq 0x12840
jmp 0x118f3
movq -0x8(%rbp), %rdi
callq 0x13ba0
movl %eax, -0x1a4(%rbp)
leaq 0x17330(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x1a4(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
cmpl $0x0, 0x1130(%rax)
jne 0x11768
jmp 0x118f3
leaq 0x17301(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x1a4(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
cmpq $0x96, 0x2648(%rax)
jl 0x118a0
leaq 0x172cf(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x1a4(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
movq 0x2648(%rax), %rcx
subq $0x96, %rcx
movq %rcx, 0x2648(%rax)
leaq -0x1a0(%rbp), %rdi
leaq 0x17292(%rip), %rax     # 0x28a70
movq (%rax), %rdx
addq $0x100, %rdx            # imm = 0x100
movq -0x8(%rbp), %rcx
leaq 0xe272(%rip), %rsi      # 0x1fa65
movb $0x0, %al
callq 0x2050
leaq 0x1726f(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x1a4(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
movl 0x1110(%rax), %ecx
leaq 0x17248(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x1a4(%rbp), %rdx
imulq $0x26a8, %rdx, %rdx     # imm = 0x26A8
addq %rdx, %rax
movl %ecx, 0x110c(%rax)
leaq 0x17221(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x1a4(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
movl $0x0, 0x1130(%rax)
leaq 0x171f6(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x1a4(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
movl $0x5, 0x113c(%rax)
jmp 0x118ca
leaq -0x1a0(%rbp), %rdi
leaq 0x171c2(%rip), %rax     # 0x28a70
movq (%rax), %rdx
addq $0x100, %rdx            # imm = 0x100
movq -0x8(%rbp), %rcx
leaq 0xe20d(%rip), %rsi      # 0x1fad0
movb $0x0, %al
callq 0x2050
leaq -0x1a0(%rbp), %rax
movq %rax, -0x1c8(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0x20c0
movq -0x1c8(%rbp), %rdi
movq %rax, %rsi
callq 0x12840
addq $0x1d0, %rsp            # imm = 0x1D0
popq %rbp
retq
nopl (%rax)