// File: BenLangmead[P]bowtie/./ls.h
// Function: LarssonSadakane<int>::select_sort_split(int*, int)
inline void select_sort_split(T *p, T n) {
	   T *pa, *pb, *pi, *pn;
	   T f, v, tmp;

	   pa=p;                        /* pa is start of group being picked out.*/
	   pn=p+n-1;                    /* pn is last position of subarray.*/
	   while (pa<pn) {
		  for (pi=pb=pa+1, f=LS_KEY(pa); pi<=pn; ++pi)
			 if ((v=LS_KEY(pi))<f) {
				f=v;                /* f is smallest key found.*/
				LS_SWAP(pi, pa);       /* place smallest element at beginning.*/
				pb=pa+1;            /* pb is position for elements equal to f.*/
			 } else if (v==f) {     /* if equal to smallest key.*/
				LS_SWAP(pi, pb);       /* place next to other smallest elements.*/
				++pb;
			 }
		  update_group(pa, pb-1);   /* update group values for new group.*/
		  pa=pb;                    /* continue sorting rest of the subarray.*/
	   }
	   if (pa==pn) {                /* check if last part is single element.*/
		  V[*pa]=(T)(pa-I);
		  *pa=-1;                   /* sorted group.*/
	   }
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
addq $-0x4, %rax
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rax
cmpq -0x38(%rbp), %rax
jae 0x2d80a
movq -0x50(%rbp), %rdx
movq -0x20(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x28(%rbp)
movq %rax, -0x30(%rbp)
movq 0x8(%rdx), %rax
movq -0x20(%rbp), %rcx
movl (%rcx), %ecx
addl 0x14(%rdx), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x3c(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x38(%rbp), %rax
ja 0x2d7e8
movq -0x50(%rbp), %rdx
movq 0x8(%rdx), %rax
movq -0x30(%rbp), %rcx
movl (%rcx), %ecx
addl 0x14(%rdx), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x40(%rbp)
cmpl -0x3c(%rbp), %eax
jge 0x2d7a1
movl -0x40(%rbp), %eax
movl %eax, -0x3c(%rbp)
movq -0x30(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x44(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
movl -0x44(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x20(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x28(%rbp)
jmp 0x2d7d5
movl -0x40(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jne 0x2d7d3
movq -0x30(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x44(%rbp)
movq -0x28(%rbp), %rax
movl (%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
movl -0x44(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movq -0x28(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x28(%rbp)
jmp 0x2d7d5
jmp 0x2d7d7
movq -0x30(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x30(%rbp)
jmp 0x2d742
movq -0x50(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
addq $-0x4, %rdx
callq 0x2e030
movq -0x28(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0x2d70a
movq -0x20(%rbp), %rax
cmpq -0x38(%rbp), %rax
jne 0x2d840
movq -0x50(%rbp), %rax
movq -0x20(%rbp), %rcx
movq (%rax), %rdx
subq %rdx, %rcx
sarq $0x2, %rcx
movl %ecx, %edx
movq 0x8(%rax), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x20(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)