// File: /workspace/github_c_makefile_star2_O0/theck01[P]offbrand_lib/src/classes/obvector.c
// Function: obvector_recursive_sort
obj ** obvector_recursive_sort(obj **to_sort, uint32_t size, int8_t order,
                             ob_compare_fptr funct){

  uint32_t i,j, split;
  obj **left_sorted, **right_sorted;
  obj **sorted;

   /* base case, if the vector is of size one, its sorted */
  if(size <= 1){
    sorted = malloc(sizeof(obj *)*size);
    assert(sorted != NULL);
    *sorted = *to_sort;
    return sorted;
  }

  split = size/2;

  /* sort left half and right half of array */
  left_sorted = obvector_recursive_sort(to_sort, split, order, funct);
  right_sorted = obvector_recursive_sort(to_sort+split, size-split,
                                       order, funct);

  sorted = malloc(sizeof(obj *)*size);
  assert(sorted != NULL);

  /* merge sorted halves */
  i=0;
  j=0;

  /* while there are elements in both halves to be added to sorted */
  while(i < split && j < (size-split)){

    /* if the comparison of the left to the right matches the desired order,
     * then the next item to go in the sorted array is from the left. Ensure
     * that NULL is left at the tail of the sorted array as well */
    if(funct(left_sorted[i], right_sorted[j]) == order ||
        right_sorted[j] == NULL){
      sorted[i+j] = left_sorted[i];
      i++;
    }
    else{
      sorted[i+j] = right_sorted[j];
      j++;
    }
  }

  /* place remaining elements from remaining half in sorted */
  if(i == split){
    while(j<(size - split)){
      sorted[i+j] = right_sorted[j];
      j++;
    }
  }
  else{
    while(i<split){
      sorted[i+j] = left_sorted[i];
      i++;
    }
  }

  /* free sorted half arrays */
  free(left_sorted);
  free(right_sorted);

  return sorted;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movb %dl, %al
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movb %al, -0x15(%rbp)
movq %rcx, -0x20(%rbp)
cmpl $0x1, -0x14(%rbp)
ja 0x2773
movl -0x14(%rbp), %eax
movl %eax, %edi
shlq $0x3, %rdi
callq 0x10a0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x2739
jmp 0x2758
leaq 0x23e0(%rip), %rdi      # 0x4b20
leaq 0x20d8(%rip), %rsi      # 0x481f
movl $0xf2, %edx
leaq 0x23dc(%rip), %rcx      # 0x4b2f
callq 0x1050
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movq -0x48(%rbp), %rax
movq %rcx, (%rax)
movq -0x48(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x293d
movl -0x14(%rbp), %eax
shrl %eax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rdi
movl -0x2c(%rbp), %esi
movb -0x15(%rbp), %al
movq -0x20(%rbp), %rcx
movsbl %al, %edx
callq 0x2700
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
movl -0x2c(%rbp), %eax
shlq $0x3, %rax
addq %rax, %rdi
movl -0x14(%rbp), %esi
subl -0x2c(%rbp), %esi
movb -0x15(%rbp), %al
movq -0x20(%rbp), %rcx
movsbl %al, %edx
callq 0x2700
movq %rax, -0x40(%rbp)
movl -0x14(%rbp), %eax
movl %eax, %edi
shlq $0x3, %rdi
callq 0x10a0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x27d7
jmp 0x27f6
leaq 0x2342(%rip), %rdi      # 0x4b20
leaq 0x203a(%rip), %rsi      # 0x481f
movl $0xff, %edx
leaq 0x233e(%rip), %rcx      # 0x4b2f
callq 0x1050
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x24(%rbp), %ecx
xorl %eax, %eax
cmpl -0x2c(%rbp), %ecx
movb %al, -0x49(%rbp)
jae 0x2822
movl -0x28(%rbp), %eax
movl -0x14(%rbp), %ecx
subl -0x2c(%rbp), %ecx
cmpl %ecx, %eax
setb %al
movb %al, -0x49(%rbp)
movb -0x49(%rbp), %al
testb $0x1, %al
jne 0x282e
jmp 0x28b2
movq -0x20(%rbp), %rax
movq -0x38(%rbp), %rcx
movl -0x24(%rbp), %edx
movq (%rcx,%rdx,8), %rdi
movq -0x40(%rbp), %rcx
movl -0x28(%rbp), %edx
movq (%rcx,%rdx,8), %rsi
callq *%rax
movsbl %al, %eax
movsbl -0x15(%rbp), %ecx
cmpl %ecx, %eax
je 0x2863
movq -0x40(%rbp), %rax
movl -0x28(%rbp), %ecx
cmpq $0x0, (%rax,%rcx,8)
jne 0x2889
movq -0x38(%rbp), %rax
movl -0x24(%rbp), %ecx
movq (%rax,%rcx,8), %rdx
movq -0x48(%rbp), %rax
movl -0x24(%rbp), %ecx
addl -0x28(%rbp), %ecx
movl %ecx, %ecx
movq %rdx, (%rax,%rcx,8)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x28ad
movq -0x40(%rbp), %rax
movl -0x28(%rbp), %ecx
movq (%rax,%rcx,8), %rdx
movq -0x48(%rbp), %rax
movl -0x24(%rbp), %ecx
addl -0x28(%rbp), %ecx
movl %ecx, %ecx
movq %rdx, (%rax,%rcx,8)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x2804
movl -0x24(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jne 0x28f1
jmp 0x28bc
movl -0x28(%rbp), %eax
movl -0x14(%rbp), %ecx
subl -0x2c(%rbp), %ecx
cmpl %ecx, %eax
jae 0x28ef
movq -0x40(%rbp), %rax
movl -0x28(%rbp), %ecx
movq (%rax,%rcx,8), %rdx
movq -0x48(%rbp), %rax
movl -0x24(%rbp), %ecx
addl -0x28(%rbp), %ecx
movl %ecx, %ecx
movq %rdx, (%rax,%rcx,8)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x28bc
jmp 0x2923
jmp 0x28f3
movl -0x24(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jae 0x2921
movq -0x38(%rbp), %rax
movl -0x24(%rbp), %ecx
movq (%rax,%rcx,8), %rdx
movq -0x48(%rbp), %rax
movl -0x24(%rbp), %ecx
addl -0x28(%rbp), %ecx
movl %ecx, %ecx
movq %rdx, (%rax,%rcx,8)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x28f3
jmp 0x2923
movq -0x38(%rbp), %rdi
callq 0x1030
movq -0x40(%rbp), %rdi
callq 0x1030
movq -0x48(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)