// File: sisong[P]ApkDiffPatch/HDiffPatch/libHDiffPatch/HDiff/private_diff/libdivsufsort/trsort.c.inc.h
// Function: trsort64(long long*, long long*, long long, long long)
void
trsort(sastore_t *ISA, sastore_t* SA, saidx_t n, saidx_t depth) {
  sastore_t*ISAd;
  sastore_t*first, *last;
  trbudget_t budget;
  saidx_t t, skip, unsorted;

  trbudget_init(&budget, tr_ilg(n) * 2 / 3, n);
/*  trbudget_init(&budget, tr_ilg(n) * 3 / 4, n); */
  for(ISAd = ISA + depth; -n < *SA; ISAd += ISAd - ISA) {
    first = SA;
    skip = 0;
    unsorted = 0;
    do {
      if((t = *first) < 0) { first -= t; skip += t; }
      else {
        if(skip != 0) { *(first + skip) = skip; skip = 0; }
        last = SA + ISA[t] + 1;
        if(1 < (last - first)) {
          budget.count = 0;
          tr_introsort(ISA, ISAd, SA, first, last, &budget);
          if(budget.count != 0) { unsorted += budget.count; }
          else { skip = (saidx_t)(first - last); }
        } else if((last - first) == 1) {
          skip = -1;
        }
        first = last;
      }
    } while(first < (SA + n));
    if(skip != 0) { *(first + skip) = skip; }
    if(unsorted == 0) { break; }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x18(%rbp), %rdi
callq 0x55d70
shll %eax
movl $0x3, %ecx
cltd
idivl %ecx
movslq %eax, %rsi
movq -0x18(%rbp), %rdx
leaq -0x58(%rbp), %rdi
callq 0x55d30
movq -0x8(%rbp), %rax
movq -0x20(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
xorl %eax, %eax
subq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq (%rcx), %rax
jge 0x55d20
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movq $0x0, -0x68(%rbp)
movq $0x0, -0x70(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
jge 0x55bf3
movq -0x60(%rbp), %rdx
movq -0x30(%rbp), %rax
xorl %ecx, %ecx
subq %rdx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x60(%rbp), %rax
addq -0x68(%rbp), %rax
movq %rax, -0x68(%rbp)
jmp 0x55cc0
cmpq $0x0, -0x68(%rbp)
je 0x55c12
movq -0x68(%rbp), %rdx
movq -0x30(%rbp), %rax
movq -0x68(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq $0x0, -0x68(%rbp)
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rcx
movq -0x60(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
addq $0x8, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rcx
movq -0x30(%rbp), %rax
subq %rax, %rcx
sarq $0x3, %rcx
movl $0x1, %eax
cmpq %rcx, %rax
jge 0x55c99
movq $0x0, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x10(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %r8
leaq -0x58(%rbp), %r9
callq 0x55f20
cmpq $0x0, -0x40(%rbp)
je 0x55c84
movq -0x40(%rbp), %rax
addq -0x70(%rbp), %rax
movq %rax, -0x70(%rbp)
jmp 0x55c97
movq -0x30(%rbp), %rax
movq -0x38(%rbp), %rcx
subq %rcx, %rax
sarq $0x3, %rax
movq %rax, -0x68(%rbp)
jmp 0x55cb8
movq -0x38(%rbp), %rax
movq -0x30(%rbp), %rcx
subq %rcx, %rax
sarq $0x3, %rax
cmpq $0x1, %rax
jne 0x55cb6
movq $-0x1, -0x68(%rbp)
jmp 0x55cb8
movq -0x38(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x55cc2
movq -0x30(%rbp), %rax
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %rdx
shlq $0x3, %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
jb 0x55bb9
cmpq $0x0, -0x68(%rbp)
je 0x55cf5
movq -0x68(%rbp), %rdx
movq -0x30(%rbp), %rax
movq -0x68(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
cmpq $0x0, -0x70(%rbp)
jne 0x55cfe
jmp 0x55d20
jmp 0x55d00
movq -0x28(%rbp), %rax
movq -0x8(%rbp), %rcx
subq %rcx, %rax
sarq $0x3, %rax
shlq $0x3, %rax
addq -0x28(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x55b8e
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)