// File: /workspace/github_cpp_makefile_star2_O2/cjc12[P]ezSTL/src/../include/algorithm.h
// Function: void ezSTL::__heap_sort<unsigned int*, ezSTL::less<unsigned int>>(unsigned int*, unsigned int*, ezSTL::less<unsigned int>)
inline void __heap_sort(Iterator First, Iterator Last, Compare cmp) {
		Iterator now, left, right;
		// make heap
		for (Iterator ite = (Last - First - 1) / 2 + First; ite >= First; --ite) {
			now = ite;
			left = First + (now - First) * 2 + 1;
			right = First + (now - First) * 2 + 2;
			// if has both left and right children
			while (right < Last) {
				// exchange father and left
				if (!cmp(*left, *right) && cmp(*now, *left)) {
					swap(*left, *now);
					now = left;
					left = First + (now - First) * 2 + 1;
					right = First + (now - First) * 2 + 2;
				}
				// exchange father and right
				else if (!cmp(*right, *left) && cmp(*now, *right)) {
					swap(*right, *now);
					now = right;
					left = First + (now - First) * 2 + 1;
					right = First + (now - First) * 2 + 2;
				}
				else break;
			}
			// if only has left child
			if (right == Last && cmp(*now, *left))
				swap(*left, *now);
		}
		// heap sort
		for (Iterator ite = Last - 1; ite >= First; --ite) {
			swap(*First, *ite);
			now = First;
			left = First + 1;
			right = First + 2;
			// if has both left and right children
			while (right < ite) {
				// exchange father and left
				if (!cmp(*left, *right) && cmp(*now, *left)) {
					swap(*left, *now);
					now = left;
					left = First + (now - First) * 2 + 1;
					right = First + (now - First) * 2 + 2;
				}
				// exchange father and right
				else if (!cmp(*right, *left) && cmp(*now, *right)) {
					swap(*right, *now);
					now = right;
					left = First + (now - First) * 2 + 1;
					right = First + (now - First) * 2 + 2;
				}
				else break;
			}
			// if only has left child
			if (right == ite && cmp(*now, *left))
				swap(*left, *now);
		}
	}

// Assembly:
movq %rsi, %rax
subq %rdi, %rax
sarq $0x2, %rax
decq %rax
pushq $0x2
popq %rcx
cqto
idivq %rcx
leaq (%rdi,%rax,4), %rax
movq %rax, %rcx
cmpq %rdi, %rax
jb 0xaf8b
movq %rcx, %rdx
subq %rdi, %rdx
leaq (%rdi,%rdx,2), %r8
addq $0x8, %r8
leaq (%rdi,%rdx,2), %rdx
addq $0x4, %rdx
cmpq %rsi, %r8
jae 0xaf03
movl (%rdx), %r9d
movl (%r8), %r10d
cmpl %r10d, %r9d
jb 0xaee5
movl (%rcx), %r11d
cmpl %r9d, %r11d
jae 0xaee5
movl %r11d, (%rdx)
jmp 0xaefb
cmpl %r9d, %r10d
jb 0xaf03
movl (%rcx), %r9d
cmpl %r10d, %r9d
jae 0xaf03
movl %r9d, (%r8)
movl %r10d, %r9d
movq %r8, %rdx
movl %r9d, (%rcx)
movq %rdx, %rcx
jmp 0xaeb2
cmpq %rsi, %r8
jne 0xaf19
movl (%rcx), %r8d
movl (%rdx), %r9d
cmpl %r9d, %r8d
jae 0xaf19
movl %r8d, (%rdx)
movl %r9d, (%rcx)
addq $-0x4, %rax
jmp 0xaea6
movl (%rdi), %eax
movl (%rsi), %ecx
movl %ecx, (%rdi)
movl %eax, (%rsi)
movq %rdi, %rax
movq %rdi, %rcx
leaq 0x8(%rcx), %rdx
addq $0x4, %rcx
cmpq %rsi, %rdx
jae 0xaf77
movl (%rcx), %r8d
movl (%rdx), %r9d
cmpl %r9d, %r8d
jb 0xaf52
movl (%rax), %r10d
cmpl %r8d, %r10d
jae 0xaf52
movl %r10d, (%rcx)
jmp 0xaf68
cmpl %r8d, %r9d
jb 0xaf77
movl (%rax), %r8d
cmpl %r9d, %r8d
jae 0xaf77
movl %r8d, (%rdx)
movl %r9d, %r8d
movq %rdx, %rcx
movl %r8d, (%rax)
movq %rcx, %rax
subq %rdi, %rcx
leaq (%rdi,%rcx,2), %rcx
jmp 0xaf2d
cmpq %rsi, %rdx
jne 0xaf8b
movl (%rax), %edx
movl (%rcx), %r8d
cmpl %r8d, %edx
jae 0xaf8b
movl %edx, (%rcx)
movl %r8d, (%rax)
addq $-0x4, %rsi
cmpq %rdi, %rsi
jae 0xaf1f
retq