// File: /workspace/github_c_makefile_star2_O2/Ziddykins[P]Dawn/src/spells.c
// Function: check_learn_spells
void check_learn_spells(const char *username) {
    int pindex = get_pindex(username);
    int plevel = dawn->players[pindex].level;
    char out[MAX_MESSAGE_BUFFER];
    char spell[20];

    switch (plevel) {
        case 3:
            dawn->players[pindex].spellbook.heal.learned = 1;
            dawn->players[pindex].spellbook.heal.level = 1;
            strcpy(spell, "Heal");
            break;
        case 5:
            dawn->players[pindex].spellbook.frost.learned = 1;
            dawn->players[pindex].spellbook.frost.level = 1;
            dawn->players[pindex].spellbook.frost.element = ICE;
            strcpy(spell, "Frost");
            break;
        case 8:
            dawn->players[pindex].spellbook.rain.learned = 1;
            dawn->players[pindex].spellbook.rain.level = 1;
            strcpy(spell, "Rain");
            break;
        case 10:
            dawn->players[pindex].spellbook.revive.learned = 1;
            dawn->players[pindex].spellbook.revive.level = 1;
            strcpy(spell, "Revive");
            break;
        case 17:
            dawn->players[pindex].spellbook.fireball.learned = 1;
            dawn->players[pindex].spellbook.fireball.level = 1;
            strcpy(spell, "Fireball");
            break;
        case 21:
            dawn->players[pindex].spellbook.teleport.learned = 1;
            dawn->players[pindex].spellbook.teleport.level = 1;
            strcpy(spell, "Teleport");
            break;
        default:
            return;
    }
    snprintf(out, MAX_MESSAGE_BUFFER, "PRIVMSG %s :%s has learned the spell %s!\r\n",
             dawn->active_room, username, spell);
    add_msg(out, strlen(out));
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x1b8, %rsp            # imm = 0x1B8
movq %rdi, %rbx
callq 0xc860
leaq 0x11cfb(%rip), %rcx     # 0x1fa80
movq (%rcx), %rcx
leaq 0x1a0(%rcx), %rdx
cltq
imulq $0x26a8, %rax, %rax     # imm = 0x26A8
movl 0x2808(%rcx,%rax), %esi
leal -0x3(%rsi), %edi
cmpl $0x7, %edi
ja 0xddd9
leaq 0x8fba(%rip), %rsi      # 0x16d68
movslq (%rsi,%rdi,4), %rdi
addq %rsi, %rdi
jmpq *%rdi
pushq $0x1
popq %rsi
movl %esi, 0x1158(%rdx,%rax)
movl %esi, 0x1150(%rdx,%rax)
movb $0x0, 0x4(%rsp)
movl $0x6c616548, (%rsp)     # imm = 0x6C616548
jmp 0xde9d
cmpl $0x11, %esi
je 0xde79
cmpl $0x15, %esi
jne 0xded8
pushq $0x1
popq %rsi
movl %esi, 0x1198(%rdx,%rax)
movl %esi, 0x1190(%rdx,%rax)
movabsq $0x74726f70656c6554, %rax # imm = 0x74726F70656C6554
jmp 0xde94
pushq $0x1
popq %rsi
movl %esi, 0x118c(%rdx,%rax)
movl %esi, 0x1184(%rdx,%rax)
movl $0x657669, 0x3(%rsp)    # imm = 0x657669
movl $0x69766552, (%rsp)     # imm = 0x69766552
jmp 0xde9d
movabsq $0x100000001, %rsi      # imm = 0x100000001
movq %rsi, 0x1170(%rdx,%rax)
movl $0x1, 0x1168(%rdx,%rax)
movw $0x74, 0x4(%rsp)
movl $0x736f7246, (%rsp)     # imm = 0x736F7246
jmp 0xde9d
pushq $0x1
popq %rsi
movl %esi, 0x1164(%rdx,%rax)
movl %esi, 0x115c(%rdx,%rax)
movb $0x0, 0x4(%rsp)
movl $0x6e696152, (%rsp)     # imm = 0x6E696152
jmp 0xde9d
pushq $0x1
popq %rsi
movl %esi, 0x1180(%rdx,%rax)
movl %esi, 0x1178(%rdx,%rax)
movabsq $0x6c6c616265726946, %rax # imm = 0x6C6C616265726946
movq %rax, (%rsp)
movb $0x0, 0x8(%rsp)
addq $0x100, %rcx            # imm = 0x100
leaq 0x935e(%rip), %rdx      # 0x17209
leaq 0x20(%rsp), %r14
movq %rsp, %r9
movl $0x190, %esi            # imm = 0x190
movq %r14, %rdi
movq %rbx, %r8
xorl %eax, %eax
callq 0x23a0
movq %r14, %rdi
callq 0x20c0
movq %r14, %rdi
movq %rax, %rsi
callq 0xbd04
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r14
retq
nop