// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/univariatetree.c
// Function: sort_instances
Instanceptr sort_instances(Instanceptr instances,int fno,int* size)
{
 /*!Last Changed 21.05.2005*/
 /*!Last Changed 02.02.2004*/
 /*!Last Changed 26.01.2003*/
 Instanceptr result, tmp = instances;
 int i, sorted = 1;
 (*size) = data_size(instances);
 result = (Instanceptr)safemalloc((*size)*sizeof(Instance), "sort_instances", 4);
 i = 0;
 while (tmp)
  {
   result[i] = (*tmp);
   if (i > 0)
    {
     if (!mustrealize)
      {
       if (current_dataset->features[fno].type == INTEGER)
        {
         if (result[i - 1].values[fno].intvalue > result[i].values[fno].intvalue)
           sorted = 0;
        }
       else
        {
         if (result[i - 1].values[fno].floatvalue > result[i].values[fno].floatvalue)
           sorted = 0;
        }
      }
     else
      {
       if (real_feature(&(result[i - 1]), fno) > real_feature(&(result[i]), fno))
         sorted = 0;
      }
    }
   i++;   
   tmp = tmp->next;
  }
 if (!sorted)
  {
   if (!mustrealize && current_dataset->features[fno].type == INTEGER && (current_dataset->features[fno].max.intvalue - current_dataset->features[fno].min.intvalue < (*size)))
    {
     if (!bucketsort_instances(result, *size, fno))
       quicksort_instances(result, 0, i - 1, fno);
    }
   else
     quicksort_instances(result, 0, i - 1, fno);  
  }
 return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
movl $0x1, -0x30(%rbp)
movq -0x8(%rbp), %rdi
callq 0x449f0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movq -0x18(%rbp), %rax
movslq (%rax), %rax
imulq $0x30, %rax, %rdi
leaq 0x129b1(%rip), %rsi     # 0xeea46
movl $0x4, %edx
callq 0x52d70
movq %rax, -0x20(%rbp)
movl $0x0, -0x2c(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0xdc203
movq -0x20(%rbp), %rdi
movslq -0x2c(%rbp), %rax
imulq $0x30, %rax, %rax
addq %rax, %rdi
movq -0x28(%rbp), %rsi
movl $0x30, %edx
callq 0x42b0
cmpl $0x0, -0x2c(%rbp)
jle 0xdc1e9
leaq 0x305e91(%rip), %rax    # 0x3e1f74
cmpl $0x0, (%rax)
jne 0xdc199
leaq 0x2974d(%rip), %rax     # 0x105840
movq (%rax), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0xc(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
cmpl $0x0, (%rax)
jne 0xdc151
movq -0x20(%rbp), %rax
movl -0x2c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movslq -0xc(%rbp), %rcx
movl (%rax,%rcx,8), %eax
movq -0x20(%rbp), %rcx
movslq -0x2c(%rbp), %rdx
imulq $0x30, %rdx, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movslq -0xc(%rbp), %rdx
cmpl (%rcx,%rdx,8), %eax
jle 0xdc14f
movl $0x0, -0x30(%rbp)
jmp 0xdc197
movq -0x20(%rbp), %rax
movl -0x2c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movslq -0xc(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movslq -0xc(%rbp), %rcx
ucomisd (%rax,%rcx,8), %xmm0
jbe 0xdc195
movl $0x0, -0x30(%rbp)
jmp 0xdc197
jmp 0xdc1e7
movq -0x20(%rbp), %rdi
movl -0x2c(%rbp), %eax
subl $0x1, %eax
cltq
imulq $0x30, %rax, %rax
addq %rax, %rdi
movl -0xc(%rbp), %esi
callq 0x42c40
movsd %xmm0, -0x38(%rbp)
movq -0x20(%rbp), %rdi
movslq -0x2c(%rbp), %rax
imulq $0x30, %rax, %rax
addq %rax, %rdi
movl -0xc(%rbp), %esi
callq 0x42c40
movaps %xmm0, %xmm1
movsd -0x38(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xdc1e5
movl $0x0, -0x30(%rbp)
jmp 0xdc1e7
jmp 0xdc1e9
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0xdc0aa
cmpl $0x0, -0x30(%rbp)
jne 0xdc2ce
leaq 0x305d60(%rip), %rax    # 0x3e1f74
cmpl $0x0, (%rax)
jne 0xdc2b8
leaq 0x2961c(%rip), %rax     # 0x105840
movq (%rax), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0xc(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
cmpl $0x0, (%rax)
jne 0xdc2b8
leaq 0x295f9(%rip), %rax     # 0x105840
movq (%rax), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0xc(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
movl 0x10(%rax), %eax
leaq 0x295d8(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
addq $0x30f08, %rcx          # imm = 0x30F08
movslq -0xc(%rbp), %rdx
imulq $0x340, %rdx, %rdx      # imm = 0x340
addq %rdx, %rcx
subl 0x8(%rcx), %eax
movq -0x18(%rbp), %rcx
cmpl (%rcx), %eax
jge 0xdc2b8
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rax
movl (%rax), %esi
movl -0xc(%rbp), %edx
callq 0xdbc70
cmpl $0x0, %eax
jne 0xdc2b6
movq -0x20(%rbp), %rdi
movl -0x2c(%rbp), %edx
subl $0x1, %edx
movl -0xc(%rbp), %ecx
xorl %esi, %esi
callq 0xdc2e0
jmp 0xdc2cc
movq -0x20(%rbp), %rdi
movl -0x2c(%rbp), %edx
subl $0x1, %edx
movl -0xc(%rbp), %ecx
xorl %esi, %esi
callq 0xdc2e0
jmp 0xdc2ce
movq -0x20(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)