// File: /workspace/github_c_makefile_star2_O0/sachinites[P]CommandParser/clistd.c
// Function: show_history_callback
int
show_history_callback(param_t *param, ser_buff_t *b, op_mode enable_or_disable){
   
    unsigned int cmd_counter = 0;

    unsigned long cmd_offset[MAX_SAVED_CMDS];

    memset(&cmd_offset, 0, MAX_SAVED_CMDS * sizeof(unsigned long));
    FILE *f = fopen(CMD_HIST_RECORD_FILE, "r");
    
    if(!f){
        printf("Error : History file could not be read\n");
        return 0;
    }
   
   memset(file_cmsd_size, 0, FILE_CMD_SIZE_MAX);
  
   cmd_offset[cmd_counter++] = ftell(f);
   while(fgets(file_cmsd_size, FILE_CMD_SIZE_MAX, f) != NULL) {
       printf("%d. %s", cmd_counter - 1, file_cmsd_size);
       cmd_offset[cmd_counter++] = ftell(f);
       memset(file_cmsd_size, 0, FILE_CMD_SIZE_MAX);
   } 
 
    int cmd_choice;
    printf("Enter command no to trigger : ");
    scanf("%d", &cmd_choice);
    if(!(cmd_choice >= 0 && cmd_choice < cmd_counter)){
        printf("Invalid choice\n");
        fclose(f) ;
        return 0;
    }

    
   fseek(f, cmd_offset[cmd_choice], SEEK_SET);
   memset(file_cmsd_size, 0, FILE_CMD_SIZE_MAX);
   fgets(file_cmsd_size, FILE_CMD_SIZE_MAX, f);
   file_cmsd_size[FILE_CMD_SIZE_MAX -1] = '\0';

   printf("Command to be triggered : %s", file_cmsd_size); 
   parse_input_cmd(file_cmsd_size, strlen(file_cmsd_size), NULL);   

   fclose(f) ;
   return 0; 
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
leaq -0x110(%rbp), %rdi
xorl %esi, %esi
movl $0xf0, %edx
callq 0x10d0
leaq 0x3a2a(%rip), %rdi      # 0xaba1
leaq 0x3488(%rip), %rsi      # 0xa606
callq 0x11b0
movq %rax, -0x118(%rbp)
cmpq $0x0, -0x118(%rbp)
jne 0x71ae
leaq 0x400e(%rip), %rdi      # 0xb1a9
movb $0x0, %al
callq 0x10b0
movl $0x0, -0x4(%rbp)
jmp 0x7349
leaq 0xde0b(%rip), %rdi      # 0x14fc0
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x10d0
movq -0x118(%rbp), %rdi
callq 0x1130
movq %rax, %rcx
movl -0x20(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x20(%rbp)
movl %eax, %eax
movq %rcx, -0x110(%rbp,%rax,8)
movq -0x118(%rbp), %rdx
leaq 0xddcd(%rip), %rdi      # 0x14fc0
movl $0x400, %esi            # imm = 0x400
callq 0x10f0
cmpq $0x0, %rax
je 0x7257
movl -0x20(%rbp), %esi
subl $0x1, %esi
leaq 0x3fc1(%rip), %rdi      # 0xb1d1
leaq 0xdda9(%rip), %rdx      # 0x14fc0
movb $0x0, %al
callq 0x10b0
movq -0x118(%rbp), %rdi
callq 0x1130
movq %rax, %rcx
movl -0x20(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x20(%rbp)
movl %eax, %eax
movq %rcx, -0x110(%rbp,%rax,8)
leaq 0xdd77(%rip), %rdi      # 0x14fc0
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x10d0
jmp 0x71e5
leaq 0x3f7a(%rip), %rdi      # 0xb1d8
movb $0x0, %al
callq 0x10b0
leaq 0x3861(%rip), %rdi      # 0xaacd
leaq -0x11c(%rbp), %rsi
movb $0x0, %al
callq 0x11e0
cmpl $0x0, -0x11c(%rbp)
jl 0x728e
movl -0x11c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jb 0x72b4
leaq 0x3f62(%rip), %rdi      # 0xb1f7
movb $0x0, %al
callq 0x10b0
movq -0x118(%rbp), %rdi
callq 0x1070
movl $0x0, -0x4(%rbp)
jmp 0x7349
movq -0x118(%rbp), %rdi
movslq -0x11c(%rbp), %rax
movq -0x110(%rbp,%rax,8), %rsi
xorl %edx, %edx
callq 0x1180
leaq 0xdce8(%rip), %rdi      # 0x14fc0
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x10d0
movq -0x118(%rbp), %rdx
leaq 0xdcce(%rip), %rdi      # 0x14fc0
movl $0x400, %esi            # imm = 0x400
callq 0x10f0
movb $0x0, 0xe0bc(%rip)      # 0x153bf
leaq 0x3efd(%rip), %rdi      # 0xb207
leaq 0xdcaf(%rip), %rsi      # 0x14fc0
movb $0x0, %al
callq 0x10b0
leaq 0xdca1(%rip), %rdi      # 0x14fc0
callq 0x1090
movl %eax, %esi
leaq 0xdc93(%rip), %rdi      # 0x14fc0
xorl %eax, %eax
movl %eax, %edx
callq 0x41f0
movq -0x118(%rbp), %rdi
callq 0x1070
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nopw %cs:(%rax,%rax)