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

    if(ccs->capacity == 0) {
        CALLEXIT(!(ccs->hashes = calloc(1, sizeof *ccs->hashes)))
        CALLEXIT(!(ccs->cmds = calloc(1, sizeof *ccs->cmds)))
        CALLEXIT(!(ccs->helptexts = calloc(1, sizeof *ccs->helptexts)))
        CALLEXIT(!(ccs->auth_levels = calloc(1, sizeof *ccs->auth_levels)))
        CALLEXIT(!(ccs->fn = calloc(1, sizeof *ccs->fn)))
        ccs->capacity = 1;
    }

    if(ccs->len >= ccs->capacity) {
        ccs->capacity *= 2;
        trim_arrays(ccs);
    }

    ccs->hashes[ccs->len] = hash_code(cmd);

    size_t len = strlen(cmd) + 1;
    assert(len < MAX_MESSAGE_BUFFER);
    CALLEXIT(!(ccs->cmds[ccs->len] = calloc(len+1, 1)))
    strncpy(ccs->cmds[ccs->len], cmd, len);

    len = strlen(helptext);
    assert(len < MAX_MESSAGE_BUFFER);
    CALLEXIT(!(ccs->helptexts[ccs->len] = calloc(len+1, 1)))
    strncpy(ccs->helptexts[ccs->len], helptext, len);

    ccs->auth_levels[ccs->len] = auth_level;
    ccs->fn[ccs->len] = fn;

    ccs->len++;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x34dc
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x34e7
movq 0x22d85(%rip), %rax     # 0x26268
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x350d
cmpq $0x0, -0x10(%rbp)
je 0x350d
cmpq $0x0, -0x18(%rbp)
je 0x350d
cmpq $0x0, -0x28(%rbp)
je 0x350d
jmp 0x352c
leaq 0x16df7(%rip), %rdi     # 0x1a30b
leaq 0x16dc9(%rip), %rsi     # 0x1a2e4
movl $0x2e, %edx
leaq 0x16e01(%rip), %rcx     # 0x1a328
callq 0x2100
movq -0x30(%rbp), %rax
movq $0x2, 0x38(%rax)
movq -0x30(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x3652
movl $0x1, %edi
movl $0x8, %esi
callq 0x2110
movq -0x30(%rbp), %rcx
movq %rax, 0x10(%rcx)
cmpq $0x0, %rax
jne 0x357a
leaq 0x16e0d(%rip), %rdi     # 0x1a378
callq 0x2190
movl $0x1, %edi
callq 0x2260
movl $0x1, %edi
movl $0x8, %esi
callq 0x2110
movq -0x30(%rbp), %rcx
movq %rax, 0x18(%rcx)
cmpq $0x0, %rax
jne 0x35ad
leaq 0x16e2e(%rip), %rdi     # 0x1a3cc
callq 0x2190
movl $0x1, %edi
callq 0x2260
movl $0x1, %edi
movl $0x8, %esi
callq 0x2110
movq -0x30(%rbp), %rcx
movq %rax, 0x20(%rcx)
cmpq $0x0, %rax
jne 0x35e0
leaq 0x16e4b(%rip), %rdi     # 0x1a41c
callq 0x2190
movl $0x1, %edi
callq 0x2260
movl $0x1, %edi
movl $0x4, %esi
callq 0x2110
movq -0x30(%rbp), %rcx
movq %rax, 0x28(%rcx)
cmpq $0x0, %rax
jne 0x3613
leaq 0x16e72(%rip), %rdi     # 0x1a476
callq 0x2190
movl $0x1, %edi
callq 0x2260
movl $0x1, %edi
movl $0x8, %esi
callq 0x2110
movq -0x30(%rbp), %rcx
movq %rax, 0x30(%rcx)
cmpq $0x0, %rax
jne 0x3646
leaq 0x16e9d(%rip), %rdi     # 0x1a4d4
callq 0x2190
movl $0x1, %edi
callq 0x2260
movq -0x30(%rbp), %rax
movq $0x1, 0x8(%rax)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq -0x30(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jb 0x367b
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rcx
shlq %rcx
movq %rcx, 0x8(%rax)
movq -0x30(%rbp), %rdi
callq 0x3810
movq -0x10(%rbp), %rdi
callq 0x3940
movq %rax, %rdx
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x30(%rbp), %rcx
movq (%rcx), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x10(%rbp), %rdi
callq 0x20c0
addq $0x1, %rax
movq %rax, -0x38(%rbp)
cmpq $0x190, -0x38(%rbp)     # imm = 0x190
jae 0x36b7
jmp 0x36d6
leaq 0x16e62(%rip), %rdi     # 0x1a520
leaq 0x16c1f(%rip), %rsi     # 0x1a2e4
movl $0x42, %edx
leaq 0x16c57(%rip), %rcx     # 0x1a328
callq 0x2100
movq -0x38(%rbp), %rdi
addq $0x1, %rdi
movl $0x1, %esi
callq 0x2110
movq -0x30(%rbp), %rcx
movq 0x18(%rcx), %rcx
movq -0x30(%rbp), %rdx
movq (%rdx), %rdx
movq %rax, (%rcx,%rdx,8)
cmpq $0x0, %rax
jne 0x3717
leaq 0x16e31(%rip), %rdi     # 0x1a539
callq 0x2190
movl $0x1, %edi
callq 0x2260
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x30(%rbp), %rcx
movq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x20e0
movq -0x18(%rbp), %rdi
callq 0x20c0
movq %rax, -0x38(%rbp)
cmpq $0x190, -0x38(%rbp)     # imm = 0x190
jae 0x3750
jmp 0x376f
leaq 0x16dc9(%rip), %rdi     # 0x1a520
leaq 0x16b86(%rip), %rsi     # 0x1a2e4
movl $0x47, %edx
leaq 0x16bbe(%rip), %rcx     # 0x1a328
callq 0x2100
movq -0x38(%rbp), %rdi
addq $0x1, %rdi
movl $0x1, %esi
callq 0x2110
movq -0x30(%rbp), %rcx
movq 0x20(%rcx), %rcx
movq -0x30(%rbp), %rdx
movq (%rdx), %rdx
movq %rax, (%rcx,%rdx,8)
cmpq $0x0, %rax
jne 0x37b0
leaq 0x16de6(%rip), %rdi     # 0x1a587
callq 0x2190
movl $0x1, %edi
callq 0x2260
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x30(%rbp), %rcx
movq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x18(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x20e0
movl -0x1c(%rbp), %edx
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x30(%rbp), %rcx
movq (%rcx), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x30(%rbp), %rcx
movq (%rcx), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x30(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
addq $0x40, %rsp
popq %rbp
retq