// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/regressionrule.c
// Function: regression_rule_learner
Regressionruleset regression_rule_learner(Instanceptr* traindata, Instanceptr* cvdata, Regrule_parameterptr param)
{
	/*!Last Changed 06.03.2005*/
	Regressionruleset result;
	matrix w;
	double regvalue;
	int exitnow, i;
	Regressionruleptr newrule;
	Instanceptr grow, prune, coveredtrain = NULL;
	result = empty_regression_ruleset();
	result.leaftype = param->leaftype;
	while (can_be_divided_rule(*traindata, param->sigma, &w, &regvalue, param->leaftype))
	 {
		 exitnow = 0;
			if (*cvdata)
				{
     divide_instancelist(traindata, &prune, &grow, 3);
     newrule = grow_regression_rule(&grow, param);
				}
			else
					newrule = grow_regression_rule(traindata, param);
  	if (newrule && newrule->start)
			 {
				 if (*cvdata)
						 prune_regression_rule(newrule, prune, param->modelselectionmethod);
					else
						 prune_regression_rule(newrule, *traindata, param->modelselectionmethod);
					if (newrule->start)
					 {
						 add_regression_rule(&result, newrule);
							if (*cvdata)
							 {
  				   *traindata = restore_instancelist(*traindata, grow);
  				  	merge_instancelist(traindata, prune);
							 }
					 }
					else
						 exitnow = 1;
			 }
			else
				 exitnow = 1;
			if (!exitnow)
			 {
				 remove_regression_covered(traindata, &coveredtrain, newrule);
  		 if (param->leaftype == LINEARLEAF)
    		 matrix_free(w);				 
			 }
			else
			 {
				 if (*cvdata)
					 {
  		  	*traindata = restore_instancelist(*traindata, grow);
  			  merge_instancelist(traindata, prune);
					 }
				 break;
			 }
	 }
	if (param->leaftype == CONSTANTLEAF)
		 result.regressionvalue = regvalue;
	else
  	result.w = w;
	merge_instancelist(traindata, coveredtrain);
	for (i = 0; i < param->optimizecount; i++)
	 {
   optimize_regression_ruleset(&result, traindata, cvdata, param);
			if (*cvdata)
  			simplify_regression_ruleset(&result, *cvdata, param->modelselectionmethod);
			else
  			simplify_regression_ruleset(&result, *traindata, param->modelselectionmethod);
	 }
	return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x98(%rbp)
movq %rdi, -0xa0(%rbp)
movq %rsi, -0x8(%rbp)
movq %rdx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq $0x0, -0x58(%rbp)
leaq -0x90(%rbp), %rdi
callq 0xa4960
movq -0x98(%rbp), %rdi
leaq -0x90(%rbp), %rsi
movl $0x38, %edx
callq 0x42b0
movq -0x98(%rbp), %rdi
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, 0x20(%rdi)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movsd 0x10(%rax), %xmm0
movq -0x18(%rbp), %rax
movl (%rax), %ecx
leaq -0x28(%rbp), %rsi
leaq -0x30(%rbp), %rdx
callq 0xa3ee0
cmpl $0x0, %eax
je 0xa5c0e
movl $0x0, -0x34(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
je 0xa5ae7
movq -0x8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
leaq -0x48(%rbp), %rdx
movl $0x3, %ecx
callq 0x45f60
movq -0x18(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0xa4000
movq %rax, -0x40(%rbp)
jmp 0xa5af8
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xa4000
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0xa5ba0
movq -0x40(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0xa5ba0
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
je 0xa5b32
movq -0x40(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x18(%rbp), %rax
movl 0x4(%rax), %edx
callq 0xa4140
jmp 0xa5b49
movq -0x40(%rbp), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rsi
movq -0x18(%rbp), %rax
movl 0x4(%rax), %edx
callq 0xa4140
movq -0x40(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0xa5b97
movq -0x98(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0xa44c0
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
je 0xa5b95
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x48(%rbp), %rsi
callq 0x464e0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x44f40
jmp 0xa5b9e
movl $0x1, -0x34(%rbp)
jmp 0xa5ba7
movl $0x1, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jne 0xa5bd6
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rdx
leaq -0x58(%rbp), %rsi
callq 0xa43a0
movq -0x18(%rbp), %rax
cmpl $0x1, (%rax)
jne 0xa5bd4
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x59ea0
jmp 0xa5c09
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
je 0xa5c07
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x48(%rbp), %rsi
callq 0x464e0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x44f40
jmp 0xa5c0e
jmp 0xa5a81
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
jne 0xa5c2a
movq -0x98(%rbp), %rax
movsd -0x30(%rbp), %xmm0
movsd %xmm0, 0x28(%rax)
jmp 0xa5c41
movq -0x98(%rbp), %rax
movq -0x28(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rcx
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x44f40
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0xa5cc6
movq -0x98(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq -0x10(%rbp), %rdx
movq -0x18(%rbp), %rcx
callq 0xa35c0
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
je 0xa5c9f
movq -0x98(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movq -0x18(%rbp), %rax
movl 0x4(%rax), %edx
callq 0xa2da0
jmp 0xa5cb9
movq -0x98(%rbp), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rsi
movq -0x18(%rbp), %rax
movl 0x4(%rax), %edx
callq 0xa2da0
jmp 0xa5cbb
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0xa5c55
movq -0xa0(%rbp), %rax
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)