// File: /workspace/github_c_makefile_star2_O0/Ziddykins[P]Dawn/src/cmdsys.c
// Function: invoke_cmd
void invoke_cmd(CmdSys cs, int pindex, char * cmd, struct Message * msg, int mode) {
    struct cmd_sys * ccs = cs ? cs : commands;
    assert(ccs && msg && cmd);
    assert(ccs->flags == CMD_FINALIZED);

    char * out;
    CALLEXIT(!(out = malloc(MAX_MESSAGE_BUFFER+175)))
    if (pindex == -1 && strcmp(cmd, ";new") != 0) {
        sprintf(out, "PRIVMSG %s :Please create a new account by issuing ';new'\r\n", msg->receiver);
        add_msg(out, strlen(out));
    } else {
        size_t cmdID = get_cmd_id(ccs, cmd);
        if(cmdID == (size_t)(-1)) {
            if(mode == CMD_EXEC) {
                snprintf(out, MAX_MESSAGE_BUFFER, "PRIVMSG %s :Unknown command. Please use ';help'\r\n", msg->receiver);
            } else {
                snprintf(out, MAX_MESSAGE_BUFFER, "PRIVMSG %s :Command does not exist.\r\n", msg->receiver);
            }
            add_msg(out, strlen(out));
            //printf("%s", out);
        } else {
            if(mode == CMD_EXEC) {
                if(dawn->players[pindex].auth_level >= ccs->auth_levels[cmdID]) {
                    ccs->fn[cmdID](pindex, msg);
                } else {
                    snprintf(out, MAX_MESSAGE_BUFFER, "PRIVMSG %s :You are not authorized to issue this command!\r\n", msg->receiver);
                    add_msg(out, strlen(out));
                }
            } else if(mode == CMD_HELP) {
                snprintf(out, MAX_MESSAGE_BUFFER, "PRIVMSG %s :'%s': %s\r\n", msg->receiver, ccs->cmds[cmdID], ccs->helptexts[cmdID]);
                add_msg(out, strlen(out));
            }
        }
    }
    free(out);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x40ec
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
jmp 0x40f7
movq 0x22175(%rip), %rax     # 0x26268
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x4116
cmpq $0x0, -0x20(%rbp)
je 0x4116
cmpq $0x0, -0x18(%rbp)
je 0x4116
jmp 0x4135
leaq 0x164db(%rip), %rdi     # 0x1a5f8
leaq 0x161c0(%rip), %rsi     # 0x1a2e4
movl $0x5e, %edx
leaq 0x164da(%rip), %rcx     # 0x1a60a
callq 0x2100
movq -0x30(%rbp), %rax
cmpq $0x4, 0x38(%rax)
jne 0x4142
jmp 0x4161
leaq 0x164fd(%rip), %rdi     # 0x1a646
leaq 0x16194(%rip), %rsi     # 0x1a2e4
movl $0x5f, %edx
leaq 0x164ae(%rip), %rcx     # 0x1a60a
callq 0x2100
movl $0x23f, %edi            # imm = 0x23F
callq 0x22b0
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
jne 0x418b
leaq 0x164e6(%rip), %rdi     # 0x1a662
callq 0x2190
movl $0x1, %edi
callq 0x2260
cmpl $-0x1, -0xc(%rbp)
jne 0x41e5
movq -0x18(%rbp), %rdi
leaq 0x16512(%rip), %rsi     # 0x1a6ae
callq 0x22d0
cmpl $0x0, %eax
je 0x41e5
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rdx
addq $0xc0, %rdx
leaq 0x164f7(%rip), %rsi     # 0x1a6b3
movb $0x0, %al
callq 0x2050
movq -0x38(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x38(%rbp), %rdi
callq 0x20c0
movq -0x50(%rbp), %rdi
movq %rax, %rsi
callq 0x12840
jmp 0x4372
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x4390
movq %rax, -0x40(%rbp)
cmpq $-0x1, -0x40(%rbp)
jne 0x426b
cmpl $0x0, -0x24(%rbp)
jne 0x4227
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rcx
addq $0xc0, %rcx
movl $0x190, %esi            # imm = 0x190
leaq 0x164d1(%rip), %rdx     # 0x1a6ef
movb $0x0, %al
callq 0x2390
jmp 0x4249
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rcx
addq $0xc0, %rcx
movl $0x190, %esi            # imm = 0x190
leaq 0x164df(%rip), %rdx     # 0x1a721
movb $0x0, %al
callq 0x2390
movq -0x38(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x38(%rbp), %rdi
callq 0x20c0
movq -0x58(%rbp), %rdi
movq %rax, %rsi
callq 0x12840
jmp 0x4370
cmpl $0x0, -0x24(%rbp)
jne 0x4307
leaq 0x247f4(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0xc(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
movzbl 0x26a0(%rax), %eax
movq -0x30(%rbp), %rcx
movq 0x28(%rcx), %rcx
movq -0x40(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jl 0x42c6
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0xc(%rbp), %edi
movq -0x20(%rbp), %rsi
callq *%rax
jmp 0x4305
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rcx
addq $0xc0, %rcx
movl $0x190, %esi            # imm = 0x190
leaq 0x16466(%rip), %rdx     # 0x1a747
movb $0x0, %al
callq 0x2390
movq -0x38(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x38(%rbp), %rdi
callq 0x20c0
movq -0x60(%rbp), %rdi
movq %rax, %rsi
callq 0x12840
jmp 0x436e
cmpl $0x1, -0x24(%rbp)
jne 0x436c
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rcx
addq $0xc0, %rcx
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x40(%rbp), %rdx
movq (%rax,%rdx,8), %r8
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x40(%rbp), %rdx
movq (%rax,%rdx,8), %r9
movl $0x190, %esi            # imm = 0x190
leaq 0x1643b(%rip), %rdx     # 0x1a783
movb $0x0, %al
callq 0x2390
movq -0x38(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x38(%rbp), %rdi
callq 0x20c0
movq -0x68(%rbp), %rdi
movq %rax, %rsi
callq 0x12840
jmp 0x436e
jmp 0x4370
jmp 0x4372
movq -0x38(%rbp), %rdi
callq 0x2240
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)