// File: /workspace/github_c_makefile_star2_O3/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 0x22b0
testq %rax, %rax
je 0x683e
movq %rax, %rbx
leaq 0xc0(%r14), %rdx
leaq 0xc445(%rip), %rsi      # 0x12a97
movq %rax, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2050
leaq 0x1b41a(%rip), %r12     # 0x21a80
movq (%r12), %r14
movslq %ebp, %rax
imulq $0x26a8, %rax, %r15     # imm = 0x26A8
cmpl $0x0, 0x12f8(%r14,%r15)
je 0x66b5
leaq (%r14,%r15), %rax
addq $0x12f0, %rax           # imm = 0x12F0
movl (%rax), %ecx
leaq 0xc423(%rip), %rdx      # 0x12ab5
movq %rsp, %r14
movl $0x19, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x2390
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2410
movq (%r12), %r14
jmp 0x66cd
movabsq $0x5d7974706d455b, %rax # imm = 0x5D7974706D455B
movq %rsp, %rsi
movq %rax, (%rsi)
movq %rbx, %rdi
callq 0x2410
cmpl $0x0, 0x1310(%r14,%r15)
je 0x670c
leaq (%r14,%r15), %rax
addq $0x1308, %rax           # imm = 0x1308
movl (%rax), %ecx
leaq 0xc3d9(%rip), %rdx      # 0x12ac4
movq %rsp, %r14
movl $0x19, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x2390
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2410
movq (%r12), %r14
cmpl $0x0, 0x1304(%r14,%r15)
je 0x674b
leaq (%r14,%r15), %rax
addq $0x12fc, %rax           # imm = 0x12FC
movl (%rax), %ecx
leaq 0xc3aa(%rip), %rdx      # 0x12ad4
movq %rsp, %r14
movl $0x19, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x2390
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2410
movq (%r12), %r14
cmpl $0x0, 0x132c(%r14,%r15)
je 0x678a
leaq (%r14,%r15), %rax
addq $0x1324, %rax           # imm = 0x1324
movl (%rax), %ecx
leaq 0xc37a(%rip), %rdx      # 0x12ae3
movq %rsp, %r14
movl $0x19, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x2390
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2410
movq (%r12), %r14
cmpl $0x0, 0x1320(%r14,%r15)
je 0x67c9
leaq (%r14,%r15), %rax
addq $0x1318, %rax           # imm = 0x1318
movl (%rax), %ecx
leaq 0xc34c(%rip), %rdx      # 0x12af4
movq %rsp, %r14
movl $0x19, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x2390
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2410
movq (%r12), %r14
cmpl $0x0, 0x1338(%r14,%r15)
je 0x6804
leaq (%r14,%r15), %rax
addq $0x1330, %rax           # imm = 0x1330
movl (%rax), %ecx
leaq 0xc320(%rip), %rdx      # 0x12b07
movq %rsp, %r14
movl $0x19, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x2390
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 0xcefe
movq %rbx, %rdi
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x2240
callq 0x27b9