// File: /workspace/github_cpp_makefile_star2_O1/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 %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rdi), %rdi
testq %rdi, %rdi
je 0x7110
callq 0x2240
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x711e
callq 0x2240
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x712c
callq 0x2240
movq 0x28(%rbx), %rdi
testq %rdi, %rdi
je 0x713a
callq 0x2240
movq 0x880(%rbx), %rdi
testq %rdi, %rdi
je 0x714b
callq 0x2240
movq 0x888(%rbx), %rdi
testq %rdi, %rdi
je 0x715c
callq 0x2240
movq 0x890(%rbx), %rdi
testq %rdi, %rdi
je 0x716d
callq 0x2240
movq 0x8b8(%rbx), %rdi
testq %rdi, %rdi
je 0x717e
callq 0x2240
movq 0x898(%rbx), %rdi
testq %rdi, %rdi
je 0x718f
callq 0x2240
movq 0x8a0(%rbx), %rdi
testq %rdi, %rdi
je 0x71a0
callq 0x2240
movq 0x8a8(%rbx), %rdi
testq %rdi, %rdi
je 0x71b1
callq 0x2240
movq 0x8b0(%rbx), %rdi
testq %rdi, %rdi
je 0x71c2
callq 0x2240
movq 0x8c0(%rbx), %rdi
testq %rdi, %rdi
je 0x71d3
callq 0x2240
movq 0x8c8(%rbx), %rdi
testq %rdi, %rdi
je 0x71ea
movl 0x8f8(%rbx), %esi
callq 0x7747
movq 0x8d0(%rbx), %rdi
testq %rdi, %rdi
je 0x71fb
callq 0x2240
cmpb $0x0, 0x52(%rbx)
jle 0x7213
movq 0x58(%rbx), %rdi
callq 0x2240
movq 0x60(%rbx), %rdi
callq 0x2240
movq 0x928(%rbx), %r14
testq %r14, %r14
je 0x7234
movq %r14, %rdi
callq 0x37b6
movl $0x30, %esi
movq %r14, %rdi
callq 0x21d0
movq 0x930(%rbx), %r14
testq %r14, %r14
je 0x7255
movq %r14, %rdi
callq 0x382e
movl $0x30, %esi
movq %r14, %rdi
callq 0x21d0
movq 0x938(%rbx), %r14
testq %r14, %r14
je 0x7276
movq %r14, %rdi
callq 0x37b6
movl $0x30, %esi
movq %r14, %rdi
callq 0x21d0
movq 0x940(%rbx), %r14
testq %r14, %r14
je 0x7297
movq %r14, %rdi
callq 0x382e
movl $0x30, %esi
movq %r14, %rdi
callq 0x21d0
movq 0x948(%rbx), %r14
testq %r14, %r14
je 0x72b8
movq %r14, %rdi
callq 0x37b6
movl $0x30, %esi
movq %r14, %rdi
callq 0x21d0
movq 0x950(%rbx), %r14
testq %r14, %r14
je 0x72d9
movq %r14, %rdi
callq 0x382e
movl $0x30, %esi
movq %r14, %rdi
callq 0x21d0
cmpq $0x0, 0x8f0(%rbx)
je 0x735a
cmpb $0x0, 0x8d8(%rbx)
jle 0x731a
xorl %r14d, %r14d
movq 0x8e0(%rbx), %rax
movq 0x8f0(%rbx), %rcx
movq (%rcx,%r14,8), %rdi
movl (%rax,%r14,4), %esi
callq 0x7777
incq %r14
movsbq 0x8d8(%rbx), %rax
cmpq %rax, %r14
jl 0x72ef
movq 0x8f0(%rbx), %rdi
callq 0x2240
movq 0x8e0(%rbx), %rdi
callq 0x2240
movq 0x8e8(%rbx), %rdi
callq 0x2240
movb $0x0, 0x8d8(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x8e0(%rbx)
movq $0x0, 0x8f0(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq