// File: /workspace/github_c_makefile_star2_O2/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 $0x78, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x20(%rdi), %r15
movq 0x20(%rdi), %rdi
callq 0x2c3cc
movl %eax, %ebp
leaq 0x48(%rsp), %rsi
leaq 0x40(%rsp), %rdx
leaq 0x58(%rsp), %r12
leaq 0x50(%rsp), %r13
movq %rbx, %rdi
movq %r12, %rcx
movq %r13, %r8
callq 0x6de8c
movq (%r12), %rax
movq %rax, 0x28(%rsp)
movq (%r13), %rax
movq %rax, 0x20(%rsp)
leaq 0x48(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x18(%rsp)
leaq 0x40(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x10(%rsp)
cvtsi2sd %ebp, %xmm0
movsd %xmm0, 0x30(%rsp)
xorl %r13d, %r13d
cmpq $0x3, %r13
je 0x6e107
andq $0x0, (%rsp)
andq $0x0, 0x8(%rsp)
cmpl $0x2, %r13d
je 0x6e040
cmpl $0x1, %r13d
jne 0x6e075
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
movq %rsp, %rdx
movq 0x18(%rsp), %rcx
movq 0x10(%rsp), %r8
xorl %r9d, %r9d
callq 0x2ca3c
leaq 0x5f83c(%rip), %rax     # 0xcd870
movq (%rax), %rax
movl 0x1c0(%rax), %r12d
jmp 0x6e091
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
movq %rsp, %rdx
movq 0x28(%rsp), %rcx
movq 0x20(%rsp), %r8
pushq $0x1
popq %r9
callq 0x2ca3c
leaq 0x5f80b(%rip), %rax     # 0xcd870
movq (%rax), %rdi
callq 0x126ea
movl %eax, %r12d
incl %r12d
jmp 0x6e091
movl 0x68(%rbx), %ecx
movsd 0x50(%rbx), %xmm0
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
movq %rsp, %rdx
callq 0x2caf4
pushq $0x2
popq %r12
movq 0x8(%rsp), %rdi
movl (%r14), %edx
movq %rdi, %rsi
callq 0x6d63d
movsd %xmm0, 0x38(%rsp)
movq (%rsp), %rdi
movl (%r14), %edx
movq %rdi, %rsi
callq 0x6d63d
addsd 0x38(%rsp), %xmm0
divsd 0x30(%rsp), %xmm0
cmpl $0x1, 0x8(%r14)
cvtsi2sd %r12d, %xmm1
movl %ebp, %edi
jne 0x6e0d7
callq 0x40b9e
jmp 0x6e0dc
callq 0x40f59
movsd %xmm0, 0x60(%rsp,%r13,8)
movq (%r15), %rdi
movq 0x8(%rsp), %rsi
callq 0x2d2da
movq %rax, (%r15)
movq (%rsp), %rsi
movq %r15, %rdi
callq 0x2c6e4
incq %r13
jmp 0x6dfef
leaq 0x60(%rsp), %rdi
pushq $0x3
popq %rsi
callq 0x338cc
movq %rbx, %rdi
movl %eax, %esi
movq 0x18(%rsp), %rdx
movq 0x10(%rsp), %rcx
movq 0x28(%rsp), %r8
movq 0x20(%rsp), %r9
callq 0x6def6
pushq $0x1
popq %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq