// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/svmtree.c
// Function: find_best_svm_split_for_partition
Svm_split find_best_svm_split_for_partition(Instanceptr data, Partition p)
{
 /*!Last Changed 18.02.2008*/
 int i, j, size;
 Svm_parameter param;
 Svm_problem prob;
 Svm_modelptr model;
 Svm_split result;
 prepare_svm_problem(&prob, TWO_CLASS, data, p);
 prepare_svm_parameters(&param, TWO_CLASS);
 model = svm_train(prob, param, BOOLEAN_FALSE);
 result.l = model->l;
 result.nSV = model->nSV[0] + model->nSV[1];
 result.param = param;
 result.rho = model->rho[0];
 result.sv_coef = safemalloc(model->l * sizeof(double), "find_best_svm_split_for_partition", 13);
 memcpy(result.sv_coef, model->sv_coef[0], model->l * sizeof(double));
 result.SV = safemalloc(model->l * sizeof(Svm_nodeptr), "find_best_svm_split_for_partition", 15);
 result.weights = safecalloc(current_dataset->multifeaturecount - 1, sizeof(double), "find_best_svm_split_for_partition", 16); 
 for (i = 0; i < model->l; i++)
  {
   size = support_vector_length(model->SV[i]);
   result.SV[i] = safemalloc(sizeof(Svm_node) * size, "find_best_svm_split_for_partition", 19);
   for (j = 0; j < size - 1; j++)
    {
     result.SV[i][j].index = model->SV[i][j].index;
     result.SV[i][j].value = model->SV[i][j].value;
     result.weights[result.SV[i][j].index] += result.sv_coef[i] * result.SV[i][j].value;
    }
   result.SV[i][j].index = model->SV[i][j].index;
   result.SV[i][j].value = model->SV[i][j].value;
  }
 free_svm_model(model);
 free_svm_problem(prob);
 return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rsi, %rdx
movq %rdi, %rbx
movq 0x150(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x140(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x90(%rsp), %r14
movq %r14, %rdi
movl $0x5, %esi
callq 0x93fdc
leaq 0xb0(%rsp), %r15
movq %r15, %rdi
movl $0x5, %esi
callq 0x9410f
leaq 0x20(%rsp), %rdi
movl $0xb, %ecx
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
xorl %edi, %edi
callq 0x91556
movq %rax, %r14
movslq 0x5c(%rax), %rax
movl %eax, 0x58(%rbx)
movq 0x78(%r14), %rcx
movl 0x4(%rcx), %edx
addl (%rcx), %edx
movl %edx, 0x80(%rbx)
movl $0xb, %ecx
movq %rbx, %rdi
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq 0x70(%r14), %rcx
movsd (%rcx), %xmm0
movsd %xmm0, 0x70(%rbx)
shlq $0x3, %rax
leaq 0x1a5ec(%rip), %r13     # 0xb1c90
movq %rax, %rdi
movq %r13, %rsi
movl $0xd, %edx
callq 0x3a0e1
movq %rax, %r15
movq %rax, 0x68(%rbx)
movq 0x68(%r14), %rax
movq (%rax), %rsi
movslq 0x5c(%r14), %rdx
shlq $0x3, %rdx
movq %r15, %rdi
callq 0x4310
movslq 0x5c(%r14), %rdi
shlq $0x3, %rdi
movq %r13, %rsi
movl $0xf, %edx
callq 0x3a0e1
movq %rax, 0x88(%rsp)
movq %rax, 0x60(%rbx)
leaq 0x3e176(%rip), %rax     # 0xd5870
movq (%rax), %rax
movslq 0x1c0(%rax), %rdi
decq %rdi
movl $0x8, %esi
movq %r13, %rdx
movl $0x10, %ecx
callq 0x3a1fc
movq %r14, %rdi
movq %rbx, 0x78(%rsp)
movq %rax, 0x78(%rbx)
cmpl $0x0, 0x5c(%r14)
jle 0x97823
movq %rax, %r13
movq 0x60(%rdi), %rcx
xorl %ebx, %ebx
movabsq $0x100000000, %rbp      # imm = 0x100000000
movq %rdi, 0x80(%rsp)
movq (%rcx,%rbx,8), %rax
movl $0x1, %r12d
xorl %ecx, %ecx
xorl %edi, %edi
addq %rbp, %rdi
decq %r12
cmpl $-0x1, (%rax)
movl %ecx, %r14d
leaq 0x10(%rax), %rax
leal 0x1(%r14), %ecx
jne 0x97759
sarq $0x1c, %rdi
leaq 0x1a516(%rip), %rsi     # 0xb1c90
movl $0x13, %edx
callq 0x3a0e1
movq 0x88(%rsp), %rcx
movq %rax, (%rcx,%rbx,8)
movq 0x80(%rsp), %rdi
movq 0x60(%rdi), %rcx
movq (%rcx,%rbx,8), %rdx
testq %r12, %r12
je 0x977f9
negq %r12
cmpl $0x2, %r12d
movl $0x1, %esi
cmovll %esi, %r12d
cmpl $0x2, %r14d
cmovll %esi, %r14d
shlq $0x4, %r14
xorl %esi, %esi
movslq (%rdx,%rsi), %r8
movl %r8d, (%rax,%rsi)
movsd 0x8(%rdx,%rsi), %xmm0
movsd %xmm0, 0x8(%rax,%rsi)
mulsd (%r15,%rbx,8), %xmm0
addsd (%r13,%r8,8), %xmm0
movsd %xmm0, (%r13,%r8,8)
addq $0x10, %rsi
cmpq %rsi, %r14
jne 0x977c3
movl %r12d, %esi
jmp 0x977fb
xorl %esi, %esi
shlq $0x4, %rsi
movl (%rdx,%rsi), %r8d
movl %r8d, (%rax,%rsi)
movsd 0x8(%rdx,%rsi), %xmm0
movsd %xmm0, 0x8(%rax,%rsi)
incq %rbx
movslq 0x5c(%rdi), %rax
cmpq %rax, %rbx
jl 0x9774b
callq 0x90593
movups 0x90(%rsp), %xmm0
movups 0xa0(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x9060a
movq 0x78(%rsp), %rax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq