// File: /workspace/github_c_makefile_star2_O1/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 0x9157c
leaq 0xb0(%rsp), %r15
movq %r15, %rdi
movl $0x5, %esi
callq 0x916af
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 0x8eb29
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 0x1a118(%rip), %r13     # 0xaec18
movq %rax, %rdi
movq %r13, %rsi
movl $0xd, %edx
callq 0x390f5
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 0x390f5
movq %rax, 0x88(%rsp)
movq %rax, 0x60(%rbx)
leaq 0x3dd1a(%rip), %rax     # 0xd2870
movq (%rax), %rax
movslq 0x1c0(%rax), %rdi
decq %rdi
movl $0x8, %esi
movq %r13, %rdx
movl $0x10, %ecx
callq 0x39210
movq %rbx, 0x80(%rsp)
movq %rax, 0x78(%rbx)
cmpl $0x0, 0x5c(%r14)
jle 0x94c7a
movq %rax, %r13
xorl %ebx, %ebx
movabsq $0x100000000, %rbp      # imm = 0x100000000
movq %r14, 0x78(%rsp)
movq 0x60(%r14), %rax
movq (%rax,%rbx,8), %rax
movl $0x1, %r14d
xorl %ecx, %ecx
xorl %edi, %edi
addq %rbp, %rdi
decq %r14
cmpl $-0x1, (%rax)
movl %ecx, %r12d
leaq 0x10(%rax), %rax
leal 0x1(%r12), %ecx
jne 0x94bb2
sarq $0x1c, %rdi
leaq 0x1a044(%rip), %rsi     # 0xaec18
movl $0x13, %edx
callq 0x390f5
movq 0x88(%rsp), %rcx
movq %rax, (%rcx,%rbx,8)
testq %r14, %r14
je 0x94c45
movq 0x78(%rsp), %r14
movq 0x60(%r14), %rcx
movq (%rcx,%rbx,8), %rdx
cmpl $0x2, %r12d
movl $0x1, %ecx
cmovll %ecx, %r12d
movl $0x8, %esi
xorl %ecx, %ecx
movslq -0x8(%rdx,%rsi), %rdi
movl %edi, -0x8(%rax,%rsi)
movsd (%rdx,%rsi), %xmm0
movsd %xmm0, (%rax,%rsi)
mulsd (%r15,%rbx,8), %xmm0
addsd (%r13,%rdi,8), %xmm0
movsd %xmm0, (%r13,%rdi,8)
incq %rcx
addq $0x10, %rsi
cmpq %rcx, %r12
jne 0x94c10
jmp 0x94c4c
xorl %ecx, %ecx
movq 0x78(%rsp), %r14
movq 0x60(%r14), %rdx
movq (%rdx,%rbx,8), %rdx
shlq $0x4, %rcx
movl (%rdx,%rcx), %esi
movl %esi, (%rax,%rcx)
movsd 0x8(%rdx,%rcx), %xmm0
movsd %xmm0, 0x8(%rax,%rcx)
incq %rbx
movslq 0x5c(%r14), %rax
cmpq %rax, %rbx
jl 0x94ba0
movq %r14, %rdi
callq 0x8ddc0
movups 0x90(%rsp), %xmm0
movups 0xa0(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x8de37
movq 0x80(%rsp), %rax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq