// File: 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 %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, (%rax)
je 0xb852
movq -0x8(%rbp), %rax
movq (%rax), %rdi
callq 0x5380
movq -0x8(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0xb86a
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x5380
movq -0x8(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0xb882
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x5380
movq -0x8(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0xb89a
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x5380
movq -0x8(%rbp), %rax
cmpq $0x0, 0x870(%rax)
je 0xb8b8
movq -0x8(%rbp), %rax
movq 0x870(%rax), %rdi
callq 0x5380
movq -0x8(%rbp), %rax
cmpq $0x0, 0x878(%rax)
je 0xb8d6
movq -0x8(%rbp), %rax
movq 0x878(%rax), %rdi
callq 0x5380
movq -0x8(%rbp), %rax
cmpq $0x0, 0x8a0(%rax)
je 0xb8f4
movq -0x8(%rbp), %rax
movq 0x8a0(%rax), %rdi
callq 0x5380
movq -0x8(%rbp), %rax
cmpq $0x0, 0x880(%rax)
je 0xb912
movq -0x8(%rbp), %rax
movq 0x880(%rax), %rdi
callq 0x5380
movq -0x8(%rbp), %rax
cmpq $0x0, 0x888(%rax)
je 0xb930
movq -0x8(%rbp), %rax
movq 0x888(%rax), %rdi
callq 0x5380
movq -0x8(%rbp), %rax
cmpq $0x0, 0x890(%rax)
je 0xb94e
movq -0x8(%rbp), %rax
movq 0x890(%rax), %rdi
callq 0x5380
movq -0x8(%rbp), %rax
cmpq $0x0, 0x898(%rax)
je 0xb96c
movq -0x8(%rbp), %rax
movq 0x898(%rax), %rdi
callq 0x5380
movq -0x8(%rbp), %rax
cmpq $0x0, 0x8a8(%rax)
je 0xb98a
movq -0x8(%rbp), %rax
movq 0x8a8(%rax), %rdi
callq 0x5380
movq -0x8(%rbp), %rax
movsbl 0x42(%rax), %eax
cmpl $0x0, %eax
jle 0xb9b1
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x5380
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rdi
callq 0x5380
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x8dc(%rcx), %eax
jge 0xba2f
movq -0x8(%rbp), %rax
movq 0x8e8(%rax), %rax
movslq -0xc(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdi
callq 0x5380
movq -0x8(%rbp), %rax
movq 0x8e8(%rax), %rax
movslq -0xc(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, 0x18(%rax)
je 0xba22
movq -0x8(%rbp), %rax
movq 0x8e8(%rax), %rax
movslq -0xc(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rdi
callq 0x5380
jmp 0xba24
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0xb9b8
movq -0x8(%rbp), %rax
cmpq $0x0, 0x8e8(%rax)
je 0xba4d
movq -0x8(%rbp), %rax
movq 0x8e8(%rax), %rdi
callq 0x5380
movq -0x8(%rbp), %rax
cmpq $0x0, 0x8f0(%rax)
je 0xba6b
movq -0x8(%rbp), %rax
movq 0x8f0(%rax), %rdi
callq 0x5380
movq -0x8(%rbp), %rax
cmpq $0x0, 0x908(%rax)
je 0xba89
movq -0x8(%rbp), %rax
movq 0x908(%rax), %rdi
callq 0x5380
movq -0x8(%rbp), %rax
cmpq $0x0, 0x8f8(%rax)
je 0xbaa7
movq -0x8(%rbp), %rax
movq 0x8f8(%rax), %rdi
callq 0x5380
movq -0x8(%rbp), %rax
cmpq $0x0, 0x910(%rax)
je 0xbac5
movq -0x8(%rbp), %rax
movq 0x910(%rax), %rdi
callq 0x5380
movq -0x8(%rbp), %rax
cmpq $0x0, 0x8e0(%rax)
je 0xbae3
movq -0x8(%rbp), %rax
movq 0x8e0(%rax), %rdi
callq 0x5380
movq -0x8(%rbp), %rax
cmpq $0x0, 0x900(%rax)
je 0xbb01
movq -0x8(%rbp), %rax
movq 0x900(%rax), %rdi
callq 0x5380
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x8d8(%rcx), %eax
jge 0xbb41
movq -0x8(%rbp), %rax
movq 0x8d0(%rax), %rax
movslq -0x10(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdi
callq 0x5380
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0xbb08
movq -0x8(%rbp), %rax
cmpq $0x0, 0x8d0(%rax)
je 0xbb5f
movq -0x8(%rbp), %rax
movq 0x8d0(%rax), %rdi
callq 0x5380
movq -0x8(%rbp), %rax
movq 0x920(%rax), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
je 0xbb8b
movq -0x18(%rbp), %rdi
callq 0x6870
movq -0x18(%rbp), %rdi
movl $0x30, %esi
callq 0x52e0
movq -0x8(%rbp), %rax
movq 0x928(%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0xbbb7
movq -0x20(%rbp), %rdi
callq 0x68b0
movq -0x20(%rbp), %rdi
movl $0x30, %esi
callq 0x52e0
movq -0x8(%rbp), %rax
movq 0x930(%rax), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0xbbe3
movq -0x28(%rbp), %rdi
callq 0x6870
movq -0x28(%rbp), %rdi
movl $0x30, %esi
callq 0x52e0
movq -0x8(%rbp), %rax
movq 0x938(%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
je 0xbc0f
movq -0x30(%rbp), %rdi
callq 0x68b0
movq -0x30(%rbp), %rdi
movl $0x30, %esi
callq 0x52e0
movq -0x8(%rbp), %rax
movq 0x940(%rax), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
je 0xbc3b
movq -0x38(%rbp), %rdi
callq 0x6870
movq -0x38(%rbp), %rdi
movl $0x30, %esi
callq 0x52e0
movq -0x8(%rbp), %rax
movq 0x948(%rax), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
je 0xbc67
movq -0x40(%rbp), %rdi
callq 0x68b0
movq -0x40(%rbp), %rdi
movl $0x30, %esi
callq 0x52e0
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)