// File: /workspace/github_c_makefile_star2_O2/sachinites[P]CommandParser/cmd_hier.c
// Function: init_param
void
init_param(param_t *param,                               /* pointer to static param_t variable*/
        param_type_t param_type,                         /* CMD|LEAF*/
        char *cmd_name,                                  /* <command name> | NULL*/
        cmd_callback callback,                           /* Callback field*/
        user_validation_callback user_validation_cb_fn,  /* NULL | <callback ptr>*/
        leaf_type_t leaf_type,                           /* INVALID | leaf type*/
        char *leaf_id,                                   /* NULL, <STRING>*/
        char *help){                                     /* Help String*/

    int i = 0;
    if(param_type == CMD){
        GET_PARAM_CMD(param) = (cmd_t *)calloc(1, sizeof(cmd_t));
        param->param_type = CMD;
        strncpy(GET_CMD_NAME(param), cmd_name, MIN(CMD_NAME_SIZE, strlen(cmd_name)));
        GET_CMD_NAME(param)[CMD_NAME_SIZE -1] = '\0';
    }
    else if(param_type == LEAF){
        GET_PARAM_LEAF(param) = (leaf_t *)calloc(1, sizeof(leaf_t));
        param->param_type = LEAF;
        GET_PARAM_LEAF(param)->leaf_type = leaf_type;
        param->cmd_type.leaf->user_validation_cb_fn = user_validation_cb_fn;
        strncpy(GET_LEAF_ID(param), leaf_id, MIN(LEAF_ID_SIZE, strlen(leaf_id)));
        GET_LEAF_ID(param)[LEAF_ID_SIZE -1] = '\0';
    }
    else if(param_type == NO_CMD){
        GET_PARAM_CMD(param) = (cmd_t *)calloc(1, sizeof(cmd_t));
        param->param_type = NO_CMD;
        strncpy(GET_CMD_NAME(param), NEGATE_CHARACTER, strlen(NEGATE_CHARACTER));
        GET_CMD_NAME(param)[CMD_NAME_SIZE -1] = '\0';
    }

    param->ishidden = 0;
    param->parent = NULL;
    param->callback = callback;
    strncpy(GET_PARAM_HELP_STRING(param), help, MIN(PARAM_HELP_STRING_SIZE, strlen(help)));
    GET_PARAM_HELP_STRING(param)[PARAM_HELP_STRING_SIZE -1] = '\0';
    param->disp_callback = NULL;

    for(; i < MAX_OPTION_SIZE; i++){
        param->options[i] = NULL;
    }

    param->CMDCODE = -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r15
movq %rdi, %rbx
movq 0x48(%rsp), %r14
cmpl $0x2, %esi
je 0x2775
cmpl $0x1, %esi
je 0x2722
testl %esi, %esi
jne 0x278f
movq %rdx, %r12
pushq $0x1
popq %rdi
pushq $0x20
popq %r13
movq %r13, %rsi
callq 0x1140
movq %rax, %rbp
movq %rax, 0x8(%rbx)
andl $0x0, (%rbx)
movq %r12, %rdi
callq 0x10c0
cmpq $0x20, %rax
cmovbq %rax, %r13
movq %rbp, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x1060
movb $0x0, 0x1f(%rbp)
jmp 0x278f
movl %r9d, %ebp
movq %r8, %r13
pushq $0x1
popq %rdi
pushq $0x70
popq %rsi
callq 0x1140
movq %rax, %r12
movq %rax, 0x8(%rbx)
movl $0x1, (%rbx)
movl %ebp, (%rax)
movq %r13, 0x48(%rax)
leaq 0x50(%rax), %r13
movq 0x40(%rsp), %rbp
movq %rbp, %rdi
callq 0x10c0
cmpq $0x20, %rax
pushq $0x20
popq %rdx
cmovbq %rax, %rdx
movq %r13, %rdi
movq %rbp, %rsi
callq 0x1060
movb $0x0, 0x6f(%r12)
jmp 0x278f
pushq $0x1
popq %rdi
pushq $0x20
popq %rsi
callq 0x1140
movq %rax, 0x8(%rbx)
movl $0x2, (%rbx)
movw $0x6f6e, (%rax)         # imm = 0x6F6E
xorl %r12d, %r12d
movb %r12b, 0x18(%rbx)
andq $0x0, 0xe0(%rbx)
movq %r15, 0x10(%rbx)
leaq 0x19(%rbx), %r15
movq %r14, %rdi
callq 0x10c0
cmpq $0x40, %rax
pushq $0x40
popq %rdx
cmovbq %rax, %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x1060
movb %r12b, 0x58(%rbx)
andq $0x0, 0xe8(%rbx)
cmpq $0x10, %r12
je 0x27e1
andq $0x0, 0x60(%rbx,%r12,8)
incq %r12
jmp 0x27d0
orl $-0x1, 0xf0(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq