// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/regressiontree.c
// Function: prune_regression_tree
void prune_regression_tree(Regressionnodeptr root, Regtree_parameterptr param)
{
	/*!Last Changed 02.03.2005*/
	double generalizationerrorbeforeprune = 0.0, generalizationerrorafterprune = 0.0, errorbeforeprune;
	int dafterprune, dbeforeprune;
 if (root->featureno == LEAF_NODE)
   return;
	if (param->leaftype == CONSTANTLEAF)
		 dafterprune = 1;
	else
		 dafterprune = current_dataset->multifeaturecount;
 dbeforeprune = complexity_of_regression_tree(root);
	errorbeforeprune = mse_error_of_regression_tree(root);
	switch (param->modelselectionmethod)
	 {
	  case MODEL_SELECTION_CV :generalizationerrorbeforeprune = root->left->errorforprune + root->right->errorforprune;
				                        generalizationerrorafterprune = root->errorforprune;
										                  break;
	  case MODEL_SELECTION_AIC:generalizationerrorbeforeprune = aic_squared_error(errorbeforeprune / root->covered, dbeforeprune, root->covered);
				                        generalizationerrorafterprune = aic_squared_error(root->mseerror / root->covered, dafterprune, root->covered);
				                        break;
			case MODEL_SELECTION_BIC:generalizationerrorbeforeprune = bic_squared_error(errorbeforeprune / root->covered, dbeforeprune, root->covered);
				                        generalizationerrorafterprune = bic_squared_error(root->mseerror / root->covered, dafterprune, root->covered);
				                        break;
    default                :if (param->prunetype == VALIDATIONPRUNING)
                             {
                              generalizationerrorbeforeprune = root->left->errorforprune + root->right->errorforprune;
                              generalizationerrorafterprune = root->errorforprune;
                             }
                            else
                              printf(m1230, param->modelselectionmethod);
                            break;
	 }
	if (generalizationerrorafterprune < generalizationerrorbeforeprune)
	 {
			accumulate_instances_regression_tree(&(root->instances), &(root->cvinstances), root);
   deallocate_regression_tree(root->left);
			safe_free(root->left);
   deallocate_regression_tree(root->right);
			safe_free(root->right);
			make_leaf_regression_node(root, param->leaftype);
	 }
	else
	 {
		 prune_regression_tree(root->left, param);
		 prune_regression_tree(root->right, param);
	 }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x18(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x20(%rbp)
movq -0x8(%rbp), %rax
cmpl $-0x1, 0x68(%rax)
jne 0xa73bf
jmp 0xa75e5
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
jne 0xa73d1
movl $0x1, -0x2c(%rbp)
jmp 0xa73e4
leaq 0x5e468(%rip), %rax     # 0x105840
movq (%rax), %rax
movl 0x1c0(%rax), %eax
movl %eax, -0x2c(%rbp)
movq -0x8(%rbp), %rdi
callq 0xa5fe0
movl %eax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
callq 0xa5ec0
movsd %xmm0, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x34(%rbp)
testl %eax, %eax
je 0xa7429
jmp 0xa740e
movl -0x34(%rbp), %eax
subl $0x1, %eax
je 0xa745a
jmp 0xa7418
movl -0x34(%rbp), %eax
subl $0x2, %eax
je 0xa74b3
jmp 0xa7509
movq -0x8(%rbp), %rax
movq (%rax), %rax
movsd 0x58(%rax), %xmm0
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
addsd 0x58(%rax), %xmm0
movsd %xmm0, -0x18(%rbp)
movq -0x8(%rbp), %rax
movsd 0x58(%rax), %xmm0
movsd %xmm0, -0x20(%rbp)
jmp 0xa7558
movsd -0x28(%rbp), %xmm0
movq -0x8(%rbp), %rax
cvtsi2sdl 0x78(%rax), %xmm1
divsd %xmm1, %xmm0
cvtsi2sdl -0x30(%rbp), %xmm1
movq -0x8(%rbp), %rax
movl 0x78(%rax), %edi
callq 0x663e0
movsd %xmm0, -0x18(%rbp)
movq -0x8(%rbp), %rax
movsd 0x60(%rax), %xmm0
movq -0x8(%rbp), %rax
cvtsi2sdl 0x78(%rax), %xmm1
divsd %xmm1, %xmm0
cvtsi2sdl -0x2c(%rbp), %xmm1
movq -0x8(%rbp), %rax
movl 0x78(%rax), %edi
callq 0x663e0
movsd %xmm0, -0x20(%rbp)
jmp 0xa7558
movsd -0x28(%rbp), %xmm0
movq -0x8(%rbp), %rax
cvtsi2sdl 0x78(%rax), %xmm1
divsd %xmm1, %xmm0
cvtsi2sdl -0x30(%rbp), %xmm1
movq -0x8(%rbp), %rax
movl 0x78(%rax), %edi
callq 0x66950
movsd %xmm0, -0x18(%rbp)
movq -0x8(%rbp), %rax
movsd 0x60(%rax), %xmm0
movq -0x8(%rbp), %rax
cvtsi2sdl 0x78(%rax), %xmm1
divsd %xmm1, %xmm0
cvtsi2sdl -0x2c(%rbp), %xmm1
movq -0x8(%rbp), %rax
movl 0x78(%rax), %edi
callq 0x66950
movsd %xmm0, -0x20(%rbp)
jmp 0xa7558
movq -0x10(%rbp), %rax
cmpl $0x1, 0x4(%rax)
jne 0xa7541
movq -0x8(%rbp), %rax
movq (%rax), %rax
movsd 0x58(%rax), %xmm0
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
addsd 0x58(%rax), %xmm0
movsd %xmm0, -0x18(%rbp)
movq -0x8(%rbp), %rax
movsd 0x58(%rax), %xmm0
movsd %xmm0, -0x20(%rbp)
jmp 0xa7556
movq -0x10(%rbp), %rax
movl 0x8(%rax), %esi
leaq 0x44d25(%rip), %rdi     # 0xec274
movb $0x0, %al
callq 0x4030
jmp 0xa7558
movsd -0x20(%rbp), %xmm1
movsd -0x18(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xa75c4
movq -0x8(%rbp), %rdi
addq $0x20, %rdi
movq -0x8(%rbp), %rsi
addq $0x28, %rsi
movq -0x8(%rbp), %rdx
callq 0xa7330
movq -0x8(%rbp), %rax
movq (%rax), %rdi
callq 0xa6f70
movq -0x8(%rbp), %rax
movq (%rax), %rdi
callq 0x52e80
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0xa6f70
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x52e80
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl (%rax), %esi
callq 0xa60c0
jmp 0xa75e5
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0xa7390
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0xa7390
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)