// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/regressionrule.c
// Function: best_regression_condition_aic_or_bic
void best_regression_condition_aic_or_bic(Regressionconditionptr condition, Instanceptr* data, LEAF_TYPE leaftype, int modelselectionmethod)
{
	/*!Last Changed 27.03.2005*/
	int i, size = data_size(*data), d, bestmodel;
	double error, results[3];
 Instanceptr leftl, rightl, leftq, rightq, leftinstances, rightinstances;
 find_uni_and_multi_regression_conditions(condition, *data, &leftl, &rightl, &leftq, &rightq, leaftype);
	for (i = 0; i < 3; i++)
	 {
		 switch (i)
    {
		   case MODEL_UNI:divide_instancelist_according_to_split(data, &leftinstances, &rightinstances, condition->featureindex, condition->value);
						              d = 2;
						              break;
					case MODEL_LIN:divide_instancelist_according_centers(data, &leftinstances, &rightinstances, leftl, rightl, NO);
						              d = current_dataset->multifeaturecount;
						              break;
					case MODEL_QUA:divide_instancelist_according_centers(data, &leftinstances, &rightinstances, leftq, rightq, YES);
						              d = multifeaturecount_2d(current_dataset) + 1;
						              break;
    }
			error = (constant_or_linear_model_mse(leftinstances, leftinstances, leaftype) + constant_or_linear_model_mse(rightinstances, rightinstances, leaftype)) / size;
			if (modelselectionmethod == 1)
     results[i] = aic_squared_error(error, d, size);
			else
				 results[i] = bic_squared_error(error, d, size);
  	*data = restore_instancelist(*data, leftinstances);
	  merge_instancelist(data, rightinstances);	
	 }
	bestmodel = find_min_in_list_double(results, 3);
	set_best_model_in_regression_rule(condition, bestmodel, leftl, rightl, leftq, rightq);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x449f0
movl %eax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movl -0x14(%rbp), %eax
leaq -0x58(%rbp), %rdx
leaq -0x60(%rbp), %rcx
leaq -0x68(%rbp), %r8
leaq -0x70(%rbp), %r9
movl %eax, (%rsp)
callq 0xa5350
movl $0x0, -0x1c(%rbp)
cmpl $0x3, -0x1c(%rbp)
jge 0xa56a3
movl -0x1c(%rbp), %eax
movl %eax, -0x84(%rbp)
testl %eax, %eax
je 0xa555b
jmp 0xa553e
movl -0x84(%rbp), %eax
subl $0x1, %eax
je 0xa5584
jmp 0xa554b
movl -0x84(%rbp), %eax
subl $0x2, %eax
je 0xa55b5
jmp 0xa55e9
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movl (%rax), %ecx
movq -0x8(%rbp), %rax
movsd 0x8(%rax), %xmm0
leaq -0x78(%rbp), %rsi
leaq -0x80(%rbp), %rdx
callq 0x456d0
movl $0x2, -0x24(%rbp)
jmp 0xa55e9
movq -0x10(%rbp), %rdi
movq -0x58(%rbp), %rcx
movq -0x60(%rbp), %r8
leaq -0x78(%rbp), %rsi
leaq -0x80(%rbp), %rdx
xorl %r9d, %r9d
callq 0x45590
leaq 0x60299(%rip), %rax     # 0x105840
movq (%rax), %rax
movl 0x1c0(%rax), %eax
movl %eax, -0x24(%rbp)
jmp 0xa55e9
movq -0x10(%rbp), %rdi
movq -0x68(%rbp), %rcx
movq -0x70(%rbp), %r8
leaq -0x78(%rbp), %rsi
leaq -0x80(%rbp), %rdx
movl $0x1, %r9d
callq 0x45590
leaq 0x60265(%rip), %rax     # 0x105840
movq (%rax), %rdi
callq 0x1b690
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movq -0x78(%rbp), %rdi
movq -0x78(%rbp), %rsi
movl -0x14(%rbp), %edx
callq 0xa7830
movsd %xmm0, -0x90(%rbp)
movq -0x80(%rbp), %rdi
movq -0x80(%rbp), %rsi
movl -0x14(%rbp), %edx
callq 0xa7830
movaps %xmm0, %xmm1
movsd -0x90(%rbp), %xmm0
addsd %xmm1, %xmm0
cvtsi2sdl -0x20(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
cmpl $0x1, -0x18(%rbp)
jne 0xa5652
movsd -0x30(%rbp), %xmm0
cvtsi2sdl -0x24(%rbp), %xmm1
movl -0x20(%rbp), %edi
callq 0x663e0
movslq -0x1c(%rbp), %rax
movsd %xmm0, -0x50(%rbp,%rax,8)
jmp 0xa566e
movsd -0x30(%rbp), %xmm0
cvtsi2sdl -0x24(%rbp), %xmm1
movl -0x20(%rbp), %edi
callq 0x66950
movslq -0x1c(%rbp), %rax
movsd %xmm0, -0x50(%rbp,%rax,8)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x78(%rbp), %rsi
callq 0x464e0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rdi
movq -0x80(%rbp), %rsi
callq 0x44f40
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xa5525
leaq -0x50(%rbp), %rdi
movl $0x3, %esi
callq 0x50490
movl %eax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movl -0x28(%rbp), %esi
movq -0x58(%rbp), %rdx
movq -0x60(%rbp), %rcx
movq -0x68(%rbp), %r8
movq -0x70(%rbp), %r9
callq 0xa53f0
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax)