// File: /workspace/github_c_makefile_star2_O1/Ziddykins[P]Dawn/src/commands.c
// Function: cmd_setauth
void cmd_setauth(int pindex, struct Message * msg) {
    char * out;
    CALLEXIT(!(out = malloc(MAX_MESSAGE_BUFFER)))
    if(matches_regex(msg->message, CMD_LIT " (\\w+) (\\w+)")) {
        int useridx = get_pindex(regex_group[1]);
        if(useridx == -1) {
            snprintf(out, MAX_MESSAGE_BUFFER, "PRIVMSG %s :This user does not exist.\r\n", msg->receiver);
            add_msg(out, strlen(out));
        } else {
            enum auth_level newlevel = str_to_auth_level(regex_group[2]);
            if (newlevel > dawn->players[pindex].auth_level) {
                snprintf(out, MAX_MESSAGE_BUFFER,
                         "PRIVMSG %s :You are not allowed to set this authentication level.\r\n", msg->receiver);
                add_msg(out, strlen(out));
            } else if(pindex == useridx) {
                snprintf(out, MAX_MESSAGE_BUFFER, "PRIVMSG %s :You cannot set your own authentication level.\r\n",
                         msg->receiver);
                add_msg(out, strlen(out));
            } else {
                dawn->players[useridx].max_auth = newlevel;
                dawn->players[useridx].auth_level = dawn->players[useridx].max_auth;
                snprintf(out, MAX_MESSAGE_BUFFER, "PRIVMSG %s :%s set to %s.\r\n",
                         msg->receiver,
                         dawn->players[useridx].username,
                         auth_level_to_str(newlevel));
                add_msg(out, strlen(out));
            }
        }
    } else {
        snprintf(out, MAX_MESSAGE_BUFFER, "PRIVMSG %s :Please provide a user and an authentication level.\r\n",
                 msg->receiver);
        add_msg(out, strlen(out));
    }
    free(out);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movl %edi, %ebp
movl $0x190, %edi            # imm = 0x190
callq 0x22b0
testq %rax, %rax
je 0x6de7
movq %rax, %rbx
leaq 0x100(%r14), %rdi
leaq 0xcb1b(%rip), %rsi      # 0x137e3
callq 0xd1ba
testl %eax, %eax
je 0x6d2b
movl $0x190, %edi            # imm = 0x190
addq 0x18303(%rip), %rdi     # 0x1efe0
callq 0xd89c
cmpl $-0x1, %eax
je 0x6d3b
movl %eax, %r15d
movl $0x320, %edi            # imm = 0x320
addq 0x182ea(%rip), %rdi     # 0x1efe0
callq 0xe486
leaq 0x1ad7e(%rip), %rcx     # 0x21a80
movq (%rcx), %rcx
movslq %ebp, %rdx
imulq $0x26a8, %rdx, %rdx     # imm = 0x26A8
movzbl 0x2840(%rcx,%rdx), %edx
cmpl %edx, %eax
jbe 0x6d4b
addq $0xc0, %r14
leaq 0xcaf9(%rip), %rdx      # 0x13822
jmp 0x6d5e
addq $0xc0, %r14
leaq 0xcb85(%rip), %rdx      # 0x138be
jmp 0x6d5e
addq $0xc0, %r14
leaq 0xcab1(%rip), %rdx      # 0x137fa
jmp 0x6d5e
cmpl %ebp, %r15d
jne 0x6d95
addq $0xc0, %r14
leaq 0xcb08(%rip), %rdx      # 0x13866
movl $0x190, %esi            # imm = 0x190
movq %rbx, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2390
movq %rbx, %rdi
callq 0x20c0
movq %rbx, %rdi
movq %rax, %rsi
callq 0xcd1c
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x2240
addq $0x1a0, %rcx            # imm = 0x1A0
movslq %r15d, %rdx
imulq $0x26a8, %rdx, %rdx     # imm = 0x26A8
leaq (%rcx,%rdx), %r15
movb %al, 0x26a1(%rcx,%rdx)
movb %al, 0x26a0(%rcx,%rdx)
addq $0xc0, %r14
movl %eax, %edi
callq 0xe457
leaq 0xcad5(%rip), %rdx      # 0x138a2
movl $0x190, %esi            # imm = 0x190
movq %rbx, %rdi
movq %r14, %rcx
movq %r15, %r8
movq %rax, %r9
xorl %eax, %eax
callq 0x2390
jmp 0x6d70
callq 0x2822