// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/svm.c
// Function: svm_predict
double svm_predict(Svm_modelptr model, Svm_nodeptr x)
{
	/*Last Changed 02.05.2005*/
 int i, j, nr_class, *vote, pos = 0, vote_max_idx;
	double res, *dec_values;
	if (in_list(model->param.svm_type, 3, ONE_CLASS, EPSILON_SVR, NU_SVR))
	 {
		 svm_predict_values(model, x, &res);		
		 if (model->param.svm_type == ONE_CLASS)
				 if (res > 0)
						 return 1;
					else
						 return -1;
		 else
			  return res;
	 }
	else
	 {
		 nr_class = model->nr_class;
		 dec_values = safemalloc(sizeof(double) * nr_class * (nr_class-1) / 2, "svm_predict", 17);
		 svm_predict_values(model, x, dec_values);
		 vote = safemalloc(sizeof(int) * nr_class, "svm_predict", 19);
		 for (i = 0; i < nr_class; i++)
			  vote[i] = 0;
		 for (i = 0; i < nr_class; i++)
  			for (j = i + 1; j < nr_class; j++)
					 {
				   if (dec_values[pos] > 0)
    					++vote[i];
			   	else
					    ++vote[j];
				   pos++;
					 }  
		 vote_max_idx = 0;
		 for (i = 1; i < nr_class; i++)
			  if (vote[i] > vote[vote_max_idx])
				   vote_max_idx = i;
		 safe_free(vote);
		 safe_free(dec_values);
		 return vote_max_idx;
	 }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %edi
movl $0x3, %ecx
movl $0x2, %edx
movl $0x4, %r8d
movl %ecx, %esi
movb $0x0, %al
callq 0x53e40
cmpl $0x0, %eax
je 0xc9d76
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0xc85c0
movq -0x10(%rbp), %rax
cmpl $0x2, (%rax)
jne 0xc9d67
movsd -0x40(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xc9d55
movsd 0x182cd(%rip), %xmm0    # 0xe2018
movsd %xmm0, -0x8(%rbp)
jmp 0xc9edb
movsd 0x18ceb(%rip), %xmm0    # 0xe2a48
movsd %xmm0, -0x8(%rbp)
jmp 0xc9edb
movsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0xc9edb
movq -0x10(%rbp), %rax
movl 0x58(%rax), %eax
movl %eax, -0x24(%rbp)
movslq -0x24(%rbp), %rdi
shlq $0x3, %rdi
movl -0x24(%rbp), %eax
subl $0x1, %eax
cltq
imulq %rax, %rdi
shrq %rdi
leaq 0x24388(%rip), %rsi     # 0xee126
movl $0x11, %edx
callq 0x52d70
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0xc85c0
movslq -0x24(%rbp), %rdi
shlq $0x2, %rdi
leaq 0x2435a(%rip), %rsi     # 0xee126
movl $0x13, %edx
callq 0x52d70
movq %rax, -0x30(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0xc9e03
movq -0x30(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xc9de1
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0xc9e7e
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0xc9e71
movq -0x48(%rbp), %rax
movslq -0x34(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xc9e4c
movq -0x30(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
jmp 0xc9e5d
movq -0x30(%rbp), %rax
movslq -0x20(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xc9e1b
jmp 0xc9e73
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xc9e0a
movl $0x0, -0x38(%rbp)
movl $0x1, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0xc9ebf
movq -0x30(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq -0x30(%rbp), %rcx
movslq -0x38(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jle 0xc9eb2
movl -0x1c(%rbp), %eax
movl %eax, -0x38(%rbp)
jmp 0xc9eb4
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xc9e8c
movq -0x30(%rbp), %rdi
callq 0x52e80
movq -0x48(%rbp), %rdi
callq 0x52e80
cvtsi2sdl -0x38(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
movsd -0x8(%rbp), %xmm0
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)