// File: /workspace/github_c_makefile_star2_O0/Ziddykins[P]Dawn/src/cmdsys.c
// Function: get_cmd_id
size_t get_cmd_id(CmdSys cs, char * cmd) {
    struct cmd_sys * ccs = cs;
    assert(ccs);
    uint64_t hash = hash_code(cmd);
    size_t min = 0, max = ccs->len-1, mid = (size_t)(-1);
    int valid = 0;

    while(max >= min) {
        if (min == 0) min += 1;
        mid = (min+max)/2;
        if(ccs->hashes[mid] == hash) {
            valid = 1; break;
        } else if(ccs->hashes[mid] > hash) {
            max = mid-1;
        } else {
            min = mid+1;
        }
    }

    if(valid) {
        for(size_t iter = mid; iter < ccs->len && ccs->hashes[iter] == hash; iter++) {
            if(strcmp(cmd, ccs->cmds[iter]) == 0) {
                return iter;
            }
        }
        for(size_t iter = mid; iter < ccs->len && ccs->hashes[iter] == hash; iter--) {
            if(strcmp(cmd, ccs->cmds[iter]) == 0) {
                return iter;
            }
        }
    }
    return (size_t)-1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x43b1
jmp 0x43d0
leaq 0x15f28(%rip), %rdi     # 0x1a2e0
leaq 0x15f25(%rip), %rsi     # 0x1a2e4
movl $0xd8, %edx
leaq 0x166c3(%rip), %rcx     # 0x1aa8e
callq 0x2100
movq -0x18(%rbp), %rdi
callq 0x3940
movq %rax, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rax
subq $0x1, %rax
movq %rax, -0x38(%rbp)
movq $-0x1, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x30(%rbp), %rax
jb 0x4482
cmpq $0x0, -0x30(%rbp)
jne 0x4420
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
addq -0x38(%rbp), %rax
shrq %rax
movq %rax, -0x40(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rax
cmpq -0x28(%rbp), %rax
jne 0x444e
movl $0x1, -0x44(%rbp)
jmp 0x4482
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rax
cmpq -0x28(%rbp), %rax
jbe 0x4472
movq -0x40(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x447e
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x4480
jmp 0x4403
cmpl $0x0, -0x44(%rbp)
je 0x457b
movq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rcx
movq -0x20(%rbp), %rdx
xorl %eax, %eax
cmpq (%rdx), %rcx
movb %al, -0x59(%rbp)
jae 0x44c0
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x50(%rbp), %rcx
movq (%rax,%rcx,8), %rax
cmpq -0x28(%rbp), %rax
sete %al
movb %al, -0x59(%rbp)
movb -0x59(%rbp), %al
testb $0x1, %al
jne 0x44c9
jmp 0x4504
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x50(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x22d0
cmpl $0x0, %eax
jne 0x44f4
movq -0x50(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x4583
jmp 0x44f6
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x4494
movq -0x40(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rcx
movq -0x20(%rbp), %rdx
xorl %eax, %eax
cmpq (%rdx), %rcx
movb %al, -0x5a(%rbp)
jae 0x4538
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rax
cmpq -0x28(%rbp), %rax
sete %al
movb %al, -0x5a(%rbp)
movb -0x5a(%rbp), %al
testb $0x1, %al
jne 0x4541
jmp 0x4579
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x22d0
cmpl $0x0, %eax
jne 0x4569
movq -0x58(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x4583
jmp 0x456b
movq -0x58(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x450c
jmp 0x457b
movq $-0x1, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)