// File: /workspace/github_c_makefile_star2_O0/Ziddykins[P]Dawn/src/inventory.c
// Function: equip_inventory
void equip_inventory(struct Message *message, int slot, int unequip, int all) {
    int i = get_pindex(message->sender_nick);
    char out[MAX_MESSAGE_BUFFER];

    if (all) {
        int count = 0;
        for (int j = 0; j < MAX_INVENTORY_SLOTS - dawn->players[i].available_slots; j++) {
            if (!unequip && !is_equipped(i, j)) {
                equip_toggle(i, j);
                acknowledge_new(i, j);
                count++;
            } else if (unequip && is_equipped(i, j)) {
                equip_toggle(i, j);
                count++;
            }
        }

        sprintf(out, "PRIVMSG %s :%s, %d pieces of equipment have been %s\r\n",
                message->receiver, message->sender_nick, count, unequip ? "unequipped" : "equipped");
        add_msg(out, strlen(out));
        return;
    }

    if (slot > MAX_INVENTORY_SLOTS) return;

    if (slot >= (MAX_INVENTORY_SLOTS - dawn->players[i].available_slots)) {
        sprintf(out, "PRIVMSG %s :There is nothing in slot %d\r\n", message->receiver, slot);
        add_msg(out, strlen(out));
        return;
    }

    if (unequip && is_equipped(i, slot)) {
        sprintf(out, "PRIVMSG %s :%s unequipped\r\n", message->receiver, dawn->players[i].inventory[slot].name);
        equip_toggle(i, slot);
        add_msg(out, strlen(out));
        return;
    } else if (unequip && !is_equipped(i, slot)) {
        sprintf(out, "PRIVMSG %s :%s is not equipped\r\n", message->receiver,
                dawn->players[i].inventory[slot].name);
        add_msg(out, strlen(out));
        return;
    }

    if (is_equippable(i, slot) && !is_equipped(i, slot)) {
        sprintf(out, "PRIVMSG %s :%s equipped\r\n", message->receiver, dawn->players[i].inventory[slot].name);
        equip_toggle(i, slot);
        acknowledge_new(i, slot);
    } else {
        sprintf(out, "PRIVMSG %s :%s is either unequippable or already equipped\r\n",
                message->receiver,
                dawn->players[i].inventory[slot].name);
    }
    add_msg(out, strlen(out));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1e0, %rsp            # imm = 0x1E0
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movq -0x8(%rbp), %rdi
callq 0x13ba0
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0xa0cf
movl $0x0, -0x1b4(%rbp)
movl $0x0, -0x1b8(%rbp)
movl -0x1b8(%rbp), %eax
leaq 0x1ead1(%rip), %rcx     # 0x28a70
movq (%rcx), %rdx
addq $0x1a0, %rdx            # imm = 0x1A0
movslq -0x18(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rdx
movl $0x19, %ecx
subl 0x2678(%rdx), %ecx
cmpl %ecx, %eax
jge 0xa05e
cmpl $0x0, -0x10(%rbp)
jne 0xa010
movl -0x18(%rbp), %edi
movl -0x1b8(%rbp), %esi
callq 0x9a40
cmpl $0x0, %eax
jne 0xa010
movl -0x18(%rbp), %edi
movl -0x1b8(%rbp), %esi
callq 0x9a90
movl -0x18(%rbp), %edi
movl -0x1b8(%rbp), %esi
callq 0x9b30
movl -0x1b4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1b4(%rbp)
jmp 0xa048
cmpl $0x0, -0x10(%rbp)
je 0xa046
movl -0x18(%rbp), %edi
movl -0x1b8(%rbp), %esi
callq 0x9a40
cmpl $0x0, %eax
je 0xa046
movl -0x18(%rbp), %edi
movl -0x1b8(%rbp), %esi
callq 0x9a90
movl -0x1b4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1b4(%rbp)
jmp 0xa048
jmp 0xa04a
movl -0x1b8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1b8(%rbp)
jmp 0x9f92
leaq -0x1b0(%rbp), %rdi
movq -0x8(%rbp), %rdx
addq $0xc0, %rdx
movq -0x8(%rbp), %rcx
movl -0x1b4(%rbp), %r8d
movl -0x10(%rbp), %esi
leaq 0x131bd(%rip), %r9      # 0x1d242
leaq 0x131b4(%rip), %rax     # 0x1d240
cmpl $0x0, %esi
cmovneq %rax, %r9
leaq 0x13170(%rip), %rsi     # 0x1d20a
movb $0x0, %al
callq 0x2050
leaq -0x1b0(%rbp), %rax
movq %rax, -0x1c0(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x20c0
movq -0x1c0(%rbp), %rdi
movq %rax, %rsi
callq 0x12840
jmp 0xa3b2
cmpl $0x19, -0xc(%rbp)
jle 0xa0da
jmp 0xa3b2
movl -0xc(%rbp), %eax
leaq 0x1e98c(%rip), %rcx     # 0x28a70
movq (%rcx), %rdx
addq $0x1a0, %rdx            # imm = 0x1A0
movslq -0x18(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rdx
movl $0x19, %ecx
subl 0x2678(%rdx), %ecx
cmpl %ecx, %eax
jl 0xa15c
leaq -0x1b0(%rbp), %rdi
movq -0x8(%rbp), %rdx
addq $0xc0, %rdx
movl -0xc(%rbp), %ecx
leaq 0x13124(%rip), %rsi     # 0x1d24b
movb $0x0, %al
callq 0x2050
leaq -0x1b0(%rbp), %rax
movq %rax, -0x1c8(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x20c0
movq -0x1c8(%rbp), %rdi
movq %rax, %rsi
callq 0x12840
jmp 0xa3b2
cmpl $0x0, -0x10(%rbp)
je 0xa207
movl -0x18(%rbp), %edi
movl -0xc(%rbp), %esi
callq 0x9a40
cmpl $0x0, %eax
je 0xa207
leaq -0x1b0(%rbp), %rdi
movq -0x8(%rbp), %rdx
addq $0xc0, %rdx
leaq 0x1e8dd(%rip), %rax     # 0x28a70
movq (%rax), %rcx
addq $0x1a0, %rcx            # imm = 0x1A0
movslq -0x18(%rbp), %rax
imulq $0x26a8, %rax, %rax     # imm = 0x26A8
addq %rax, %rcx
addq $0x190, %rcx            # imm = 0x190
movslq -0xc(%rbp), %rax
imulq $0x9c, %rax, %rax
addq %rax, %rcx
leaq 0x130ae(%rip), %rsi     # 0x1d275
movb $0x0, %al
callq 0x2050
movl -0x18(%rbp), %edi
movl -0xc(%rbp), %esi
callq 0x9a90
leaq -0x1b0(%rbp), %rax
movq %rax, -0x1d0(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x20c0
movq -0x1d0(%rbp), %rdi
movq %rax, %rsi
callq 0x12840
jmp 0xa3b2
cmpl $0x0, -0x10(%rbp)
je 0xa2a7
movl -0x18(%rbp), %edi
movl -0xc(%rbp), %esi
callq 0x9a40
cmpl $0x0, %eax
jne 0xa2a7
leaq -0x1b0(%rbp), %rdi
movq -0x8(%rbp), %rdx
addq $0xc0, %rdx
leaq 0x1e832(%rip), %rax     # 0x28a70
movq (%rax), %rcx
addq $0x1a0, %rcx            # imm = 0x1A0
movslq -0x18(%rbp), %rax
imulq $0x26a8, %rax, %rax     # imm = 0x26A8
addq %rax, %rcx
addq $0x190, %rcx            # imm = 0x190
movslq -0xc(%rbp), %rax
imulq $0x9c, %rax, %rax
addq %rax, %rcx
leaq 0x1301f(%rip), %rsi     # 0x1d291
movb $0x0, %al
callq 0x2050
leaq -0x1b0(%rbp), %rax
movq %rax, -0x1d8(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x20c0
movq -0x1d8(%rbp), %rdi
movq %rax, %rsi
callq 0x12840
jmp 0xa3b2
jmp 0xa2a9
movl -0x18(%rbp), %edi
movl -0xc(%rbp), %esi
callq 0x9ae0
cmpl $0x0, %eax
je 0xa335
movl -0x18(%rbp), %edi
movl -0xc(%rbp), %esi
callq 0x9a40
cmpl $0x0, %eax
jne 0xa335
leaq -0x1b0(%rbp), %rdi
movq -0x8(%rbp), %rdx
addq $0xc0, %rdx
leaq 0x1e78e(%rip), %rax     # 0x28a70
movq (%rax), %rcx
addq $0x1a0, %rcx            # imm = 0x1A0
movslq -0x18(%rbp), %rax
imulq $0x26a8, %rax, %rax     # imm = 0x26A8
addq %rax, %rcx
addq $0x190, %rcx            # imm = 0x190
movslq -0xc(%rbp), %rax
imulq $0x9c, %rax, %rax
addq %rax, %rcx
leaq 0x12f9c(%rip), %rsi     # 0x1d2b2
movb $0x0, %al
callq 0x2050
movl -0x18(%rbp), %edi
movl -0xc(%rbp), %esi
callq 0x9a90
movl -0x18(%rbp), %edi
movl -0xc(%rbp), %esi
callq 0x9b30
jmp 0xa389
leaq -0x1b0(%rbp), %rdi
movq -0x8(%rbp), %rdx
addq $0xc0, %rdx
leaq 0x1e722(%rip), %rax     # 0x28a70
movq (%rax), %rcx
addq $0x1a0, %rcx            # imm = 0x1A0
movslq -0x18(%rbp), %rax
imulq $0x26a8, %rax, %rax     # imm = 0x26A8
addq %rax, %rcx
addq $0x190, %rcx            # imm = 0x190
movslq -0xc(%rbp), %rax
imulq $0x9c, %rax, %rax
addq %rax, %rcx
leaq 0x12f4a(%rip), %rsi     # 0x1d2cc
movb $0x0, %al
callq 0x2050
leaq -0x1b0(%rbp), %rax
movq %rax, -0x1e0(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x20c0
movq -0x1e0(%rbp), %rdi
movq %rax, %rsi
callq 0x12840
addq $0x1e0, %rsp            # imm = 0x1E0
popq %rbp
retq
nopl (%rax,%rax)