// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edx, %r15d
movq %rsi, 0x20(%rsp)
movq %rdi, %rbx
movabsq $0x41dfffffffc00000, %rax # imm = 0x41DFFFFFFFC00000
movq %rcx, 0x8(%rsp)
movq %rax, (%rcx)
movl %edx, %edi
callq 0x3463b
movq %rax, %r13
movl %r15d, (%rbx)
movslq %r15d, %r12
leaq (,%r12,8), %rdi
leaq 0x69f87(%rip), %rsi     # 0x98bff
pushq $0x6
popq %rdx
callq 0x34f59
movq %rax, %r14
movq %rbx, (%rsp)
movq %rax, 0x18(%rbx)
xorl %ebp, %ebp
movq %r12, 0x10(%rsp)
testl %r12d, %r12d
movl $0x0, %ebx
cmovgl %r15d, %ebx
pushq $0x4
popq %r12
cmpq %rbp, %rbx
je 0x2ecc2
movq %r12, %rdi
leaq 0x69f4e(%rip), %rsi     # 0x98bff
pushq $0x6
popq %rdx
callq 0x34f59
movq %rax, (%r14,%rbp,8)
incq %rbp
jmp 0x2eca2
movq 0x10(%rsp), %rbp
shlq $0x2, %rbp
leaq 0x69f2d(%rip), %r14     # 0x98bff
pushq $0x7
popq %rdx
movq %rbp, %rdi
movq %r14, %rsi
callq 0x34f59
movq (%rsp), %r12
movq %rax, 0x8(%r12)
pushq $0x8
popq %rdx
movq %rbp, %rdi
movq %r14, %rsi
callq 0x34f59
movq %rax, 0x10(%r12)
pushq $0x9
popq %rdx
movq %rbp, %rdi
movq %r14, %rsi
callq 0x34f59
movq %rax, %rbp
xorl %edx, %edx
pushq $0x1
popq %rsi
leal -0x1(%r15), %eax
movq %rax, 0x10(%rsp)
pushq $0x1
popq %r12
xorl %ecx, %ecx
cmpq %rbx, %rdx
jne 0x2ed4b
leaq 0x9eb43(%rip), %rax     # 0xcd870
movq (%rax), %rax
xorl %edx, %edx
cmpq %rdx, %rbx
je 0x2ed71
movl (%r13,%rdx,4), %esi
cmpl 0x1407128(%rax), %esi
cmovel %r12d, %ecx
incq %rdx
jmp 0x2ed32
leaq (,%rsi,4), %rax
addq %r13, %rax
movl %esi, %edi
cmpl %r15d, %edi
jge 0x2edc7
movl (%r13,%rdx,4), %r8d
cmpl (%rax), %r8d
cmovel %r12d, %ecx
addq $0x4, %rax
incl %edi
jmp 0x2ed58
testl %ecx, %ecx
jne 0x2ee70
movq 0x20(%rsp), %rax
movq 0x20(%rax), %rdi
movq %r13, %rsi
movl %r15d, %edx
leaq 0x1c(%rsp), %rcx
callq 0x9193f
movq %rax, %r14
leaq 0x9ead4(%rip), %rax     # 0xcd870
movq (%rax), %rax
movl $0x30f08, %ecx          # imm = 0x30F08
addq %rcx, %rax
xorl %ecx, %ecx
cmpq %rcx, %rbx
je 0x2edd2
movslq (%r13,%rcx,4), %rdx
imulq $0x340, %rdx, %rdx      # imm = 0x340
movl 0x18(%rax,%rdx), %edx
movl %edx, (%rbp,%rcx,4)
incq %rcx
jmp 0x2eda9
incq %rdx
incq %rsi
jmp 0x2ed21
movq 0x20(%rsp), %rax
movq 0xa0(%rax), %r8
movq 0x10(%rsp), %rax
cmpl $0x3, %eax
ja 0x2edf8
leaq 0x69e61(%rip), %rcx     # 0x98c50
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq (%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %r14, %rcx
movq 0x8(%rsp), %r9
callq 0x2e6ac
jmp 0x2ee5a
movq (%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %r14, %rcx
movq 0x8(%rsp), %r9
callq 0x2e9c7
jmp 0x2ee5a
movq (%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %r14, %rcx
movq 0x8(%rsp), %r9
callq 0x2eada
jmp 0x2ee5a
movq (%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %r14, %rcx
movq 0x8(%rsp), %r9
callq 0x2e8fa
movl 0x1c(%rsp), %esi
movq %r14, %rdi
callq 0x34fc3
leaq 0x9ea03(%rip), %rax     # 0xcd870
movq (%rax), %rax
movl 0x1bc(%rax), %edx
decl %edx
movq %r13, %rdi
movl %r15d, %esi
callq 0x34ae8
xorl %edx, %edx
pushq $0x1
popq %rsi
movl $0x0, %ecx
testl %eax, %eax
jne 0x2ed21
movq %r13, %rdi
callq 0x34ff7
movq %rbp, %rdi
callq 0x34ff7
movq 0x8(%rsp), %rax
movsd (%rax), %xmm0
ucomisd 0x66e42(%rip), %xmm0    # 0x95cf8
movq (%rsp), %rax
jne 0x2eec1
jp 0x2eec1
andl $0x0, (%rax)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq