// File: /workspace/github_c_makefile_star2_O2/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 $0x48, %rsp
movq %r9, %rbp
movq %r8, 0x20(%rsp)
movq %rcx, 0x40(%rsp)
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r13
movq 0x80(%rsp), %rax
movq %rax, 0x10(%rsp)
movl (%rdi), %r14d
movl %r14d, %edi
callq 0x3466d
movq %rax, %rbx
movl (%rbp), %edi
movl 0x4(%rbp), %esi
addl %edi, %esi
callq 0x71fae
movsd %xmm0, 0x18(%rsp)
xorl %r8d, %r8d
testl %r14d, %r14d
movl $0x0, %ebp
movl %r14d, 0xc(%rsp)
cmovgl %r14d, %ebp
xorl %r14d, %r14d
xorl %eax, %eax
pushq $0x1
popq %rdx
xorl %ecx, %ecx
cmpq %rax, %rbp
je 0x2dcb8
movq (%r12,%rax,8), %rsi
movslq (%rbx,%rax,4), %rdi
movl (%rsi,%rdi,4), %esi
imull %edx, %esi
addl %esi, %ecx
imull (%r15,%rax,4), %edx
incq %rax
jmp 0x2dc99
movslq %ecx, %rax
movq 0x20(%rsp), %rcx
movq (%rcx,%rax,8), %rax
addl (%rax), %r14d
addl 0x4(%rax), %r8d
movq %r8, 0x38(%rsp)
leal (%r8,%r14), %esi
movl %r14d, %edi
callq 0x71fae
movq %r14, 0x30(%rsp)
cvtsi2sd %r14d, %xmm2
movsd 0x18(%rsp), %xmm1
subsd %xmm0, %xmm1
mulsd %xmm2, %xmm1
movq 0x10(%rsp), %rax
movsd (%rax), %xmm0
movsd %xmm1, 0x28(%rsp)
callq 0x34c76
testl %eax, %eax
je 0x2dd86
movq 0x10(%rsp), %rax
movsd 0x28(%rsp), %xmm0
movsd %xmm0, (%rax)
xorl %r14d, %r14d
cmpq %rbp, %r14
je 0x2dd86
movq 0x40(%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 0x6aeb0(%rip), %rsi     # 0x98bff
pushq $0x46
popq %rdx
callq 0x34f59
movq 0x18(%r13), %rcx
movq %rax, (%rcx,%r14,8)
xorl %eax, %eax
movslq (%r15,%r14,4), %rcx
cmpq %rcx, %rax
jge 0x2dd81
movq (%r12,%r14,8), %rcx
movl (%rcx,%rax,4), %ecx
movq 0x18(%r13), %rdx
movq (%rdx,%r14,8), %rdx
movl %ecx, (%rdx,%rax,4)
incq %rax
jmp 0x2dd61
incq %r14
jmp 0x2dd1e
movq %rbx, %rdi
movl 0xc(%rsp), %esi
movq %r15, %rdx
callq 0x34b0d
testl %eax, %eax
movq 0x38(%rsp), %r8
movq 0x30(%rsp), %r14
jne 0x2dc92
movq %rbx, %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x34ff7