// File: /workspace/github_c_makefile_star2_O2/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)
andl $0x0, 0x98(%rdi)
movl $0xfffffffb, 0x30(%rdi) # imm = 0xFFFFFFFB
callq 0x1ab8f
testl %eax, %eax
je 0x1a4e9
movq %rbx, 0x10(%rsp)
movslq 0x8(%r14), %rdi
movl %edi, 0x30(%rsp)
shlq $0x3, %rdi
leaq 0x7d5d9(%rip), %r15     # 0x97887
pushq $0x14
popq %rdx
movq %r15, %rsi
callq 0x34f59
movq %rax, %r12
movq %rax, 0x48(%rsp)
xorl %ebx, %ebx
pushq $0x4
popq %r13
pushq $0x16
popq %rbp
movslq 0x8(%r14), %rdi
cmpq %rdi, %rbx
jge 0x1a2e9
movq %r13, %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0x34f59
movq %rax, (%r12,%rbx,8)
incq %rbx
jmp 0x1a2ca
shlq $0x2, %rdi
leaq 0x7d593(%rip), %r15     # 0x97887
pushq $0x17
popq %rdx
movq %r15, %rsi
callq 0x34f59
leaq 0x30(%rsp), %rbx
movq %rax, 0x8(%rbx)
movslq 0x8(%r14), %rdi
shlq $0x2, %rdi
pushq $0x18
popq %rdx
movq %r15, %rsi
callq 0x34f59
movq %rax, 0x10(%rbx)
movslq 0x8(%r14), %rdi
shlq $0x3, %rdi
pushq $0x19
popq %rdx
movq %r15, %rsi
callq 0x34f59
movq %rax, %r12
movslq 0x8(%r14), %rdi
shlq $0x2, %rdi
pushq $0x1a
popq %rdx
movq %r15, %rsi
callq 0x34f59
movq %rax, %r13
movslq 0x8(%r14), %rdi
shlq $0x2, %rdi
pushq $0x1b
popq %rdx
movq %r15, %rsi
callq 0x34f59
movq %rax, %rbp
xorl %r15d, %r15d
leaq 0xb3505(%rip), %rbx     # 0xcd870
cmpl 0x4(%r14), %r15d
jge 0x1a47d
movq (%rbx), %rax
movl 0x1bc(%rax), %edi
callq 0x35cf7
movq (%rbx), %rcx
movl $0x30f08, %edx          # imm = 0x30F08
addq %rdx, %rcx
xorl %edx, %edx
movq %rax, %rsi
cmpl 0x8(%r14), %edx
jge 0x1a3ba
movslq (%rsi), %rdi
imulq $0x340, %rdi, %r8       # imm = 0x340
cmpl $0x3, (%rcx,%r8)
je 0x1a3b4
movslq %edx, %r8
movl %edi, (%rbp,%r8,4)
incl %edx
addq $0x4, %rsi
jmp 0x1a393
movq %r15, 0x50(%rsp)
movq %rax, %rdi
callq 0x34ff7
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rdi
movl 0x8(%r14), %edx
movq %rbp, %rsi
leaq 0x1c(%rsp), %rcx
callq 0x9193f
movq %rax, 0x20(%rsp)
xorl %r15d, %r15d
movslq 0x8(%r14), %rax
cmpq %rax, %r15
jge 0x1a41b
movq (%rbx), %rax
movslq (%rbp,%r15,4), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
movl 0x30f20(%rax,%rcx), %edi
movl %edi, (%r13,%r15,4)
callq 0x35cf7
movq %rax, (%r12,%r15,8)
incq %r15
jmp 0x1a3e9
movq 0x10(%rsp), %rax
movq 0xa0(%rax), %r9
leaq 0x28(%rsp), %rax
movq %rax, (%rsp)
leaq 0x30(%rsp), %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %rbp, %rcx
movq 0x20(%rsp), %r8
callq 0x2e728
xorl %r15d, %r15d
movslq 0x8(%r14), %rax
cmpq %rax, %r15
jge 0x1a462
movq (%r12,%r15,8), %rdi
callq 0x34ff7
incq %r15
jmp 0x1a44b
movq 0x50(%rsp), %r15
incl %r15d
movl 0x1c(%rsp), %esi
movq 0x20(%rsp), %rdi
callq 0x34fc3
jmp 0x1a36b
movq %r12, %rdi
callq 0x34ff7
movq %rbp, %rdi
callq 0x34ff7
movq %r13, %rdi
callq 0x34ff7
movsd 0x28(%rsp), %xmm0
ucomisd 0x7b855(%rip), %xmm0    # 0x95cf8
jne 0x1a4f3
jp 0x1a4f3
xorl %ebx, %ebx
movslq 0x8(%r14), %rax
movq 0x48(%rsp), %rdi
cmpq %rax, %rbx
jge 0x1a4c5
movq (%rdi,%rbx,8), %rdi
callq 0x34ff7
incq %rbx
jmp 0x1a4a9
callq 0x34ff7
movq 0x40(%rsp), %rdi
callq 0x34ff7
movq 0x38(%rsp), %rdi
callq 0x34ff7
movq 0x10(%rsp), %rax
orl $-0x1, 0x30(%rax)
jmp 0x1a533
movq %rbx, %rdi
callq 0x1a6ac
jmp 0x1a533
movups 0x30(%rsp), %xmm0
movups 0x40(%rsp), %xmm1
movq 0x10(%rsp), %rbx
movups %xmm1, 0x150(%rbx)
movups %xmm0, 0x140(%rbx)
movq %rbx, %rdi
callq 0x2eed0
testl %eax, %eax
je 0x1a533
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x1a258
movq 0x8(%rbx), %rdi
movq %r14, %rsi
callq 0x1a258
pushq $0x1
popq %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq