// File: /workspace/github_c_makefile_star2_O0/Ziddykins[P]Dawn/src/commands.c
// Function: cmd_give
void cmd_give(int pindex, struct Message * msg) {
    char *out, *endptr;
    CALLEXIT(!(out = malloc(MAX_MESSAGE_BUFFER)))
    if (matches_regex(msg->message, CMD_LIT" (\\w+)\\s(\\d+)")) {
        int tindex = get_pindex(regex_group[1]);
        if (tindex != -1) {
            long amount = strtol(regex_group[2], &endptr, 10);
            if (amount <= dawn->players[pindex].gold) {
                dawn->players[pindex].gold -= amount;
                dawn->players[tindex].gold += amount;
                sprintf(out, "PRIVMSG %s :%s has sent %s %ld gold!\r\n",
                        dawn->active_room, msg->sender_nick, regex_group[1], amount);
            } else {
                sprintf(out, "PRIVMSG %s :%s, you don't have that much gold\r\n", dawn->active_room, msg->sender_nick);
            }
        } else {
            sprintf(out, "PRIVMSG %s :Invalid user\r\n", dawn->active_room);
        }
        add_msg(out, strlen(out));
    }
    free(out);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x190, %edi            # imm = 0x190
callq 0x22b0
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
jne 0x6e29
leaq 0x15026(%rip), %rdi     # 0x1be40
callq 0x2190
movl $0x1, %edi
callq 0x2260
movq -0x10(%rbp), %rdi
addq $0x100, %rdi            # imm = 0x100
leaq 0x15050(%rip), %rsi     # 0x1be8b
callq 0x13090
cmpl $0x0, %eax
je 0x6fc0
leaq 0x20480(%rip), %rdi     # 0x272d0
addq $0x190, %rdi            # imm = 0x190
callq 0x13ba0
movl %eax, -0x24(%rbp)
cmpl $-0x1, -0x24(%rbp)
je 0x6f80
leaq 0x20460(%rip), %rdi     # 0x272d0
addq $0x320, %rdi            # imm = 0x320
leaq -0x20(%rbp), %rsi
movl $0xa, %edx
callq 0x22e0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
leaq 0x21bdc(%rip), %rcx     # 0x28a70
movq (%rcx), %rcx
addq $0x1a0, %rcx            # imm = 0x1A0
movslq -0x4(%rbp), %rdx
imulq $0x26a8, %rdx, %rdx     # imm = 0x26A8
addq %rdx, %rcx
cmpq 0x2648(%rcx), %rax
jg 0x6f57
movq -0x30(%rbp), %rdx
leaq 0x21bac(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x4(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
movq 0x2648(%rax), %rcx
subq %rdx, %rcx
movq %rcx, 0x2648(%rax)
movq -0x30(%rbp), %rcx
leaq 0x21b79(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x24(%rbp), %rdx
imulq $0x26a8, %rdx, %rdx     # imm = 0x26A8
addq %rdx, %rax
addq 0x2648(%rax), %rcx
movq %rcx, 0x2648(%rax)
movq -0x18(%rbp), %rdi
leaq 0x21b49(%rip), %rax     # 0x28a70
movq (%rax), %rdx
addq $0x100, %rdx            # imm = 0x100
movq -0x10(%rbp), %rcx
movq -0x30(%rbp), %r9
leaq 0x14f63(%rip), %rsi     # 0x1bea3
leaq 0x20389(%rip), %r8      # 0x272d0
addq $0x190, %r8             # imm = 0x190
movb $0x0, %al
callq 0x2050
jmp 0x6f7e
movq -0x18(%rbp), %rdi
leaq 0x21b0e(%rip), %rax     # 0x28a70
movq (%rax), %rdx
addq $0x100, %rdx            # imm = 0x100
movq -0x10(%rbp), %rcx
leaq 0x14f53(%rip), %rsi     # 0x1beca
movb $0x0, %al
callq 0x2050
jmp 0x6fa3
movq -0x18(%rbp), %rdi
leaq 0x21ae5(%rip), %rax     # 0x28a70
movq (%rax), %rdx
addq $0x100, %rdx            # imm = 0x100
leaq 0x14c7e(%rip), %rsi     # 0x1bc1a
movb $0x0, %al
callq 0x2050
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rdi
callq 0x20c0
movq -0x38(%rbp), %rdi
movq %rax, %rsi
callq 0x12840
movq -0x18(%rbp), %rdi
callq 0x2240
addq $0x40, %rsp
popq %rbp
retq
nop