// File: /workspace/github_c_makefile_star2_O2/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 $0x78, %rsp
movq %rdx, 0x68(%rsp)
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x19e49(%rip), %rdi     # 0x9e2f9
callq 0x4cff1
movl %eax, %ebp
movl (%r14), %edi
xorl %r12d, %r12d
pushq $0x2
popq %rdx
pushq $0x3
popq %rcx
pushq $0x4
popq %r8
movl %ecx, %esi
xorl %eax, %eax
callq 0x35812
testl %eax, %eax
je 0x84572
movq 0x68(%r14), %rax
movq (%rax), %r12
xorpd %xmm0, %xmm0
xorl %r13d, %r13d
pushq $0xb
popq %r15
movslq 0x5c(%r14), %rax
cmpq %rax, %r13
jge 0x84552
movsd %xmm0, 0x58(%rsp)
movsd (%r12,%r13,8), %xmm0
movsd %xmm0, 0x60(%rsp)
movq 0x60(%r14), %rax
movq (%rax,%r13,8), %rax
movq %r15, %rcx
movq %rsp, %rdi
movq %r14, %rsi
cmpl $0x1, %ebp
jne 0x8452b
rep  movsq (%rsi), %es:(%rdi)
movq %rbx, %rdi
movq %rax, %rsi
callq 0x85a94
jmp 0x84539
rep  movsq (%rsi), %es:(%rdi)
movq %rbx, %rdi
movq %rax, %rsi
callq 0x8591e
movsd 0x60(%rsp), %xmm1
mulsd %xmm0, %xmm1
movsd 0x58(%rsp), %xmm0
addsd %xmm1, %xmm0
incq %r13
jmp 0x844ea
movq 0x70(%r14), %rax
subsd (%rax), %xmm0
movq 0x68(%rsp), %rax
movsd %xmm0, (%rax)
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movslq 0x58(%r14), %rax
movq %rax, 0x58(%rsp)
movq %rbx, %r13
movslq 0x5c(%r14), %rbx
movq %rbx, %rdi
shlq $0x3, %rdi
leaq 0x1d455(%rip), %rsi     # 0xa19e5
pushq $0xf
popq %rdx
callq 0x34f59
movq %rax, %r15
testl %ebx, %ebx
movl $0x0, %eax
cmovgl %ebx, %eax
movq %r13, %rbx
movq %rax, %r13
cmpq %r12, %r13
je 0x845ef
movq 0x60(%r14), %rax
movq (%rax,%r12,8), %rax
pushq $0xb
popq %rcx
movq %rsp, %rdi
movq %r14, %rsi
cmpl $0x1, %ebp
jne 0x845d6
rep  movsq (%rsi), %es:(%rdi)
movq %rbx, %rdi
movq %rax, %rsi
callq 0x85a94
jmp 0x845e4
rep  movsq (%rsi), %es:(%rdi)
movq %rbx, %rdi
movq %rax, %rsi
callq 0x8591e
movsd %xmm0, (%r15,%r12,8)
incq %r12
jmp 0x845ab
movq 0x58(%rsp), %rax
leaq (,%rax,4), %rdi
leaq 0x1d3e2(%rip), %rsi     # 0xa19e5
pushq $0x12
popq %rdx
callq 0x34f59
movq %rax, %r12
andl $0x0, (%rax)
pushq $0x1
popq %rax
xorl %ecx, %ecx
cmpq 0x58(%rsp), %rax
jge 0x8462e
movq 0x78(%r14), %rdx
addl -0x4(%rdx,%rax,4), %ecx
movl %ecx, (%r12,%rax,4)
incq %rax
jmp 0x84616
xorl %eax, %eax
movq 0x58(%rsp), %rcx
testl %ecx, %ecx
movl $0x0, %edx
cmovgl %ecx, %edx
movq %rdx, 0x70(%rsp)
pushq $0x1
popq %r9
xorl %esi, %esi
xorl %edi, %edi
xorl %r8d, %r8d
cmpq 0x70(%rsp), %rsi
je 0x84720
movslq %edi, %rdi
movslq %r8d, %r8
movq %r9, 0x60(%rsp)
cmpl %r9d, 0x58(%rsp)
jle 0x84710
movslq (%r12,%rsi,4), %rbx
movslq (%r12,%r9,4), %r11
movq 0x68(%r14), %rcx
movq 0x78(%r14), %rdx
movl (%rdx,%rsi,4), %ebp
testl %ebp, %ebp
cmovlel %eax, %ebp
movl (%rdx,%r9,4), %r10d
leaq (,%rbx,8), %rdx
addq -0x8(%rcx,%r9,8), %rdx
movq (%rcx,%rsi,8), %rcx
leaq (%r15,%rbx,8), %rbx
xorpd %xmm0, %xmm0
xorl %r13d, %r13d
cmpq %r13, %rbp
je 0x846c2
movsd (%rdx,%r13,8), %xmm1
mulsd (%rbx,%r13,8), %xmm1
addsd %xmm1, %xmm0
incq %r13
jmp 0x846a8
testl %r10d, %r10d
cmovlel %eax, %r10d
leaq (%rcx,%r11,8), %rcx
leaq (%r15,%r11,8), %rdx
xorl %r11d, %r11d
cmpq %r11, %r10
je 0x846ee
movsd (%rcx,%r11,8), %xmm1
mulsd (%rdx,%r11,8), %xmm1
addsd %xmm1, %xmm0
incq %r11
jmp 0x846d4
movq 0x70(%r14), %rcx
subsd (%rcx,%r8,8), %xmm0
incq %r8
movq 0x68(%rsp), %rcx
movsd %xmm0, (%rcx,%rdi,8)
incq %rdi
incq %r9
jmp 0x84665
incq %rsi
movq 0x60(%rsp), %r9
incq %r9
jmp 0x8464f
movq %r15, %rdi
callq 0x34ff7
movq %r12, %rdi
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x34ff7