// File: /workspace/github_c_makefile_star2_O3/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, %rbx
movl %edx, 0xc(%rsp)
movl %esi, %r14d
movq %rdi, %r12
xorl %eax, %eax
callq 0x7c366
movq %rax, %r15
movl $0xfffffffb, (%rax)     # imm = 0xFFFFFFFB
movq $0x1, 0x3c(%rax)
movb $0x3c, 0x4(%rax)
movq %rbx, 0x10(%rsp)
movq $0x0, (%rbx)
movq %r14, 0x30(%rsp)
movl %r14d, %edi
callq 0x3930e
movq %rax, %r13
leaq 0x50(%r15), %rax
movq %rax, 0x18(%rsp)
movl %r14d, 0x50(%r15)
movslq %r14d, %r14
leaq (,%r14,8), %rdi
leaq 0x7679e(%rip), %rbx     # 0xa8c7f
movq %rbx, %rsi
movl $0x6, %edx
callq 0x3a0e1
movq %rax, 0x68(%r15)
leaq (,%r14,4), %rbp
movq %rbp, %rdi
movq %rbx, %rsi
movl $0x7, %edx
callq 0x3a0e1
movq %rax, 0x58(%r15)
movq %rbp, %rdi
movq %rbx, %rsi
movl $0x8, %edx
callq 0x3a0e1
movq %r15, 0x40(%rsp)
movq %rax, 0x60(%r15)
movq %rbp, %rdi
movq %rbx, %rsi
movl $0x9, %edx
callq 0x3a0e1
movq %rax, %rbp
movq %r12, %rdi
movl 0xc(%rsp), %esi
callq 0x114f9
movl %eax, %ebx
leaq 0x28(%rsp), %r15
movl %eax, (%r15)
movq %r12, 0x38(%rsp)
movq %r12, %rdi
callq 0x30309
subl %ebx, %eax
movq 0x30(%rsp), %rbx
movl %eax, 0x4(%r15)
movl %r14d, %r12d
movl $0x1, %r15d
testl %ebx, %ebx
jle 0x3264a
xorl %esi, %esi
movq %r12, %rcx
movq %r13, %rdx
xorl %eax, %eax
movq %rsi, %rdi
incq %rsi
cmpq %r14, %rsi
jge 0x325a9
movl (%r13,%rdi,4), %edi
movl $0x1, %r8d
cmpl (%rdx,%r8,4), %edi
cmovel %r15d, %eax
incq %r8
cmpq %r8, %rcx
jne 0x32599
addq $0x4, %rdx
decq %rcx
cmpq %r12, %rsi
jne 0x32583
testl %ebx, %ebx
jle 0x32642
leaq 0xa32ac(%rip), %rcx     # 0xd5870
movq (%rcx), %rcx
movl 0x1407128(%rcx), %ecx
xorl %edx, %edx
cmpl %ecx, (%r13,%rdx,4)
cmovel %r15d, %eax
incq %rdx
cmpq %rdx, %r12
jne 0x325cf
testl %eax, %eax
jne 0x3271c
movq 0x38(%rsp), %rdi
movq %r13, %rsi
movl %ebx, %edx
leaq 0x24(%rsp), %rcx
movl 0xc(%rsp), %r8d
callq 0x31cec
movq %rbx, %rcx
movq %rax, %rbx
testl %ecx, %ecx
jle 0x3263b
leaq 0xa325e(%rip), %rax     # 0xd5870
movq (%rax), %rax
movl $0x30f08, %ecx          # imm = 0x30F08
addq %rcx, %rax
xorl %ecx, %ecx
movslq (%r13,%rcx,4), %rdx
imulq $0x340, %rdx, %rdx      # imm = 0x340
movl 0x18(%rax,%rdx), %edx
movl %edx, (%rbp,%rcx,4)
incq %rcx
cmpq %rcx, %r12
jne 0x3261f
movq 0x30(%rsp), %rcx
jmp 0x32669
testl %eax, %eax
jne 0x3271c
movq 0x38(%rsp), %rdi
movq %r13, %rsi
movl %ebx, %edx
leaq 0x24(%rsp), %rcx
movl 0xc(%rsp), %r8d
callq 0x31cec
movq %rbx, %rcx
movq %rax, %rbx
leal -0x1(%rcx), %eax
cmpl $0x3, %eax
ja 0x32681
leaq 0x765dc(%rip), %rcx     # 0xa8c54
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x10(%rsp), %rax
movq %rax, (%rsp)
movq 0x18(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %rbx, %rcx
leaq 0x28(%rsp), %r8
callq 0x31f7d
jmp 0x3270b
movq 0x10(%rsp), %rax
movq %rax, (%rsp)
movq 0x18(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %rbx, %rcx
leaq 0x28(%rsp), %r8
callq 0x320cf
jmp 0x3270b
movq 0x10(%rsp), %rax
movq %rax, (%rsp)
movq 0x18(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %rbx, %rcx
leaq 0x28(%rsp), %r8
callq 0x321e7
jmp 0x3270b
movq 0x10(%rsp), %rax
movq %rax, (%rsp)
movq 0x18(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %rbx, %rcx
leaq 0x28(%rsp), %r8
callq 0x31ff8
movl 0x24(%rsp), %esi
movq %rbx, %rdi
callq 0x3a14b
movq 0x30(%rsp), %rbx
leaq 0xa314d(%rip), %rax     # 0xd5870
movq (%rax), %rax
movl 0x1bc(%rax), %edx
decl %edx
movq %r13, %rdi
movl %ebx, %esi
callq 0x3991a
testl %eax, %eax
jne 0x32571
movq %r13, %rdi
callq 0x3a180
movq %rbp, %rdi
callq 0x3a180
movq 0x10(%rsp), %rax
movsd (%rax), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
movq 0x40(%rsp), %rax
jne 0x32770
jp 0x32770
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop