// File: readmapping[P]alfalfa/src/qsufsort.c
// Function: bucketsort
static void bucketsort(int *x, int *p, int n, int k)
{
   int *pi, i, c, d, g;

   for (pi=p; pi<p+k; ++pi)
      *pi=-1;                   /* mark linked lists empty.*/
   for (i=0; i<=n; ++i) {
      x[i]=p[c=x[i]];           /* insert in linked list.*/
      p[c]=i;
   }
   for (pi=p+k-1, i=n; pi>=p; --pi) {
      d=x[c=*pi];               /* c is position, d is next in list.*/
      x[c]=g=i;                 /* last position equals group number.*/
      if (d>=0) {               /* if more than one element in group.*/
         p[i--]=c;              /* p is permutation for the sorted x.*/
         do {
            d=x[c=d];           /* next in linked list.*/
            x[c]=g;             /* group number in x.*/
            p[i--]=c;           /* permutation in p.*/
         } while (d>=0);
      } else
         p[i--]=-1;             /* one element, sorted group.*/
   }
}

// Assembly:
movq %rdi, -0x8(%rsp)
movq %rsi, -0x10(%rsp)
movl %edx, -0x14(%rsp)
movl %ecx, -0x18(%rsp)
movq -0x10(%rsp), %rax
movq %rax, -0x20(%rsp)
movq -0x20(%rsp), %rax
movq -0x10(%rsp), %rcx
movslq -0x18(%rsp), %rdx
shlq $0x2, %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
jae 0x729b2
movq -0x20(%rsp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq -0x20(%rsp), %rax
addq $0x4, %rax
movq %rax, -0x20(%rsp)
jmp 0x7297c
movl $0x0, -0x24(%rsp)
movl -0x24(%rsp), %eax
cmpl -0x14(%rsp), %eax
jg 0x72a0b
movq -0x10(%rsp), %rax
movq -0x8(%rsp), %rcx
movslq -0x24(%rsp), %rdx
movl (%rcx,%rdx,4), %ecx
movl %ecx, -0x28(%rsp)
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edx
movq -0x8(%rsp), %rax
movslq -0x24(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x24(%rsp), %edx
movq -0x10(%rsp), %rax
movslq -0x28(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rsp)
jmp 0x729ba
movq -0x10(%rsp), %rax
movslq -0x18(%rsp), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
addq $-0x4, %rax
movq %rax, -0x20(%rsp)
movl -0x14(%rsp), %eax
movl %eax, -0x24(%rsp)
movq -0x20(%rsp), %rax
cmpq -0x10(%rsp), %rax
jb 0x72b0d
movq -0x8(%rsp), %rax
movq -0x20(%rsp), %rcx
movl (%rcx), %ecx
movl %ecx, -0x28(%rsp)
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x2c(%rsp)
movl -0x24(%rsp), %edx
movl %edx, -0x30(%rsp)
movq -0x8(%rsp), %rax
movslq -0x28(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
cmpl $0x0, -0x2c(%rsp)
jl 0x72adc
movl -0x28(%rsp), %edx
movq -0x10(%rsp), %rax
movl -0x24(%rsp), %ecx
movl %ecx, %esi
addl $-0x1, %esi
movl %esi, -0x24(%rsp)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movq -0x8(%rsp), %rax
movl -0x2c(%rsp), %ecx
movl %ecx, -0x28(%rsp)
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x2c(%rsp)
movl -0x30(%rsp), %edx
movq -0x8(%rsp), %rax
movslq -0x28(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x28(%rsp), %edx
movq -0x10(%rsp), %rax
movl -0x24(%rsp), %ecx
movl %ecx, %esi
addl $-0x1, %esi
movl %esi, -0x24(%rsp)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
cmpl $0x0, -0x2c(%rsp)
jge 0x72a8f
jmp 0x72af8
movq -0x10(%rsp), %rax
movl -0x24(%rsp), %ecx
movl %ecx, %edx
addl $-0x1, %edx
movl %edx, -0x24(%rsp)
movslq %ecx, %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
jmp 0x72afa
movq -0x20(%rsp), %rax
addq $-0x4, %rax
movq %rax, -0x20(%rsp)
jmp 0x72a2d
retq
nop