// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/krule.c
// Function: find_best_discrete_condition
Decisionconditionptr find_best_discrete_condition(Instanceptr growset, int depth, int positive, double* bestgain)
{
 int* iter;
 int* rangelist;
 int counts[2];
 int** featurecounts;
 int permsize;
 int i, j, anysame;
 Decisionconditionptr result;
 result = empty_condition();
 result->conditiontype = UNIVARIATE_CONDITION;
 result->featureindex = DISCRETEMIX;
 result->freeparam = 1;
 result->comparison = '<';
 *bestgain = 0.0;
 iter = first_iterator(depth);
 result->ksplit.featurecount = depth;
 result->ksplit.sortorder = safemalloc(depth * sizeof(int*), "find_best_discrete_split", 6);
 result->ksplit.featurelist = safemalloc(depth * sizeof(int), "find_best_discrete_split", 7);
 result->ksplit.discretesplit = safemalloc(depth * sizeof(int), "find_best_discrete_split", 8);
 rangelist = safemalloc(depth * sizeof(int), "find_best_discrete_split", 9);
 counts[POSITIVE_CLASS] = find_class_count(growset, positive);
 counts[NEGATIVE_CLASS] = data_size(growset) - counts[POSITIVE_CLASS];
 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_one_vs_rest(growset, iter, depth, &permsize, positive);
   for (i = 0; i < depth; i++)
     rangelist[i] = current_dataset->features[iter[i]].valuecount;
   switch (depth)
    {
     case 1:find_best_discrete_condition_1(&(result->ksplit), rangelist, iter, featurecounts, counts, positive, bestgain);
            break;
     case 2:find_best_discrete_condition_2(&(result->ksplit), rangelist, iter, featurecounts, counts, positive, bestgain);
            break;
     case 3:find_best_discrete_condition_3(&(result->ksplit), rangelist, iter, featurecounts, counts, positive, bestgain);
            break;
     case 4:find_best_discrete_condition_4(&(result->ksplit), rangelist, iter, featurecounts, counts, positive, bestgain);
            break;
     default:find_best_discrete_condition_1(&(result->ksplit), rangelist, iter, featurecounts, counts, positive, bestgain);
             break;
    }
   free_2d((void**) featurecounts, permsize);
 }while (next_iterator(iter, depth, current_dataset->featurecount - 1));
 safe_free(iter);
 safe_free(rangelist);
 if (*bestgain == 0)
   result->featureindex = -1;
 return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, %r14
movl %edx, 0x24(%rsp)
movl %esi, %r15d
movq %rdi, 0x38(%rsp)
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x71cd1
movq %rax, %r12
movl $0xfffffffb, (%rax)     # imm = 0xFFFFFFFB
movq $0x1, 0x3c(%rax)
movb $0x3c, 0x4(%rax)
movq %r14, 0x8(%rsp)
andq $0x0, (%r14)
movl %r15d, %edi
callq 0x3463b
movq %rax, %r13
leaq 0x50(%r12), %rax
movq %rax, 0x18(%rsp)
movl %r15d, 0x50(%r12)
movslq %r15d, %r14
leaq (,%r14,8), %rdi
movq %r14, 0x28(%rsp)
leaq 0x6a907(%rip), %rsi     # 0x98bff
pushq $0x6
popq %rdx
callq 0x34f59
movq %rax, 0x68(%r12)
leaq (,%r14,4), %rbp
pushq $0x7
popq %rdx
movq %rbp, %rdi
leaq 0x6a8e5(%rip), %r14     # 0x98bff
movq %r14, %rsi
callq 0x34f59
movq %rax, 0x58(%r12)
pushq $0x8
popq %rdx
movq %rbp, %rdi
movq %r14, %rsi
callq 0x34f59
movq %r12, 0x40(%rsp)
movq %rax, 0x60(%r12)
pushq $0x9
popq %rdx
movq %rbp, %rdi
movq %r14, %rsi
callq 0x34f59
movq %rax, %rbp
movq 0x38(%rsp), %r12
movq %r12, %rdi
movl 0x24(%rsp), %esi
callq 0x10827
movl %eax, %r14d
leaq 0x10(%rsp), %rax
movl %r14d, (%rax)
movq %r12, %rdi
callq 0x2c3cc
subl %r14d, %eax
leaq 0x10(%rsp), %rcx
movl %eax, 0x4(%rcx)
cmpl $0x0, 0x28(%rsp)
movl $0x0, %r14d
cmovgl %r15d, %r14d
pushq $0x1
popq %rdx
leal -0x1(%r15), %eax
movq %rax, 0x28(%rsp)
pushq $0x1
popq %r12
xorl %ecx, %ecx
cmpq %r14, %rbx
jne 0x2e3ca
leaq 0x9f4c4(%rip), %rax     # 0xcd870
movq (%rax), %rax
xorl %edx, %edx
cmpq %rdx, %r14
je 0x2e3ef
movl (%r13,%rdx,4), %esi
cmpl 0x1407128(%rax), %esi
cmovel %r12d, %ecx
incq %rdx
jmp 0x2e3b1
leaq (,%rdx,4), %rax
addq %r13, %rax
movl %edx, %esi
cmpl %r15d, %esi
jge 0x2e446
movl (%r13,%rbx,4), %edi
cmpl (%rax), %edi
cmovel %r12d, %ecx
addq $0x4, %rax
incl %esi
jmp 0x2e3d7
testl %ecx, %ecx
jne 0x2e50b
movq 0x38(%rsp), %rdi
movq %r13, %rsi
movl %r15d, %edx
leaq 0x34(%rsp), %rcx
movl 0x24(%rsp), %r8d
callq 0x2db3c
movq %rax, %rbx
leaq 0x9f455(%rip), %rax     # 0xcd870
movq (%rax), %rax
movl $0x30f08, %ecx          # imm = 0x30F08
addq %rcx, %rax
xorl %ecx, %ecx
cmpq %rcx, %r14
je 0x2e451
movslq (%r13,%rcx,4), %rdx
imulq $0x340, %rdx, %rdx      # imm = 0x340
movl 0x18(%rax,%rdx), %edx
movl %edx, (%rbp,%rcx,4)
incq %rcx
jmp 0x2e428
incq %rbx
incq %rdx
jmp 0x2e3a0
movq 0x28(%rsp), %rax
cmpl $0x3, %eax
ja 0x2e46b
leaq 0x6a772(%rip), %rcx     # 0x98bd4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x8(%rsp), %rax
movq %rax, (%rsp)
movq 0x18(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %rbx, %rcx
leaq 0x10(%rsp), %r8
callq 0x2ddbd
jmp 0x2e4f5
movq 0x8(%rsp), %rax
movq %rax, (%rsp)
movq 0x18(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %rbx, %rcx
leaq 0x10(%rsp), %r8
callq 0x2df0f
jmp 0x2e4f5
movq 0x8(%rsp), %rax
movq %rax, (%rsp)
movq 0x18(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %rbx, %rcx
leaq 0x10(%rsp), %r8
callq 0x2e027
jmp 0x2e4f5
movq 0x8(%rsp), %rax
movq %rax, (%rsp)
movq 0x18(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %rbx, %rcx
leaq 0x10(%rsp), %r8
callq 0x2de38
movl 0x34(%rsp), %esi
movq %rbx, %rdi
callq 0x34fc3
leaq 0x9f368(%rip), %rax     # 0xcd870
movq (%rax), %rax
movl 0x1bc(%rax), %edx
decl %edx
movq %r13, %rdi
movl %r15d, %esi
callq 0x34ae8
xorl %ebx, %ebx
pushq $0x1
popq %rdx
movl $0x0, %ecx
testl %eax, %eax
jne 0x2e3a0
movq %r13, %rdi
callq 0x34ff7
movq %rbp, %rdi
callq 0x34ff7
movq 0x8(%rsp), %rax
movsd (%rax), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
movq 0x40(%rsp), %rax
jne 0x2e55d
jp 0x2e55d
orl $-0x1, (%rax)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq