// File: /workspace/github_c_makefile_star2_O3/Ziddykins[P]Dawn/src/player.c
// Function: check_levelup
void check_levelup(struct Message *message) {
    int i = get_pindex(message->sender_nick);
    char out[MAX_MESSAGE_BUFFER];
    unsigned long long next_level_exp = get_nextlvl_exp(message->sender_nick);
    unsigned long long curr_level_exp = dawn->players[i].experience;
    int curr_level = dawn->players[i].level;

    if (curr_level_exp >= next_level_exp) {
        dawn->players[i].level++;
        dawn->players[i].max_health += 25;
        dawn->players[i].max_mana += 25;
        dawn->players[i].attr_pts += 20;
        dawn->players[i].health = dawn->players[i].max_health;
        dawn->players[i].mana = dawn->players[i].max_mana;
        check_learn_spells(message->sender_nick);

        if (dawn->players[i].experience > get_nextlvl_exp(message->sender_nick)) {
            check_levelup(message);
            return;
        }

        if (dawn->players[i].experience < get_nextlvl_exp(message->sender_nick)) {
            sprintf(out, "PRIVMSG %s :%s has achieved level %d. 20 attribute points ready for assignment, HP and MP"
                    " increased +25! Increase your attributes using the ;assign command!\r\n",
                    message->receiver, message->sender_nick, curr_level + 1);
            add_msg(out, strlen(out));
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x198, %rsp            # imm = 0x198
movq %rdi, %rbx
callq 0xda6c
movl %eax, %ebp
leaq 0x13732(%rip), %r12     # 0x21a80
movq (%r12), %r13
movq %rbx, %rdi
callq 0xda6c
cltq
imulq $0x26a8, %rax, %rax     # imm = 0x26A8
movslq 0x2808(%r13,%rax), %rax
movq %rax, %rcx
imulq %rax, %rcx
cmpq $0xb, %rax
movl $0x1f4, %esi            # imm = 0x1F4
movl $0x64, %edx
cmovaeq %rsi, %rdx
movl $0x64, %r14d
imulq %rcx, %rdx
leaq -0x1f4(%rdx), %rcx
addq $-0x64, %rdx
cmpq $0xb, %rax
cmovaeq %rcx, %rdx
imulq %rax, %rdx
movslq %ebp, %rax
imulq $0x26a8, %rax, %r15     # imm = 0x26A8
cmpq %rdx, 0x27f8(%r13,%r15)
jae 0xe3cb
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq (%r15,%r13), %rax
addq $0x1a0, %rax            # imm = 0x1A0
addq $0x1a0, %r13            # imm = 0x1A0
movl 0x2668(%rax), %ebp
incl %ebp
movl %ebp, 0x2668(%rax)
movslq 0x2670(%r13,%r15), %rcx
addq $0x19, %rcx
movl %ecx, 0x2670(%r13,%r15)
movl 0x2674(%r13,%r15), %edx
addl $0x19, %edx
movl %edx, 0x2674(%r13,%r15)
addl $0x14, 0x2698(%r13,%r15)
movq %rcx, 0x2650(%rax)
movl %edx, 0x2680(%rax)
movq %rbx, %rdi
movl $0x1f4, %r13d           # imm = 0x1F4
callq 0xf048
movq (%r12), %r12
movq 0x27f8(%r12,%r15), %r15
movq %rbx, %rdi
callq 0xda6c
cltq
imulq $0x26a8, %rax, %rax     # imm = 0x26A8
movslq 0x2808(%r12,%rax), %rax
movq %rax, %rcx
imulq %rax, %rcx
cmpq $0xb, %rax
cmovaeq %r13, %r14
imulq %rcx, %r14
leaq -0x64(%r14), %rcx
addq $-0x1f4, %r14           # imm = 0xFE0C
cmpq $0xb, %rax
cmovbq %rcx, %r14
imulq %rax, %r14
cmpq %r14, %r15
jbe 0xe4a2
movq %rbx, %rdi
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xe32c
jae 0xe3b9
leaq 0xc0(%rbx), %rdx
leaq 0x950f(%rip), %rsi      # 0x179c5
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rcx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x2050
movq %r14, %rdi
callq 0x20c0
movq %r14, %rdi
movq %rax, %rsi
callq 0xcefe
jmp 0xe3b9