// Code generated from sort.go using genzfunc.go; DO NOT EDIT.

// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package sort

// Auto-generated variant of sort.go:insertionSort
func insertionSort_func( lessSwap, ,  int) {
	for  :=  + 1;  < ; ++ {
		for  := ;  >  && .Less(, -1); -- {
			.Swap(, -1)
		}
	}
}

// Auto-generated variant of sort.go:siftDown
func siftDown_func( lessSwap, , ,  int) {
	 := 
	for {
		 := 2* + 1
		if  >=  {
			break
		}
		if +1 <  && .Less(+, ++1) {
			++
		}
		if !.Less(+, +) {
			return
		}
		.Swap(+, +)
		 = 
	}
}

// Auto-generated variant of sort.go:heapSort
func heapSort_func( lessSwap, ,  int) {
	 := 
	 := 0
	 :=  - 
	for  := ( - 1) / 2;  >= 0; -- {
		siftDown_func(, , , )
	}
	for  :=  - 1;  >= 0; -- {
		.Swap(, +)
		siftDown_func(, , , )
	}
}

// Auto-generated variant of sort.go:medianOfThree
func medianOfThree_func( lessSwap, , ,  int) {
	if .Less(, ) {
		.Swap(, )
	}
	if .Less(, ) {
		.Swap(, )
		if .Less(, ) {
			.Swap(, )
		}
	}
}

// Auto-generated variant of sort.go:swapRange
func swapRange_func( lessSwap, , ,  int) {
	for  := 0;  < ; ++ {
		.Swap(+, +)
	}
}

// Auto-generated variant of sort.go:doPivot
func doPivot_func( lessSwap, ,  int) (,  int) {
	 := int(uint(+) >> 1)
	if - > 40 {
		 := ( - ) / 8
		medianOfThree_func(, , +, +2*)
		medianOfThree_func(, , -, +)
		medianOfThree_func(, -1, -1-, -1-2*)
	}
	medianOfThree_func(, , , -1)
	 := 
	,  := +1, -1
	for ;  <  && .Less(, ); ++ {
	}
	 := 
	for {
		for ;  <  && !.Less(, ); ++ {
		}
		for ;  <  && .Less(, -1); -- {
		}
		if  >=  {
			break
		}
		.Swap(, -1)
		++
		--
	}
	 := - < 5
	if ! && - < (-)/4 {
		 := 0
		if !.Less(, -1) {
			.Swap(, -1)
			++
			++
		}
		if !.Less(-1, ) {
			--
			++
		}
		if !.Less(, ) {
			.Swap(, -1)
			--
			++
		}
		 =  > 1
	}
	if  {
		for {
			for ;  <  && !.Less(-1, ); -- {
			}
			for ;  <  && .Less(, ); ++ {
			}
			if  >=  {
				break
			}
			.Swap(, -1)
			++
			--
		}
	}
	.Swap(, -1)
	return  - 1, 
}

// Auto-generated variant of sort.go:quickSort
func quickSort_func( lessSwap, , ,  int) {
	for - > 12 {
		if  == 0 {
			heapSort_func(, , )
			return
		}
		--
		,  := doPivot_func(, , )
		if - < - {
			(, , , )
			 = 
		} else {
			(, , , )
			 = 
		}
	}
	if - > 1 {
		for  :=  + 6;  < ; ++ {
			if .Less(, -6) {
				.Swap(, -6)
			}
		}
		insertionSort_func(, , )
	}
}

// Auto-generated variant of sort.go:stable
func stable_func( lessSwap,  int) {
	 := 20
	,  := 0, 
	for  <=  {
		insertionSort_func(, , )
		 = 
		 += 
	}
	insertionSort_func(, , )
	for  <  {
		,  = 0, 2*
		for  <=  {
			symMerge_func(, , +, )
			 = 
			 += 2 * 
		}
		if  :=  + ;  <  {
			symMerge_func(, , , )
		}
		 *= 2
	}
}

// Auto-generated variant of sort.go:symMerge
func symMerge_func( lessSwap, , ,  int) {
	if - == 1 {
		 := 
		 := 
		for  <  {
			 := int(uint(+) >> 1)
			if .Less(, ) {
				 =  + 1
			} else {
				 = 
			}
		}
		for  := ;  < -1; ++ {
			.Swap(, +1)
		}
		return
	}
	if - == 1 {
		 := 
		 := 
		for  <  {
			 := int(uint(+) >> 1)
			if !.Less(, ) {
				 =  + 1
			} else {
				 = 
			}
		}
		for  := ;  > ; -- {
			.Swap(, -1)
		}
		return
	}
	 := int(uint(+) >> 1)
	 :=  + 
	var ,  int
	if  >  {
		 =  - 
		 = 
	} else {
		 = 
		 = 
	}
	 :=  - 1
	for  <  {
		 := int(uint(+) >> 1)
		if !.Less(-, ) {
			 =  + 1
		} else {
			 = 
		}
	}
	 :=  - 
	if  <  &&  <  {
		rotate_func(, , , )
	}
	if  <  &&  <  {
		(, , , )
	}
	if  <  &&  <  {
		(, , , )
	}
}

// Auto-generated variant of sort.go:rotate
func rotate_func( lessSwap, , ,  int) {
	 :=  - 
	 :=  - 
	for  !=  {
		if  >  {
			swapRange_func(, -, , )
			 -= 
		} else {
			swapRange_func(, -, +-, )
			 -= 
		}
	}
	swapRange_func(, -, , )
}