// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/univariatetree.c
// Function: bucketsort_instances
int bucketsort_instances(Instanceptr instances, int size, int fno)
{
 /*!Last Changed 26.11.2005 removed bug counts is deallocated before buckets is deallocated*/
 /*!Last Changed 21.05.2005*/
 int **buckets, *counts, *current, bcount, i, j, k, bucketindex, bottom = current_dataset->features[fno].min.intvalue;
 Instanceptr tmplist;
 bcount = current_dataset->features[fno].max.intvalue - bottom + 1;
 counts = safecalloc(bcount, sizeof(int), "bucketsort_instances", 4);
 buckets = safemalloc(bcount * sizeof(int *), "bucketsort_instances", 5);
 tmplist = safemalloc(size * sizeof(Instance), "bucketsort_instances", 6);
 for (i = 0; i < size; i++)
  {
   bucketindex = instances[i].values[fno].intvalue - bottom;
   if (bucketindex >= bcount || bucketindex < 0)
    {
     printf(m1267, fno, instances[i].values[fno].intvalue, bucketindex, current_dataset->features[fno].min.intvalue, current_dataset->features[fno].max.intvalue);
     safe_free(counts);
     safe_free(buckets);
     safe_free(tmplist);
     return 0;
    }
   (counts[bucketindex])++;
  }
 for (i = 0; i < bcount; i++)
   if (counts[i] > 0)
     buckets[i] = safemalloc(counts[i] * sizeof(int), "bucketsort_instances", 14);
   else
     buckets[i] = NULL;
 current = safecalloc(bcount, sizeof(int), "bucketsort_instances", 17);
 for (i = 0; i < size; i++)
  {
   bucketindex = instances[i].values[fno].intvalue - bottom;
   buckets[bucketindex][current[bucketindex]] = i;
   (current[bucketindex])++;
  }
 k = 0;
 for (i = 0; i < bcount; i++)
   for (j = 0; j < counts[i]; j++)
    {
     tmplist[k] = instances[buckets[i][j]];
     k++;
    }
 for (k = 0; k < size; k++)
   instances[k] = tmplist[k];
 safe_free(current);
 safe_free(tmplist);
 for (i = 0; i < bcount; i++)
    if (counts[i] > 0)
      safe_free(buckets[i]);
 safe_free(counts);
 safe_free(buckets);
 return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
leaq 0x29bb7(%rip), %rax     # 0x105840
movq (%rax), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0x18(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x48(%rbp)
leaq 0x29b93(%rip), %rax     # 0x105840
movq (%rax), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0x18(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
movl 0x10(%rax), %eax
subl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movslq -0x34(%rbp), %rdi
movl $0x4, %esi
leaq 0x12d60(%rip), %rdx     # 0xeea40
movl $0x4, %ecx
callq 0x52f40
movq %rax, -0x28(%rbp)
movslq -0x34(%rbp), %rdi
shlq $0x3, %rdi
leaq 0x12d43(%rip), %rsi     # 0xeea40
movl $0x5, %edx
callq 0x52d70
movq %rax, -0x20(%rbp)
movslq -0x14(%rbp), %rax
imulq $0x30, %rax, %rdi
leaq 0x12d26(%rip), %rsi     # 0xeea40
movl $0x6, %edx
callq 0x52d70
movq %rax, -0x50(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0xdbe23
movq -0x10(%rbp), %rax
movslq -0x38(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movslq -0x18(%rbp), %rcx
movl (%rax,%rcx,8), %eax
subl -0x48(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0xdbd6c
cmpl $0x0, -0x44(%rbp)
jge 0xdbe04
movl -0x18(%rbp), %esi
movq -0x10(%rbp), %rax
movslq -0x38(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movslq -0x18(%rbp), %rcx
movl (%rax,%rcx,8), %edx
movl -0x44(%rbp), %ecx
leaq 0x29aae(%rip), %rax     # 0x105840
movq (%rax), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0x18(%rbp), %rdi
imulq $0x340, %rdi, %rdi      # imm = 0x340
addq %rdi, %rax
movl 0x8(%rax), %r8d
leaq 0x29a8c(%rip), %rax     # 0x105840
movq (%rax), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0x18(%rbp), %rdi
imulq $0x340, %rdi, %rdi      # imm = 0x340
addq %rdi, %rax
movl 0x10(%rax), %r9d
leaq 0x12c7f(%rip), %rdi     # 0xeea55
movb $0x0, %al
callq 0x4030
movq -0x28(%rbp), %rdi
callq 0x52e80
movq -0x20(%rbp), %rdi
callq 0x52e80
movq -0x50(%rbp), %rdi
callq 0x52e80
movl $0x0, -0x4(%rbp)
jmp 0xdc043
movq -0x28(%rbp), %rax
movslq -0x44(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0xdbd2f
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0xdbe8f
movq -0x28(%rbp), %rax
movslq -0x38(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jle 0xdbe72
movq -0x28(%rbp), %rax
movslq -0x38(%rbp), %rcx
movslq (%rax,%rcx,4), %rdi
shlq $0x2, %rdi
leaq 0x12be9(%rip), %rsi     # 0xeea40
movl $0xe, %edx
callq 0x52d70
movq %rax, %rdx
movq -0x20(%rbp), %rax
movslq -0x38(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0xdbe82
movq -0x20(%rbp), %rax
movslq -0x38(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
jmp 0xdbe84
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0xdbe2a
movslq -0x34(%rbp), %rdi
movl $0x4, %esi
leaq 0x12ba1(%rip), %rdx     # 0xeea40
movl $0x11, %ecx
callq 0x52f40
movq %rax, -0x30(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0xdbf15
movq -0x10(%rbp), %rax
movslq -0x38(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movslq -0x18(%rbp), %rcx
movl (%rax,%rcx,8), %eax
subl -0x48(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x38(%rbp), %edx
movq -0x20(%rbp), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq -0x30(%rbp), %rcx
movslq -0x44(%rbp), %rsi
movslq (%rcx,%rsi,4), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x30(%rbp), %rax
movslq -0x44(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0xdbeb4
movl $0x0, -0x40(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0xdbf9b
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x28(%rbp), %rcx
movslq -0x38(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0xdbf8e
movq -0x50(%rbp), %rdi
movslq -0x40(%rbp), %rax
imulq $0x30, %rax, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rax
movslq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x3c(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
imulq $0x30, %rax, %rax
addq %rax, %rsi
movl $0x30, %edx
callq 0x42b0
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0xdbf32
jmp 0xdbf90
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0xdbf23
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0xdbfdd
movq -0x10(%rbp), %rdi
movslq -0x40(%rbp), %rax
imulq $0x30, %rax, %rax
addq %rax, %rdi
movq -0x50(%rbp), %rsi
movslq -0x40(%rbp), %rax
imulq $0x30, %rax, %rax
addq %rax, %rsi
movl $0x30, %edx
callq 0x42b0
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0xdbfa2
movq -0x30(%rbp), %rdi
callq 0x52e80
movq -0x50(%rbp), %rdi
callq 0x52e80
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0xdc02a
movq -0x28(%rbp), %rax
movslq -0x38(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jle 0xdc01d
movq -0x20(%rbp), %rax
movslq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x52e80
jmp 0xdc01f
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0xdbff6
movq -0x28(%rbp), %rdi
callq 0x52e80
movq -0x20(%rbp), %rdi
callq 0x52e80
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)