// File: /workspace/github_cpp_makefile_star2_O1/myudelson[P]hmm-scalable/utils.cpp
// Function: destroy_input_data(param*)
void destroy_input_data(struct param *param) {
    if(param->item_complexity) free(param->item_complexity);
	if(param->init_params != NULL) free(param->init_params);
	if(param->param_lo != NULL) free(param->param_lo);
	if(param->param_hi != NULL) free(param->param_hi);
	
    // data - checks if pointers to data are null anyway (whether we delete linear columns of data or not)
	if(param->dat_obs != NULL) free( param->dat_obs );
	if(param->dat_group != NULL) free( param->dat_group );
	if(param->dat_item != NULL) free( param->dat_item );
	if(param->dat_skill != NULL) free( param->dat_skill );
//	if(param->dat_multiskill != NULL) delete param->dat_multiskill;
    if(param->dat_skill_stacked != NULL) free( param->dat_skill_stacked );
    if(param->dat_skill_rcount != NULL) free( param->dat_skill_rcount );
    if(param->dat_skill_rix != NULL) free( param->dat_skill_rix );
	if(param->dat_slice != NULL) free( param->dat_slice );
    if( param->Cslices>0 ) {
        free( param->Cw );
        free( param->Ccenters );
    }
    
    // not null skills
    for(NDAT kg=0;kg<param->nSeq; kg++) {
		free(param->all_data[kg].ix); // was obs;
		if( param->all_data[kg].ix_stacked != NULL ) free(param->all_data[kg].ix_stacked); // was obs;
//        if(param->sliced) // handled via one global array and ix indexing
//            free(param->all_data[kg].time);
    }
    if(param->all_data != NULL) free(param->all_data); // ndat of them
    if(param->k_data != NULL)   free(param->k_data); // ndat of them (reordered by k)
    if(param->g_data != NULL)   free(param->g_data); // ndat of them (reordered by g)
    if(param->k_g_data != NULL) free(param->k_g_data); // nK of them
    if(param->g_k_data != NULL) free(param->g_k_data); // nG of them
    
	if(param->k_numg != NULL)   free(param->k_numg);
	if(param->g_numk != NULL)   free(param->g_numk);
    // null skills
    for(NCAT g=0;g<param->n_null_skill_group; g++)
        free(param->null_skills[g].ix); // was obs
    if(param->null_skills != NULL) free(param->null_skills);
    // vocabularies
    delete param->map_group_fwd;
    delete param->map_group_bwd;
    delete param->map_step_fwd;
    delete param->map_step_bwd;
    delete param->map_skill_fwd;
    delete param->map_skill_bwd;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rdi
testq %rdi, %rdi
je 0x9e77
callq 0x42a0
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
je 0x9e85
callq 0x42a0
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x9e93
callq 0x42a0
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x9ea1
callq 0x42a0
movq 0x870(%rbx), %rdi
testq %rdi, %rdi
je 0x9eb2
callq 0x42a0
movq 0x878(%rbx), %rdi
testq %rdi, %rdi
je 0x9ec3
callq 0x42a0
movq 0x8a0(%rbx), %rdi
testq %rdi, %rdi
je 0x9ed4
callq 0x42a0
movq 0x880(%rbx), %rdi
testq %rdi, %rdi
je 0x9ee5
callq 0x42a0
movq 0x888(%rbx), %rdi
testq %rdi, %rdi
je 0x9ef6
callq 0x42a0
movq 0x890(%rbx), %rdi
testq %rdi, %rdi
je 0x9f07
callq 0x42a0
movq 0x898(%rbx), %rdi
testq %rdi, %rdi
je 0x9f18
callq 0x42a0
movq 0x8a8(%rbx), %rdi
testq %rdi, %rdi
je 0x9f29
callq 0x42a0
cmpb $0x0, 0x42(%rbx)
jle 0x9f41
movq 0x48(%rbx), %rdi
callq 0x42a0
movq 0x50(%rbx), %rdi
callq 0x42a0
cmpl $0x0, 0x8dc(%rbx)
jle 0x9f8a
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x8e8(%rbx), %rax
movq 0x10(%rax,%r14), %rdi
callq 0x42a0
movq 0x8e8(%rbx), %rax
movq 0x18(%rax,%r14), %rdi
testq %rdi, %rdi
je 0x9f77
callq 0x42a0
incq %r15
movslq 0x8dc(%rbx), %rax
addq $0x60, %r14
cmpq %rax, %r15
jl 0x9f50
movq 0x8e8(%rbx), %rdi
testq %rdi, %rdi
je 0x9f9b
callq 0x42a0
movq 0x8f0(%rbx), %rdi
testq %rdi, %rdi
je 0x9fac
callq 0x42a0
movq 0x908(%rbx), %rdi
testq %rdi, %rdi
je 0x9fbd
callq 0x42a0
movq 0x8f8(%rbx), %rdi
testq %rdi, %rdi
je 0x9fce
callq 0x42a0
movq 0x910(%rbx), %rdi
testq %rdi, %rdi
je 0x9fdf
callq 0x42a0
movq 0x8e0(%rbx), %rdi
testq %rdi, %rdi
je 0x9ff0
callq 0x42a0
movq 0x900(%rbx), %rdi
testq %rdi, %rdi
je 0xa001
callq 0x42a0
cmpl $0x0, 0x8d8(%rbx)
jle 0xa036
movl $0x10, %r14d
xorl %r15d, %r15d
movq 0x8d0(%rbx), %rax
movq (%rax,%r14), %rdi
callq 0x42a0
incq %r15
movslq 0x8d8(%rbx), %rax
addq $0x60, %r14
cmpq %rax, %r15
jl 0xa013
movq 0x8d0(%rbx), %rdi
testq %rdi, %rdi
je 0xa047
callq 0x42a0
movq 0x920(%rbx), %r14
testq %r14, %r14
je 0xa068
movq %r14, %rdi
callq 0x6390
movl $0x30, %esi
movq %r14, %rdi
callq 0x4220
movq 0x928(%rbx), %r14
testq %r14, %r14
je 0xa089
movq %r14, %rdi
callq 0x6408
movl $0x30, %esi
movq %r14, %rdi
callq 0x4220
movq 0x930(%rbx), %r14
testq %r14, %r14
je 0xa0aa
movq %r14, %rdi
callq 0x6390
movl $0x30, %esi
movq %r14, %rdi
callq 0x4220
movq 0x938(%rbx), %r14
testq %r14, %r14
je 0xa0cb
movq %r14, %rdi
callq 0x6408
movl $0x30, %esi
movq %r14, %rdi
callq 0x4220
movq 0x940(%rbx), %r14
testq %r14, %r14
je 0xa0ec
movq %r14, %rdi
callq 0x6390
movl $0x30, %esi
movq %r14, %rdi
callq 0x4220
movq 0x948(%rbx), %rbx
testq %rbx, %rbx
je 0xa112
movq %rbx, %rdi
callq 0x6408
movl $0x30, %esi
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x4220
popq %rbx
popq %r14
popq %r15
retq