// File: /workspace/github_c_makefile_star2_O2/sachinites[P]CommandParser/parser.c
// Function: parse_input_cmd
CMD_PARSE_STATUS
parse_input_cmd(char *input, unsigned int len, bool *is_repeat_cmd){

    char** tokens = NULL;
    size_t token_cnt = 0;
    char file_name[128];
    CMD_PARSE_STATUS status = COMPLETE;
    
    tokens = tokenizer(input, ' ', &token_cnt);
    if(!token_cnt)
        return INCOMPLETE_COMMAND;

    if(token_cnt > 1 && 
            ((strncmp(tokens[0], DO, 2) == 0)) &&
            (get_cmd_tree_cursor() != libcli_get_root())) /*do commands are not allowed from root*/

    {
        if(IS_CURRENT_MODE_CONFIG()) /*Do commands are allowed only when user is operating in config mode*/
        {
            param_t *old_cursor_state = get_cmd_tree_cursor(), *new_cursor_state = NULL;
            set_cmd_tree_cursor(libcli_get_do_hook());/*It will also destroy the config mode serialize buffer*/

            /*There is a cross branch junp from config to Operational branch, hence reset the buffer*/
            reset_serialize_buffer(tlv_buff);
            status = build_tlv_buffer(&tokens[1], token_cnt-1);

            /*It might be possible that user may have switched the branch from within config branch*/
            new_cursor_state = get_cmd_tree_cursor();

            /*If new cursor is not same as do_hook, it means, 
             * user has entered into MODE in some operational branch*/

            if(new_cursor_state != libcli_get_do_hook()){
                if(IS_CURRENT_MODE_CONFIG()){
                    assert(0); /*Impossible case*/
                }
            }
            else{
                /*User is in the config mode only */
                set_cmd_tree_cursor(old_cursor_state);
                /*We need to rebuild the TLV buffer afresh*/
                build_cmd_tree_leaves_data(tlv_buff, libcli_get_root(), get_cmd_tree_cursor());
                mark_checkpoint_serialize_buffer(tlv_buff);
            }
        }
        else
            printf("Info : do is supported from within config mode only\n");
    }

    else if (strncmp (tokens[0], "repeat" , strlen(tokens[0])) == 0) {
        parser_process_repeat_cmd(token_cnt == 1 ? 0 : tokens[1]);
        if (is_repeat_cmd) *is_repeat_cmd = true;
    }   

    else if((strncmp(tokens[0], GOTO_ONE_LVL_UP_STRING, strlen(GOTO_ONE_LVL_UP_STRING)) == 0) && (token_cnt == 1))
        go_one_level_up_cmd_tree(get_cmd_tree_cursor());
    
    else if((strncmp(tokens[0], GOTO_TOP_STRING, strlen(GOTO_TOP_STRING)) == 0) && (token_cnt == 1))
        goto_top_of_cmd_tree(get_cmd_tree_cursor());

    
    else if((strncmp(tokens[0], CLEAR_SCR_STRING, strlen(CLEAR_SCR_STRING)) == 0) && (token_cnt == 1))
        clear_screen_handler(0, 0, MODE_UNKNOWN);

    else if (!strncmp(tokens[0], "run" , strlen("run"))  && 
	     !strncmp(tokens[1], "ut" , strlen("ut"))    &&
	     token_cnt == 4 ) {

        char *pend;
        long int tc_no = strtol(tokens[3], &pend, 10);
        strncpy(file_name, tokens[2], strlen(tokens[2]));
        file_name[strlen(tokens[2])] = '\0';
        run_test_case(file_name, tc_no);
    }
    
    else if ( !strncmp(tokens[0], "config" , strlen("config"))  &&
	      !strncmp(tokens[1], "load" , strlen("load"))      &&
	      token_cnt == 3 ) {

	    strncpy(file_name, tokens[2], strlen(tokens[2]));
	    file_name[strlen(tokens[2])] = '\0';
	    parse_file(file_name);
    }
    else 
        status = build_tlv_buffer(tokens, token_cnt); 

    re_init_tokens(MAX_CMD_TREE_DEPTH);

    if(is_user_in_cmd_mode())
        restore_checkpoint_serialize_buffer(tlv_buff);
    else
        reset_serialize_buffer(tlv_buff);

    return status;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdx, %r12
movq %rsp, %r14
andq $0x0, (%r14)
pushq $0x20
popq %rsi
movq %r14, %rdx
callq 0x46c6
movq %rax, %rbx
movq (%r14), %rax
testq %rax, %rax
je 0x3437
cmpq $0x1, %rax
je 0x33d6
movq (%rbx), %rax
cmpb $0x64, (%rax)
jne 0x33d6
cmpb $0x6f, 0x1(%rax)
jne 0x33d6
xorl %eax, %eax
callq 0x1c24
movq %rax, %r14
callq 0x1abc
cmpq %rax, %r14
je 0x33d6
xorl %r14d, %r14d
xorl %eax, %eax
callq 0x1c24
movq %rax, %rdi
callq 0x2a44
movq %rax, %r15
callq 0x1ae4
cmpq %rax, %r15
je 0x362d
leaq 0x48ce(%rip), %rdi      # 0x7c9a
callq 0x1080
jmp 0x35f2
movq (%rbx), %r15
movq %r15, %rdi
callq 0x10c0
leaq 0x4244(%rip), %rsi      # 0x762c
movq %r15, %rdi
movq %rax, %rdx
callq 0x1070
testl %eax, %eax
je 0x3440
leaq 0x424e(%rip), %rsi      # 0x764c
pushq $0x4
popq %rdx
movq %r15, %rdi
callq 0x1070
testl %eax, %eax
sete %al
movq (%rsp), %r14
cmpq $0x1, %r14
sete %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x346e
xorl %r14d, %r14d
xorl %eax, %eax
callq 0x1c24
movq %rax, %rdi
callq 0x2c00
jmp 0x35f2
pushq $0x5
popq %r14
jmp 0x361b
callq 0x1afc
movq 0x10(%rax), %rbx
callq 0x1afc
xorl %r14d, %r14d
pushq $0x2
popq %rdx
movq %rax, %rdi
xorl %esi, %esi
callq *%rbx
testq %r12, %r12
je 0x35f2
movb $0x1, (%r12)
jmp 0x35f2
movzbl (%r15), %eax
cmpl $0x72, %eax
je 0x34b1
cmpl $0x63, %eax
jne 0x356f
cmpq $0x1, %r14
sete %al
cmpb $0x64, 0x1(%r15)
sete %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x353e
xorl %r14d, %r14d
xorl %eax, %eax
callq 0x1c24
movq %rax, %rdi
callq 0x2b54
jmp 0x35f2
cmpb $0x75, 0x1(%r15)
jne 0x356f
cmpb $0x6e, 0x2(%r15)
jne 0x356f
movq 0x8(%rbx), %rax
cmpb $0x75, (%rax)
jne 0x356f
cmpb $0x74, 0x1(%rax)
sete %al
cmpq $0x4, %r14
sete %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x356f
movq 0x18(%rbx), %rdi
leaq 0x8(%rsp), %rsi
pushq $0xa
popq %rdx
callq 0x1180
movq %rax, %r14
movq 0x10(%rbx), %rbx
movq %rbx, %rdi
callq 0x10c0
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x1060
movq %rbx, %rdi
callq 0x10c0
movb $0x0, 0x10(%rsp,%rax)
movzwl %r14w, %esi
movq %r15, %rdi
callq 0x54c4
jmp 0x35df
cmpb $0x6c, 0x1(%r15)
jne 0x356f
cmpq $0x1, %r14
sete %al
cmpb $0x73, 0x2(%r15)
sete %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x356f
xorl %r14d, %r14d
pushq $0x3
popq %rdx
xorl %edi, %edi
xorl %esi, %esi
callq 0x5135
jmp 0x35f2
leaq 0x3f9d(%rip), %rsi      # 0x7513
pushq $0x6
popq %rdx
movq %r15, %rdi
callq 0x1070
testl %eax, %eax
jne 0x35e4
movq 0x8(%rbx), %rdi
leaq 0x3f96(%rip), %rsi      # 0x7526
pushq $0x4
popq %rdx
callq 0x1070
testl %eax, %eax
sete %al
cmpq $0x3, %r14
sete %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x35e4
movq 0x10(%rbx), %rbx
movq %rbx, %rdi
callq 0x10c0
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x1060
movq %rbx, %rdi
callq 0x10c0
movb $0x0, 0x10(%rsp,%rax)
movq %r14, %rdi
callq 0x3c67
xorl %r14d, %r14d
jmp 0x35f2
movq %rbx, %rdi
movq %r14, %rsi
callq 0x36f4
movl %eax, %r14d
pushq $0x10
popq %rdi
callq 0x4627
xorl %eax, %eax
callq 0x1c2c
leaq 0xae58(%rip), %rcx      # 0xe460
movq (%rcx), %rdi
testl %eax, %eax
je 0x3616
callq 0x4024
jmp 0x361b
callq 0x45de
movl %r14d, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
xorl %eax, %eax
callq 0x1c24
movq %rax, %r15
callq 0x1ac4
movq %rax, %rdi
callq 0x1bf7
leaq 0xae15(%rip), %r12      # 0xe460
movq (%r12), %rdi
callq 0x45de
addq $0x8, %rbx
movq (%rsp), %rsi
decq %rsi
movq %rbx, %rdi
callq 0x36f4
movl %eax, %r14d
xorl %eax, %eax
callq 0x1c24
movq %rax, %rbx
callq 0x1ac4
cmpq %rax, %rbx
je 0x36bd
xorl %eax, %eax
callq 0x1c24
movq %rax, %rdi
callq 0x2a44
movq %rax, %rbx
callq 0x1ae4
cmpq %rax, %rbx
jne 0x35f2
leaq 0x3c5c(%rip), %rdi      # 0x7301
leaq 0x5037(%rip), %rsi      # 0x86e3
leaq 0x43c1(%rip), %rcx      # 0x7a74
movl $0x14e, %edx            # imm = 0x14E
callq 0x10f0
movq %r15, %rdi
callq 0x1bf7
movq (%r12), %rbx
callq 0x1abc
movq %rax, %r15
xorl %eax, %eax
callq 0x1c24
movq %rbx, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x2e65
movq (%r12), %rdi
callq 0x404e
jmp 0x35f2