// File: /workspace/github_c_makefile_star2_O2/Ziddykins[P]Dawn/src/commands.c
// Function: cmd_spellbook
void cmd_spellbook(int pindex, struct Message * msg) {
    char *out;
    char append[25] = {0};

    CALLEXIT(!(out = malloc(MAX_MESSAGE_BUFFER)))
    sprintf(out, "PRIVMSG %s :[%s's spellbook] ", msg->receiver, msg->sender_nick);
    if (dawn->players[pindex].spellbook.heal.learned) {
        snprintf(append, 25, "[Heal: Lv %d] ", dawn->players[pindex].spellbook.heal.level);
        strcat(out, append);
    } else {
        snprintf(append, 25, "[Empty]");
        strcat(out, append);
    }
    if (dawn->players[pindex].spellbook.frost.learned) {
        snprintf(append, 25, "[Frost: Lv %d] ", dawn->players[pindex].spellbook.frost.level);
        strcat(out, append);
    }
    if (dawn->players[pindex].spellbook.rain.learned) {
        snprintf(append, 25, "[Rain: Lv %d] ", dawn->players[pindex].spellbook.rain.level);
        strcat(out, append);
    }
    if (dawn->players[pindex].spellbook.revive.learned) {
        snprintf(append, 25, "[Revive: Lv %d] ", dawn->players[pindex].spellbook.revive.level);
        strcat(out, append);
    }
    if (dawn->players[pindex].spellbook.fireball.learned) {
        snprintf(append, 25, "[Fireball: Lv %d] ", dawn->players[pindex].spellbook.fireball.level);
        strcat(out, append);
    }
    if (dawn->players[pindex].spellbook.teleport.learned) {
        snprintf(append, 25, "[Teleport: Lv %d] ", dawn->players[pindex].spellbook.teleport.level);
        strcat(out, append);
    }
    strcat(out, "\r\n\0");
    add_msg(out, strlen(out));
    free(out);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rsi, %r14
movl %edi, %ebp
xorps %xmm0, %xmm0
movups %xmm0, 0x9(%rsp)
movaps %xmm0, (%rsp)
movl $0x190, %edi            # imm = 0x190
callq 0x22c0
testq %rax, %rax
je 0x5a39
movq %rax, %rbx
leaq 0xc0(%r14), %rdx
leaq 0xc206(%rip), %rsi      # 0x11a5f
movq %rax, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2050
leaq 0x1a213(%rip), %r12     # 0x1fa80
movq (%r12), %r14
movslq %ebp, %rax
imulq $0x26a8, %rax, %r15     # imm = 0x26A8
cmpl $0x0, 0x12f8(%r14,%r15)
je 0x58ba
leaq (%r14,%r15), %rax
addq $0x12f0, %rax           # imm = 0x12F0
movl (%rax), %ecx
leaq 0xc1e4(%rip), %rdx      # 0x11a7d
movq %rsp, %r14
pushq $0x19
popq %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0x23a0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2410
movq (%r12), %r14
jmp 0x58d2
movabsq $0x5d7974706d455b, %rax # imm = 0x5D7974706D455B
movq %rsp, %rsi
movq %rax, (%rsi)
movq %rbx, %rdi
callq 0x2410
cmpl $0x0, 0x1310(%r14,%r15)
je 0x590f
leaq (%r14,%r15), %rax
addq $0x1308, %rax           # imm = 0x1308
movl (%rax), %ecx
leaq 0xc19c(%rip), %rdx      # 0x11a8c
movq %rsp, %r14
pushq $0x19
popq %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0x23a0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2410
movq (%r12), %r14
cmpl $0x0, 0x1304(%r14,%r15)
je 0x594c
leaq (%r14,%r15), %rax
addq $0x12fc, %rax           # imm = 0x12FC
movl (%rax), %ecx
leaq 0xc16f(%rip), %rdx      # 0x11a9c
movq %rsp, %r14
pushq $0x19
popq %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0x23a0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2410
movq (%r12), %r14
cmpl $0x0, 0x132c(%r14,%r15)
je 0x5989
leaq (%r14,%r15), %rax
addq $0x1324, %rax           # imm = 0x1324
movl (%rax), %ecx
leaq 0xc141(%rip), %rdx      # 0x11aab
movq %rsp, %r14
pushq $0x19
popq %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0x23a0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2410
movq (%r12), %r14
cmpl $0x0, 0x1320(%r14,%r15)
je 0x59c6
leaq (%r14,%r15), %rax
addq $0x1318, %rax           # imm = 0x1318
movl (%rax), %ecx
leaq 0xc115(%rip), %rdx      # 0x11abc
movq %rsp, %r14
pushq $0x19
popq %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0x23a0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2410
movq (%r12), %r14
cmpl $0x0, 0x1338(%r14,%r15)
je 0x59ff
leaq (%r14,%r15), %rax
addq $0x1330, %rax           # imm = 0x1330
movl (%rax), %ecx
leaq 0xc0eb(%rip), %rdx      # 0x11acf
movq %rsp, %r14
pushq $0x19
popq %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0x23a0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2410
movq %rbx, %rdi
callq 0x20c0
movw $0xa0d, (%rbx,%rax)     # imm = 0xA0D
movb $0x0, 0x2(%rbx,%rax)
movq %rbx, %rdi
callq 0x20c0
movq %rbx, %rdi
movq %rax, %rsi
callq 0xbd04
movq %rbx, %rdi
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x2250
leaq 0xbfd4(%rip), %rdi      # 0x11a14
callq 0x2190
pushq $0x1
popq %rdi
callq 0x2270