/*
 * SPDX-FileCopyrightText: © Hypermode Inc. <hello@hypermode.com>
 * SPDX-License-Identifier: Apache-2.0
 */

package simd

import (
	
	
	
	
)

// Search finds the key using the naive way
func ( []uint64,  uint64) int16 {
	var  int
	for  = 0;  < len();  += 2 {
		 := []
		if  >=  {
			return int16( / 2)
		}
	}
	return int16( / 2)
}

func ( []uint64,  uint64) int16 {
	if len() < 8 {
		return Naive(, )
	}
	var ,  [4]uint64
	[0] = 
	[1] = 
	[2] = 
	[3] = 
	for  := 0;  < len();  += 8 {
		[0] = []
		[1] = [+2]
		[2] = [+4]
		[3] = [+6]
		if [0] >= [0] {
			return int16( / 2)
		}
		if [1] >= [1] {
			return int16(( + 2) / 2)
		}
		if [2] >= [2] {
			return int16(( + 4) / 2)
		}
		if [3] >= [3] {
			return int16(( + 6) / 2)
		}

	}
	return int16(len() / 2)
}

func ( []uint64,  uint64) int16 {
	 := runtime.NumCPU()
	if %2 != 0 {
		panic(fmt.Sprintf("odd number of CPUs %v", ))
	}
	 := len()/ + 1
	var  sync.WaitGroup
	 := make(chan int16, )
	for  := 0;  < len();  +=  {
		 :=  + 
		if  >= len() {
			 = len()
		}
		 := [:]
		.Add(1)
		go func( int16,  []uint64,  uint64,  *sync.WaitGroup,  chan int16) {
			for  := 0;  < len();  += 2 {
				if [] >=  {
					 <- (int16() + ) / 2
					break
				}
			}
			.Done()
		}(int16(), , , &, )
	}
	.Wait()
	close()
	var  int16 = (1 << 15) - 1
	for  := range  {
		if  <  {
			 = 
		}
	}
	if  == (1<<15)-1 {
		return int16(len() / 2)
	}
	return 
}

func ( []uint64,  uint64) int16 {
	return int16(sort.Search(len(), func( int) bool {
		if *2 >= len() {
			return true
		}
		return [*2] >= 
	}))
}

//nolint:unused
func cmp2_native(,  [2]uint64) int16 {
	if [0] == [0] {
		return 0
	}
	if [1] == [1] {
		return 1
	}
	return 2
}

//nolint:unused
func cmp4_native(,  [4]uint64) int16 {
	for  := range  {
		if [] >= [] {
			return int16()
		}
	}
	return 4
}

//nolint:unused
func cmp8_native( [8]uint64,  [4]uint64) int16 {
	for  := range  {
		if [] >= [0] {
			return int16()
		}
	}
	return 8
}