// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r8, %rbx
movl %ecx, %ebp
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r14
testq %rdi, %rdi
jne 0x3b26
movq 0x1b752(%rip), %r14     # 0x1f278
testq %rbx, %rbx
je 0x3ce0
testq %r15, %r15
je 0x3ce0
testq %r12, %r12
je 0x3ce0
testq %r14, %r14
je 0x3ce0
movq $0x2, 0x38(%r14)
cmpq $0x0, 0x8(%r14)
jne 0x3bf1
movl $0x1, %edi
movl $0x8, %esi
callq 0x2110
movq %rax, 0x10(%r14)
testq %rax, %rax
je 0x3d47
movl $0x1, %edi
movl $0x8, %esi
callq 0x2110
movq %rax, 0x18(%r14)
testq %rax, %rax
je 0x3d4c
movl $0x1, %edi
movl $0x8, %esi
callq 0x2110
movq %rax, 0x20(%r14)
testq %rax, %rax
je 0x3d51
movl $0x1, %edi
movl $0x4, %esi
callq 0x2110
movq %rax, 0x28(%r14)
testq %rax, %rax
je 0x3d56
movl $0x1, %edi
movl $0x8, %esi
callq 0x2110
movq %rax, 0x30(%r14)
testq %rax, %rax
je 0x3d5b
movq $0x1, 0x8(%r14)
movq 0x8(%r14), %rax
cmpq %rax, (%r14)
jb 0x3c09
addq %rax, %rax
movq %rax, 0x8(%r14)
movq %r14, %rdi
callq 0x3d60
movq %r12, %rdi
callq 0x3e1c
movq (%r14), %rcx
movq 0x10(%r14), %rdx
movq %rax, (%rdx,%rcx,8)
movq %r12, %rdi
callq 0x20c0
leaq 0x1(%rax), %r13
cmpq $0x190, %r13            # imm = 0x190
jae 0x3cff
addq $0x2, %rax
movl $0x1, %esi
movq %rax, %rdi
callq 0x2110
movq (%r14), %rcx
movq 0x18(%r14), %rdx
movq %rax, (%rdx,%rcx,8)
testq %rax, %rax
je 0x3d1e
movq 0x18(%r14), %rax
movq (%rax,%rcx,8), %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x20e0
movq %r15, %rdi
callq 0x20c0
cmpq $0x190, %rax            # imm = 0x190
jae 0x3d23
movq %rax, %r12
leaq 0x1(%rax), %rdi
movl $0x1, %esi
callq 0x2110
movq (%r14), %rcx
movq 0x20(%r14), %rdx
movq %rax, (%rdx,%rcx,8)
testq %rax, %rax
je 0x3d42
movq 0x20(%r14), %rax
movq (%rax,%rcx,8), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x20e0
movq (%r14), %rax
movq 0x28(%r14), %rcx
movl %ebp, (%rcx,%rax,4)
movq 0x30(%r14), %rcx
movq %rbx, (%rcx,%rax,8)
incq %rax
movq %rax, (%r14)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xd624(%rip), %rdi      # 0x1130b
leaq 0xd5f6(%rip), %rsi      # 0x112e4
leaq 0xd633(%rip), %rcx      # 0x11328
movl $0x2e, %edx
callq 0x2100
leaq 0xd81a(%rip), %rdi      # 0x11520
leaq 0xd5d7(%rip), %rsi      # 0x112e4
leaq 0xd614(%rip), %rcx      # 0x11328
movl $0x42, %edx
callq 0x2100
callq 0x2543
leaq 0xd7f6(%rip), %rdi      # 0x11520
leaq 0xd5b3(%rip), %rsi      # 0x112e4
leaq 0xd5f0(%rip), %rcx      # 0x11328
movl $0x47, %edx
callq 0x2100
callq 0x252e
callq 0x25ac
callq 0x2597
callq 0x2582
callq 0x256d
callq 0x2558