// File: /workspace/github_c_makefile_star2_O1/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 0x1b7f0(%rip), %rdi     # 0xab309
callq 0x536e7
movl %eax, %ebp
movl (%rbx), %edi
movl $0x3, %esi
movl $0x2, %edx
movl $0x3, %ecx
movl $0x4, %r8d
xorl %eax, %eax
callq 0x39a80
testl %eax, %eax
je 0x8fbde
cmpl $0x0, 0x5c(%rbx)
jle 0x8fdf3
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)
cmpl $0x1, %ebp
jne 0x8fb98
movq 0x60(%rbx), %rax
movq (%rax,%r15,8), %rax
movl $0xb, %ecx
movq %rsp, %rdi
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r12, %rdi
movq %rax, %rsi
callq 0x914a9
jmp 0x8fbb9
movq 0x60(%rbx), %rax
movq (%rax,%r15,8), %rax
movl $0xb, %ecx
movq %rsp, %rdi
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r12, %rdi
movq %rax, %rsi
callq 0x912a1
movsd 0x60(%rsp), %xmm1
mulsd %xmm0, %xmm1
movsd 0x58(%rsp), %xmm0
addsd %xmm1, %xmm0
incq %r15
movslq 0x5c(%rbx), %rax
cmpq %rax, %r15
jl 0x8fb5e
jmp 0x8fdf7
movslq 0x58(%rbx), %r15
movslq 0x5c(%rbx), %r13
leaq (,%r13,8), %rdi
leaq 0x1ee18(%rip), %rsi     # 0xaea0d
movl $0xf, %edx
callq 0x390f5
movq %rax, 0x58(%rsp)
testq %r13, %r13
jle 0x8fc68
xorl %r14d, %r14d
cmpl $0x1, %ebp
jne 0x8fc34
movq 0x60(%rbx), %rax
movq (%rax,%r14,8), %rax
movl $0xb, %ecx
movq %rsp, %rdi
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r12, %rdi
movq %rax, %rsi
callq 0x914a9
jmp 0x8fc55
movq 0x60(%rbx), %rax
movq (%rax,%r14,8), %rax
movl $0xb, %ecx
movq %rsp, %rdi
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r12, %rdi
movq %rax, %rsi
callq 0x912a1
movq 0x58(%rsp), %rax
movsd %xmm0, (%rax,%r14,8)
incq %r14
cmpq %r14, %r13
jne 0x8fc0c
leaq (,%r15,4), %rdi
leaq 0x1ed96(%rip), %rsi     # 0xaea0d
movl $0x12, %edx
callq 0x390f5
movq %rax, %r14
movl $0x0, (%rax)
cmpl $0x2, %r15d
jl 0x8fcad
movq 0x78(%rbx), %rax
movl (%r14), %ecx
leaq -0x1(%r15), %rdx
xorl %esi, %esi
addl (%rax,%rsi,4), %ecx
movl %ecx, 0x4(%r14,%rsi,4)
incq %rsi
cmpq %rsi, %rdx
jne 0x8fc9d
testl %r15d, %r15d
jle 0x8fdd0
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
jae 0x8fdc4
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 0x8fd41
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 0x8fd28
jmp 0x8fd45
xorpd %xmm0, %xmm0
movq %r15, %r13
movl (%r8,%rcx,4), %eax
testl %eax, %eax
jle 0x8fd88
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 0x8fd70
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 0x8fd15
movq 0x70(%rsp), %rbx
movq 0x60(%rsp), %r14
movq 0x80(%rsp), %rcx
movq 0x78(%rsp), %rdi
incq %rdi
cmpq %r15, %rcx
jne 0x8fccb
movq 0x58(%rsp), %rdi
callq 0x39194
movq %r14, %rdi
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x39194
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