// File: /workspace/github_cpp_makefile_star2_O2/myudelson[P]hmm-scalable/utilsSt.cpp
// Function: destroy_input_data(task*)
void destroy_input_data(struct task *task) {
	if(task->init_param_values != NULL) free(task->init_param_values);
	if(task->param_values_lb != NULL) free(task->param_values_lb);
	if(task->param_values_ub != NULL) free(task->param_values_ub);
    
    if(task->elo_param_values != NULL) free(task->elo_param_values);

    // data - checks if pointers to data are null anyway (whether we delete linear columns of data or not)
    if(task->dat_obs != NULL) free( task->dat_obs );
    if(task->dat_obs_stacked != NULL) free( task->dat_obs_stacked );
	if(task->dat_group != NULL) free( task->dat_group );
	if(task->dat_item != NULL) free( task->dat_item );
	if(task->dat_skill != NULL) free( task->dat_skill );
//	if(task->dat_multiskill != NULL) delete task->dat_multiskill;
    if(task->dat_skill_stacked != NULL) free( task->dat_skill_stacked );
    if(task->dat_skill_rcount != NULL) free( task->dat_skill_rcount );
    if(task->dat_skill_rix != NULL) free( task->dat_skill_rix );
	if(task->dat_slice != NULL) free( task->dat_slice );
    if(task->dat_predict != NULL) free2D(task->dat_predict, task->N);
    if(task->dat_predict_k != NULL) free(task->dat_predict_k  );
    if( task->Cslices>0 ) {
        free( task->Cw );
        free( task->Ccenters );
    }
    
//    // not null skills
//    for(NDAT kg=0;kg<task->nSeq; kg++) {
//		free(task->all_data[kg].ix); // was obs;
//		if( task->all_data[kg].ix_stacked != NULL ) free(task->all_data[kg].ix_stacked); // was obs;
////        if(task->sliced) // handled via one global array and ix indexing
////            free(task->all_data[kg].time);
//    }
//    if(task->all_data != NULL) free(task->all_data); // ndat of them
//    if(task->k_data != NULL)   free(task->k_data); // ndat of them (reordered by k)
//    if(task->g_data != NULL)   free(task->g_data); // ndat of them (reordered by g)
//    if(task->k_g_data != NULL) free(task->k_g_data); // nK of them
//    if(task->g_k_data != NULL) free(task->g_k_data); // nG of them
//
//	if(task->k_numg != NULL)   free(task->k_numg);
//	if(task->g_numk != NULL)   free(task->g_numk);
//    // null skills
//    for(NCAT g=0;g<task->n_null_skill_group; g++)
//        free(task->null_skills[g].ix); // was obs
//    if(task->null_skills != NULL) free(task->null_skills);
    // vocabularies
    delete task->map_group_fwd;
    delete task->map_group_bwd;
    delete task->map_step_fwd;
    delete task->map_step_bwd;
    delete task->map_skill_fwd;
    delete task->map_skill_bwd;
    
    // destroy connectivities
    if(task->connectivities != NULL) {
        for(NPAR i=0; i<task->n_connectivities; i++) {
            free2D<NPAR>(task->connectivities[i], task->n_connectivity_X[i]);
        }
        free(task->connectivities);
        free(task->n_connectivity_X);
        free(task->n_connectivity_Y);
        task->connectivities = NULL;
        task->n_connectivity_X = NULL;
        task->n_connectivity_Y = NULL;
        task->n_connectivities = 0;
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rdi
callq 0x3230
movq 0x10(%rbx), %rdi
callq 0x3230
movq 0x18(%rbx), %rdi
callq 0x3230
movq 0x28(%rbx), %rdi
callq 0x3230
movq 0x880(%rbx), %rdi
callq 0x3230
movq 0x888(%rbx), %rdi
callq 0x3230
movq 0x890(%rbx), %rdi
callq 0x3230
movq 0x8b8(%rbx), %rdi
callq 0x3230
movq 0x898(%rbx), %rdi
callq 0x3230
movq 0x8a0(%rbx), %rdi
callq 0x3230
movq 0x8a8(%rbx), %rdi
callq 0x3230
movq 0x8b0(%rbx), %rdi
callq 0x3230
movq 0x8c0(%rbx), %rdi
callq 0x3230
movq 0x8c8(%rbx), %rdi
testq %rdi, %rdi
je 0x6550
movl 0x8f8(%rbx), %esi
callq 0x6bc3
movq 0x8d0(%rbx), %rdi
callq 0x3230
cmpb $0x0, 0x52(%rbx)
jle 0x6574
movq 0x58(%rbx), %rdi
callq 0x3230
movq 0x60(%rbx), %rdi
callq 0x3230
movq 0x928(%rbx), %r14
testq %r14, %r14
je 0x6588
movq %r14, %rdi
callq 0x3f74
pushq $0x30
popq %rsi
movq %r14, %rdi
callq 0x31d0
movq 0x930(%rbx), %r14
testq %r14, %r14
je 0x65a7
movq %r14, %rdi
callq 0x3fd8
pushq $0x30
popq %rsi
movq %r14, %rdi
callq 0x31d0
movq 0x938(%rbx), %r14
testq %r14, %r14
je 0x65c6
movq %r14, %rdi
callq 0x3f74
pushq $0x30
popq %rsi
movq %r14, %rdi
callq 0x31d0
movq 0x940(%rbx), %r14
testq %r14, %r14
je 0x65e5
movq %r14, %rdi
callq 0x3fd8
pushq $0x30
popq %rsi
movq %r14, %rdi
callq 0x31d0
movq 0x948(%rbx), %r14
testq %r14, %r14
je 0x6604
movq %r14, %rdi
callq 0x3f74
pushq $0x30
popq %rsi
movq %r14, %rdi
callq 0x31d0
movq 0x950(%rbx), %r14
testq %r14, %r14
je 0x6623
movq %r14, %rdi
callq 0x3fd8
pushq $0x30
popq %rsi
movq %r14, %rdi
callq 0x31d0
cmpq $0x0, 0x8f0(%rbx)
je 0x669b
leaq 0x8e0(%rbx), %r14
xorl %r15d, %r15d
movsbq 0x8d8(%rbx), %rax
movq 0x8f0(%rbx), %rdi
cmpq %rax, %r15
jge 0x666b
movq (%rdi,%r15,8), %rdi
movq (%r14), %rax
movl (%rax,%r15,4), %esi
callq 0x6bf7
incq %r15
jmp 0x6642
callq 0x3230
movq 0x8e0(%rbx), %rdi
callq 0x3230
movq 0x8e8(%rbx), %rdi
callq 0x3230
movb $0x0, 0x8d8(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
andq $0x0, 0x10(%r14)
popq %rbx
popq %r14
popq %r15
retq