// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movl $0x0, -0xb4(%rbp)
movq -0x10(%rbp), %rdi
movl $0x20, %esi
leaq -0x30(%rbp), %rdx
callq 0x6270
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x4249
movl $0x5, -0x4(%rbp)
jmp 0x4702
cmpq $0x1, -0x30(%rbp)
jbe 0x43fe
movq -0x28(%rbp), %rax
movq (%rax), %rdi
leaq 0x689b(%rip), %rsi      # 0xaafd
movl $0x2, %edx
callq 0x1060
cmpl $0x0, %eax
jne 0x43fe
movb $0x0, %al
callq 0x2020
movq %rax, -0xe0(%rbp)
callq 0x1d80
movq %rax, %rcx
movq -0xe0(%rbp), %rax
cmpq %rcx, %rax
je 0x43fe
movb $0x0, %al
callq 0x2020
movq %rax, %rdi
callq 0x3450
movq %rax, -0xe8(%rbp)
callq 0x1dd0
movq %rax, %rcx
movq -0xe8(%rbp), %rax
cmpq %rcx, %rax
jne 0x43eb
movb $0x0, %al
callq 0x2020
movq %rax, -0xc0(%rbp)
movq $0x0, -0xc8(%rbp)
callq 0x1d90
movq %rax, %rdi
callq 0x1fd0
leaq 0xd14a(%rip), %rax      # 0x11440
movq (%rax), %rdi
callq 0x6100
movq -0x28(%rbp), %rdi
addq $0x8, %rdi
movq -0x30(%rbp), %rsi
subq $0x1, %rsi
callq 0x4710
movl %eax, -0xb4(%rbp)
movb $0x0, %al
callq 0x2020
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rax
movq %rax, -0xf0(%rbp)
callq 0x1d90
movq %rax, %rcx
movq -0xf0(%rbp), %rax
cmpq %rcx, %rax
je 0x4394
movb $0x0, %al
callq 0x2020
movq %rax, %rdi
callq 0x3450
movq %rax, -0xf8(%rbp)
callq 0x1dd0
movq %rax, %rcx
movq -0xf8(%rbp), %rax
cmpq %rcx, %rax
jne 0x4392
leaq 0x5ff1(%rip), %rdi      # 0xa36b
leaq 0x73b8(%rip), %rsi      # 0xb739
movl $0x14e, %edx            # imm = 0x14E
leaq 0x6773(%rip), %rcx      # 0xab00
callq 0x10c0
jmp 0x43e9
movq -0xc0(%rbp), %rdi
callq 0x1fd0
leaq 0xd099(%rip), %rax      # 0x11440
movq (%rax), %rax
movq %rax, -0x108(%rbp)
callq 0x1d80
movq %rax, -0x100(%rbp)
movb $0x0, %al
callq 0x2020
movq -0x108(%rbp), %rdi
movq -0x100(%rbp), %rsi
movq %rax, %rdx
callq 0x3a50
leaq 0xd05f(%rip), %rax      # 0x11440
movq (%rax), %rdi
callq 0x5630
jmp 0x43f9
leaq 0x674e(%rip), %rdi      # 0xab40
movb $0x0, %al
callq 0x10b0
jmp 0x46c3
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x110(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rdi
callq 0x1090
movq -0x110(%rbp), %rdi
movq %rax, %rdx
leaq 0x626d(%rip), %rsi      # 0xa696
callq 0x1060
cmpl $0x0, %eax
jne 0x4473
cmpq $0x1, -0x30(%rbp)
jne 0x4445
xorl %eax, %eax
movq %rax, -0x118(%rbp)
jmp 0x4454
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x118(%rbp)
movq -0x118(%rbp), %rdi
callq 0x4ee0
cmpq $0x0, -0x20(%rbp)
je 0x446e
movq -0x20(%rbp), %rax
movb $0x1, (%rax)
jmp 0x46c1
movq -0x28(%rbp), %rax
movq (%rax), %rdi
leaq 0x6235(%rip), %rsi      # 0xa6b6
movl $0x4, %edx
callq 0x1060
cmpl $0x0, %eax
jne 0x44ab
cmpq $0x1, -0x30(%rbp)
jne 0x44ab
movb $0x0, %al
callq 0x2020
movq %rax, %rdi
callq 0x3730
jmp 0x46bf
movq -0x28(%rbp), %rax
movq (%rax), %rdi
leaq 0x6214(%rip), %rsi      # 0xa6cd
movl $0x2, %edx
callq 0x1060
cmpl $0x0, %eax
jne 0x44e3
cmpq $0x1, -0x30(%rbp)
jne 0x44e3
movb $0x0, %al
callq 0x2020
movq %rax, %rdi
callq 0x3630
jmp 0x46bd
movq -0x28(%rbp), %rax
movq (%rax), %rdi
leaq 0x61b4(%rip), %rsi      # 0xa6a5
movl $0x3, %edx
callq 0x1060
cmpl $0x0, %eax
jne 0x451d
cmpq $0x1, -0x30(%rbp)
jne 0x451d
xorl %eax, %eax
movl %eax, %esi
movl $0x3, %edx
movq %rsi, %rdi
callq 0x7420
jmp 0x46bb
movq -0x28(%rbp), %rax
movq (%rax), %rdi
leaq 0x60e8(%rip), %rsi      # 0xa613
movl $0x3, %edx
callq 0x1060
cmpl $0x0, %eax
jne 0x45fb
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x5fe1(%rip), %rsi      # 0xa52e
movl $0x2, %edx
callq 0x1060
cmpl $0x0, %eax
jne 0x45fb
cmpq $0x4, -0x30(%rbp)
jne 0x45fb
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0xd0(%rbp), %rsi
movl $0xa, %edx
callq 0x1140
movq %rax, -0xd8(%rbp)
leaq -0xb0(%rbp), %rax
movq %rax, -0x128(%rbp)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x120(%rbp)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x1090
movq -0x128(%rbp), %rdi
movq -0x120(%rbp), %rsi
movq %rax, %rdx
callq 0x1050
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x1090
movb $0x0, -0xb0(%rbp,%rax)
leaq -0xb0(%rbp), %rdi
movq -0xd8(%rbp), %rax
movzwl %ax, %esi
callq 0x79e0
jmp 0x46b9
movq -0x28(%rbp), %rax
movq (%rax), %rdi
leaq 0x5f74(%rip), %rsi      # 0xa57d
movl $0x6, %edx
callq 0x1060
cmpl $0x0, %eax
jne 0x46a4
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x5f65(%rip), %rsi      # 0xa590
movl $0x4, %edx
callq 0x1060
cmpl $0x0, %eax
jne 0x46a4
cmpq $0x3, -0x30(%rbp)
jne 0x46a4
leaq -0xb0(%rbp), %rax
movq %rax, -0x138(%rbp)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x130(%rbp)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x1090
movq -0x138(%rbp), %rdi
movq -0x130(%rbp), %rsi
movq %rax, %rdx
callq 0x1050
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x1090
movb $0x0, -0xb0(%rbp,%rax)
leaq -0xb0(%rbp), %rdi
callq 0x4f20
jmp 0x46b7
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x4710
movl %eax, -0xb4(%rbp)
jmp 0x46b9
jmp 0x46bb
jmp 0x46bd
jmp 0x46bf
jmp 0x46c1
jmp 0x46c3
movl $0x10, %edi
callq 0x6170
movb $0x0, %al
callq 0x2030
cmpl $0x0, %eax
je 0x46ea
leaq 0xcd60(%rip), %rax      # 0x11440
movq (%rax), %rdi
callq 0x55e0
jmp 0x46f9
leaq 0xcd4f(%rip), %rax      # 0x11440
movq (%rax), %rdi
callq 0x6100
movl -0xb4(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
nop