// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/svm.c
// Function: svm_binary_svc_probability
void svm_binary_svc_probability(Svm_problem prob, Svm_parameter param, double Cp, double Cn, double* probA, double* probB)
{
 int i, nr_fold = 5, *perm, begin, end, j, k, p_count, n_count;
 double* dec_values, firstlabel;
 Svm_problem subprob;
 Svm_parameter subparam;
 Svm_modelptr submodel;
 dec_values = safemalloc(prob.l * sizeof(double), "svm_binary_svc_probability", 3);
 perm = random_array(prob.l);
 for (i = 0; i < nr_fold; i++)
  {
   begin = i * prob.l / nr_fold;
   end = (i + 1) * prob.l / nr_fold;
   subprob.l = prob.l - (end - begin);
   subprob.x = safemalloc(subprob.l * sizeof(Svm_nodeptr), "svm_binary_svc_probability", 10);
   subprob.y = safemalloc(subprob.l * sizeof(double), "svm_binary_svc_probability", 11);
   k = 0;
   for (j = 0; j < begin; j++)
    {
     if (k == 0)
       firstlabel = prob.y[perm[j]];
     subprob.x[k] = prob.x[perm[j]];
     subprob.y[k] = prob.y[perm[j]];
     k++;
    }
   for (j = end; j < prob.l; j++)
    {
     if (k == 0)
       firstlabel = prob.y[perm[j]];
     subprob.x[k] = prob.x[perm[j]];
     subprob.y[k] = prob.y[perm[j]];
     k++;
    }
   p_count = 0;
   n_count = 0;
   for (j = 0; j < k; j++)
    {
     if (subprob.y[j] > 0)
       p_count++;
     else
       n_count++;
    }
   if (p_count == 0 && n_count == 0)
     for (j = begin; j < end; j++)
       dec_values[perm[j]] = 0;
   else 
     if (p_count > 0 && n_count == 0)
       for (j = begin; j < end; j++)
         dec_values[perm[j]] = 1;
     else 
       if (p_count == 0 && n_count > 0)
         for (j = begin; j < end; j++)
           dec_values[perm[j]] = -1;
       else
        {
         subparam = param;
         subparam.C = 1.0;
         subparam.cweights = safemalloc(2 * sizeof(double), "svm_binary_svc_probability", 40);
         subparam.cweights[0] = Cp;
         subparam.cweights[1] = Cn;
         submodel = svm_train(subprob, subparam, 0);
         for (j = begin; j < end; j++)
          {
           svm_predict_values(submodel, prob.x[perm[j]], &(dec_values[perm[j]])); 
           dec_values[perm[j]] *= -1;
          }
         free_svm_model(submodel);
         safe_free(subparam.cweights);
         safe_free(subprob.x);
         safe_free(subprob.y);
        }
  }
 sigmoid_train(prob.l, dec_values, prob.y, probA, probB);
 safe_free(dec_values);
 safe_free(perm);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %rsi, 0xc8(%rsp)
movq %rdi, 0xc0(%rsp)
movsd %xmm1, 0xd8(%rsp)
movsd %xmm0, 0xd0(%rsp)
movl 0x180(%rsp), %eax
movl %eax, 0x84(%rsp)
movslq %eax, %rbx
leaq (,%rbx,8), %rdi
leaq 0x1f92c(%rip), %rsi     # 0xb1ad3
movl $0x3, %edx
callq 0x3a0e1
movq %rax, %r15
movq %rbx, 0xe0(%rsp)
movl %ebx, %edi
callq 0x3afe4
movq %rax, %rbx
movq 0x188(%rsp), %r12
movq 0x190(%rsp), %r14
xorl %esi, %esi
movq %r15, 0x98(%rsp)
movl %esi, %eax
movl 0x84(%rsp), %ecx
imull %ecx, %eax
cltq
movq %rax, 0xe8(%rsp)
imulq $0x66666667, %rax, %r15 # imm = 0x66666667
movq %r15, %rax
shrq $0x3f, %rax
sarq $0x21, %r15
addl %eax, %r15d
incl %esi
movq %rsi, 0x88(%rsp)
movl %esi, %eax
imull %ecx, %eax
cltq
imulq $0x66666667, %rax, %rdx # imm = 0x66666667
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x21, %rdx
addl %eax, %edx
movl %r15d, %eax
movq %rdx, 0x90(%rsp)
subl %edx, %eax
addl %ecx, %eax
movl %eax, 0xa0(%rsp)
movslq %eax, %r13
shlq $0x3, %r13
movq %r13, %rdi
leaq 0x1f87c(%rip), %rbp     # 0xb1ad3
movq %rbp, %rsi
movl $0xa, %edx
callq 0x3a0e1
movq %rax, 0xb0(%rsp)
movq %r13, %rdi
movq %rbp, %rsi
movq %r15, %rbp
movl $0xb, %edx
callq 0x3a0e1
movq %rax, 0xa8(%rsp)
movl $0x0, %ecx
cmpl $0x5, 0xe8(%rsp)
jl 0x922cb
movl %ebp, %ecx
xorl %edx, %edx
movslq (%rbx,%rdx,4), %rax
movq (%r14,%rax,8), %rsi
movq 0xb0(%rsp), %rdi
movq %rsi, (%rdi,%rdx,8)
movsd (%r12,%rax,8), %xmm0
movq 0xa8(%rsp), %rax
movsd %xmm0, (%rax,%rdx,8)
incq %rdx
cmpq %rdx, %rcx
jne 0x9229a
movl %ebp, %ecx
movq 0x90(%rsp), %r11
cmpl 0x84(%rsp), %r11d
jge 0x92339
movslq %r11d, %rax
movl %ecx, %ecx
leaq (%rbx,%rax,4), %rsi
movq 0xe0(%rsp), %rdi
subq %rax, %rdi
xorl %edx, %edx
movq %rcx, %r8
xorpd %xmm1, %xmm1
movq 0x98(%rsp), %r15
movslq (%rsi,%rdx,4), %rax
movq (%r14,%rax,8), %r9
movq 0xb0(%rsp), %r10
movq %r9, (%r10,%r8,8)
movsd (%r12,%rax,8), %xmm0
movq 0xa8(%rsp), %rax
movsd %xmm0, (%rax,%r8,8)
incq %r8
incq %rdx
cmpq %rdx, %rdi
jne 0x92302
addl %edx, %ecx
jmp 0x9234d
testl %ecx, %ecx
xorpd %xmm1, %xmm1
movq 0x98(%rsp), %r15
je 0x92441
movl %ecx, %esi
xorl %edi, %edi
xorl %ecx, %ecx
xorl %edx, %edx
movsd (%rax,%rdi,8), %xmm0
xorl %r8d, %r8d
xorl %r9d, %r9d
ucomisd %xmm1, %xmm0
setbe %r8b
seta %r9b
addl %r9d, %edx
addl %r8d, %ecx
incq %rdi
cmpq %rdi, %rsi
jne 0x92355
movl %edx, %eax
orl %ecx, %eax
jne 0x923b0
cmpl %r11d, %ebp
movq 0x88(%rsp), %rsi
jge 0x92567
movslq %ebp, %rax
movslq %r11d, %rcx
movslq (%rbx,%rax,4), %rdx
movq $0x0, (%r15,%rdx,8)
incq %rax
cmpq %rax, %rcx
jne 0x92397
jmp 0x92567
testl %ecx, %ecx
sete %al
testl %edx, %edx
setg %sil
andb %al, %sil
cmpb $0x1, %sil
movabsq $0x3ff0000000000000, %r8 # imm = 0x3FF0000000000000
jne 0x923fa
cmpl %r11d, %ebp
movq 0x88(%rsp), %rsi
jge 0x92567
movslq %ebp, %rax
movslq %r11d, %rcx
movslq (%rbx,%rax,4), %rdx
movq %r8, (%r15,%rdx,8)
incq %rax
cmpq %rax, %rcx
jne 0x923e5
jmp 0x92567
testl %edx, %edx
sete %al
testl %ecx, %ecx
setg %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x9244a
cmpl %r11d, %ebp
movq 0x88(%rsp), %rsi
jge 0x92567
movslq %ebp, %rax
movslq %r11d, %rcx
movslq (%rbx,%rax,4), %rdx
movabsq $-0x4010000000000000, %rdi # imm = 0xBFF0000000000000
movq %rdi, (%r15,%rdx,8)
incq %rax
cmpq %rax, %rcx
jne 0x92422
jmp 0x92567
xorl %edx, %edx
xorl %ecx, %ecx
jmp 0x9237a
movl $0xb, %ecx
leaq 0xf0(%rsp), %r13
movq %r13, %rdi
leaq 0x1a0(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r8, 0x120(%rsp)
movl $0x10, %edi
leaq 0x1f65a(%rip), %rsi     # 0xb1ad3
movl $0x28, %edx
callq 0x3a0e1
movq %rax, 0x128(%rsp)
movsd 0xd0(%rsp), %xmm0
movsd %xmm0, (%rax)
movsd 0xd8(%rsp), %xmm0
movsd %xmm0, 0x8(%rax)
leaq 0x20(%rsp), %rdi
movl $0xb, %ecx
movq %r13, %rsi
rep  movsq (%rsi), %es:(%rdi)
movupd 0xa0(%rsp), %xmm0
movupd 0xb0(%rsp), %xmm1
movupd %xmm1, 0x10(%rsp)
movupd %xmm0, (%rsp)
xorl %edi, %edi
callq 0x91556
movq 0x90(%rsp), %rcx
movq %rax, %r13
cmpl %ecx, %ebp
jge 0x92530
movslq %ebp, %rbp
movslq %ecx, %rax
movq %rax, 0x90(%rsp)
movslq (%rbx,%rbp,4), %rax
movq (%r14,%rax,8), %rsi
leaq (%r15,%rax,8), %rdx
movq %r13, %rdi
callq 0x925b3
movslq (%rbx,%rbp,4), %rax
movsd (%r15,%rax,8), %xmm0
xorpd 0x13cb3(%rip), %xmm0    # 0xa61d0
movlpd %xmm0, (%r15,%rax,8)
incq %rbp
cmpq %rbp, 0x90(%rsp)
jne 0x924f7
movq %r13, %rdi
callq 0x90593
movq 0x128(%rsp), %rdi
callq 0x3a180
movq 0xb0(%rsp), %rdi
callq 0x3a180
movq 0xa8(%rsp), %rdi
callq 0x3a180
movq 0x88(%rsp), %rsi
cmpl $0x5, %esi
jne 0x921e0
movl 0x84(%rsp), %edi
movq %r15, %rsi
movq %r12, %rdx
movq 0xc0(%rsp), %rcx
movq 0xc8(%rsp), %r8
callq 0x928b0
movq %r15, %rdi
callq 0x3a180
movq %rbx, %rdi
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3a180