// File: /workspace/github_c_makefile_star2_O0/Ziddykins[P]Dawn/src/items.c
// Function: drop_item
void drop_item(struct Message *message, int slot) {
    char out[MAX_MESSAGE_BUFFER];
    char item_name[128];
    int pindex = get_pindex(message->sender_nick);
    int total_items = MAX_INVENTORY_SLOTS - dawn->players[pindex].available_slots;
    static const struct Inventory empty;

    if (is_favorite(pindex, slot)) {
        sprintf(out, "PRIVMSG %s :%s, %s is a favorite item and can not be dropped\r\n",
                dawn->active_room, dawn->players[pindex].username, dawn->players[pindex].inventory[slot].name);
        add_msg(out, strlen(out));
        return;
    }

    item_name[0]   = '\0';
    strcpy(item_name, dawn->players[pindex].inventory[slot].name);

    if (total_items > 0 && slot < total_items && slot > -1) {
        int last_index = total_items - 1;
        if (slot == last_index) {
            dawn->players[pindex].inventory[slot] = empty;
        } else {
            for (int i=slot; i<last_index; i++) {
                dawn->players[pindex].inventory[i] = dawn->players[pindex].inventory[i + 1];
            }
            dawn->players[pindex].inventory[last_index] = empty;
        }
        dawn->players[pindex].available_slots++;
        sprintf(out, "PRIVMSG %s :%s has dropped the %s\r\n", message->receiver, message->sender_nick, item_name);
        add_msg(out, strlen(out));
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x240, %rsp            # imm = 0x240
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rdi
callq 0x13ba0
movl %eax, -0x224(%rbp)
leaq 0x1d9f8(%rip), %rax     # 0x28a70
movq (%rax), %rcx
addq $0x1a0, %rcx            # imm = 0x1A0
movslq -0x224(%rbp), %rax
imulq $0x26a8, %rax, %rax     # imm = 0x26A8
addq %rax, %rcx
movl $0x19, %eax
subl 0x2678(%rcx), %eax
movl %eax, -0x228(%rbp)
movl -0x224(%rbp), %edi
movl -0xc(%rbp), %esi
callq 0x9bd0
cmpl $0x0, %eax
je 0xb168
leaq -0x1a0(%rbp), %rdi
leaq 0x1d9a7(%rip), %rax     # 0x28a70
movq (%rax), %rdx
addq $0x100, %rdx            # imm = 0x100
leaq 0x1d996(%rip), %rax     # 0x28a70
movq (%rax), %rcx
addq $0x1a0, %rcx            # imm = 0x1A0
movslq -0x224(%rbp), %rax
imulq $0x26a8, %rax, %rax     # imm = 0x26A8
addq %rax, %rcx
leaq 0x1d974(%rip), %rax     # 0x28a70
movq (%rax), %r8
addq $0x1a0, %r8             # imm = 0x1A0
movslq -0x224(%rbp), %rax
imulq $0x26a8, %rax, %rax     # imm = 0x26A8
addq %rax, %r8
addq $0x190, %r8             # imm = 0x190
movslq -0xc(%rbp), %rax
imulq $0x9c, %rax, %rax
addq %rax, %r8
leaq 0x124c9(%rip), %rsi     # 0x1d5fc
movb $0x0, %al
callq 0x2050
leaq -0x1a0(%rbp), %rax
movq %rax, -0x238(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0x20c0
movq -0x238(%rbp), %rdi
movq %rax, %rsi
callq 0x12840
jmp 0xb3bf
movb $0x0, -0x220(%rbp)
leaq -0x220(%rbp), %rdi
leaq 0x1d8f3(%rip), %rax     # 0x28a70
movq (%rax), %rsi
addq $0x1a0, %rsi            # imm = 0x1A0
movslq -0x224(%rbp), %rax
imulq $0x26a8, %rax, %rax     # imm = 0x26A8
addq %rax, %rsi
addq $0x190, %rsi            # imm = 0x190
movslq -0xc(%rbp), %rax
imulq $0x9c, %rax, %rax
addq %rax, %rsi
callq 0x21c0
cmpl $0x0, -0x228(%rbp)
jle 0xb3bf
movl -0xc(%rbp), %eax
cmpl -0x228(%rbp), %eax
jge 0xb3bf
cmpl $-0x1, -0xc(%rbp)
jle 0xb3bf
movl -0x228(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x22c(%rbp)
movl -0xc(%rbp), %eax
cmpl -0x22c(%rbp), %eax
jne 0xb23f
leaq 0x1d877(%rip), %rax     # 0x28a70
movq (%rax), %rdi
addq $0x1a0, %rdi            # imm = 0x1A0
movslq -0x224(%rbp), %rax
imulq $0x26a8, %rax, %rax     # imm = 0x26A8
addq %rax, %rdi
addq $0x190, %rdi            # imm = 0x190
movslq -0xc(%rbp), %rax
imulq $0x9c, %rax, %rax
addq %rax, %rdi
leaq 0x12498(%rip), %rsi     # 0x1d6c8
movl $0x9c, %edx
callq 0x2170
jmp 0xb33b
movl -0xc(%rbp), %eax
movl %eax, -0x230(%rbp)
movl -0x230(%rbp), %eax
cmpl -0x22c(%rbp), %eax
jge 0xb2f0
leaq 0x1d80f(%rip), %rax     # 0x28a70
movq (%rax), %rdi
addq $0x1a0, %rdi            # imm = 0x1A0
movslq -0x224(%rbp), %rax
imulq $0x26a8, %rax, %rax     # imm = 0x26A8
addq %rax, %rdi
addq $0x190, %rdi            # imm = 0x190
movslq -0x230(%rbp), %rax
imulq $0x9c, %rax, %rax
addq %rax, %rdi
leaq 0x1d7d5(%rip), %rax     # 0x28a70
movq (%rax), %rsi
addq $0x1a0, %rsi            # imm = 0x1A0
movslq -0x224(%rbp), %rax
imulq $0x26a8, %rax, %rax     # imm = 0x26A8
addq %rax, %rsi
addq $0x190, %rsi            # imm = 0x190
movl -0x230(%rbp), %eax
addl $0x1, %eax
cltq
imulq $0x9c, %rax, %rax
addq %rax, %rsi
movl $0x9c, %edx
callq 0x2170
movl -0x230(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x230(%rbp)
jmp 0xb248
leaq 0x1d779(%rip), %rax     # 0x28a70
movq (%rax), %rdi
addq $0x1a0, %rdi            # imm = 0x1A0
movslq -0x224(%rbp), %rax
imulq $0x26a8, %rax, %rax     # imm = 0x26A8
addq %rax, %rdi
addq $0x190, %rdi            # imm = 0x190
movslq -0x22c(%rbp), %rax
imulq $0x9c, %rax, %rax
addq %rax, %rdi
leaq 0x12397(%rip), %rsi     # 0x1d6c8
movl $0x9c, %edx
callq 0x2170
leaq 0x1d72e(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x224(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
movl 0x2678(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x2678(%rax)
leaq -0x1a0(%rbp), %rdi
movq -0x8(%rbp), %rdx
addq $0xc0, %rdx
movq -0x8(%rbp), %rcx
leaq -0x220(%rbp), %r8
leaq 0x122ac(%rip), %rsi     # 0x1d63b
movb $0x0, %al
callq 0x2050
leaq -0x1a0(%rbp), %rax
movq %rax, -0x240(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0x20c0
movq -0x240(%rbp), %rdi
movq %rax, %rsi
callq 0x12840
addq $0x240, %rsp            # imm = 0x240
popq %rbp
retq
nopl (%rax,%rax)