// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/multivariatetree.c
// Function: find_best_multi_ldt_split
int find_best_multi_ldt_split(Instanceptr* instances, matrix* bestw, double *bestw0, MULTIVARIATE_TYPE multivariate_type, double variance_explained)
{
 /*!Last Changed 22.09.2004*/
 int improved, j, bestdim, dim;
 Partition initial,current,best;
 double bestgain, gain, w0;
 matrix w;
 initial = get_initial_partition(*instances);
 if (initial.count <= 2)
   bestgain = find_gain_for_partition_multivariate(instances, initial, bestw, bestw0, multivariate_type, &bestdim, variance_explained);
 else
  {
   current = create_copy(initial);
   bestgain = find_gain_for_partition_multivariate(instances, current, bestw, bestw0, multivariate_type, &bestdim, variance_explained);
   best = create_copy(current);
   improved = 1;
   while (improved)
    {
     improved = 0;
     for (j = 0; j < current.count; j++)
      {
       current.assignments[j] = 1 - current.assignments[j];
       gain = find_gain_for_partition_multivariate(instances, current, &w, &w0, multivariate_type, &dim, variance_explained);
       if (dless(gain, bestgain))
        {
         bestdim = dim;
         bestgain = gain;
         free_partition(best);
         best = create_copy(current);
         *bestw0 = w0;
         matrix_free(*bestw);
         *bestw = matrix_copy(w);
         matrix_free(w);
         improved = 1;
        }
       else
         matrix_free(w);
       current.assignments[j] = 1 - current.assignments[j];
      }
     if (improved)
      {
       free_partition(current);
       current = create_copy(best);
      }
    }
   free_partition(best);
   free_partition(current);
  }
 free_partition(initial);
 if (bestgain == ISELL)
   return 0;
 return bestdim;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movsd %xmm0, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rsi
leaq -0xc8(%rbp), %rdi
callq 0x2aea0
movq -0xc8(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0xc0(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0xb8(%rbp), %rax
movq %rax, -0x48(%rbp)
cmpl $0x2, -0x48(%rbp)
jg 0x6fdc0
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movl -0x24(%rbp), %ecx
movsd -0x30(%rbp), %xmm0
leaq -0x58(%rbp), %rax
leaq -0x3c(%rbp), %r8
movq (%rax), %r9
movq %r9, (%rsp)
movq 0x8(%rax), %r9
movq %r9, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x6fb50
movsd %xmm0, -0x90(%rbp)
jmp 0x70151
leaq -0xe0(%rbp), %rdi
leaq -0x58(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x7a990
movq -0xe0(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0xd8(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0xd0(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movl -0x24(%rbp), %ecx
movsd -0x30(%rbp), %xmm0
leaq -0x70(%rbp), %rax
leaq -0x3c(%rbp), %r8
movq (%rax), %r9
movq %r9, (%rsp)
movq 0x8(%rax), %r9
movq %r9, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x6fb50
movsd %xmm0, -0x90(%rbp)
leaq -0xf8(%rbp), %rdi
leaq -0x70(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x7a990
movq -0xf8(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0xf0(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0xe8(%rbp), %rax
movq %rax, -0x78(%rbp)
movl $0x1, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x7010a
movl $0x0, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x60(%rbp), %eax
jge 0x70090
movq -0x68(%rbp), %rax
movslq -0x38(%rbp), %rcx
movl $0x1, %edx
subl (%rax,%rcx,4), %edx
movq -0x68(%rbp), %rax
movslq -0x38(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %ecx
movsd -0x30(%rbp), %xmm0
leaq -0x70(%rbp), %rax
leaq -0xb0(%rbp), %rsi
leaq -0xa0(%rbp), %rdx
leaq -0x40(%rbp), %r8
movq (%rax), %r9
movq %r9, (%rsp)
movq 0x8(%rax), %r9
movq %r9, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x6fb50
movsd %xmm0, -0x98(%rbp)
movsd -0x98(%rbp), %xmm0
movsd -0x90(%rbp), %xmm1
callq 0x52750
cmpl $0x0, %eax
je 0x70054
movl -0x40(%rbp), %eax
movl %eax, -0x3c(%rbp)
movsd -0x98(%rbp), %xmm0
movsd %xmm0, -0x90(%rbp)
leaq -0x88(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x7aa80
leaq -0x110(%rbp), %rdi
leaq -0x70(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x7a990
movq -0x110(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x108(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x100(%rbp), %rax
movq %rax, -0x78(%rbp)
movsd -0xa0(%rbp), %xmm0
movq -0x20(%rbp), %rax
movsd %xmm0, (%rax)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movq 0x8(%rax), %rsi
callq 0x59ea0
movq -0x18(%rbp), %rax
movq %rax, -0x140(%rbp)
movq -0xb0(%rbp), %rdi
movq -0xa8(%rbp), %rsi
callq 0x58550
movq %rax, %rcx
movq -0x140(%rbp), %rax
movq %rcx, -0x120(%rbp)
movq %rdx, -0x118(%rbp)
movq -0x120(%rbp), %rcx
movq %rcx, (%rax)
movq -0x118(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0xb0(%rbp), %rdi
movq -0xa8(%rbp), %rsi
callq 0x59ea0
movl $0x1, -0x34(%rbp)
jmp 0x70067
movq -0xb0(%rbp), %rdi
movq -0xa8(%rbp), %rsi
callq 0x59ea0
movq -0x68(%rbp), %rax
movslq -0x38(%rbp), %rcx
movl $0x1, %edx
subl (%rax,%rcx,4), %edx
movq -0x68(%rbp), %rax
movslq -0x38(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x6feb8
cmpl $0x0, -0x34(%rbp)
je 0x70105
leaq -0x70(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x7aa80
leaq -0x138(%rbp), %rdi
leaq -0x88(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x7a990
movq -0x138(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x130(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x128(%rbp), %rax
movq %rax, -0x60(%rbp)
jmp 0x6fea0
leaq -0x88(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x7aa80
leaq -0x70(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x7aa80
leaq -0x58(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x7aa80
movsd -0x90(%rbp), %xmm0
movsd 0x72815(%rip), %xmm1    # 0xe2998
ucomisd %xmm1, %xmm0
jne 0x70194
jp 0x70194
movl $0x0, -0x4(%rbp)
jmp 0x7019a
movl -0x3c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
nopw %cs:(%rax,%rax)