// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/svm.c
// Function: svm_predict_values
void svm_predict_values(Svm_modelptr model, Svm_nodeptr x, double* dec_values)
{
	/*Last Changed 02.05.2005*/
 ON_OFF normalizekernel = get_parameter_o("normalizekernel");
	int i, j, k, nr_class, l, *start, p = 0, pos = 0, si, sj, ci, cj;
	double* sv_coef, sum = 0.0, *kvalue, *coef1, *coef2;
	if (in_list(model->param.svm_type, 3, ONE_CLASS, EPSILON_SVR, NU_SVR))
	 {
	 	sv_coef = model->sv_coef[0];
		 for (i = 0; i < model->l; i++)
     if (normalizekernel == ON)
  			  sum += sv_coef[i] * k_function_normalized(x, model->SV[i], model->param);
     else
       sum += sv_coef[i] * k_function(x, model->SV[i], model->param);
		 sum -= model->rho[0];
		 *dec_values = sum;
	 }
	else
	 {
 		nr_class = model->nr_class;
 		l = model->l;
 		kvalue = safemalloc(sizeof(double) * l, "svm_predict_values", 15);
 		for (i = 0; i < l; i++)
     if (normalizekernel == ON)
   			 kvalue[i] = k_function_normalized(x, model->SV[i], model->param);
     else
       kvalue[i] = k_function(x, model->SV[i], model->param);
 		start = safemalloc(sizeof(int) * nr_class, "svm_predict_values", 18);
 		start[0] = 0;
 		for (i = 1; i < nr_class; i++)
 			 start[i] = start[i - 1] + model->nSV[i - 1];
 		for (i = 0; i < nr_class; i++)
 			 for (j = i + 1; j < nr_class; j++)
					 {
						 sum = 0;
			 	  si = start[i];
			 	  sj = start[j];
			 	  ci = model->nSV[i];
			 	  cj = model->nSV[j];				
			 	  coef1 = model->sv_coef[j-1];
			 	  coef2 = model->sv_coef[i];
  	 			for (k = 0; k < ci; k++)
  	  				sum += coef1[si + k] * kvalue[si + k];
  	 			for (k = 0; k < cj; k++)
    					sum += coef2[sj + k] * kvalue[sj + k];
  	 			sum -= model->rho[p++];
  	 			dec_values[pos++] = sum;
					 }
		 safe_free(kvalue);
		 safe_free(start);
	 }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdx, 0x68(%rsp)
movq %rsi, %r12
movq %rdi, %rbx
leaq 0x1bdff(%rip), %rdi     # 0xae3d5
callq 0x54bec
movl %eax, %ebp
movl (%rbx), %edi
movl $0x3, %esi
movl $0x2, %edx
movl $0x3, %ecx
movl $0x4, %r8d
xorl %eax, %eax
callq 0x3aa8c
testl %eax, %eax
je 0x92688
cmpl $0x0, 0x5c(%rbx)
jle 0x92889
movq 0x68(%rbx), %rax
movq (%rax), %r14
xorpd %xmm0, %xmm0
xorl %r15d, %r15d
movsd %xmm0, 0x58(%rsp)
movsd (%r14,%r15,8), %xmm0
movsd %xmm0, 0x60(%rsp)
movq 0x60(%rbx), %rax
movq (%rax,%r15,8), %rax
movl $0xb, %ecx
movq %rsp, %rdi
movq %rbx, %rsi
cmpl $0x1, %ebp
jne 0x92655
rep  movsq (%rsi), %es:(%rdi)
movq %r12, %rdi
movq %rax, %rsi
callq 0x93f0b
jmp 0x92663
rep  movsq (%rsi), %es:(%rdi)
movq %r12, %rdi
movq %rax, %rsi
callq 0x93d00
movsd 0x60(%rsp), %xmm1
mulsd %xmm0, %xmm1
movsd 0x58(%rsp), %xmm0
addsd %xmm1, %xmm0
incq %r15
movslq 0x5c(%rbx), %rax
cmpq %rax, %r15
jl 0x9261b
jmp 0x9288d
movslq 0x58(%rbx), %r15
movslq 0x5c(%rbx), %r13
leaq (,%r13,8), %rdi
leaq 0x1f3e6(%rip), %rsi     # 0xb1a85
movl $0xf, %edx
callq 0x3a0e1
movq %rax, 0x58(%rsp)
testq %r13, %r13
jle 0x926ff
xorl %r14d, %r14d
movq 0x60(%rbx), %rax
movq (%rax,%r14,8), %rax
movl $0xb, %ecx
movq %rsp, %rdi
movq %rbx, %rsi
cmpl $0x1, %ebp
jne 0x926de
rep  movsq (%rsi), %es:(%rdi)
movq %r12, %rdi
movq %rax, %rsi
callq 0x93f0b
jmp 0x926ec
rep  movsq (%rsi), %es:(%rdi)
movq %r12, %rdi
movq %rax, %rsi
callq 0x93d00
movq 0x58(%rsp), %rax
movsd %xmm0, (%rax,%r14,8)
incq %r14
cmpq %r14, %r13
jne 0x926b6
leaq (,%r15,4), %rdi
leaq 0x1f377(%rip), %rsi     # 0xb1a85
movl $0x12, %edx
callq 0x3a0e1
movq %rax, %r14
movl $0x0, (%rax)
cmpl $0x2, %r15d
jl 0x92743
movq 0x78(%rbx), %rax
leaq -0x1(%r15), %rcx
xorl %edx, %edx
xorl %esi, %esi
addl (%rax,%rdx,4), %esi
movl %esi, 0x4(%r14,%rdx,4)
incq %rdx
cmpq %rdx, %rcx
jne 0x92733
testl %r15d, %r15d
jle 0x92866
xorl %ecx, %ecx
movl $0x1, %edi
xorl %edx, %edx
xorl %esi, %esi
movq %rbx, 0x70(%rsp)
movq %r14, 0x60(%rsp)
movq %rcx, %rax
incq %rcx
cmpq %r15, %rcx
jge 0x9285a
movq %rcx, 0x80(%rsp)
movq %rdi, %rcx
movslq (%r14,%rax,4), %rdi
movq 0x78(%rbx), %r8
movl (%r8,%rax,4), %r9d
movq 0x68(%rbx), %r10
movq 0x70(%rbx), %r11
movq (%r10,%rax,8), %rbp
movslq %edx, %rdx
movslq %esi, %rsi
movq 0x58(%rsp), %rax
leaq (%rax,%rdi,8), %r14
shlq $0x3, %rdi
movq %rcx, 0x78(%rsp)
testl %r9d, %r9d
jle 0x927d7
movq -0x8(%r10,%rcx,8), %rax
addq %rdi, %rax
xorpd %xmm0, %xmm0
xorl %ebx, %ebx
movsd (%rax,%rbx,8), %xmm1
mulsd (%r14,%rbx,8), %xmm1
addsd %xmm1, %xmm0
incq %rbx
cmpq %rbx, %r9
jne 0x927be
jmp 0x927db
xorpd %xmm0, %xmm0
movq %r15, %r13
movl (%r8,%rcx,4), %eax
testl %eax, %eax
jle 0x9281e
movq 0x60(%rsp), %rbx
movslq (%rbx,%rcx,4), %r15
leaq (,%r15,8), %rbx
addq %rbp, %rbx
movq 0x58(%rsp), %r12
leaq (%r12,%r15,8), %r15
xorl %r12d, %r12d
movsd (%rbx,%r12,8), %xmm1
mulsd (%r15,%r12,8), %xmm1
addsd %xmm1, %xmm0
incq %r12
cmpq %r12, %rax
jne 0x92806
subsd (%r11,%rdx,8), %xmm0
incq %rdx
movq 0x68(%rsp), %rax
movsd %xmm0, (%rax,%rsi,8)
incq %rsi
incq %rcx
movq %r13, %r15
cmpq %r13, %rcx
jne 0x927ab
movq 0x70(%rsp), %rbx
movq 0x60(%rsp), %r14
movq 0x80(%rsp), %rcx
movq 0x78(%rsp), %rdi
incq %rdi
cmpq %r15, %rcx
jne 0x92761
movq 0x58(%rsp), %rdi
callq 0x3a180
movq %r14, %rdi
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3a180
xorpd %xmm0, %xmm0
movq 0x70(%rbx), %rax
subsd (%rax), %xmm0
movq 0x68(%rsp), %rax
movsd %xmm0, (%rax)
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq