// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x190, %edi            # imm = 0x190
callq 0x22b0
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
jne 0x8209
leaq 0x145a6(%rip), %rdi     # 0x1c7a0
callq 0x2190
movl $0x1, %edi
callq 0x2260
movq -0x10(%rbp), %rdi
addq $0x100, %rdi            # imm = 0x100
leaq 0x145d0(%rip), %rsi     # 0x1c7eb
callq 0x13090
cmpl $0x0, %eax
je 0x8452
leaq 0x1f0a0(%rip), %rdi     # 0x272d0
addq $0x190, %rdi            # imm = 0x190
callq 0x13ba0
movl %eax, -0x1c(%rbp)
cmpl $-0x1, -0x1c(%rbp)
jne 0x8289
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rcx
addq $0xc0, %rcx
movl $0x190, %esi            # imm = 0x190
leaq 0x145a2(%rip), %rdx     # 0x1c802
movb $0x0, %al
callq 0x2390
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rdi
callq 0x20c0
movq -0x28(%rbp), %rdi
movq %rax, %rsi
callq 0x12840
jmp 0x8450
leaq 0x1f040(%rip), %rdi     # 0x272d0
addq $0x320, %rdi            # imm = 0x320
callq 0x151a0
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
leaq 0x207c7(%rip), %rcx     # 0x28a70
movq (%rcx), %rcx
addq $0x1a0, %rcx            # imm = 0x1A0
movslq -0x4(%rbp), %rdx
imulq $0x26a8, %rdx, %rdx     # imm = 0x26A8
addq %rdx, %rcx
movzbl 0x26a0(%rcx), %ecx
cmpl %ecx, %eax
jbe 0x8310
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rcx
addq $0xc0, %rcx
movl $0x190, %esi            # imm = 0x190
leaq 0x14543(%rip), %rdx     # 0x1c82a
movb $0x0, %al
callq 0x2390
movq -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rdi
callq 0x20c0
movq -0x30(%rbp), %rdi
movq %rax, %rsi
callq 0x12840
jmp 0x844e
movl -0x4(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jne 0x835c
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rcx
addq $0xc0, %rcx
movl $0x190, %esi            # imm = 0x190
leaq 0x1453b(%rip), %rdx     # 0x1c86e
movb $0x0, %al
callq 0x2390
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rdi
callq 0x20c0
movq -0x38(%rbp), %rdi
movq %rax, %rsi
callq 0x12840
jmp 0x844c
movl -0x20(%rbp), %eax
movb %al, %cl
leaq 0x20708(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x1c(%rbp), %rdx
imulq $0x26a8, %rdx, %rdx     # imm = 0x26A8
addq %rdx, %rax
movb %cl, 0x26a1(%rax)
leaq 0x206e4(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x1c(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
movb 0x26a1(%rax), %cl
leaq 0x206c0(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x1c(%rbp), %rdx
imulq $0x26a8, %rdx, %rdx     # imm = 0x26A8
addq %rdx, %rax
movb %cl, 0x26a0(%rax)
movq -0x18(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
addq $0xc0, %rax
movq %rax, -0x50(%rbp)
leaq 0x20686(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x1c(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movl -0x20(%rbp), %edi
callq 0x15110
movq -0x58(%rbp), %rdi
movq -0x50(%rbp), %rcx
movq -0x48(%rbp), %r8
movq %rax, %r9
movl $0x190, %esi            # imm = 0x190
leaq 0x14482(%rip), %rdx     # 0x1c8aa
movb $0x0, %al
callq 0x2390
movq -0x18(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rdi
callq 0x20c0
movq -0x40(%rbp), %rdi
movq %rax, %rsi
callq 0x12840
jmp 0x844e
jmp 0x8450
jmp 0x8491
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rcx
addq $0xc0, %rcx
movl $0x190, %esi            # imm = 0x190
leaq 0x14459(%rip), %rdx     # 0x1c8c6
movb $0x0, %al
callq 0x2390
movq -0x18(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x18(%rbp), %rdi
callq 0x20c0
movq -0x60(%rbp), %rdi
movq %rax, %rsi
callq 0x12840
movq -0x18(%rbp), %rdi
callq 0x2240
addq $0x60, %rsp
popq %rbp
retq