// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/ktree.c
// Function: update_best_discrete_split
void update_best_discrete_split(Korderingsplit* split, int* perm[], int* rangelist, int* iter, int** featurecounts, int* nodecounts, double* bestgain)
{
	int i, j, size = split->featurecount, permpos, permmultiplier;
 int* mixediter;
 int counts[2][MAXCLASSES];
	double gain;
 for (i = 0; i < MAXCLASSES; i++)
   counts[0][i] = counts[1][i] = 0;
 for (i = 0; i < current_dataset->classno; i++)
   counts[1][i] = nodecounts[i];
 mixediter = first_mixed_iterator(size);
 do{
   permpos = 0;
   permmultiplier = 1;
   for (i = 0; i < size; i++)
    {
     permpos += permmultiplier * perm[i][mixediter[i]];
     permmultiplier *= rangelist[i];
    }
   for (i = 0; i < current_dataset->classno; i++)
    {
     counts[0][i] += featurecounts[permpos][i];
     counts[1][i] -= featurecounts[permpos][i];
    }
   gain = information_gain(counts);
   if (dless(gain, *bestgain))
    {
     *bestgain = gain;
     for (i = 0; i < size; i++)
      {
       split->featurelist[i] = iter[i];
       split->discretesplit[i] = mixediter[i];
       safe_free(split->sortorder[i]);
       split->sortorder[i] = safemalloc(rangelist[i] * sizeof(int), "update_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 $0x1b8, %rsp            # imm = 0x1B8
movq %r9, %rbx
movq %r8, 0x8(%rsp)
movq %rcx, 0x18(%rsp)
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r13
movl (%rdi), %ebp
leaq 0x20(%rsp), %rdi
movl $0xc8, %edx
xorl %esi, %esi
callq 0x4050
movdqa 0x73aaf(%rip), %xmm0    # 0xa6430
movdqa 0x73ab7(%rip), %xmm1    # 0xa6440
movl $0x35, %eax
movdqa 0x73aba(%rip), %xmm2    # 0xa6450
movdqa 0x76332(%rip), %xmm3    # 0xa8cd0
pshufd $0xf5, %xmm3, %xmm4     # xmm4 = xmm3[1,1,3,3]
movdqa 0x73ab5(%rip), %xmm5    # 0xa6460
movdqa %xmm1, %xmm6
pxor %xmm2, %xmm6
movdqa %xmm3, %xmm7
pcmpgtd %xmm6, %xmm7
pshufd $0xf5, %xmm6, %xmm6     # xmm6 = xmm6[1,1,3,3]
pcmpeqd %xmm4, %xmm6
pand %xmm7, %xmm6
movd %xmm6, %ecx
testb $0x1, %cl
je 0x329d9
movl $0x0, 0x14(%rsp,%rax,4)
pextrw $0x4, %xmm6, %ecx
testb $0x1, %cl
je 0x329eb
movl $0x0, 0x18(%rsp,%rax,4)
movdqa %xmm0, %xmm6
pxor %xmm2, %xmm6
movdqa %xmm3, %xmm7
pcmpgtd %xmm6, %xmm7
pshufd $0xf5, %xmm6, %xmm6     # xmm6 = xmm6[1,1,3,3]
pcmpeqd %xmm4, %xmm6
pand %xmm7, %xmm6
pextrw $0x0, %xmm6, %ecx
testb $0x1, %cl
je 0x32a1a
movl $0x0, 0x1c(%rsp,%rax,4)
pextrw $0x4, %xmm6, %ecx
testb $0x1, %cl
je 0x32a2c
movl $0x0, 0x20(%rsp,%rax,4)
paddq %xmm5, %xmm1
paddq %xmm5, %xmm0
addq $0x4, %rax
cmpq $0x69, %rax
jne 0x329ab
leaq 0xa2e27(%rip), %rax     # 0xd5870
movq (%rax), %rax
movslq 0x10(%rax), %rax
testq %rax, %rax
jle 0x32a69
xorl %ecx, %ecx
movl (%rbx,%rcx,4), %edx
movl %edx, 0xe8(%rsp,%rcx,4)
incq %rcx
cmpq %rax, %rcx
jb 0x32a57
movl %ebp, %edi
callq 0x39354
movq %rax, %rbx
testl %ebp, %ebp
jle 0x32aa2
xorl %eax, %eax
movl $0x1, %ecx
xorl %edx, %edx
movq (%r12,%rax,8), %rsi
movslq (%rbx,%rax,4), %rdi
movl (%rsi,%rdi,4), %esi
imull %ecx, %esi
addl %esi, %edx
imull (%r15,%rax,4), %ecx
incq %rax
cmpq %rax, %rbp
jne 0x32a80
movslq %edx, %rcx
jmp 0x32aa4
xorl %ecx, %ecx
leaq 0xa2dc5(%rip), %rax     # 0xd5870
movq (%rax), %rax
cmpl $0x0, 0x10(%rax)
jle 0x32adc
movq 0x8(%rsp), %rdx
movq (%rdx,%rcx,8), %rcx
xorl %edx, %edx
movl (%rcx,%rdx,4), %esi
addl %esi, 0x20(%rsp,%rdx,4)
movl (%rcx,%rdx,4), %esi
subl %esi, 0xe8(%rsp,%rdx,4)
incq %rdx
movslq 0x10(%rax), %rsi
cmpq %rsi, %rdx
jl 0x32abf
leaq 0x20(%rsp), %rdi
callq 0x1df2d
movq 0x1f0(%rsp), %rax
movq (%rax), %xmm1
movq %xmm0, 0x10(%rsp)
callq 0x39aee
testl %eax, %eax
je 0x32b98
movq 0x1f0(%rsp), %rax
movq 0x10(%rsp), %xmm0
movq %xmm0, (%rax)
testl %ebp, %ebp
jle 0x32b98
xorl %r14d, %r14d
movq 0x18(%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)
movq 0x18(%r13), %rax
movq (%rax,%r14,8), %rdi
callq 0x3a180
movslq (%r15,%r14,4), %rdi
shlq $0x2, %rdi
leaq 0x761b0(%rip), %rsi     # 0xa8d07
movl $0x46, %edx
callq 0x3a0e1
movq 0x18(%r13), %rcx
movq %rax, (%rcx,%r14,8)
cmpl $0x0, (%r15,%r14,4)
jle 0x32b90
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 0x32b7e
incq %r14
cmpq %rbp, %r14
jne 0x32b1e
movq %rbx, %rdi
movl %ebp, %esi
movq %r15, %rdx
callq 0x3994b
testl %eax, %eax
jne 0x32a73
movq %rbx, %rdi
callq 0x3a180
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq