// File: /workspace/github_cpp_makefile_star2_O3/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 0x9e8a
callq 0x42a0
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
je 0x9e98
callq 0x42a0
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x9ea6
callq 0x42a0
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x9eb4
callq 0x42a0
movq 0x870(%rbx), %rdi
testq %rdi, %rdi
je 0x9ec5
callq 0x42a0
movq 0x878(%rbx), %rdi
testq %rdi, %rdi
je 0x9ed6
callq 0x42a0
movq 0x8a0(%rbx), %rdi
testq %rdi, %rdi
je 0x9ee7
callq 0x42a0
movq 0x880(%rbx), %rdi
testq %rdi, %rdi
je 0x9ef8
callq 0x42a0
movq 0x888(%rbx), %rdi
testq %rdi, %rdi
je 0x9f09
callq 0x42a0
movq 0x890(%rbx), %rdi
testq %rdi, %rdi
je 0x9f1a
callq 0x42a0
movq 0x898(%rbx), %rdi
testq %rdi, %rdi
je 0x9f2b
callq 0x42a0
movq 0x8a8(%rbx), %rdi
testq %rdi, %rdi
je 0x9f3c
callq 0x42a0
cmpb $0x0, 0x42(%rbx)
jle 0x9f54
movq 0x48(%rbx), %rdi
callq 0x42a0
movq 0x50(%rbx), %rdi
callq 0x42a0
cmpl $0x0, 0x8dc(%rbx)
jle 0x9f9d
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 0x9f8a
callq 0x42a0
incq %r15
movslq 0x8dc(%rbx), %rax
addq $0x60, %r14
cmpq %rax, %r15
jl 0x9f63
movq 0x8e8(%rbx), %rdi
testq %rdi, %rdi
je 0x9fae
callq 0x42a0
movq 0x8f0(%rbx), %rdi
testq %rdi, %rdi
je 0x9fbf
callq 0x42a0
movq 0x908(%rbx), %rdi
testq %rdi, %rdi
je 0x9fd0
callq 0x42a0
movq 0x8f8(%rbx), %rdi
testq %rdi, %rdi
je 0x9fe1
callq 0x42a0
movq 0x910(%rbx), %rdi
testq %rdi, %rdi
je 0x9ff2
callq 0x42a0
movq 0x8e0(%rbx), %rdi
testq %rdi, %rdi
je 0xa003
callq 0x42a0
movq 0x900(%rbx), %rdi
testq %rdi, %rdi
je 0xa014
callq 0x42a0
cmpl $0x0, 0x8d8(%rbx)
jle 0xa049
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 0xa026
movq 0x8d0(%rbx), %rdi
testq %rdi, %rdi
je 0xa05a
callq 0x42a0
movq 0x920(%rbx), %r14
testq %r14, %r14
je 0xa06e
movq %r14, %rdi
callq 0x62ae
movl $0x30, %esi
movq %r14, %rdi
callq 0x4220
movq 0x928(%rbx), %r14
testq %r14, %r14
je 0xa08f
movq %r14, %rdi
callq 0x6326
movl $0x30, %esi
movq %r14, %rdi
callq 0x4220
movq 0x930(%rbx), %r14
testq %r14, %r14
je 0xa0b0
movq %r14, %rdi
callq 0x62ae
movl $0x30, %esi
movq %r14, %rdi
callq 0x4220
movq 0x938(%rbx), %r14
testq %r14, %r14
je 0xa0d1
movq %r14, %rdi
callq 0x6326
movl $0x30, %esi
movq %r14, %rdi
callq 0x4220
movq 0x940(%rbx), %r14
testq %r14, %r14
je 0xa0f2
movq %r14, %rdi
callq 0x62ae
movl $0x30, %esi
movq %r14, %rdi
callq 0x4220
movq 0x948(%rbx), %rbx
testq %rbx, %rbx
je 0xa113
movq %rbx, %rdi
callq 0x6326
movl $0x30, %esi
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x4220