// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/ktree.c
// Function: find_best_discrete_split
Korderingsplit find_best_discrete_split(Decisionnodeptr node, int depth, double* gain)
{
 int* iter;
 int* rangelist;
 int** featurecounts;
 int permsize;
 int i, j, anysame;
 Korderingsplit ksplit;
 *gain = +INT_MAX;
 iter = first_iterator(depth);
 ksplit.featurecount = depth;
 ksplit.sortorder = safemalloc(depth * sizeof(int*), "find_best_discrete_split", 6);
 for (i = 0; i < depth; i++)
   ksplit.sortorder[i] = safemalloc(sizeof(int), "find_best_discrete_split", 6);
 ksplit.featurelist = safemalloc(depth * sizeof(int), "find_best_discrete_split", 7);
 ksplit.discretesplit = safemalloc(depth * sizeof(int), "find_best_discrete_split", 8);
 rangelist = safemalloc(depth * sizeof(int), "find_best_discrete_split", 9);
 do{
   anysame = NO;
   for (i = 0; i < depth; i++)
     for (j = i + 1; j < depth; j++)
       if (iter[i] == iter[j])
         anysame = YES;
   for (i = 0; i < depth; i++)
     if (iter[i] == current_dataset->classdefno)
       anysame = YES;
   if (anysame)
     continue;
   featurecounts = count_feature_combinations(node->instances, iter, depth, &permsize);
   for (i = 0; i < depth; i++)
     rangelist[i] = current_dataset->features[iter[i]].valuecount;
   switch (depth)
    {
     case 1:find_best_discrete_split_1(&ksplit, rangelist, iter, featurecounts, node->counts, gain);
            break;
     case 2:find_best_discrete_split_2(&ksplit, rangelist, iter, featurecounts, node->counts, gain);
            break;
     case 3:find_best_discrete_split_3(&ksplit, rangelist, iter, featurecounts, node->counts, gain);
            break;
     case 4:find_best_discrete_split_4(&ksplit, rangelist, iter, featurecounts, node->counts, gain);
            break;
     default:find_best_discrete_split_1(&ksplit, rangelist, iter, featurecounts, node->counts, gain);
             break;
    }
   free_2d((void**) featurecounts, permsize);
 }while (next_iterator(iter, depth, current_dataset->featurecount - 1));
 safe_free(iter);
 safe_free(rangelist);
 if (*gain == ISELL)
   ksplit.featurecount = 0;
 return ksplit;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x48(%rbp)
movq %rdi, -0x50(%rbp)
movq %rsi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
movq %rcx, -0x18(%rbp)
movq -0x18(%rbp), %rax
movsd 0x99929(%rip), %xmm0    # 0xe2010
movsd %xmm0, (%rax)
movl -0xc(%rbp), %edi
callq 0x51b20
movq -0x48(%rbp), %rdi
movq %rax, -0x20(%rbp)
movl -0xc(%rbp), %eax
movl %eax, (%rdi)
movslq -0xc(%rbp), %rdi
shlq $0x3, %rdi
leaq 0x9d0a8(%rip), %rsi     # 0xe57b7
movl $0x6, %edx
callq 0x52d70
movq -0x48(%rbp), %rdi
movq %rax, 0x18(%rdi)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x48764
movl $0x4, %edi
leaq 0x9d07b(%rip), %rsi     # 0xe57b7
movl $0x6, %edx
callq 0x52d70
movq %rax, %rdx
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x38(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x48728
movslq -0xc(%rbp), %rdi
shlq $0x2, %rdi
leaq 0x9d044(%rip), %rsi     # 0xe57b7
movl $0x7, %edx
callq 0x52d70
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x8(%rax)
movslq -0xc(%rbp), %rdi
shlq $0x2, %rdi
leaq 0x9d020(%rip), %rsi     # 0xe57b7
movl $0x8, %edx
callq 0x52d70
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x10(%rax)
movslq -0xc(%rbp), %rdi
shlq $0x2, %rdi
leaq 0x9cffc(%rip), %rsi     # 0xe57b7
movl $0x9, %edx
callq 0x52d70
movq %rax, -0x28(%rbp)
movl $0x0, -0x40(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x48829
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x4881c
movq -0x20(%rbp), %rax
movslq -0x38(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq -0x20(%rbp), %rcx
movslq -0x3c(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jne 0x4880f
movl $0x1, -0x40(%rbp)
jmp 0x48811
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x487e8
jmp 0x4881e
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x487d7
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x48869
movq -0x20(%rbp), %rax
movslq -0x38(%rbp), %rcx
movl (%rax,%rcx,4), %eax
leaq 0xbcff6(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x1407128(%rcx), %eax
jne 0x4885c
movl $0x1, -0x40(%rbp)
jmp 0x4885e
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x48830
cmpl $0x0, -0x40(%rbp)
je 0x48874
jmp 0x489d1
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x20(%rbp), %rsi
movl -0xc(%rbp), %edx
leaq -0x34(%rbp), %rcx
callq 0xdd400
movq %rax, -0x30(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x488de
leaq 0xbcf9a(%rip), %rax     # 0x105840
movq (%rax), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movq -0x20(%rbp), %rcx
movslq -0x38(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
movl 0x18(%rax), %edx
movq -0x28(%rbp), %rax
movslq -0x38(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x48897
movl -0xc(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x58(%rbp)
subl $0x3, %eax
ja 0x489a1
movq -0x58(%rbp), %rax
leaq 0x9cf0b(%rip), %rcx     # 0xe5808
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x48(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0xa0(%rax), %r8
movq -0x18(%rbp), %r9
callq 0x480c0
jmp 0x489c5
movq -0x48(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0xa0(%rax), %r8
movq -0x18(%rbp), %r9
callq 0x48420
jmp 0x489c5
movq -0x48(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0xa0(%rax), %r8
movq -0x18(%rbp), %r9
callq 0x484d0
jmp 0x489c5
movq -0x48(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0xa0(%rax), %r8
movq -0x18(%rbp), %r9
callq 0x485b0
jmp 0x489c5
movq -0x48(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0xa0(%rax), %r8
movq -0x18(%rbp), %r9
callq 0x480c0
movq -0x30(%rbp), %rdi
movl -0x34(%rbp), %esi
callq 0x52e20
movq -0x20(%rbp), %rdi
movl -0xc(%rbp), %esi
leaq 0xbce61(%rip), %rax     # 0x105840
movq (%rax), %rax
movl 0x1bc(%rax), %edx
subl $0x1, %edx
callq 0x52330
cmpl $0x0, %eax
jne 0x487c9
movq -0x20(%rbp), %rdi
callq 0x52e80
movq -0x28(%rbp), %rdi
callq 0x52e80
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
movsd 0x99f7d(%rip), %xmm1    # 0xe2998
ucomisd %xmm1, %xmm0
jne 0x48a2d
jp 0x48a2d
movq -0x48(%rbp), %rax
movl $0x0, (%rax)
movq -0x50(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)