// File: /workspace/github_c_makefile_star2_O2/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 0x22c0
testq %rax, %rax
je 0x6072
movq %rax, %rbx
leaq 0x100(%r14), %rdi
leaq 0xc890(%rip), %rsi      # 0x127e3
callq 0xc187
testl %eax, %eax
je 0x5fb6
movl $0x190, %edi            # imm = 0x190
addq 0x17078(%rip), %rdi     # 0x1cfe0
callq 0xc860
cmpl $-0x1, %eax
je 0x5fc6
movl %eax, %r15d
movl $0x320, %edi            # imm = 0x320
addq 0x1705f(%rip), %rdi     # 0x1cfe0
callq 0xd4b7
leaq 0x19af3(%rip), %rcx     # 0x1fa80
movq (%rcx), %rcx
movslq %ebp, %rdx
imulq $0x26a8, %rdx, %rdx     # imm = 0x26A8
movzbl 0x2840(%rcx,%rdx), %edx
cmpl %edx, %eax
jbe 0x5fd6
addq $0xc0, %r14
leaq 0xc86e(%rip), %rdx      # 0x12822
jmp 0x5fe9
addq $0xc0, %r14
leaq 0xc8fa(%rip), %rdx      # 0x128be
jmp 0x5fe9
addq $0xc0, %r14
leaq 0xc826(%rip), %rdx      # 0x127fa
jmp 0x5fe9
cmpl %ebp, %r15d
jne 0x6020
addq $0xc0, %r14
leaq 0xc87d(%rip), %rdx      # 0x12866
movl $0x190, %esi            # imm = 0x190
movq %rbx, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x23a0
movq %rbx, %rdi
callq 0x20c0
movq %rbx, %rdi
movq %rax, %rsi
callq 0xbd04
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x2250
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 0xd488
leaq 0xc84a(%rip), %rdx      # 0x128a2
movl $0x190, %esi            # imm = 0x190
movq %rbx, %rdi
movq %r14, %rcx
movq %r15, %r8
movq %rax, %r9
xorl %eax, %eax
callq 0x23a0
jmp 0x5ffb
leaq 0xc71f(%rip), %rdi      # 0x12798
callq 0x2190
pushq $0x1
popq %rdi
callq 0x2270