// File: /workspace/github_cpp_makefile_star2_O2/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
callq 0x4290
movq 0x8(%rbx), %rdi
callq 0x4290
movq 0x18(%rbx), %rdi
callq 0x4290
movq 0x20(%rbx), %rdi
callq 0x4290
movq 0x870(%rbx), %rdi
callq 0x4290
movq 0x878(%rbx), %rdi
callq 0x4290
movq 0x8a0(%rbx), %rdi
callq 0x4290
movq 0x880(%rbx), %rdi
callq 0x4290
movq 0x888(%rbx), %rdi
callq 0x4290
movq 0x890(%rbx), %rdi
callq 0x4290
movq 0x898(%rbx), %rdi
callq 0x4290
movq 0x8a8(%rbx), %rdi
callq 0x4290
cmpb $0x0, 0x42(%rbx)
jle 0x77c9
movq 0x48(%rbx), %rdi
callq 0x4290
movq 0x50(%rbx), %rdi
callq 0x4290
xorl %r14d, %r14d
xorl %r15d, %r15d
movslq 0x8dc(%rbx), %rax
movq 0x8e8(%rbx), %rdi
cmpq %rax, %r15
jge 0x7806
movq 0x10(%rdi,%r14), %rdi
callq 0x4290
movq 0x8e8(%rbx), %rax
movq 0x18(%rax,%r14), %rdi
callq 0x4290
incq %r15
addq $0x60, %r14
jmp 0x77cf
callq 0x4290
movq 0x8f0(%rbx), %rdi
callq 0x4290
movq 0x908(%rbx), %rdi
callq 0x4290
movq 0x8f8(%rbx), %rdi
callq 0x4290
movq 0x910(%rbx), %rdi
callq 0x4290
movq 0x8e0(%rbx), %rdi
callq 0x4290
movq 0x900(%rbx), %rdi
callq 0x4290
pushq $0x10
popq %r14
xorl %r15d, %r15d
movslq 0x8d8(%rbx), %rax
movq 0x8d0(%rbx), %rdi
cmpq %rax, %r15
jge 0x787f
movq (%rdi,%r14), %rdi
callq 0x4290
incq %r15
addq $0x60, %r14
jmp 0x785a
callq 0x4290
movq 0x920(%rbx), %r14
testq %r14, %r14
je 0x7898
movq %r14, %rdi
callq 0x518e
pushq $0x30
popq %rsi
movq %r14, %rdi
callq 0x4230
movq 0x928(%rbx), %r14
testq %r14, %r14
je 0x78b7
movq %r14, %rdi
callq 0x51f2
pushq $0x30
popq %rsi
movq %r14, %rdi
callq 0x4230
movq 0x930(%rbx), %r14
testq %r14, %r14
je 0x78d6
movq %r14, %rdi
callq 0x518e
pushq $0x30
popq %rsi
movq %r14, %rdi
callq 0x4230
movq 0x938(%rbx), %r14
testq %r14, %r14
je 0x78f5
movq %r14, %rdi
callq 0x51f2
pushq $0x30
popq %rsi
movq %r14, %rdi
callq 0x4230
movq 0x940(%rbx), %r14
testq %r14, %r14
je 0x7914
movq %r14, %rdi
callq 0x518e
pushq $0x30
popq %rsi
movq %r14, %rdi
callq 0x4230
movq 0x948(%rbx), %rbx
testq %rbx, %rbx
je 0x7933
movq %rbx, %rdi
callq 0x51f2
pushq $0x30
popq %rsi
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x4230