// File: /workspace/github_c_makefile_star2_O1/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, 0x48(%rsp)
movl $0x0, 0x98(%rdi)
movl $0xfffffffb, 0x30(%rdi) # imm = 0xFFFFFFFB
callq 0x1c85f
testl %eax, %eax
je 0x1c1c7
movq %rbx, 0x10(%rsp)
movslq 0x8(%r14), %rdi
movl %edi, 0x28(%rsp)
shlq $0x3, %rdi
leaq 0x8896f(%rip), %rsi     # 0xa48c4
movl $0x14, %edx
callq 0x390f5
movq %rax, 0x40(%rsp)
movl 0x8(%r14), %eax
testl %eax, %eax
jle 0x1bf9c
xorl %ebx, %ebx
leaq 0x8894f(%rip), %r15     # 0xa48c4
movl $0x4, %edi
movq %r15, %rsi
movl $0x16, %edx
callq 0x390f5
movq 0x40(%rsp), %rcx
movq %rax, (%rcx,%rbx,8)
incq %rbx
movslq 0x8(%r14), %rax
cmpq %rax, %rbx
jl 0x1bf75
movslq %eax, %rdi
shlq $0x2, %rdi
leaq 0x8891a(%rip), %r13     # 0xa48c4
movq %r13, %rsi
movl $0x17, %edx
callq 0x390f5
movq %rax, 0x30(%rsp)
movslq 0x8(%r14), %rdi
shlq $0x2, %rdi
movq %r13, %rsi
movl $0x18, %edx
callq 0x390f5
movq %rax, 0x38(%rsp)
movslq 0x8(%r14), %rdi
shlq $0x3, %rdi
movq %r13, %rsi
movl $0x19, %edx
callq 0x390f5
movq %rax, %r15
movslq 0x8(%r14), %rdi
shlq $0x2, %rdi
movq %r13, %rsi
movl $0x1a, %edx
callq 0x390f5
movq %rax, %r12
movslq 0x8(%r14), %rdi
shlq $0x2, %rdi
movq %r13, %rsi
movl $0x1b, %edx
callq 0x390f5
movq %rax, %r13
cmpl $0x0, 0x4(%r14)
jle 0x1c14d
xorl %ebx, %ebx
leaq 0xb683e(%rip), %rbp     # 0xd2870
movq (%rbp), %rax
movl 0x1bc(%rax), %edi
callq 0x39fdc
cmpl $0x0, 0x8(%r14)
jle 0x1c07e
movq (%rbp), %rcx
movl $0x30f08, %edx          # imm = 0x30F08
addq %rdx, %rcx
xorl %edx, %edx
movq %rax, %rsi
movslq (%rsi), %rdi
imulq $0x340, %rdi, %r8       # imm = 0x340
cmpl $0x3, (%rcx,%r8)
je 0x1c074
movslq %edx, %rdx
movl %edi, (%r13,%rdx,4)
incl %edx
addq $0x4, %rsi
cmpl 0x8(%r14), %edx
jl 0x1c059
movq %rbx, 0x50(%rsp)
movq %rax, %rdi
callq 0x39194
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rdi
movl 0x8(%r14), %edx
movq %r13, %rsi
leaq 0x1c(%rsp), %rcx
callq 0x9de4b
movq %rax, 0x20(%rsp)
cmpl $0x0, 0x8(%r14)
jle 0x1c0e3
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 0x39fdc
movq %rax, (%r15,%rbx,8)
incq %rbx
movslq 0x8(%r14), %rax
cmpq %rax, %rbx
jl 0x1c0b3
movq 0x10(%rsp), %rax
movq 0xa0(%rax), %r9
leaq 0x48(%rsp), %rax
movq %rax, (%rsp)
leaq 0x28(%rsp), %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %r13, %rcx
movq 0x20(%rsp), %r8
callq 0x3200b
cmpl $0x0, 0x8(%r14)
jle 0x1c12e
xorl %ebx, %ebx
movq (%r15,%rbx,8), %rdi
callq 0x39194
incq %rbx
movslq 0x8(%r14), %rax
cmpq %rax, %rbx
jl 0x1c119
movq 0x50(%rsp), %rbx
incl %ebx
movl 0x1c(%rsp), %esi
movq 0x20(%rsp), %rdi
callq 0x3915f
cmpl 0x4(%r14), %ebx
jl 0x1c032
movq %r15, %rdi
callq 0x39194
movq %r13, %rdi
callq 0x39194
movq %r12, %rdi
callq 0x39194
movsd 0x48(%rsp), %xmm0
ucomisd 0x86b7d(%rip), %xmm0    # 0xa2cf0
jne 0x1c1d1
jp 0x1c1d1
cmpl $0x0, 0x8(%r14)
movq 0x10(%rsp), %r15
jle 0x1c19f
xorl %ebx, %ebx
movq 0x40(%rsp), %rax
movq (%rax,%rbx,8), %rdi
callq 0x39194
incq %rbx
movslq 0x8(%r14), %rax
cmpq %rax, %rbx
jl 0x1c185
movq 0x40(%rsp), %rdi
callq 0x39194
movq 0x38(%rsp), %rdi
callq 0x39194
movq 0x30(%rsp), %rdi
callq 0x39194
movl $0xffffffff, 0x30(%r15) # imm = 0xFFFFFFFF
jmp 0x1c213
movq %rbx, %rdi
callq 0x1c39c
jmp 0x1c213
movupd 0x28(%rsp), %xmm0
movups 0x38(%rsp), %xmm1
movq 0x10(%rsp), %rbx
movups %xmm1, 0x150(%rbx)
movupd %xmm0, 0x140(%rbx)
movq %rbx, %rdi
callq 0x327f1
testl %eax, %eax
je 0x1c213
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x1befc
movq 0x8(%rbx), %rdi
movq %r14, %rsi
callq 0x1befc
movl $0x1, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq