// File: /workspace/github_c_makefile_star2_O1/sachinites[P]CommandParser/parser.c
// Function: find_matching_param
param_t*
find_matching_param(param_t **options, const char *cmd_name){
    
    int i = 0, leaf_index = -1,
        j = 0,
        choice = -1;

    bool ex_match = false;

    memset(array_of_possibilities, 0, POSSIBILITY_ARRAY_SIZE * sizeof(param_t *));

    for(; options[i] && i <= CHILDREN_END_INDEX; i++){

        if(IS_PARAM_LEAF(options[i])){
            leaf_index = i;
            continue;
        }

        if (is_cmd_string_match(options[i], cmd_name, &ex_match) == 0) {

            if (ex_match) {
                array_of_possibilities[ 0 ] = options[i];
                j = 1;
                break;
            }
            array_of_possibilities[ j++ ] = options[i];
            assert (j < POSSIBILITY_ARRAY_SIZE);
            continue;
        }
    }

    if(leaf_index >= 0 && j == 0)
        return options[leaf_index];

    if( j == 0)
        return NULL;

    if(j == 1)
        return array_of_possibilities[0];

    /* More than one param matched*/
    printf("%d possibilities :\n", j);
    for(i = 0; i < j; i++)
        printf("%-2d. %s\n", i, GET_CMD_NAME(array_of_possibilities[i]));

    printf("Choice [0-%d] : ? ", j-1);
    scanf("%d", &choice);

    /*  Read \n and discard */
    if((fgets((char *)cons_input_buffer, sizeof(cons_input_buffer)-1, stdin) == NULL)){
        printf("error in reading from stdin\n");
    }

    if(choice < 0 || choice > (j-1)){
        printf("\nInvalid Choice");
        return NULL;
    }

    return array_of_possibilities[choice];   
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, 0x10(%rsp)
movq %rdi, %r15
movl $0xffffffff, 0x8(%rsp)  # imm = 0xFFFFFFFF
xorps %xmm0, %xmm0
movaps %xmm0, 0xe9af(%rip)     # 0x11e00
movaps %xmm0, 0xe9b8(%rip)     # 0x11e10
movaps %xmm0, 0xe9c1(%rip)     # 0x11e20
movaps %xmm0, 0xe9ca(%rip)     # 0x11e30
movaps %xmm0, 0xe9d3(%rip)     # 0x11e40
movq (%rdi), %r14
testq %r14, %r14
je 0x3519
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
xorl %ebx, %ebx
movq $0x0, (%rsp)
cmpl $0x1, (%r14)
jne 0x3492
movl %ebx, %edx
jmp 0x3500
movl %edx, 0xc(%rsp)
movq 0x10(%rsp), %rbp
movq %rbp, %rdi
callq 0x10c0
movq %rax, %r12
movq 0x8(%r14), %r13
movslq %r12d, %rdx
movq %r13, %rdi
movq %rbp, %rsi
callq 0x1070
movl %eax, %ebp
testl %eax, %eax
je 0x34c2
xorl %eax, %eax
jmp 0x34d0
movq %r13, %rdi
callq 0x10c0
cmpl %eax, %r12d
sete %al
testl %ebp, %ebp
movl 0xc(%rsp), %edx
jne 0x3500
testb %al, %al
jne 0x3528
movq (%rsp), %rcx
movslq %ecx, %rax
leaq 0xe916(%rip), %rsi      # 0x11e00
movq %r14, (%rsi,%rax,8)
movq %rcx, %rax
cmpl $0x9, %eax
jge 0x3654
incl %eax
movq %rax, (%rsp)
cmpq $0xe, %rbx
ja 0x3538
movq 0x8(%r15,%rbx,8), %r14
incq %rbx
testq %r14, %r14
jne 0x3488
jmp 0x3538
movq $0x0, (%rsp)
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
jmp 0x3538
movq %r14, 0xe8d1(%rip)      # 0x11e00
movl $0x1, %eax
movq %rax, (%rsp)
testl %edx, %edx
setns %al
movq (%rsp), %rbx
testl %ebx, %ebx
sete %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x3558
movl %edx, %eax
movq (%r15,%rax,8), %rbx
jmp 0x3642
testl %ebx, %ebx
je 0x356d
cmpl $0x1, %ebx
jne 0x3574
movq 0xe898(%rip), %rbx      # 0x11e00
jmp 0x3642
xorl %ebx, %ebx
jmp 0x3642
leaq 0x54ce(%rip), %rdi      # 0x8a49
movl %ebx, %esi
xorl %eax, %eax
callq 0x10e0
testl %ebx, %ebx
jle 0x35bd
movl (%rsp), %ebx
leaq 0xe86e(%rip), %r12      # 0x11e00
leaq 0x54c4(%rip), %r14      # 0x8a5d
xorl %r15d, %r15d
movq (%r12), %rax
movq 0x8(%rax), %rdx
movq %r14, %rdi
movl %r15d, %esi
xorl %eax, %eax
callq 0x10e0
incq %r15
addq $0x8, %r12
cmpq %r15, %rbx
jne 0x359c
movq (%rsp), %rbx
leal -0x1(%rbx), %esi
leaq 0x549c(%rip), %rdi      # 0x8a67
xorl %eax, %eax
callq 0x10e0
leaq 0x54a1(%rip), %rdi      # 0x8a7a
leaq 0x8(%rsp), %rsi
xorl %eax, %eax
callq 0x1220
movq 0x99f4(%rip), %rax      # 0xcfe0
movq (%rax), %rdx
leaq 0xe85a(%rip), %rdi      # 0x11e50
movl $0x7ff, %esi            # imm = 0x7FF
callq 0x1130
testq %rax, %rax
jne 0x3611
leaq 0x5702(%rip), %rdi      # 0x8d0e
callq 0x1080
movl 0x8(%rsp), %eax
testl %eax, %eax
setns %cl
cmpl %ebx, %eax
setl %dl
testb %dl, %cl
je 0x3632
movl %eax, %eax
leaq 0xe7d4(%rip), %rcx      # 0x11e00
movq (%rcx,%rax,8), %rbx
jmp 0x3642
leaq 0x5444(%rip), %rdi      # 0x8a7d
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x10e0
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x539c(%rip), %rdi      # 0x89f7
leaq 0x60c1(%rip), %rsi      # 0x9723
leaq 0x53a9(%rip), %rcx      # 0x8a12
movl $0x57, %edx
callq 0x10f0