// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/krule.c
// Function: update_best_discrete_condition
void update_best_discrete_condition(Korderingsplit* split, int* perm[], int* rangelist, int* iter, int** featurecounts, int partitioncounts[], double* bestgain)
{
	int i, j, size = split->featurecount, permpos, permmultiplier;
 int* mixediter;
 int counts[2][2];
	double gain, it, itdot;
 counts[COVERED][POSITIVE_CLASS] = 0;
 counts[COVERED][NEGATIVE_CLASS] = 0;
 counts[UNCOVERED][POSITIVE_CLASS] = partitioncounts[POSITIVE_CLASS];
 counts[UNCOVERED][NEGATIVE_CLASS] = partitioncounts[NEGATIVE_CLASS];
 mixediter = first_mixed_iterator(size);
 it = information(partitioncounts[POSITIVE_CLASS], partitioncounts[POSITIVE_CLASS] + partitioncounts[NEGATIVE_CLASS]);
 do{
   permpos = 0;
   permmultiplier = 1;
   for (i = 0; i < size; i++)
    {
     permpos += permmultiplier * perm[i][mixediter[i]];
     permmultiplier *= rangelist[i];
    }
   counts[COVERED][POSITIVE_CLASS] += featurecounts[permpos][POSITIVE_CLASS];
   counts[COVERED][NEGATIVE_CLASS] += featurecounts[permpos][NEGATIVE_CLASS];
   counts[UNCOVERED][POSITIVE_CLASS] -= featurecounts[permpos][POSITIVE_CLASS];
   counts[UNCOVERED][NEGATIVE_CLASS] -= featurecounts[permpos][NEGATIVE_CLASS];
   itdot = information(counts[COVERED][POSITIVE_CLASS], counts[COVERED][POSITIVE_CLASS] + counts[COVERED][NEGATIVE_CLASS]);
   gain = counts[COVERED][POSITIVE_CLASS] * (it - itdot);
   if (dless(*bestgain, gain))
    {
     *bestgain = gain;
     for (i = 0; i < size; i++)
      {
       split->featurelist[i] = iter[i];
       split->discretesplit[i] = mixediter[i];
       split->sortorder[i] = safemalloc(rangelist[i] * sizeof(int), "find_best_discrete_split", 70);
       for (j = 0; j < rangelist[i]; j++)
         split->sortorder[i][j] = perm[i][j];
      }
    }
 }while (next_mixed_iterator(mixediter, size, rangelist));
 safe_free(mixediter);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, %r14
movq %r8, 0x10(%rsp)
movq %rcx, 0x30(%rsp)
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r13
movq 0x70(%rsp), %rax
movq %rax, (%rsp)
movl (%rdi), %ebp
movl %ebp, %edi
callq 0x39354
movq %rax, %rbx
movl (%r14), %edi
movl 0x4(%r14), %esi
addl %edi, %esi
callq 0x7c668
movsd %xmm0, 0x8(%rsp)
xorl %r8d, %r8d
xorl %r14d, %r14d
testl %ebp, %ebp
jle 0x31e6d
movl $0x1, %eax
xorl %ecx, %ecx
xorl %edx, %edx
movq (%r12,%rcx,8), %rsi
movslq (%rbx,%rcx,4), %rdi
movl (%rsi,%rdi,4), %esi
imull %eax, %esi
addl %esi, %edx
imull (%r15,%rcx,4), %eax
incq %rcx
cmpq %rcx, %rbp
jne 0x31e4b
movslq %edx, %rax
jmp 0x31e6f
xorl %eax, %eax
movq 0x10(%rsp), %rcx
movq (%rcx,%rax,8), %rax
addl (%rax), %r14d
addl 0x4(%rax), %r8d
movq %r8, 0x28(%rsp)
leal (%r8,%r14), %esi
movl %r14d, %edi
callq 0x7c668
movq %r14, 0x20(%rsp)
xorps %xmm2, %xmm2
cvtsi2sd %r14d, %xmm2
movsd 0x8(%rsp), %xmm1
subsd %xmm0, %xmm1
mulsd %xmm2, %xmm1
movq (%rsp), %rax
movsd (%rax), %xmm0
movsd %xmm1, 0x18(%rsp)
callq 0x39aee
testl %eax, %eax
je 0x31f48
movq (%rsp), %rax
movsd 0x18(%rsp), %xmm0
movsd %xmm0, (%rax)
testl %ebp, %ebp
jle 0x31f48
xorl %r14d, %r14d
movq 0x30(%rsp), %rax
movl (%rax,%r14,4), %eax
movq 0x8(%r13), %rcx
movl %eax, (%rcx,%r14,4)
movl (%rbx,%r14,4), %eax
movq 0x10(%r13), %rcx
movl %eax, (%rcx,%r14,4)
movslq (%r15,%r14,4), %rdi
shlq $0x2, %rdi
leaq 0x76d78(%rip), %rsi     # 0xa8c7f
movl $0x46, %edx
callq 0x3a0e1
movq 0x18(%r13), %rcx
movq %rax, (%rcx,%r14,8)
cmpl $0x0, (%r15,%r14,4)
jle 0x31f40
movq (%r12,%r14,8), %rax
movq 0x18(%r13), %rcx
movq (%rcx,%r14,8), %rcx
xorl %edx, %edx
movl (%rax,%rdx,4), %esi
movl %esi, (%rcx,%rdx,4)
incq %rdx
movslq (%r15,%r14,4), %rsi
cmpq %rsi, %rdx
jl 0x31f2e
incq %r14
cmpq %rbp, %r14
jne 0x31edb
movq %rbx, %rdi
movl %ebp, %esi
movq %r15, %rdx
callq 0x3994b
testl %eax, %eax
movq 0x28(%rsp), %r8
movq 0x20(%rsp), %r14
jne 0x31e3e
movq %rbx, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3a180