// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/decisionforest.c
// Function: create_kforestchildren
int create_kforestchildren(Decisionnodeptr node, Kforest_parameterptr p)
{
 int iteration, j, t, fno, permsize;
 double bestgain = ISELL;
 int** perm;
 int* array;
 int* iter;
 int* rangelist;
 int** featurecounts;
 Korderingsplit ksplit;
 node->conditiontype = UNIVARIATE_CONDITION;
 node->featureno = DISCRETEMIX;
 if (!(setup_node_properties(node)))
  {
   make_leaf_node(node);
   return 1;
  }
 iteration = 0;
 ksplit.featurecount = p->k;
 ksplit.sortorder = safemalloc(p->k * sizeof(int*), "create_kforestchildren", 20);
 for (j = 0; j < p->k; j++)
   ksplit.sortorder[j] = safemalloc(sizeof(int), "create_kforestchildren", 22);
 ksplit.featurelist = safemalloc(p->k * sizeof(int), "create_kforestchildren", 23);
 ksplit.discretesplit = safemalloc(p->k * sizeof(int), "create_kforestchildren", 24);
 perm = safemalloc(p->k * sizeof(int*), "create_kforestchildren", 25);
 rangelist = safemalloc(p->k * sizeof(int), "create_kforestchildren", 26);
 iter = safemalloc(p->k * sizeof(int), "create_kforestchildren", 27);
 while (iteration < p->featuresize)
  {
   array = random_array(current_dataset->featurecount);
   j = 0;
   t = 0;
   while (j < p->k)
    {
     fno = array[t];
     if (current_dataset->features[fno].type != CLASSDEF)
      {
       iter[j] = fno;
       j++;
      }
     t++;
    }
   safe_free(array);
   featurecounts = count_feature_combinations(node->instances, iter, p->k, &permsize);
   for (j = 0; j < p->k; j++)
    {
     rangelist[j] = current_dataset->features[iter[j]].valuecount;
     perm[j] = random_array(rangelist[j]);
    }
   update_best_discrete_split(&ksplit, perm, rangelist, iter, featurecounts, node->counts, &bestgain);
   iteration++;
   for (j = 0; j < p->k; j++)
     safe_free(perm[j]);
   free_2d((void**) featurecounts, permsize);
  }
 safe_free(perm);
 safe_free(iter);
 safe_free(rangelist);
 if (bestgain == ISELL)
  {
   for (j = 0; j < p->k; j++)
     safe_free(ksplit.sortorder[j]);
   safe_free(ksplit.sortorder);
   safe_free(ksplit.discretesplit);
   safe_free(ksplit.featurelist);
   node->featureno = LEAF_NODE;
   return 1;
  }
 else
   node->ksplit = ksplit;
 if (!(make_children_discrete(node)))
   return 1;
 create_kforestchildren(node->left, p);
 create_kforestchildren(node->right, p);
 return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movabsq $0x419d6f3454000000, %rax # imm = 0x419D6F3454000000
movq %rax, 0x28(%rsp)
movl $0x0, 0x98(%rdi)
movl $0xfffffffb, 0x30(%rdi) # imm = 0xFFFFFFFB
callq 0x1cfd0
testl %eax, %eax
je 0x1c8cd
movq %rbx, 0x10(%rsp)
movslq 0x8(%r14), %rdi
movl %edi, 0x30(%rsp)
shlq $0x3, %rdi
leaq 0x8b2a7(%rip), %rsi     # 0xa7904
movl $0x14, %edx
callq 0x3a0e1
movq %rax, 0x48(%rsp)
movslq 0x8(%r14), %rdi
testq %rdi, %rdi
jle 0x1c6a3
movq %rax, %r15
xorl %ebx, %ebx
leaq 0x8b283(%rip), %r12     # 0xa7904
movl $0x4, %edi
movq %r12, %rsi
movl $0x16, %edx
callq 0x3a0e1
movq %rax, (%r15,%rbx,8)
incq %rbx
movslq 0x8(%r14), %rdi
cmpq %rdi, %rbx
jl 0x1c681
shlq $0x2, %rdi
leaq 0x8b256(%rip), %r13     # 0xa7904
movq %r13, %rsi
movl $0x17, %edx
callq 0x3a0e1
movq %rax, 0x38(%rsp)
movslq 0x8(%r14), %rdi
shlq $0x2, %rdi
movq %r13, %rsi
movl $0x18, %edx
callq 0x3a0e1
movq %rax, 0x40(%rsp)
movslq 0x8(%r14), %rdi
shlq $0x3, %rdi
movq %r13, %rsi
movl $0x19, %edx
callq 0x3a0e1
movq %rax, %r15
movslq 0x8(%r14), %rdi
shlq $0x2, %rdi
movq %r13, %rsi
movl $0x1a, %edx
callq 0x3a0e1
movq %rax, %r12
movslq 0x8(%r14), %rdi
shlq $0x2, %rdi
movq %r13, %rsi
movl $0x1b, %edx
callq 0x3a0e1
movq %rax, %r13
cmpl $0x0, 0x4(%r14)
jle 0x1c854
xorl %ebx, %ebx
leaq 0xb913a(%rip), %rbp     # 0xd5870
movq %rbx, 0x50(%rsp)
movq (%rbp), %rax
movl 0x1bc(%rax), %edi
callq 0x3afe4
movl 0x8(%r14), %edx
testl %edx, %edx
movq 0x10(%rsp), %rbx
jle 0x1c78f
movq (%rbp), %rcx
movl $0x30f08, %esi          # imm = 0x30F08
addq %rsi, %rcx
xorl %esi, %esi
movq %rax, %rdi
movslq (%rdi), %r8
imulq $0x340, %r8, %r9        # imm = 0x340
cmpl $0x3, (%rcx,%r9)
je 0x1c787
movslq %esi, %rsi
movl %r8d, (%r13,%rsi,4)
incl %esi
movl 0x8(%r14), %edx
addq $0x4, %rdi
cmpl %edx, %esi
jl 0x1c768
movq %rax, %rdi
callq 0x3a180
movq 0x20(%rbx), %rdi
movl 0x8(%r14), %edx
movq %r13, %rsi
leaq 0x1c(%rsp), %rcx
callq 0xa0e62
movq %rax, 0x20(%rsp)
cmpl $0x0, 0x8(%r14)
jle 0x1c7ea
xorl %ebx, %ebx
movq (%rbp), %rax
movslq (%r13,%rbx,4), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
movl 0x30f20(%rax,%rcx), %edi
movl %edi, (%r12,%rbx,4)
callq 0x3afe4
movq %rax, (%r15,%rbx,8)
incq %rbx
movslq 0x8(%r14), %rax
cmpq %rax, %rbx
jl 0x1c7ba
movq 0x10(%rsp), %rax
movq 0xa0(%rax), %r9
leaq 0x28(%rsp), %rax
movq %rax, (%rsp)
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %r13, %rcx
movq 0x20(%rsp), %r8
callq 0x3293f
cmpl $0x0, 0x8(%r14)
jle 0x1c835
xorl %ebx, %ebx
movq (%r15,%rbx,8), %rdi
callq 0x3a180
incq %rbx
movslq 0x8(%r14), %rax
cmpq %rax, %rbx
jl 0x1c820
movq 0x50(%rsp), %rbx
incl %ebx
movl 0x1c(%rsp), %esi
movq 0x20(%rsp), %rdi
callq 0x3a14b
cmpl 0x4(%r14), %ebx
jl 0x1c736
movq %r15, %rdi
callq 0x3a180
movq %r13, %rdi
callq 0x3a180
movq %r12, %rdi
callq 0x3a180
movsd 0x28(%rsp), %xmm0
ucomisd 0x89476(%rip), %xmm0    # 0xa5cf0
jne 0x1c8d7
jp 0x1c8d7
cmpl $0x0, 0x8(%r14)
jle 0x1c8a1
xorl %ebx, %ebx
movq 0x48(%rsp), %rax
movq (%rax,%rbx,8), %rdi
callq 0x3a180
incq %rbx
movslq 0x8(%r14), %rax
cmpq %rax, %rbx
jl 0x1c887
movq 0x48(%rsp), %rdi
callq 0x3a180
movq 0x40(%rsp), %rdi
callq 0x3a180
movq 0x38(%rsp), %rdi
callq 0x3a180
movq 0x10(%rsp), %rax
movl $0xffffffff, 0x30(%rax) # imm = 0xFFFFFFFF
jmp 0x1c919
movq %rbx, %rdi
callq 0x1cab0
jmp 0x1c919
movupd 0x30(%rsp), %xmm0
movups 0x40(%rsp), %xmm1
movq 0x10(%rsp), %rbx
movups %xmm1, 0x150(%rbx)
movupd %xmm0, 0x140(%rbx)
movq %rbx, %rdi
callq 0x331ef
testl %eax, %eax
je 0x1c919
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x1c604
movq 0x8(%rbx), %rdi
movq %r14, %rsi
callq 0x1c604
movl $0x1, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq