// File: BenLangmead[P]bowtie/./ls.h
// Function: LarssonSadakane<int>::bucketsort(int*, int*, int, int)
inline void bucketsort(T *x, T *p, T n, T k)
	{
	   T *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 || 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 || d > 0);
		  } else
			 p[i--]=-1;             /* one element, sorted group.*/
	   }
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
movslq -0x20(%rbp), %rdx
shlq $0x2, %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
jae 0x2d1bf
movq -0x28(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq -0x28(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x28(%rbp)
jmp 0x2d18f
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jg 0x2d20a
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq -0x2c(%rbp), %rdx
movl (%rcx,%rdx,4), %ecx
movl %ecx, -0x30(%rbp)
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edx
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x2c(%rbp), %edx
movq -0x18(%rbp), %rax
movslq -0x30(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x2d1c6
movq -0x18(%rbp), %rax
movslq -0x20(%rbp), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
addq $-0x4, %rax
movq %rax, -0x28(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x18(%rbp), %rax
jb 0x2d303
movq -0x10(%rbp), %rax
movq -0x28(%rbp), %rcx
movl (%rcx), %ecx
movl %ecx, -0x30(%rbp)
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x34(%rbp)
movl -0x2c(%rbp), %edx
movl %edx, -0x38(%rbp)
movq -0x10(%rbp), %rax
movslq -0x30(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
cmpl $0x0, -0x34(%rbp)
je 0x2d268
cmpl $0x0, -0x34(%rbp)
jle 0x2d2d7
movl -0x30(%rbp), %edx
movq -0x18(%rbp), %rax
movl -0x2c(%rbp), %ecx
movl %ecx, %esi
addl $-0x1, %esi
movl %esi, -0x2c(%rbp)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movq -0x10(%rbp), %rax
movl -0x34(%rbp), %ecx
movl %ecx, -0x30(%rbp)
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x34(%rbp)
movl -0x38(%rbp), %edx
movq -0x10(%rbp), %rax
movslq -0x30(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x30(%rbp), %edx
movq -0x18(%rbp), %rax
movl -0x2c(%rbp), %ecx
movl %ecx, %esi
addl $-0x1, %esi
movl %esi, -0x2c(%rbp)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movb $0x1, %al
cmpl $0x0, -0x34(%rbp)
movb %al, -0x39(%rbp)
je 0x2d2ce
cmpl $0x0, -0x34(%rbp)
setg %al
movb %al, -0x39(%rbp)
movb -0x39(%rbp), %al
testb $0x1, %al
jne 0x2d280
jmp 0x2d2f0
movq -0x18(%rbp), %rax
movl -0x2c(%rbp), %ecx
movl %ecx, %edx
addl $-0x1, %edx
movl %edx, -0x2c(%rbp)
movslq %ecx, %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
jmp 0x2d2f2
movq -0x28(%rbp), %rax
addq $-0x4, %rax
movq %rax, -0x28(%rbp)
jmp 0x2d227
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop