// File: /workspace/github_cpp_makefile_star2_O3/jvanns[P]verbatim/sub/lmdb/libraries/liblmdb/midl.c
// Function: mdb_midl_sort
void
mdb_midl_sort( MDB_IDL ids )
{
	/* Max possible depth of int-indexed tree * 2 items/level */
	int istack[sizeof(int)*CHAR_BIT * 2];
	int i,j,k,l,ir,jstack;
	MDB_ID a, itmp;

	ir = (int)ids[0];
	l = 1;
	jstack = 0;
	for(;;) {
		if (ir - l < SMALL) {	/* Insertion sort */
			for (j=l+1;j<=ir;j++) {
				a = ids[j];
				for (i=j-1;i>=1;i--) {
					if (ids[i] >= a) break;
					ids[i+1] = ids[i];
				}
				ids[i+1] = a;
			}
			if (jstack == 0) break;
			ir = istack[jstack--];
			l = istack[jstack--];
		} else {
			k = (l + ir) >> 1;	/* Choose median of left, center, right */
			MIDL_SWAP(ids[k], ids[l+1]);
			if (ids[l] < ids[ir]) {
				MIDL_SWAP(ids[l], ids[ir]);
			}
			if (ids[l+1] < ids[ir]) {
				MIDL_SWAP(ids[l+1], ids[ir]);
			}
			if (ids[l] < ids[l+1]) {
				MIDL_SWAP(ids[l], ids[l+1]);
			}
			i = l+1;
			j = ir;
			a = ids[l+1];
			for(;;) {
				do i++; while(ids[i] > a);
				do j--; while(ids[j] < a);
				if (j < i) break;
				MIDL_SWAP(ids[i],ids[j]);
			}
			ids[l+1] = ids[j];
			ids[j] = a;
			jstack += 2;
			if (ir-i+1 >= j-l) {
				istack[jstack] = ir;
				istack[jstack-1] = i;
				ir = j-1;
			} else {
				istack[jstack] = j-1;
				istack[jstack-1] = l;
				l = i;
			}
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl (%rdi), %edx
xorl %ebp, %ebp
movl $0x1, %esi
leal 0x1(%rsi), %r8d
movslq %r8d, %r9
movslq %esi, %rax
movl %eax, %r10d
negl %r10d
movl %ebp, %ecx
movl %edx, %r11d
subl %esi, %r11d
cmpl $0x7, %r11d
jle 0xbe1d
leal (%rdx,%rsi), %r11d
sarl %r11d
movslq %r11d, %rbx
movq (%rdi,%rbx,8), %r11
movq (%rdi,%r9,8), %r14
movq %r14, (%rdi,%rbx,8)
movq %r11, (%rdi,%r9,8)
movq (%rdi,%rax,8), %r14
movslq %edx, %rbx
movq (%rdi,%rbx,8), %r15
cmpq %r15, %r14
jae 0xbd7f
movq %r15, (%rdi,%rax,8)
movq %r14, (%rdi,%rbx,8)
movq (%rdi,%r9,8), %r11
jmp 0xbd82
movq %r15, %r14
cmpq %r14, %r11
jae 0xbd93
movq %r14, (%rdi,%r9,8)
movq %r11, (%rdi,%rbx,8)
movq (%rdi,%r9,8), %r11
movq (%rdi,%rax,8), %r14
cmpq %r11, %r14
jae 0xbda6
movq %r11, (%rdi,%rax,8)
movq %r14, (%rdi,%r9,8)
jmp 0xbda9
movq %r11, %r14
movl %edx, %r11d
movl %r8d, %ebx
movslq %ebx, %rbx
movq 0x8(%rdi,%rbx,8), %r15
incq %rbx
cmpq %r14, %r15
ja 0xbdb2
movslq %r11d, %r12
incq %r12
movq -0x10(%rdi,%r12,8), %r13
decl %r11d
decq %r12
cmpq %r14, %r13
jb 0xbdc5
cmpq %rbx, %r12
jle 0xbde5
movq %r13, (%rdi,%rbx,8)
movq %r15, -0x8(%rdi,%r12,8)
jmp 0xbdaf
movq %r13, (%rdi,%r9,8)
movq %r14, -0x8(%rdi,%r12,8)
leal 0x2(%rcx), %ebp
movl %edx, %r15d
subl %ebx, %r15d
incl %r15d
leal (%r10,%r11), %r12d
movslq %ebp, %r14
movslq %ecx, %rcx
cmpl %r12d, %r15d
jl 0xbe7e
movl %edx, -0x80(%rsp,%r14,4)
movl %ebx, -0x7c(%rsp,%rcx,4)
decl %r11d
movl %r11d, %edx
jmp 0xbd35
cmpl %esi, %edx
jle 0xbe62
movslq %edx, %rdx
movq 0x8(%rdi,%rax,8), %rsi
movl %eax, %r8d
testq %rax, %rax
jle 0xbe52
movl %r8d, %r9d
movq (%rdi,%r9,8), %r10
cmpq %rsi, %r10
jae 0xbe52
movq %r10, 0x8(%rdi,%r9,8)
leal -0x1(%r8), %r9d
cmpl $0x1, %r8d
movl %r9d, %r8d
jg 0xbe31
xorl %r8d, %r8d
incq %rax
movslq %r8d, %r8
movq %rsi, 0x8(%rdi,%r8,8)
cmpq %rdx, %rax
jne 0xbe24
testl %ecx, %ecx
je 0xbe91
movslq %ecx, %rax
movl -0x84(%rsp,%rax,4), %esi
movl -0x80(%rsp,%rax,4), %edx
addl $-0x2, %ecx
movl %ecx, %ebp
jmp 0xbd25
decl %r11d
movl %r11d, -0x80(%rsp,%r14,4)
movl %esi, -0x7c(%rsp,%rcx,4)
movl %ebx, %esi
jmp 0xbd25
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq