// Code generated by libc-gen. DO NOT EDIT.

package vec1

import (
	"bytes"
	"strconv"
	"unsafe"
)

func (m *Module) _memcmp(s1, s2, n int32) int32 {
	e1, e2 := s1+n, s2+n
	b1 := (*m.memory)[uint32(s1):uint32(e1)]
	b2 := (*m.memory)[uint32(s2):uint32(e2)]
	return int32(bytes.Compare(b1, b2))
}
func (m *Module) _strtod(s, endptr int32) float64 {
	return m._strtod_helper(s, endptr, 64)
}

func (m *Module) _strtod_helper(s, endptr int32, bitSize int) float64 {
	m0 := (*m.memory)[uint32(s):]
	m1 := bytes.TrimLeft(m0, " \t\n\v\f\r")
	m2 := bytes.TrimLeft(m1, "+-.0123456789abcdefinptxyABCDEFINPTXY")
	prefix := len(m0) - len(m1)
	digits := len(m1) - len(m2)

	var val float64
	for ; digits > 0; digits-- {
		var err error
		str := unsafe.String(&m1[0], digits)
		val, err = strconv.ParseFloat(str, bitSize)
		if e, ok := err.(*strconv.NumError); !ok || e.Err == strconv.ErrRange {
			break
		}
	}

	if endptr != 0 {
		if digits > 0 {
			s += int32(prefix + digits)
		}
		store32((*m.memory)[uint32(endptr):], uint32(s))
	}
	return val
}
