// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/instancelist.c
// Function: divide_instancelist_into_parts
Instanceptr* divide_instancelist_into_parts(Instanceptr* parentlist, int partcount)
{
 /*!Last Changed 03.08.2006*/
 int i = 0, *classes = NULL, *classcounts = NULL, *partition, pos;
 Instanceptr *result, *next, ptmp, pnext;
 result = safemalloc(partcount * sizeof(Instanceptr), "divide_instancelist_into_parts", 3);
 next = safecalloc(partcount, sizeof(Instanceptr), "divide_instancelist_into_parts", 4);
 if (current_dataset->classno > 0)
  {
   classes = find_classes(*parentlist);
   classcounts = find_class_counts(*parentlist);
  }
 partition = stratified_partition(classes, data_size(*parentlist), current_dataset->classno, classcounts);
 i = 0;
 ptmp = (*parentlist);
 while (ptmp)
  {
   pnext = ptmp->next;
   pos = partition[i] % partcount;
   if (!next[pos])
     result[pos] = ptmp;
   else
     next[pos]->next = ptmp;
   next[pos] = ptmp;
   ptmp = pnext;
   i++;
  }
 for (i = 0; i < partcount; i++)
   if (next[i])
     next[i]->next = NULL;
 (*parentlist) = NULL;
 if (current_dataset->classno > 0)
  {
   safe_free(classcounts);
   safe_free(classes);
  }
 safe_free(partition);
 safe_free(next);
 return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl $0x0, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movslq -0xc(%rbp), %rdi
shlq $0x3, %rdi
leaq 0x9fa39(%rip), %rsi     # 0xe56ae
movl $0x3, %edx
callq 0x52d70
movq %rax, -0x38(%rbp)
movslq -0xc(%rbp), %rdi
movl $0x8, %esi
leaq 0x9fa1b(%rip), %rdx     # 0xe56ae
movl $0x4, %ecx
callq 0x52f40
movq %rax, -0x40(%rbp)
leaq 0xbfb98(%rip), %rax     # 0x105840
movq (%rax), %rax
cmpl $0x0, 0x10(%rax)
jle 0x45cd1
movq -0x8(%rbp), %rax
movq (%rax), %rdi
callq 0x18500
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
callq 0x183a0
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
callq 0x449f0
movq -0x58(%rbp), %rdi
movl %eax, %esi
leaq 0xbfb4e(%rip), %rax     # 0x105840
movq (%rax), %rax
movl 0x10(%rax), %edx
movq -0x20(%rbp), %rcx
callq 0x43d20
movq %rax, -0x28(%rbp)
movl $0x0, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x45d94
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x28(%rbp), %rax
movslq -0x10(%rbp), %rcx
movl (%rax,%rcx,4), %eax
cltd
idivl -0xc(%rbp)
movl %edx, -0x2c(%rbp)
movq -0x40(%rbp), %rax
movslq -0x2c(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jne 0x45d5d
movq -0x48(%rbp), %rdx
movq -0x38(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x45d71
movq -0x48(%rbp), %rcx
movq -0x40(%rbp), %rax
movslq -0x2c(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, 0x10(%rax)
movq -0x48(%rbp), %rdx
movq -0x40(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x50(%rbp), %rax
movq %rax, -0x48(%rbp)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x45d17
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x45dd3
movq -0x40(%rbp), %rax
movslq -0x10(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x45dc6
movq -0x40(%rbp), %rax
movslq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq $0x0, 0x10(%rax)
jmp 0x45dc8
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x45d9b
movq -0x8(%rbp), %rax
movq $0x0, (%rax)
leaq 0xbfa5b(%rip), %rax     # 0x105840
movq (%rax), %rax
cmpl $0x0, 0x10(%rax)
jle 0x45e00
movq -0x20(%rbp), %rdi
callq 0x52e80
movq -0x18(%rbp), %rdi
callq 0x52e80
movq -0x28(%rbp), %rdi
callq 0x52e80
movq -0x40(%rbp), %rdi
callq 0x52e80
movq -0x38(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)