// File: /workspace/github_c_makefile_star2_O0/Ziddykins[P]Dawn/src/combat.c
// Function: check_alive
int check_alive(struct Message *message) {
    int pindex = get_pindex(message->sender_nick);
    char out[MAX_MESSAGE_BUFFER];

    if (dawn->players[pindex].health <= 0 || dawn->players[pindex].fullness <= 0) {
        if (dawn->players[pindex].alive) {
            char reason[32];
            float newexp = (float) dawn->players[pindex].experience * 0.90f;
            strcpy(reason, dawn->players[pindex].health <= 0 ? "been killed" : "died from starvation");
            sprintf(out, "PRIVMSG %s :%s has %s! 10%% experience has been lost\r\n",
                    message->receiver, message->sender_nick, reason);
            add_msg(out, strlen(out));
            dawn->players[pindex].deaths++;
            dawn->players[pindex].alive = 0;
            dawn->players[pindex].experience = (unsigned long long) newexp;
            if (dawn->players[pindex].fullness <= 0)
                dawn->players[pindex].fullness = 100;
            return 0;
        }
    }

    if (dawn->global_monster.hp <= 0 && dawn->global_monster.active) {
        sprintf(out, "PRIVMSG %s :The %s has been killed!\r\n", message->receiver, dawn->global_monster.name);
        add_msg(out, strlen(out));
        for (int i = 0; i < dawn->player_count; i++) {
            if (dawn->players[i].contribution > 0) {
                int drop_chance = rand()%100;
                double percent = ((float) dawn->players[i].contribution / (float) dawn->global_monster.mhp);
                double expgain = percent * dawn->global_monster.exp;
                double goldgain = percent * dawn->global_monster.gold;

                //Need to change the sender_nick so the proper drops are awarded as well as level checking
                strncpy(message->sender_nick, dawn->players[i].username, MAX_NICK_LENGTH);
                dawn->players[i].experience += (unsigned long long) expgain;
                dawn->players[i].gold += (int) goldgain;
                sprintf(out, "PRIVMSG %s :%s has helped defeat the foe and receives %d experience and %d gold"
                                " for their efforts!\r\n", message->receiver, dawn->players[i].username, (int) expgain,
                        (int) goldgain);
                dawn->global_monster.active = 0;
                dawn->players[i].kills++;
                check_levelup(message);
                check_bounty(message);

                if (drop_chance < 85) {
                    generate_drop(message);
                }

                if (dawn->global_monster.alignment == EVIL) {
                    dawn->players[pindex].alignment++;
                    if (dawn->players[pindex].alignment == 26) {
                        snprintf(out, MAX_MESSAGE_BUFFER, "PRIVMSG %s :%s is enveloped by a glowing aura!\r\n", 
                                dawn->active_room, dawn->players[i].username);
                    }
                } else if (dawn->global_monster.alignment == GOOD) {
                    dawn->players[pindex].alignment--;
                    if (dawn->players[pindex].alignment == 26) {
                        snprintf(out, MAX_MESSAGE_BUFFER, "PRIVMSG %s :%s has grown horns and the town grows worrisome\r\n", 
                                dawn->active_room, dawn->players[i].username);
                    }
                }
                add_msg(out, strlen(out));
            }
        }
        return 0;
    }
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x230, %rsp            # imm = 0x230
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x13ba0
movl %eax, -0x14(%rbp)
leaq 0x244be(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x14(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
cmpq $0x0, 0x2650(%rax)
jle 0x4601
leaq 0x24496(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x14(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
movswl 0x26a2(%rax), %eax
cmpl $0x0, %eax
jg 0x4831
leaq 0x24468(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x14(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
cmpl $0x0, 0x2660(%rax)
je 0x482f
leaq 0x2443d(%rip), %rax     # 0x28a70
movq %rax, -0x208(%rbp)
movq (%rax), %rax
movslq -0x14(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
movq 0x27f8(%rax,%rcx), %rax
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, -0x200(%rbp)
testq %rax, %rax
movss %xmm0, -0x1fc(%rbp)
js 0x4691
movss -0x200(%rbp), %xmm0
movss %xmm0, -0x1fc(%rbp)
movq -0x208(%rbp), %rax
movss -0x1fc(%rbp), %xmm0
movss 0x16438(%rip), %xmm1    # 0x1aae0
mulss %xmm1, %xmm0
movss %xmm0, -0x1d4(%rbp)
movq (%rax), %rax
movslq -0x14(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
movq 0x27f0(%rax,%rcx), %rax
testq %rax, %rax
leaq 0x16414(%rip), %rax     # 0x1aae8
leaq 0x16419(%rip), %rsi     # 0x1aaf4
cmovleq %rax, %rsi
leaq -0x1d0(%rbp), %rdi
movq %rdi, -0x218(%rbp)
callq 0x21c0
movq -0x218(%rbp), %r8
movq -0x10(%rbp), %rcx
movq %rcx, %rdx
addq $0xc0, %rdx
leaq 0x163fb(%rip), %rsi     # 0x1ab09
xorl %eax, %eax
leaq -0x1b0(%rbp), %rdi
movq %rdi, -0x210(%rbp)
callq 0x2050
movq -0x210(%rbp), %rdi
callq 0x20c0
movq -0x210(%rbp), %rdi
movq %rax, %rsi
callq 0x12840
movq -0x208(%rbp), %rax
movq (%rax), %rcx
movslq -0x14(%rbp), %rdx
imulq $0x26a8, %rdx, %rdx     # imm = 0x26A8
movq 0x27e0(%rcx,%rdx), %rsi
incq %rsi
movq %rsi, 0x27e0(%rcx,%rdx)
movq (%rax), %rax
movslq -0x14(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
movl $0x0, 0x2800(%rax,%rcx)
movss -0x1d4(%rbp), %xmm0
movss 0x16355(%rip), %xmm2    # 0x1aae4
movaps %xmm0, %xmm1
subss %xmm2, %xmm1
cvttss2si %xmm1, %rax
cvttss2si %xmm0, %rcx
movq %rcx, %rdx
sarq $0x3f, %rdx
andq %rdx, %rax
orq %rax, %rcx
leaq 0x242bc(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x14(%rbp), %rdx
imulq $0x26a8, %rdx, %rdx     # imm = 0x26A8
addq %rdx, %rax
movq %rcx, 0x2658(%rax)
leaq 0x24297(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x14(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
movswl 0x26a2(%rax), %eax
cmpl $0x0, %eax
jg 0x4823
leaq 0x2426d(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x14(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
movw $0x64, 0x26a2(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x4cf6
jmp 0x4831
leaq 0x24238(%rip), %rax     # 0x28a70
movq (%rax), %rax
cmpl $0x0, 0xf2e40(%rax)
jg 0x4cef
leaq 0x24221(%rip), %rax     # 0x28a70
movq (%rax), %rax
cmpl $0x0, 0xf2e64(%rax)
je 0x4cef
leaq -0x1b0(%rbp), %rdi
movq -0x10(%rbp), %rdx
addq $0xc0, %rdx
leaq 0x241f8(%rip), %rax     # 0x28a70
movq (%rax), %rcx
addq $0xf2e00, %rcx          # imm = 0xF2E00
leaq 0x162b7(%rip), %rsi     # 0x1ab40
movb $0x0, %al
callq 0x2050
leaq -0x1b0(%rbp), %rax
movq %rax, -0x220(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x20c0
movq -0x220(%rbp), %rdi
movq %rax, %rsi
callq 0x12840
movl $0x0, -0x1d8(%rbp)
movl -0x1d8(%rbp), %eax
leaq 0x241a0(%rip), %rcx     # 0x28a70
movq (%rcx), %rcx
cmpl 0x148(%rcx), %eax
jge 0x4ce6
leaq 0x2418a(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x1d8(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
cmpl $0x0, 0x266c(%rax)
jle 0x4cd0
callq 0x2080
movslq %eax, %rcx
imulq $0x51eb851f, %rcx, %rcx # imm = 0x51EB851F
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x25, %rcx
addl %edx, %ecx
imull $0x64, %ecx, %ecx
subl %ecx, %eax
movl %eax, -0x1dc(%rbp)
leaq 0x24135(%rip), %rax     # 0x28a70
movq (%rax), %rcx
movslq -0x1d8(%rbp), %rdx
imulq $0x26a8, %rdx, %rdx     # imm = 0x26A8
cvtsi2ssl 0x280c(%rcx,%rdx), %xmm0
cvtsi2ssl 0xf2e44(%rcx), %xmm1
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x1e8(%rbp)
movsd -0x1e8(%rbp), %xmm0
movq (%rax), %rcx
cvtsi2sdl 0xf2e5c(%rcx), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x1f0(%rbp)
movsd -0x1e8(%rbp), %xmm0
movq (%rax), %rcx
cvtsi2sdl 0xf2e58(%rcx), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x1f8(%rbp)
movq -0x10(%rbp), %rdi
movq (%rax), %rax
movslq -0x1d8(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
leaq 0x1a0(%rax,%rcx), %rsi
leaq 0x2188d(%rip), %rax     # 0x2625c
movl (%rax), %eax
movl %eax, %edx
callq 0x20e0
movsd -0x1f0(%rbp), %xmm0
movsd 0x160f0(%rip), %xmm2    # 0x1aad8
movaps %xmm0, %xmm1
subsd %xmm2, %xmm1
cvttsd2si %xmm1, %rax
cvttsd2si %xmm0, %rcx
movq %rcx, %rdx
sarq $0x3f, %rdx
andq %rdx, %rax
orq %rax, %rcx
leaq 0x24063(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x1d8(%rbp), %rdx
imulq $0x26a8, %rdx, %rdx     # imm = 0x26A8
addq %rdx, %rax
addq 0x2658(%rax), %rcx
movq %rcx, 0x2658(%rax)
cvttsd2si -0x1f8(%rbp), %eax
movslq %eax, %rcx
leaq 0x24029(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x1d8(%rbp), %rdx
imulq $0x26a8, %rdx, %rdx     # imm = 0x26A8
addq %rdx, %rax
addq 0x2648(%rax), %rcx
movq %rcx, 0x2648(%rax)
leaq -0x1b0(%rbp), %rdi
movq -0x10(%rbp), %rdx
addq $0xc0, %rdx
leaq 0x23fe8(%rip), %rax     # 0x28a70
movq (%rax), %rcx
addq $0x1a0, %rcx            # imm = 0x1A0
movslq -0x1d8(%rbp), %rax
imulq $0x26a8, %rax, %rax     # imm = 0x26A8
addq %rax, %rcx
cvttsd2si -0x1f0(%rbp), %r8d
cvttsd2si -0x1f8(%rbp), %r9d
leaq 0x160aa(%rip), %rsi     # 0x1ab66
movb $0x0, %al
callq 0x2050
leaq 0x23fa6(%rip), %rax     # 0x28a70
movq (%rax), %rax
movl $0x0, 0xf2e64(%rax)
leaq 0x23f92(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x1d8(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
movq 0x2638(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x2638(%rax)
movq -0x10(%rbp), %rdi
callq 0x14950
movq -0x10(%rbp), %rdi
callq 0x2fd0
cmpl $0x55, -0x1dc(%rbp)
jge 0x4b2e
movq -0x10(%rbp), %rdi
callq 0xa3c0
leaq 0x23f3b(%rip), %rax     # 0x28a70
movq (%rax), %rax
cmpl $0x1, 0xf2e74(%rax)
jne 0x4beb
leaq 0x23f24(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x14(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
movl 0x2694(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x2694(%rax)
leaq 0x23ef7(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x14(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
cmpl $0x1a, 0x2694(%rax)
jne 0x4be6
leaq -0x1b0(%rbp), %rdi
leaq 0x23ec9(%rip), %rax     # 0x28a70
movq (%rax), %rcx
addq $0x100, %rcx            # imm = 0x100
leaq 0x23eb8(%rip), %rax     # 0x28a70
movq (%rax), %r8
addq $0x1a0, %r8             # imm = 0x1A0
movslq -0x1d8(%rbp), %rax
imulq $0x26a8, %rax, %rax     # imm = 0x26A8
addq %rax, %r8
movl $0x190, %esi            # imm = 0x190
leaq 0x15fec(%rip), %rdx     # 0x1abcb
movb $0x0, %al
callq 0x2390
jmp 0x4ca7
leaq 0x23e7e(%rip), %rax     # 0x28a70
movq (%rax), %rax
cmpl $0x0, 0xf2e74(%rax)
jne 0x4ca5
leaq 0x23e67(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x14(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
movl 0x2694(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x2694(%rax)
leaq 0x23e3a(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x14(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
cmpl $0x1a, 0x2694(%rax)
jne 0x4ca3
leaq -0x1b0(%rbp), %rdi
leaq 0x23e0c(%rip), %rax     # 0x28a70
movq (%rax), %rcx
addq $0x100, %rcx            # imm = 0x100
leaq 0x23dfb(%rip), %rax     # 0x28a70
movq (%rax), %r8
addq $0x1a0, %r8             # imm = 0x1A0
movslq -0x1d8(%rbp), %rax
imulq $0x26a8, %rax, %rax     # imm = 0x26A8
addq %rax, %r8
movl $0x190, %esi            # imm = 0x190
leaq 0x15f60(%rip), %rdx     # 0x1abfc
movb $0x0, %al
callq 0x2390
jmp 0x4ca5
jmp 0x4ca7
leaq -0x1b0(%rbp), %rax
movq %rax, -0x228(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x20c0
movq -0x228(%rbp), %rdi
movq %rax, %rsi
callq 0x12840
jmp 0x4cd2
movl -0x1d8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1d8(%rbp)
jmp 0x48c3
movl $0x0, -0x4(%rbp)
jmp 0x4cf6
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x230, %rsp            # imm = 0x230
popq %rbp
retq
nopw %cs:(%rax,%rax)