// File: /workspace/github_cpp_makefile_star2_O1/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 0xc28a
leal (%rdx,%rsi), %r11d
sarl %r11d
movslq %r11d, %r11
movq (%rdi,%r11,8), %rbx
movq (%rdi,%r9,8), %r14
movq %r14, (%rdi,%r11,8)
movq %rbx, (%rdi,%r9,8)
movq (%rdi,%rax,8), %rbx
movslq %edx, %r11
movq (%rdi,%r11,8), %r14
cmpq %r14, %rbx
jae 0xc1e8
movq %r14, (%rdi,%rax,8)
movq %rbx, (%rdi,%r11,8)
movq (%rdi,%r9,8), %rbx
movq (%rdi,%r11,8), %r14
cmpq %r14, %rbx
jae 0xc1fd
movq %r14, (%rdi,%r9,8)
movq %rbx, (%rdi,%r11,8)
movq (%rdi,%rax,8), %r11
movq (%rdi,%r9,8), %rbx
cmpq %rbx, %r11
jae 0xc212
movq %rbx, (%rdi,%rax,8)
movq %r11, (%rdi,%r9,8)
movq (%rdi,%r9,8), %r14
movl %edx, %r11d
movl %r8d, %ebx
movslq %ebx, %rbx
movq 0x8(%rdi,%rbx,8), %r15
incq %rbx
cmpq %r14, %r15
ja 0xc21f
movslq %r11d, %r12
incq %r12
movq -0x10(%rdi,%r12,8), %r13
decl %r11d
decq %r12
cmpq %r14, %r13
jb 0xc232
cmpq %rbx, %r12
jle 0xc252
movq %r13, (%rdi,%rbx,8)
movq %r15, -0x8(%rdi,%r12,8)
jmp 0xc21c
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 0xc2eb
movl %edx, -0x80(%rsp,%r14,4)
movl %ebx, -0x7c(%rsp,%rcx,4)
decl %r11d
movl %r11d, %edx
jmp 0xc1a4
cmpl %esi, %edx
jle 0xc2cf
movslq %edx, %rdx
movq 0x8(%rdi,%rax,8), %rsi
movl %eax, %r8d
testq %rax, %rax
jle 0xc2bf
movl %r8d, %r9d
movq (%rdi,%r9,8), %r10
cmpq %rsi, %r10
jae 0xc2bf
movq %r10, 0x8(%rdi,%r9,8)
leal -0x1(%r8), %r9d
cmpl $0x1, %r8d
movl %r9d, %r8d
jg 0xc29e
xorl %r8d, %r8d
incq %rax
movslq %r8d, %r8
movq %rsi, 0x8(%rdi,%r8,8)
cmpq %rdx, %rax
jne 0xc291
testl %ecx, %ecx
je 0xc2fe
movslq %ecx, %rax
movl -0x84(%rsp,%rax,4), %esi
movl -0x80(%rsp,%rax,4), %edx
addl $-0x2, %ecx
movl %ecx, %ebp
jmp 0xc194
decl %r11d
movl %r11d, -0x80(%rsp,%r14,4)
movl %esi, -0x7c(%rsp,%rcx,4)
movl %ebx, %esi
jmp 0xc194
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq