// File: /workspace/github_c_makefile_star2_O1/olcaytaner[P]Isell/regressiontree.c
// Function: best_hybrid_regression_tree_split_aic_or_bic
int best_hybrid_regression_tree_split_aic_or_bic(Regressionnodeptr node, Regtree_parameterptr param)
{
	/*!Last Changed 27.03.2005*/
	int i, size = data_size(node->instances), d, bestmodel;
	double error, results[3];
 Instanceptr leftl, rightl, leftq, rightq, leftinstances, rightinstances;
 find_uni_and_multi_regression_splits(node, &leftl, &rightl, &leftq, &rightq);
	for (i = 0; i < 3; i++)
	 {
   leftinstances = rightinstances = NULL;
		 switch (i)
    {
		   case MODEL_UNI:divide_instancelist_according_to_split(&(node->instances), &leftinstances, &rightinstances, node->featureno, node->split);
						              d = 2;
						              break;
					case MODEL_LIN:divide_instancelist_according_centers(&(node->instances), &leftinstances, &rightinstances, leftl, rightl, NO);
						              d = current_dataset->multifeaturecount;
						              break;
					case MODEL_QUA:divide_instancelist_according_centers(&(node->instances), &leftinstances, &rightinstances, leftq, rightq, YES);
						              d = multifeaturecount_2d(current_dataset) + 1;
						              break;
    }
			error = (constant_or_linear_model_mse(leftinstances, leftinstances, param->leaftype) + constant_or_linear_model_mse(rightinstances, rightinstances, param->leaftype)) / size;
			if (param->modelselectionmethod == 1)
     results[i] = aic_squared_error(error, d, size);
			else
				 results[i] = bic_squared_error(error, d, size);
  	node->instances = restore_instancelist(node->instances, leftinstances);
	  merge_instancelist(&(node->instances), rightinstances);	
	 }
	bestmodel = find_min_in_list_double(results, 3);
	set_best_model_in_regression_tree(node, bestmodel, leftl, rightl, leftq, rightq);
	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x20(%rdi), %r15
movq 0x20(%rdi), %rdi
callq 0x2fa14
movl %eax, %ebp
leaq 0x68(%rsp), %rsi
leaq 0x20(%rsp), %rdx
leaq 0x60(%rsp), %r12
leaq 0x58(%rsp), %r13
movq %rbx, 0x18(%rsp)
movq %rbx, %rdi
movq %rsi, %rbx
movq %r12, %rcx
movq %r13, %r8
callq 0x76812
movq (%r12), %rax
movq %rax, 0x40(%rsp)
movq (%r13), %rax
movq %rax, 0x38(%rsp)
movq (%rbx), %rax
movq %rax, 0x30(%rsp)
leaq 0x20(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x28(%rsp)
cvtsi2sd %ebp, %xmm0
movsd %xmm0, 0x48(%rsp)
xorl %r13d, %r13d
xorl %ebx, %ebx
movq %r13, 0x8(%rsp)
movq %r13, 0x10(%rsp)
cmpl $0x2, %ebx
je 0x769f2
cmpl $0x1, %ebx
je 0x769c0
testl %ebx, %ebx
jne 0x76a29
movq 0x18(%rsp), %rax
movl 0x68(%rax), %ecx
movsd 0x50(%rax), %xmm0
movq %r15, %rdi
leaq 0x10(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0x301e1
movl $0x2, %r12d
jmp 0x76a29
movq %r15, %rdi
leaq 0x10(%rsp), %rsi
leaq 0x8(%rsp), %rdx
movq 0x30(%rsp), %rcx
movq 0x28(%rsp), %r8
xorl %r9d, %r9d
callq 0x3010e
leaq 0x5be8a(%rip), %rax     # 0xd2870
movq (%rax), %rax
movl 0x1c0(%rax), %r12d
jmp 0x76a29
movq %r15, %rdi
leaq 0x10(%rsp), %rsi
leaq 0x8(%rsp), %rdx
movq 0x40(%rsp), %rcx
movq 0x38(%rsp), %r8
movl $0x1, %r9d
callq 0x3010e
leaq 0x5be55(%rip), %rax     # 0xd2870
movq (%rax), %rdi
callq 0x13726
movl %eax, %r12d
incl %r12d
movq 0x10(%rsp), %rdi
movl (%r14), %edx
movq %rdi, %rsi
callq 0x75f33
movsd %xmm0, 0x50(%rsp)
movq 0x8(%rsp), %rdi
movl (%r14), %edx
movq %rdi, %rsi
callq 0x75f33
addsd 0x50(%rsp), %xmm0
divsd 0x48(%rsp), %xmm0
cmpl $0x1, 0x8(%r14)
xorps %xmm1, %xmm1
cvtsi2sd %r12d, %xmm1
movl %ebp, %edi
jne 0x76a73
callq 0x46491
jmp 0x76a78
callq 0x468e1
movsd %xmm0, 0x70(%rsp,%rbx,8)
movq (%r15), %rdi
movq 0x10(%rsp), %rsi
callq 0x30ad5
movq %rax, (%r15)
movq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x2fd59
incq %rbx
cmpq $0x3, %rbx
jne 0x7697d
leaq 0x70(%rsp), %rdi
movl $0x3, %esi
callq 0x37740
movq 0x68(%rsp), %rdx
movq 0x20(%rsp), %rcx
movq 0x60(%rsp), %r8
movq 0x58(%rsp), %r9
movq 0x18(%rsp), %rdi
movl %eax, %esi
callq 0x7687c
movl $0x1, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq