// File: /workspace/github_c_makefile_star2_O3/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 0x6e41
movq %rax, %rbx
leaq 0x100(%r14), %rdi
leaq 0xcaf9(%rip), %rsi      # 0x1381b
callq 0xd3aa
testl %eax, %eax
je 0x6d85
movl $0x190, %edi            # imm = 0x190
addq 0x182a9(%rip), %rdi     # 0x1efe0
callq 0xda6c
cmpl $-0x1, %eax
je 0x6d95
movl %eax, %r15d
movl $0x320, %edi            # imm = 0x320
addq 0x18290(%rip), %rdi     # 0x1efe0
callq 0xe766
leaq 0x1ad24(%rip), %rcx     # 0x21a80
movq (%rcx), %rcx
movslq %ebp, %rdx
imulq $0x26a8, %rdx, %rdx     # imm = 0x26A8
movzbl 0x2840(%rcx,%rdx), %edx
cmpl %edx, %eax
jbe 0x6da5
addq $0xc0, %r14
leaq 0xcad7(%rip), %rdx      # 0x1385a
jmp 0x6db8
addq $0xc0, %r14
leaq 0xcb63(%rip), %rdx      # 0x138f6
jmp 0x6db8
addq $0xc0, %r14
leaq 0xca8f(%rip), %rdx      # 0x13832
jmp 0x6db8
cmpl %ebp, %r15d
jne 0x6def
addq $0xc0, %r14
leaq 0xcae6(%rip), %rdx      # 0x1389e
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 0xcefe
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 0xe737
leaq 0xcab3(%rip), %rdx      # 0x138da
movl $0x190, %esi            # imm = 0x190
movq %rbx, %rdi
movq %r14, %rcx
movq %r15, %r8
movq %rax, %r9
xorl %eax, %eax
callq 0x2390
jmp 0x6dca
callq 0x2822