// File: 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:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
movq %rsi, 0x30(%rsp)
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
subq %rcx, %rax
sarq $0x2, %rax
subq $0x1, %rax
movl $0x2, %ecx
cqto
idivq %rcx
shlq $0x2, %rax
addq 0x38(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
cmpq 0x38(%rsp), %rax
jb 0x1a803
movq 0x10(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x38(%rsp), %rax
movq 0x28(%rsp), %rcx
movq 0x38(%rsp), %rdx
subq %rdx, %rcx
sarq $0x2, %rcx
shlq %rcx
shlq $0x2, %rcx
addq %rcx, %rax
addq $0x4, %rax
movq %rax, 0x20(%rsp)
movq 0x38(%rsp), %rax
movq 0x28(%rsp), %rcx
movq 0x38(%rsp), %rdx
subq %rdx, %rcx
sarq $0x2, %rcx
shlq %rcx
shlq $0x2, %rcx
addq %rcx, %rax
addq $0x8, %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
cmpq 0x30(%rsp), %rax
jae 0x1a7b9
movq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rdx
leaq 0x47(%rsp), %rdi
callq 0x15e40
testb $0x1, %al
jne 0x1a70d
movq 0x28(%rsp), %rsi
movq 0x20(%rsp), %rdx
leaq 0x47(%rsp), %rdi
callq 0x15e40
testb $0x1, %al
jne 0x1a69d
jmp 0x1a70d
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x1ab00
movq 0x20(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x38(%rsp), %rax
movq 0x28(%rsp), %rcx
movq 0x38(%rsp), %rdx
subq %rdx, %rcx
sarq $0x2, %rcx
shlq %rcx
shlq $0x2, %rcx
addq %rcx, %rax
addq $0x4, %rax
movq %rax, 0x20(%rsp)
movq 0x38(%rsp), %rax
movq 0x28(%rsp), %rcx
movq 0x38(%rsp), %rdx
subq %rdx, %rcx
sarq $0x2, %rcx
shlq %rcx
shlq $0x2, %rcx
addq %rcx, %rax
addq $0x8, %rax
movq %rax, 0x18(%rsp)
jmp 0x1a7b4
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
leaq 0x47(%rsp), %rdi
callq 0x15e40
testb $0x1, %al
jne 0x1a7b0
movq 0x28(%rsp), %rsi
movq 0x18(%rsp), %rdx
leaq 0x47(%rsp), %rdi
callq 0x15e40
testb $0x1, %al
jne 0x1a743
jmp 0x1a7b0
movq 0x18(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x1ab00
movq 0x18(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x38(%rsp), %rax
movq 0x28(%rsp), %rcx
movq 0x38(%rsp), %rdx
subq %rdx, %rcx
sarq $0x2, %rcx
shlq %rcx
shlq $0x2, %rcx
addq %rcx, %rax
addq $0x4, %rax
movq %rax, 0x20(%rsp)
movq 0x38(%rsp), %rax
movq 0x28(%rsp), %rcx
movq 0x38(%rsp), %rdx
subq %rdx, %rcx
sarq $0x2, %rcx
shlq %rcx
shlq $0x2, %rcx
addq %rcx, %rax
addq $0x8, %rax
movq %rax, 0x18(%rsp)
jmp 0x1a7b2
jmp 0x1a7b9
jmp 0x1a7b4
jmp 0x1a657
movq 0x18(%rsp), %rax
cmpq 0x30(%rsp), %rax
jne 0x1a7ee
movq 0x28(%rsp), %rsi
movq 0x20(%rsp), %rdx
leaq 0x47(%rsp), %rdi
callq 0x15e40
testb $0x1, %al
jne 0x1a7df
jmp 0x1a7ee
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x1ab00
jmp 0x1a7f0
movq 0x10(%rsp), %rax
addq $-0x4, %rax
movq %rax, 0x10(%rsp)
jmp 0x1a5eb
movq 0x30(%rsp), %rax
addq $-0x4, %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
cmpq 0x38(%rsp), %rax
jb 0x1aa02
movq 0x38(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x1ab00
movq 0x38(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x38(%rsp), %rax
addq $0x4, %rax
movq %rax, 0x20(%rsp)
movq 0x38(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
cmpq 0x8(%rsp), %rax
jae 0x1a9b8
movq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rdx
leaq 0x47(%rsp), %rdi
callq 0x15e40
testb $0x1, %al
jne 0x1a90c
movq 0x28(%rsp), %rsi
movq 0x20(%rsp), %rdx
leaq 0x47(%rsp), %rdi
callq 0x15e40
testb $0x1, %al
jne 0x1a89c
jmp 0x1a90c
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x1ab00
movq 0x20(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x38(%rsp), %rax
movq 0x28(%rsp), %rcx
movq 0x38(%rsp), %rdx
subq %rdx, %rcx
sarq $0x2, %rcx
shlq %rcx
shlq $0x2, %rcx
addq %rcx, %rax
addq $0x4, %rax
movq %rax, 0x20(%rsp)
movq 0x38(%rsp), %rax
movq 0x28(%rsp), %rcx
movq 0x38(%rsp), %rdx
subq %rdx, %rcx
sarq $0x2, %rcx
shlq %rcx
shlq $0x2, %rcx
addq %rcx, %rax
addq $0x8, %rax
movq %rax, 0x18(%rsp)
jmp 0x1a9b3
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
leaq 0x47(%rsp), %rdi
callq 0x15e40
testb $0x1, %al
jne 0x1a9af
movq 0x28(%rsp), %rsi
movq 0x18(%rsp), %rdx
leaq 0x47(%rsp), %rdi
callq 0x15e40
testb $0x1, %al
jne 0x1a942
jmp 0x1a9af
movq 0x18(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x1ab00
movq 0x18(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x38(%rsp), %rax
movq 0x28(%rsp), %rcx
movq 0x38(%rsp), %rdx
subq %rdx, %rcx
sarq $0x2, %rcx
shlq %rcx
shlq $0x2, %rcx
addq %rcx, %rax
addq $0x4, %rax
movq %rax, 0x20(%rsp)
movq 0x38(%rsp), %rax
movq 0x28(%rsp), %rcx
movq 0x38(%rsp), %rdx
subq %rdx, %rcx
sarq $0x2, %rcx
shlq %rcx
shlq $0x2, %rcx
addq %rcx, %rax
addq $0x8, %rax
movq %rax, 0x18(%rsp)
jmp 0x1a9b1
jmp 0x1a9b8
jmp 0x1a9b3
jmp 0x1a856
movq 0x18(%rsp), %rax
cmpq 0x8(%rsp), %rax
jne 0x1a9ed
movq 0x28(%rsp), %rsi
movq 0x20(%rsp), %rdx
leaq 0x47(%rsp), %rdi
callq 0x15e40
testb $0x1, %al
jne 0x1a9de
jmp 0x1a9ed
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x1ab00
jmp 0x1a9ef
movq 0x8(%rsp), %rax
addq $-0x4, %rax
movq %rax, 0x8(%rsp)
jmp 0x1a811
addq $0x48, %rsp
retq
nopw (%rax,%rax)