// Code generated by modernc.org/undup from the per-target vec_*.go files; DO NOT EDIT.

//go:build (windows && (amd64 || arm64)) || (windows && 386)

package vec

import (
	"unsafe"

	"modernc.org/libc"
	libsqlite3 "modernc.org/sqlite/lib"
)

type LC_ID = TLC_ID

type LPLC_ID = TLPLC_ID

type TFILE = struct {
	F_ptr      uintptr
	F_cnt      int32
	F_base     uintptr
	F_flag     int32
	F_file     int32
	F_charbuf  int32
	F_bufsiz   int32
	F_tmpfname uintptr
}

type TLC_ID = struct {
	FwLanguage uint16
	FwCountry  uint16
	FwCodePage uint16
}

type TLPLC_ID = uintptr

type T_CRT_FLOAT = struct {
	Ff float32
}

type T_HEAPINFO = struct {
	F_pentry  uintptr
	F_size    Tsize_t
	F_useflag int32
}

type T_LDBL12 = struct {
	Fld12 [12]uint8
}

type T_LDOUBLE = struct {
	Fld [10]uint8
}

type T_MM_MANTISSA_NORM_ENUM = int32

type T_MM_MANTISSA_SIGN_ENUM = int32

type T_MM_PERM_ENUM = int32

type T_MM_TERNLOG_ENUM = int32

type T_div_t = Tdiv_t

type T_heapinfo = T_HEAPINFO

type T_invalid_parameter_handler = uintptr

type T_iobuf = struct {
	F_ptr      uintptr
	F_cnt      int32
	F_base     uintptr
	F_flag     int32
	F_file     int32
	F_charbuf  int32
	F_bufsiz   int32
	F_tmpfname uintptr
}

type T_ldiv_t = Tldiv_t

type T_locale_t = uintptr

type T_locale_tstruct = struct {
	Flocinfo Tpthreadlocinfo
	Fmbcinfo Tpthreadmbcinfo
}

type T_off64_t = int64

type T_off_t = int32

type T_onexit_t = uintptr

type T_purecall_handler = uintptr

type Tlocaleinfo_struct = T_locale_tstruct

type Toff32_t = int32

type Tpthreadlocinfo = uintptr

type Tpthreadmbcinfo = uintptr

type TtagLC_ID = TLC_ID

type Tthreadlocaleinfostruct = struct {
	Frefcount      int32
	Flc_codepage   uint32
	Flc_collate_cp uint32
	Flc_handle     [6]uint32
	Flc_id         [6]TLC_ID
	Flc_category   [6]struct {
		Flocale    uintptr
		Fwlocale   uintptr
		Frefcount  uintptr
		Fwrefcount uintptr
	}
	Flc_clike            int32
	Fmb_cur_max          int32
	Flconv_intl_refcount uintptr
	Flconv_num_refcount  uintptr
	Flconv_mon_refcount  uintptr
	Flconv               uintptr
	Fctype1_refcount     uintptr
	Fctype1              uintptr
	Fpctype              uintptr
	Fpclmap              uintptr
	Fpcumap              uintptr
	Flc_time_curr        uintptr
}

type Tthreadlocinfo = struct {
	Frefcount      int32
	Flc_codepage   uint32
	Flc_collate_cp uint32
	Flc_handle     [6]uint32
	Flc_id         [6]TLC_ID
	Flc_category   [6]struct {
		Flocale    uintptr
		Fwlocale   uintptr
		Frefcount  uintptr
		Fwrefcount uintptr
	}
	Flc_clike            int32
	Fmb_cur_max          int32
	Flconv_intl_refcount uintptr
	Flconv_num_refcount  uintptr
	Flconv_mon_refcount  uintptr
	Flconv               uintptr
	Fctype1_refcount     uintptr
	Fctype1              uintptr
	Fpctype              uintptr
	Fpclmap              uintptr
	Fpcumap              uintptr
	Flc_time_curr        uintptr
}

type Twchar_t = uint16

type Twctype_t = uint16

type Twint_t = uint16

func Xbitmap_and_inplace(tls *libc.TLS, base uintptr, other uintptr, n Ti32) {
	var i int32
	_ = i
	i = 0
	for {
		if !(i < n/int32(m___CHAR_BIT__)) {
			break
		}
		**(**Tu8)(__ccgo_up(base + uintptr(i))) = uint8(int32(**(**Tu8)(__ccgo_up(base + uintptr(i)))) & int32(**(**Tu8)(__ccgo_up(other + uintptr(i)))))
		goto _1
	_1:
		;
		i = i + 1
	}
}

func Xbitmap_get(tls *libc.TLS, bitmap uintptr, position Ti32) (r int32) {
	return int32(**(**Tu8)(__ccgo_up(bitmap + uintptr(position/int32(m___CHAR_BIT__))))) >> (position % int32(m___CHAR_BIT__)) & int32(1)
}

func Xnpy_token_next(tls *libc.TLS, start uintptr, end uintptr, out uintptr) (r int32) {
	var curr uint8
	var ptr, start1, start2, v1 uintptr
	_, _, _, _, _ = curr, ptr, start1, start2, v1
	ptr = start
	for ptr < end {
		curr = **(**uint8)(__ccgo_up(ptr))
		if Xis_whitespace(tls, int8(curr)) != 0 {
			ptr = ptr + 1
			continue
		} else {
			if int32(curr) == int32('(') {
				v1 = ptr
				ptr = ptr + 1
				(*TNpyToken)(unsafe.Pointer(out)).Fstart = v1
				(*TNpyToken)(unsafe.Pointer(out)).Fend = ptr
				(*TNpyToken)(unsafe.Pointer(out)).Ftoken_type = int32(_NPY_TOKEN_TYPE_LPAREN)
				return int32(m_VEC0_TOKEN_RESULT_SOME)
			} else {
				if int32(curr) == int32(')') {
					v1 = ptr
					ptr = ptr + 1
					(*TNpyToken)(unsafe.Pointer(out)).Fstart = v1
					(*TNpyToken)(unsafe.Pointer(out)).Fend = ptr
					(*TNpyToken)(unsafe.Pointer(out)).Ftoken_type = int32(_NPY_TOKEN_TYPE_RPAREN)
					return int32(m_VEC0_TOKEN_RESULT_SOME)
				} else {
					if int32(curr) == int32('{') {
						v1 = ptr
						ptr = ptr + 1
						(*TNpyToken)(unsafe.Pointer(out)).Fstart = v1
						(*TNpyToken)(unsafe.Pointer(out)).Fend = ptr
						(*TNpyToken)(unsafe.Pointer(out)).Ftoken_type = int32(_NPY_TOKEN_TYPE_LBRACE)
						return int32(m_VEC0_TOKEN_RESULT_SOME)
					} else {
						if int32(curr) == int32('}') {
							v1 = ptr
							ptr = ptr + 1
							(*TNpyToken)(unsafe.Pointer(out)).Fstart = v1
							(*TNpyToken)(unsafe.Pointer(out)).Fend = ptr
							(*TNpyToken)(unsafe.Pointer(out)).Ftoken_type = int32(_NPY_TOKEN_TYPE_RBRACE)
							return int32(m_VEC0_TOKEN_RESULT_SOME)
						} else {
							if int32(curr) == int32(':') {
								v1 = ptr
								ptr = ptr + 1
								(*TNpyToken)(unsafe.Pointer(out)).Fstart = v1
								(*TNpyToken)(unsafe.Pointer(out)).Fend = ptr
								(*TNpyToken)(unsafe.Pointer(out)).Ftoken_type = int32(_NPY_TOKEN_TYPE_COLON)
								return int32(m_VEC0_TOKEN_RESULT_SOME)
							} else {
								if int32(curr) == int32(',') {
									v1 = ptr
									ptr = ptr + 1
									(*TNpyToken)(unsafe.Pointer(out)).Fstart = v1
									(*TNpyToken)(unsafe.Pointer(out)).Fend = ptr
									(*TNpyToken)(unsafe.Pointer(out)).Ftoken_type = int32(_NPY_TOKEN_TYPE_COMMA)
									return int32(m_VEC0_TOKEN_RESULT_SOME)
								} else {
									if int32(curr) == int32('\'') {
										start1 = ptr
										ptr = ptr + 1
										for ptr < end {
											if int32(**(**uint8)(__ccgo_up(ptr))) == int32('\'') {
												break
											}
											ptr = ptr + 1
										}
										if ptr >= end || int32(**(**uint8)(__ccgo_up(ptr))) != int32('\'') {
											return int32(m_VEC0_TOKEN_RESULT_ERROR)
										}
										(*TNpyToken)(unsafe.Pointer(out)).Fstart = start1
										ptr = ptr + 1
										v1 = ptr
										(*TNpyToken)(unsafe.Pointer(out)).Fend = v1
										(*TNpyToken)(unsafe.Pointer(out)).Ftoken_type = int32(_NPY_TOKEN_TYPE_STRING)
										return int32(m_VEC0_TOKEN_RESULT_SOME)
									} else {
										if int32(curr) == int32('F') && libc.Xstrncmp(tls, ptr, __ccgo_ts+1916, libc.Xstrlen(tls, __ccgo_ts+1916)) == 0 {
											(*TNpyToken)(unsafe.Pointer(out)).Fstart = ptr
											(*TNpyToken)(unsafe.Pointer(out)).Fend = ptr + uintptr(int32(libc.Xstrlen(tls, __ccgo_ts+1916)))
											ptr = (*TNpyToken)(unsafe.Pointer(out)).Fend
											(*TNpyToken)(unsafe.Pointer(out)).Ftoken_type = int32(_NPY_TOKEN_TYPE_FALSE)
											return int32(m_VEC0_TOKEN_RESULT_SOME)
										} else {
											if Xis_digit(tls, int8(curr)) != 0 {
												start2 = ptr
												for ptr < end && Xis_digit(tls, int8(**(**uint8)(__ccgo_up(ptr)))) != 0 {
													ptr = ptr + 1
												}
												(*TNpyToken)(unsafe.Pointer(out)).Fstart = start2
												(*TNpyToken)(unsafe.Pointer(out)).Fend = ptr
												(*TNpyToken)(unsafe.Pointer(out)).Ftoken_type = int32(_NPY_TOKEN_TYPE_NUMBER)
												return int32(m_VEC0_TOKEN_RESULT_SOME)
											} else {
												return int32(m_VEC0_TOKEN_RESULT_ERROR)
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
	return int32(m_VEC0_TOKEN_RESULT_ERROR)
}

func Xvec0Update_Delete(tls *libc.TLS, pVTab uintptr, idValue uintptr) (r int32) {
	bp := tls.Alloc(32)
	defer tls.Free(32)
	var i, rc int32
	var p uintptr
	var _ /* chunkDeleted at bp+24 */ int32
	var _ /* chunk_id at bp+8 */ Ti64
	var _ /* chunk_offset at bp+16 */ Ti64
	var _ /* rowid at bp+0 */ Ti64
	_, _, _ = i, p, rc
	p = pVTab
	if (*Tvec0_vtab)(unsafe.Pointer(p)).FpkIsText != 0 {
		rc = Xvec0_rowid_from_id(tls, p, idValue, bp)
		if rc != m_SQLITE_OK {
			return rc
		}
	} else {
		**(**Ti64)(__ccgo_up(bp)) = libsqlite3.Xsqlite3_value_int64(tls, idValue)
	}
	// 1. Find chunk position for given rowid
	// 2. Ensure that validity bit for position is 1, then set to 0
	// 3. Zero out rowid in chunks.rowid
	// 4. Zero out vector data in all vector column chunks
	// 5. Delete value in _rowids table
	// 1. get chunk_id and chunk_offset from _rowids
	rc = Xvec0_get_chunk_position(tls, p, **(**Ti64)(__ccgo_up(bp)), libc.UintptrFromInt32(0), bp+8, bp+16)
	if rc != m_SQLITE_OK {
		return rc
	}
	// 2. clear validity bit
	rc = Xvec0Update_Delete_ClearValidity(tls, p, **(**Ti64)(__ccgo_up(bp + 8)), uint64(**(**Ti64)(__ccgo_up(bp + 16))))
	if rc != m_SQLITE_OK {
		return rc
	}
	// 3. zero out rowid in chunks.rowids
	rc = Xvec0Update_Delete_ClearRowid(tls, p, **(**Ti64)(__ccgo_up(bp + 8)), uint64(**(**Ti64)(__ccgo_up(bp + 16))))
	if rc != m_SQLITE_OK {
		return rc
	}
	// 4. zero out any data in vector chunks tables
	rc = Xvec0Update_Delete_ClearVectors(tls, p, **(**Ti64)(__ccgo_up(bp + 8)), uint64(**(**Ti64)(__ccgo_up(bp + 16))))
	if rc != m_SQLITE_OK {
		return rc
	}
	// 5. delete from _rowids table
	rc = Xvec0Update_Delete_DeleteRowids(tls, p, **(**Ti64)(__ccgo_up(bp)))
	if rc != m_SQLITE_OK {
		return rc
	}
	// 6. delete any auxiliary rows
	if (*Tvec0_vtab)(unsafe.Pointer(p)).FnumAuxiliaryColumns > 0 {
		rc = Xvec0Update_Delete_DeleteAux(tls, p, **(**Ti64)(__ccgo_up(bp)))
		if rc != m_SQLITE_OK {
			return rc
		}
	}
	// 7. delete metadata
	i = 0
	for {
		if !(i < (*Tvec0_vtab)(unsafe.Pointer(p)).FnumMetadataColumns) {
			break
		}
		rc = Xvec0Update_Delete_ClearMetadata(tls, p, i, **(**Ti64)(__ccgo_up(bp)), **(**Ti64)(__ccgo_up(bp + 8)), uint64(**(**Ti64)(__ccgo_up(bp + 16))))
		if rc != m_SQLITE_OK {
			return rc
		}
		goto _1
	_1:
		;
		i = i + 1
	}
	// 8. reclaim chunk if fully empty
	rc = Xvec0Update_Delete_DeleteChunkIfEmpty(tls, p, **(**Ti64)(__ccgo_up(bp + 8)), bp+24)
	if rc != m_SQLITE_OK {
		return rc
	}
	return m_SQLITE_OK
}

func Xvec0Update_Delete_ClearRowid(tls *libc.TLS, p uintptr, chunk_id Ti64, chunk_offset Tu64) (r int32) {
	bp := tls.Alloc(64)
	defer tls.Free(64)
	var brc, rc int32
	var _ /* blobChunksRowids at bp+0 */ uintptr
	var _ /* zero at bp+8 */ Ti64
	_, _ = brc, rc
	**(**uintptr)(__ccgo_up(bp)) = libc.UintptrFromInt32(0)
	**(**Ti64)(__ccgo_up(bp + 8)) = 0
	rc = libsqlite3.Xsqlite3_blob_open(tls, (*Tvec0_vtab)(unsafe.Pointer(p)).Fdb, (*Tvec0_vtab)(unsafe.Pointer(p)).FschemaName, (*Tvec0_vtab)(unsafe.Pointer(p)).FshadowChunksName, __ccgo_ts+9690, chunk_id, int32(1), bp)
	if rc != m_SQLITE_OK {
		Xvtab_set_error(tls, p, __ccgo_ts+14034, libc.VaList(bp+24, (*Tvec0_vtab)(unsafe.Pointer(p)).FschemaName, (*Tvec0_vtab)(unsafe.Pointer(p)).FshadowChunksName, chunk_id))
		return int32(m_SQLITE_ERROR)
	}
	rc = libsqlite3.Xsqlite3_blob_write(tls, **(**uintptr)(__ccgo_up(bp)), bp+8, int32(8), int32(chunk_offset*uint64(8)))
	if rc != m_SQLITE_OK {
		Xvtab_set_error(tls, p, __ccgo_ts+14076, libc.VaList(bp+24, (*Tvec0_vtab)(unsafe.Pointer(p)).FschemaName, (*Tvec0_vtab)(unsafe.Pointer(p)).FshadowChunksName, chunk_id, chunk_offset))
	}
	brc = libsqlite3.Xsqlite3_blob_close(tls, **(**uintptr)(__ccgo_up(bp)))
	if rc != m_SQLITE_OK {
		return rc
	}
	if brc != m_SQLITE_OK {
		Xvtab_set_error(tls, p, __ccgo_ts+14130, libc.VaList(bp+24, (*Tvec0_vtab)(unsafe.Pointer(p)).FschemaName, (*Tvec0_vtab)(unsafe.Pointer(p)).FshadowChunksName, chunk_id, chunk_offset))
		return brc
	}
	return m_SQLITE_OK
}

// C documentation
//
//	/**
//	 * @brief Determines the "next available" chunk position for a newly inserted
//	 * vec0 row.
//	 *
//	 * This operation may insert a new "blank" chunk the _chunks table, if there is
//	 * no more space in previous chunks.
//	 *
//	 * @param p: virtual table
//	 * @param partitionKeyValues: array of partition key column values, to constrain
//	 * against any partition key columns.
//	 * @param chunk_rowid: Output rowid of the chunk in the _chunks virtual table
//	 * that has the avialabiity.
//	 * @param chunk_offset: Output the index of the available space insert the
//	 * chunk, based on the index of the first available validity bit.
//	 * @param pBlobValidity: Output blob of the validity column of the available
//	 * chunk. Will be opened with read/write permissions.
//	 * @param pValidity: Output buffer of the original chunk's validity column.
//	 *    Needs to be cleaned up with sqlite3_free().
//	 * @return int SQLITE_OK on success, error code on failure
//	 */
func Xvec0Update_InsertNextAvailableStep(tls *libc.TLS, p uintptr, partitionKeyValues uintptr, chunk_rowid uintptr, chunk_offset uintptr, blobChunksValidity uintptr, bufferChunksValidity uintptr) (r int32) {
	bp := tls.Alloc(48)
	defer tls.Free(48)
	var i, j, rc int32
	var validitySize Ti64
	_, _, _, _ = i, j, rc, validitySize
	**(**Ti64)(__ccgo_up(chunk_offset)) = int64(-int32(1))
	rc = Xvec0_get_latest_chunk_rowid(tls, p, chunk_rowid, partitionKeyValues)
	if rc == int32(m_SQLITE_EMPTY) {
		goto done
	}
	if rc != m_SQLITE_OK {
		goto cleanup
	}
	rc = libsqlite3.Xsqlite3_blob_open(tls, (*Tvec0_vtab)(unsafe.Pointer(p)).Fdb, (*Tvec0_vtab)(unsafe.Pointer(p)).FschemaName, (*Tvec0_vtab)(unsafe.Pointer(p)).FshadowChunksName, __ccgo_ts+11207, **(**Ti64)(__ccgo_up(chunk_rowid)), int32(1), blobChunksValidity)
	if rc != m_SQLITE_OK {
		// IMP: V22053_06123
		Xvtab_set_error(tls, p, __ccgo_ts+11216, libc.VaList(bp+8, (*Tvec0_vtab)(unsafe.Pointer(p)).FschemaName, (*Tvec0_vtab)(unsafe.Pointer(p)).FshadowChunksName, **(**Ti64)(__ccgo_up(chunk_rowid))))
		goto cleanup
	}
	validitySize = int64(libsqlite3.Xsqlite3_blob_bytes(tls, **(**uintptr)(__ccgo_up(blobChunksValidity))))
	if validitySize != int64((*Tvec0_vtab)(unsafe.Pointer(p)).Fchunk_size/int32(m___CHAR_BIT__)) {
		// IMP: V29362_13432
		Xvtab_set_error(tls, p, __ccgo_ts+11286, libc.VaList(bp+8, (*Tvec0_vtab)(unsafe.Pointer(p)).FschemaName, (*Tvec0_vtab)(unsafe.Pointer(p)).FshadowChunksName, **(**Ti64)(__ccgo_up(chunk_rowid)), int64((*Tvec0_vtab)(unsafe.Pointer(p)).Fchunk_size/libc.Int32FromInt32(m___CHAR_BIT__)), validitySize))
		rc = int32(m_SQLITE_ERROR)
		goto cleanup
	}
	**(**uintptr)(__ccgo_up(bufferChunksValidity)) = libsqlite3.Xsqlite3_malloc(tls, int32(validitySize))
	if !(**(**uintptr)(__ccgo_up(bufferChunksValidity)) != 0) {
		Xvtab_set_error(tls, p, __ccgo_ts+11389, 0)
		rc = int32(m_SQLITE_NOMEM)
		goto cleanup
	}
	rc = libsqlite3.Xsqlite3_blob_read(tls, **(**uintptr)(__ccgo_up(blobChunksValidity)), **(**uintptr)(__ccgo_up(bufferChunksValidity)), int32(validitySize), 0)
	if rc != m_SQLITE_OK {
		Xvtab_set_error(tls, p, __ccgo_ts+11462, libc.VaList(bp+8, (*Tvec0_vtab)(unsafe.Pointer(p)).FschemaName, (*Tvec0_vtab)(unsafe.Pointer(p)).FshadowChunksName, **(**Ti64)(__ccgo_up(chunk_rowid))))
		goto cleanup
	}
	// find the next available offset, ie first `0` in the bitmap.
	i = 0
	for {
		if !(int64(i) < validitySize) {
			break
		}
		if int32(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bufferChunksValidity)) + uintptr(i)))) == int32(0b11111111) {
			goto _1
		}
		j = 0
		for {
			if !(j < int32(m___CHAR_BIT__)) {
				break
			}
			if int32(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bufferChunksValidity)) + uintptr(i))))>>j&int32(1) == 0 {
				**(**Ti64)(__ccgo_up(chunk_offset)) = int64(i*int32(m___CHAR_BIT__) + j)
				goto done
			}
			goto _2
		_2:
			;
			j = j + 1
		}
		goto _1
	_1:
		;
		i = i + 1
	}
	goto done
done:
	;
	// latest chunk was full, so need to create a new one
	if **(**Ti64)(__ccgo_up(chunk_offset)) == int64(-int32(1)) {
		rc = Xvec0_new_chunk(tls, p, partitionKeyValues, chunk_rowid)
		if rc != m_SQLITE_OK {
			// IMP: V08441_25279
			Xvtab_set_error(tls, p, __ccgo_ts+11535, 0)
			rc = int32(m_SQLITE_ERROR) // otherwise raises a DatabaseError and not operational
			// error?
			goto cleanup
		}
		**(**Ti64)(__ccgo_up(chunk_offset)) = 0
		// blobChunksValidity and pValidity are stale, pointing to the previous
		// (full) chunk. to re-assign them
		rc = libsqlite3.Xsqlite3_blob_close(tls, **(**uintptr)(__ccgo_up(blobChunksValidity)))
		libsqlite3.Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bufferChunksValidity)))
		**(**uintptr)(__ccgo_up(blobChunksValidity)) = libc.UintptrFromInt32(0)
		**(**uintptr)(__ccgo_up(bufferChunksValidity)) = libc.UintptrFromInt32(0)
		if rc != m_SQLITE_OK {
			Xvtab_set_error(tls, p, __ccgo_ts+11598, 0)
			rc = int32(m_SQLITE_ERROR)
			goto cleanup
		}
		rc = libsqlite3.Xsqlite3_blob_open(tls, (*Tvec0_vtab)(unsafe.Pointer(p)).Fdb, (*Tvec0_vtab)(unsafe.Pointer(p)).FschemaName, (*Tvec0_vtab)(unsafe.Pointer(p)).FshadowChunksName, __ccgo_ts+11207, **(**Ti64)(__ccgo_up(chunk_rowid)), int32(1), blobChunksValidity)
		if rc != m_SQLITE_OK {
			Xvtab_set_error(tls, p, __ccgo_ts+11702, libc.VaList(bp+8, (*Tvec0_vtab)(unsafe.Pointer(p)).FschemaName, (*Tvec0_vtab)(unsafe.Pointer(p)).FshadowChunksName, **(**Ti64)(__ccgo_up(chunk_rowid))))
			goto cleanup
		}
		validitySize = int64(libsqlite3.Xsqlite3_blob_bytes(tls, **(**uintptr)(__ccgo_up(blobChunksValidity))))
		if validitySize != int64((*Tvec0_vtab)(unsafe.Pointer(p)).Fchunk_size/int32(m___CHAR_BIT__)) {
			Xvtab_set_error(tls, p, __ccgo_ts+11793, libc.VaList(bp+8, (*Tvec0_vtab)(unsafe.Pointer(p)).FschemaName, (*Tvec0_vtab)(unsafe.Pointer(p)).FshadowChunksName, **(**Ti64)(__ccgo_up(chunk_rowid)), (*Tvec0_vtab)(unsafe.Pointer(p)).Fchunk_size/int32(m___CHAR_BIT__), validitySize))
			goto cleanup
		}
		**(**uintptr)(__ccgo_up(bufferChunksValidity)) = libsqlite3.Xsqlite3_malloc(tls, int32(validitySize))
		rc = libsqlite3.Xsqlite3_blob_read(tls, **(**uintptr)(__ccgo_up(blobChunksValidity)), **(**uintptr)(__ccgo_up(bufferChunksValidity)), int32(validitySize), 0)
		if rc != m_SQLITE_OK {
			Xvtab_set_error(tls, p, __ccgo_ts+11908, libc.VaList(bp+8, (*Tvec0_vtab)(unsafe.Pointer(p)).FschemaName, (*Tvec0_vtab)(unsafe.Pointer(p)).FshadowChunksName, **(**Ti64)(__ccgo_up(chunk_rowid))))
			goto cleanup
		}
	}
	rc = m_SQLITE_OK
	goto cleanup
cleanup:
	;
	return rc
	return r
}

// C documentation
//
//	/**
//	 * @brief Extract a vector from a sqlite3_value. Can be a float32, int8, or bit
//	 * vector.
//	 *
//	 * @param value: the sqlite3_value to read from.
//	 * @param vector: Output pointer to vector data.
//	 * @param dimensions: Output number of dimensions
//	 * @param dimensions: Output vector element type
//	 * @param cleanup
//	 * @param pzErrorMessage
//	 * @return int SQLITE_OK on success, error code otherwise
//	 */
func Xvector_from_value(tls *libc.TLS, value uintptr, vector uintptr, dimensions uintptr, element_type uintptr, __ccgo_fp_cleanup uintptr, pzErrorMessage uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var rc, rc1, rc2, subtype int32
	_, _, _, _ = rc, rc1, rc2, subtype
	subtype = int32(libsqlite3.Xsqlite3_value_subtype(tls, value))
	if !(subtype != 0) || subtype == int32(_SQLITE_VEC_ELEMENT_TYPE_FLOAT32) || subtype == int32(m_JSON_SUBTYPE) {
		rc = _fvec_from_value(tls, value, vector, dimensions, __ccgo_fp_cleanup, pzErrorMessage)
		if rc == m_SQLITE_OK {
			**(**_VectorElementType)(__ccgo_up(element_type)) = int32(_SQLITE_VEC_ELEMENT_TYPE_FLOAT32)
		}
		return rc
	}
	if subtype == int32(_SQLITE_VEC_ELEMENT_TYPE_BIT) {
		rc1 = _bitvec_from_value(tls, value, vector, dimensions, __ccgo_fp_cleanup, pzErrorMessage)
		if rc1 == m_SQLITE_OK {
			**(**_VectorElementType)(__ccgo_up(element_type)) = int32(_SQLITE_VEC_ELEMENT_TYPE_BIT)
		}
		return rc1
	}
	if subtype == int32(_SQLITE_VEC_ELEMENT_TYPE_INT8) {
		rc2 = _int8_vec_from_value(tls, value, vector, dimensions, __ccgo_fp_cleanup, pzErrorMessage)
		if rc2 == m_SQLITE_OK {
			**(**_VectorElementType)(__ccgo_up(element_type)) = int32(_SQLITE_VEC_ELEMENT_TYPE_INT8)
		}
		return rc2
	}
	**(**uintptr)(__ccgo_up(pzErrorMessage)) = libsqlite3.Xsqlite3_mprintf(tls, __ccgo_ts+419, libc.VaList(bp+8, subtype))
	return int32(m_SQLITE_ERROR)
}

type _CRT_DOUBLE = T_CRT_DOUBLE

type _CRT_FLOAT = T_CRT_FLOAT

type _HEAPINFO = T_HEAPINFO

type _JUMP_BUFFER = T_JUMP_BUFFER

type _LDBL12 = T_LDBL12

type _LDOUBLE = T_LDOUBLE

type _LONGDOUBLE = T_LONGDOUBLE

type _MM_MANTISSA_NORM_ENUM = T_MM_MANTISSA_NORM_ENUM

type _MM_MANTISSA_SIGN_ENUM = T_MM_MANTISSA_SIGN_ENUM

type _MM_PERM_ENUM = T_MM_PERM_ENUM

type _MM_TERNLOG_ENUM = T_MM_TERNLOG_ENUM

const __MM_HINT_ET0 = 7

const __MM_HINT_ET1 = 6

const __MM_HINT_NTA = 0

const __MM_HINT_T0 = 3

const __MM_HINT_T1 = 2

const __MM_HINT_T2 = 1

const __MM_MANT_NORM_1_2 = 0

const __MM_MANT_NORM_p5_1 = 2

const __MM_MANT_NORM_p5_2 = 1

const __MM_MANT_NORM_p75_1p5 = 3

const __MM_MANT_SIGN_nan = 2

const __MM_MANT_SIGN_src = 0

const __MM_MANT_SIGN_zero = 1

const __MM_PERM_AAAA = 0

const __MM_PERM_AAAB = 1

const __MM_PERM_AAAC = 2

const __MM_PERM_AAAD = 3

const __MM_PERM_AABA = 4

const __MM_PERM_AABB = 5

const __MM_PERM_AABC = 6

const __MM_PERM_AABD = 7

const __MM_PERM_AACA = 8

const __MM_PERM_AACB = 9

const __MM_PERM_AACC = 10

const __MM_PERM_AACD = 11

const __MM_PERM_AADA = 12

const __MM_PERM_AADB = 13

const __MM_PERM_AADC = 14

const __MM_PERM_AADD = 15

const __MM_PERM_ABAA = 16

const __MM_PERM_ABAB = 17

const __MM_PERM_ABAC = 18

const __MM_PERM_ABAD = 19

const __MM_PERM_ABBA = 20

const __MM_PERM_ABBB = 21

const __MM_PERM_ABBC = 22

const __MM_PERM_ABBD = 23

const __MM_PERM_ABCA = 24

const __MM_PERM_ABCB = 25

const __MM_PERM_ABCC = 26

const __MM_PERM_ABCD = 27

const __MM_PERM_ABDA = 28

const __MM_PERM_ABDB = 29

const __MM_PERM_ABDC = 30

const __MM_PERM_ABDD = 31

const __MM_PERM_ACAA = 32

const __MM_PERM_ACAB = 33

const __MM_PERM_ACAC = 34

const __MM_PERM_ACAD = 35

const __MM_PERM_ACBA = 36

const __MM_PERM_ACBB = 37

const __MM_PERM_ACBC = 38

const __MM_PERM_ACBD = 39

const __MM_PERM_ACCA = 40

const __MM_PERM_ACCB = 41

const __MM_PERM_ACCC = 42

const __MM_PERM_ACCD = 43

const __MM_PERM_ACDA = 44

const __MM_PERM_ACDB = 45

const __MM_PERM_ACDC = 46

const __MM_PERM_ACDD = 47

const __MM_PERM_ADAA = 48

const __MM_PERM_ADAB = 49

const __MM_PERM_ADAC = 50

const __MM_PERM_ADAD = 51

const __MM_PERM_ADBA = 52

const __MM_PERM_ADBB = 53

const __MM_PERM_ADBC = 54

const __MM_PERM_ADBD = 55

const __MM_PERM_ADCA = 56

const __MM_PERM_ADCB = 57

const __MM_PERM_ADCC = 58

const __MM_PERM_ADCD = 59

const __MM_PERM_ADDA = 60

const __MM_PERM_ADDB = 61

const __MM_PERM_ADDC = 62

const __MM_PERM_ADDD = 63

const __MM_PERM_BAAA = 64

const __MM_PERM_BAAB = 65

const __MM_PERM_BAAC = 66

const __MM_PERM_BAAD = 67

const __MM_PERM_BABA = 68

const __MM_PERM_BABB = 69

const __MM_PERM_BABC = 70

const __MM_PERM_BABD = 71

const __MM_PERM_BACA = 72

const __MM_PERM_BACB = 73

const __MM_PERM_BACC = 74

const __MM_PERM_BACD = 75

const __MM_PERM_BADA = 76

const __MM_PERM_BADB = 77

const __MM_PERM_BADC = 78

const __MM_PERM_BADD = 79

const __MM_PERM_BBAA = 80

const __MM_PERM_BBAB = 81

const __MM_PERM_BBAC = 82

const __MM_PERM_BBAD = 83

const __MM_PERM_BBBA = 84

const __MM_PERM_BBBB = 85

const __MM_PERM_BBBC = 86

const __MM_PERM_BBBD = 87

const __MM_PERM_BBCA = 88

const __MM_PERM_BBCB = 89

const __MM_PERM_BBCC = 90

const __MM_PERM_BBCD = 91

const __MM_PERM_BBDA = 92

const __MM_PERM_BBDB = 93

const __MM_PERM_BBDC = 94

const __MM_PERM_BBDD = 95

const __MM_PERM_BCAA = 96

const __MM_PERM_BCAB = 97

const __MM_PERM_BCAC = 98

const __MM_PERM_BCAD = 99

const __MM_PERM_BCBA = 100

const __MM_PERM_BCBB = 101

const __MM_PERM_BCBC = 102

const __MM_PERM_BCBD = 103

const __MM_PERM_BCCA = 104

const __MM_PERM_BCCB = 105

const __MM_PERM_BCCC = 106

const __MM_PERM_BCCD = 107

const __MM_PERM_BCDA = 108

const __MM_PERM_BCDB = 109

const __MM_PERM_BCDC = 110

const __MM_PERM_BCDD = 111

const __MM_PERM_BDAA = 112

const __MM_PERM_BDAB = 113

const __MM_PERM_BDAC = 114

const __MM_PERM_BDAD = 115

const __MM_PERM_BDBA = 116

const __MM_PERM_BDBB = 117

const __MM_PERM_BDBC = 118

const __MM_PERM_BDBD = 119

const __MM_PERM_BDCA = 120

const __MM_PERM_BDCB = 121

const __MM_PERM_BDCC = 122

const __MM_PERM_BDCD = 123

const __MM_PERM_BDDA = 124

const __MM_PERM_BDDB = 125

const __MM_PERM_BDDC = 126

const __MM_PERM_BDDD = 127

const __MM_PERM_CAAA = 128

const __MM_PERM_CAAB = 129

const __MM_PERM_CAAC = 130

const __MM_PERM_CAAD = 131

const __MM_PERM_CABA = 132

const __MM_PERM_CABB = 133

const __MM_PERM_CABC = 134

const __MM_PERM_CABD = 135

const __MM_PERM_CACA = 136

const __MM_PERM_CACB = 137

const __MM_PERM_CACC = 138

const __MM_PERM_CACD = 139

const __MM_PERM_CADA = 140

const __MM_PERM_CADB = 141

const __MM_PERM_CADC = 142

const __MM_PERM_CADD = 143

const __MM_PERM_CBAA = 144

const __MM_PERM_CBAB = 145

const __MM_PERM_CBAC = 146

const __MM_PERM_CBAD = 147

const __MM_PERM_CBBA = 148

const __MM_PERM_CBBB = 149

const __MM_PERM_CBBC = 150

const __MM_PERM_CBBD = 151

const __MM_PERM_CBCA = 152

const __MM_PERM_CBCB = 153

const __MM_PERM_CBCC = 154

const __MM_PERM_CBCD = 155

const __MM_PERM_CBDA = 156

const __MM_PERM_CBDB = 157

const __MM_PERM_CBDC = 158

const __MM_PERM_CBDD = 159

const __MM_PERM_CCAA = 160

const __MM_PERM_CCAB = 161

const __MM_PERM_CCAC = 162

const __MM_PERM_CCAD = 163

const __MM_PERM_CCBA = 164

const __MM_PERM_CCBB = 165

const __MM_PERM_CCBC = 166

const __MM_PERM_CCBD = 167

const __MM_PERM_CCCA = 168

const __MM_PERM_CCCB = 169

const __MM_PERM_CCCC = 170

const __MM_PERM_CCCD = 171

const __MM_PERM_CCDA = 172

const __MM_PERM_CCDB = 173

const __MM_PERM_CCDC = 174

const __MM_PERM_CCDD = 175

const __MM_PERM_CDAA = 176

const __MM_PERM_CDAB = 177

const __MM_PERM_CDAC = 178

const __MM_PERM_CDAD = 179

const __MM_PERM_CDBA = 180

const __MM_PERM_CDBB = 181

const __MM_PERM_CDBC = 182

const __MM_PERM_CDBD = 183

const __MM_PERM_CDCA = 184

const __MM_PERM_CDCB = 185

const __MM_PERM_CDCC = 186

const __MM_PERM_CDCD = 187

const __MM_PERM_CDDA = 188

const __MM_PERM_CDDB = 189

const __MM_PERM_CDDC = 190

const __MM_PERM_CDDD = 191

const __MM_PERM_DAAA = 192

const __MM_PERM_DAAB = 193

const __MM_PERM_DAAC = 194

const __MM_PERM_DAAD = 195

const __MM_PERM_DABA = 196

const __MM_PERM_DABB = 197

const __MM_PERM_DABC = 198

const __MM_PERM_DABD = 199

const __MM_PERM_DACA = 200

const __MM_PERM_DACB = 201

const __MM_PERM_DACC = 202

const __MM_PERM_DACD = 203

const __MM_PERM_DADA = 204

const __MM_PERM_DADB = 205

const __MM_PERM_DADC = 206

const __MM_PERM_DADD = 207

const __MM_PERM_DBAA = 208

const __MM_PERM_DBAB = 209

const __MM_PERM_DBAC = 210

const __MM_PERM_DBAD = 211

const __MM_PERM_DBBA = 212

const __MM_PERM_DBBB = 213

const __MM_PERM_DBBC = 214

const __MM_PERM_DBBD = 215

const __MM_PERM_DBCA = 216

const __MM_PERM_DBCB = 217

const __MM_PERM_DBCC = 218

const __MM_PERM_DBCD = 219

const __MM_PERM_DBDA = 220

const __MM_PERM_DBDB = 221

const __MM_PERM_DBDC = 222

const __MM_PERM_DBDD = 223

const __MM_PERM_DCAA = 224

const __MM_PERM_DCAB = 225

const __MM_PERM_DCAC = 226

const __MM_PERM_DCAD = 227

const __MM_PERM_DCBA = 228

const __MM_PERM_DCBB = 229

const __MM_PERM_DCBC = 230

const __MM_PERM_DCBD = 231

const __MM_PERM_DCCA = 232

const __MM_PERM_DCCB = 233

const __MM_PERM_DCCC = 234

const __MM_PERM_DCCD = 235

const __MM_PERM_DCDA = 236

const __MM_PERM_DCDB = 237

const __MM_PERM_DCDC = 238

const __MM_PERM_DCDD = 239

const __MM_PERM_DDAA = 240

const __MM_PERM_DDAB = 241

const __MM_PERM_DDAC = 242

const __MM_PERM_DDAD = 243

const __MM_PERM_DDBA = 244

const __MM_PERM_DDBB = 245

const __MM_PERM_DDBC = 246

const __MM_PERM_DDBD = 247

const __MM_PERM_DDCA = 248

const __MM_PERM_DDCB = 249

const __MM_PERM_DDCC = 250

const __MM_PERM_DDCD = 251

const __MM_PERM_DDDA = 252

const __MM_PERM_DDDB = 253

const __MM_PERM_DDDC = 254

const __MM_PERM_DDDD = 255

const __MM_TERNLOG_A = 240

const __MM_TERNLOG_B = 204

const __MM_TERNLOG_C = 170

type __mm_hint = int32

type _complex = T_complex

type _div_t = T_div_t

type _exception = T_exception

type _heapinfo = T_heapinfo

type _invalid_parameter_handler = T_invalid_parameter_handler

type _iobuf = T_iobuf

type _ldiv_t = T_ldiv_t

type _locale_t = T_locale_t

type _locale_tstruct = T_locale_tstruct

type _off64_t = T_off64_t

type _off_t = T_off_t

type _onexit_t = T_onexit_t

type _purecall_handler = T_purecall_handler

func _vec0Filter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var idxStrLength, numValueEntries int32
	var p, pCur uintptr
	var query_plan int8
	_, _, _, _, _ = idxStrLength, numValueEntries, p, pCur, query_plan
	p = (*Tsqlite3_vtab_cursor)(unsafe.Pointer(pVtabCursor)).FpVtab
	pCur = pVtabCursor
	Xvec0_cursor_clear(tls, pCur)
	idxStrLength = int32(libc.Xstrlen(tls, idxStr))
	if idxStrLength <= 0 {
		return int32(m_SQLITE_ERROR)
	}
	if (idxStrLength-int32(1))%int32(4) != 0 {
		return int32(m_SQLITE_ERROR)
	}
	numValueEntries = (idxStrLength - int32(1)) / int32(4)
	if numValueEntries != argc {
		return int32(m_SQLITE_ERROR)
	}
	query_plan = **(**int8)(__ccgo_up(idxStr))
	switch int32(query_plan) {
	case int32(_VEC0_QUERY_PLAN_FULLSCAN):
		return Xvec0Filter_fullscan(tls, p, pCur)
	case int32(_VEC0_QUERY_PLAN_KNN):
		return Xvec0Filter_knn(tls, pCur, p, idxNum, idxStr, argc, argv)
	case int32(_VEC0_QUERY_PLAN_POINT):
		return Xvec0Filter_point(tls, pCur, p, argc, argv)
	default:
		Xvtab_set_error(tls, (*Tsqlite3_vtab_cursor)(unsafe.Pointer(pVtabCursor)).FpVtab, __ccgo_ts+10745, libc.VaList(bp+8, idxStr))
		return int32(m_SQLITE_ERROR)
	}
	return r
}

func _vec_eachBestIndex(tls *libc.TLS, pVTab uintptr, pIdxInfo uintptr) (r int32) {
	var hasVector, i int32
	var pCons uintptr
	_, _, _ = hasVector, i, pCons
	_ = pVTab
	hasVector = 0
	i = 0
	for {
		if !(i < (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint) {
			break
		}
		pCons = (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(i)*12
		// printf("i=%d iColumn=%d, op=%d, usable=%d\n", i, pCons->iColumn,
		// pCons->op, pCons->usable);
		switch (*Tsqlite3_index_constraint)(unsafe.Pointer(pCons)).FiColumn {
		case int32(m_VEC_EACH_COLUMN_VECTOR):
			if int32((*Tsqlite3_index_constraint)(unsafe.Pointer(pCons)).Fop) == int32(m_SQLITE_INDEX_CONSTRAINT_EQ) && (*Tsqlite3_index_constraint)(unsafe.Pointer(pCons)).Fusable != 0 {
				hasVector = int32(1)
				(**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8))).FargvIndex = int32(1)
				(**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8))).Fomit = uint8(1)
			}
			break
		}
		goto _1
	_1:
		;
		i = i + 1
	}
	if !(hasVector != 0) {
		return int32(m_SQLITE_CONSTRAINT)
	}
	(*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = libc.Float64FromInt32(100000)
	(*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(100000)
	return m_SQLITE_OK
}

func _vec_eachColumn(tls *libc.TLS, cur uintptr, context uintptr, i int32) (r int32) {
	var pCur uintptr
	var x Tu8
	_, _ = pCur, x
	pCur = cur
	switch i {
	case m_VEC_EACH_COLUMN_VALUE:
		switch (*Tvec_each_cursor)(unsafe.Pointer(pCur)).Fvector_type {
		case int32(_SQLITE_VEC_ELEMENT_TYPE_FLOAT32):
			libsqlite3.Xsqlite3_result_double(tls, context, float64(**(**Tf32)(__ccgo_up((*Tvec_each_cursor)(unsafe.Pointer(pCur)).Fvector + uintptr((*Tvec_each_cursor)(unsafe.Pointer(pCur)).FiRowid)*4))))
		case int32(_SQLITE_VEC_ELEMENT_TYPE_BIT):
			x = **(**Tu8)(__ccgo_up((*Tvec_each_cursor)(unsafe.Pointer(pCur)).Fvector + uintptr((*Tvec_each_cursor)(unsafe.Pointer(pCur)).FiRowid/int64(m___CHAR_BIT__))))
			libsqlite3.Xsqlite3_result_int(tls, context, libc.BoolInt32(int32(x)&(int32(0b10000000)>>((*Tvec_each_cursor)(unsafe.Pointer(pCur)).FiRowid%int64(m___CHAR_BIT__))) > 0))
		case int32(_SQLITE_VEC_ELEMENT_TYPE_INT8):
			libsqlite3.Xsqlite3_result_int(tls, context, int32(**(**Ti8)(__ccgo_up((*Tvec_each_cursor)(unsafe.Pointer(pCur)).Fvector + uintptr((*Tvec_each_cursor)(unsafe.Pointer(pCur)).FiRowid)))))
			break
		}
		break
	}
	return m_SQLITE_OK
}

func _vec_eachEof(tls *libc.TLS, cur uintptr) (r int32) {
	var pCur uintptr
	_ = pCur
	pCur = cur
	return libc.BoolInt32((*Tvec_each_cursor)(unsafe.Pointer(pCur)).FiRowid >= int64((*Tvec_each_cursor)(unsafe.Pointer(pCur)).Fdimensions))
}

func _vec_npy_eachBestIndex(tls *libc.TLS, pVTab uintptr, pIdxInfo uintptr) (r int32) {
	var hasInput, i int32
	var pCons uintptr
	_, _, _ = hasInput, i, pCons
	i = 0
	for {
		if !(i < (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint) {
			break
		}
		pCons = (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(i)*12
		// printf("i=%d iColumn=%d, op=%d, usable=%d\n", i, pCons->iColumn,
		// pCons->op, pCons->usable);
		switch (*Tsqlite3_index_constraint)(unsafe.Pointer(pCons)).FiColumn {
		case int32(m_VEC_NPY_EACH_COLUMN_INPUT):
			if int32((*Tsqlite3_index_constraint)(unsafe.Pointer(pCons)).Fop) == int32(m_SQLITE_INDEX_CONSTRAINT_EQ) && (*Tsqlite3_index_constraint)(unsafe.Pointer(pCons)).Fusable != 0 {
				hasInput = int32(1)
				(**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8))).FargvIndex = int32(1)
				(**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8))).Fomit = uint8(1)
			}
			break
		}
		goto _1
	_1:
		;
		i = i + 1
	}
	if !(hasInput != 0) {
		(*Tsqlite3_vtab)(unsafe.Pointer(pVTab)).FzErrMsg = libsqlite3.Xsqlite3_mprintf(tls, __ccgo_ts+3371, 0)
		return int32(m_SQLITE_ERROR)
	}
	(*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = libc.Float64FromInt32(100000)
	(*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(100000)
	return m_SQLITE_OK
}

func _vec_static_blob_entriesBestIndex(tls *libc.TLS, pVTab uintptr, pIdxInfo uintptr) (r int32) {
	var i, iColumn, iKTerm, iLimitTerm, iMatchTerm, op int32
	var p uintptr
	_, _, _, _, _, _, _ = i, iColumn, iKTerm, iLimitTerm, iMatchTerm, op, p
	p = pVTab
	iMatchTerm = -int32(1)
	iLimitTerm = -int32(1)
	// int iRowidTerm = -1; // https://github.com/asg017/sqlite-vec/issues/47
	iKTerm = -int32(1)
	i = 0
	for {
		if !(i < (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint) {
			break
		}
		if !((**(**Tsqlite3_index_constraint)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(i)*12))).Fusable != 0) {
			goto _1
		}
		iColumn = (**(**Tsqlite3_index_constraint)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(i)*12))).FiColumn
		op = int32((**(**Tsqlite3_index_constraint)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(i)*12))).Fop)
		if op == int32(m_SQLITE_INDEX_CONSTRAINT_MATCH) && iColumn == m_VEC_STATIC_BLOB_ENTRIES_VECTOR {
			if iMatchTerm > -int32(1) {
				// https://github.com/asg017/sqlite-vec/issues/51
				return int32(m_SQLITE_ERROR)
			}
			iMatchTerm = i
		}
		if op == int32(m_SQLITE_INDEX_CONSTRAINT_LIMIT) {
			iLimitTerm = i
		}
		if op == int32(m_SQLITE_INDEX_CONSTRAINT_EQ) && iColumn == int32(m_VEC_STATIC_BLOB_ENTRIES_K) {
			iKTerm = i
		}
		goto _1
	_1:
		;
		i = i + 1
	}
	if iMatchTerm >= 0 {
		if iLimitTerm < 0 && iKTerm < 0 {
			// https://github.com/asg017/sqlite-vec/issues/51
			return int32(m_SQLITE_ERROR)
		}
		if iLimitTerm >= 0 && iKTerm >= 0 {
			return int32(m_SQLITE_ERROR) // limit or k, not both
		}
		if (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnOrderBy < int32(1) {
			Xvtab_set_error(tls, pVTab, __ccgo_ts+16003, 0)
			return int32(m_SQLITE_CONSTRAINT)
		}
		if (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnOrderBy > int32(1) {
			// https://github.com/asg017/sqlite-vec/issues/51
			Xvtab_set_error(tls, pVTab, __ccgo_ts+16030, 0)
			return int32(m_SQLITE_CONSTRAINT)
		}
		if (**(**Tsqlite3_index_orderby)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy))).FiColumn != int32(m_VEC_STATIC_BLOB_ENTRIES_DISTANCE) {
			Xvtab_set_error(tls, pVTab, __ccgo_ts+16067, 0)
			return int32(m_SQLITE_CONSTRAINT)
		}
		if (**(**Tsqlite3_index_orderby)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy))).Fdesc != 0 {
			Xvtab_set_error(tls, pVTab, __ccgo_ts+8832, 0)
			return int32(m_SQLITE_CONSTRAINT)
		}
		(*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = int32(_VEC_SBE__QUERYPLAN_KNN)
		(*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = libc.Float64FromInt32(10)
		(*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(10)
		(*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).ForderByConsumed = int32(1)
		(**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iMatchTerm)*8))).FargvIndex = int32(1)
		(**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iMatchTerm)*8))).Fomit = uint8(1)
		if iLimitTerm >= 0 {
			(**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iLimitTerm)*8))).FargvIndex = int32(2)
			(**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iLimitTerm)*8))).Fomit = uint8(1)
		} else {
			(**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iKTerm)*8))).FargvIndex = int32(2)
			(**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iKTerm)*8))).Fomit = uint8(1)
		}
	} else {
		(*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = int32(_VEC_SBE__QUERYPLAN_FULLSCAN)
		(*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64((*Tstatic_blob)(unsafe.Pointer((*Tvec_static_blob_entries_vtab)(unsafe.Pointer(p)).Fblob)).Fnvectors)
		(*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64((*Tstatic_blob)(unsafe.Pointer((*Tvec_static_blob_entries_vtab)(unsafe.Pointer(p)).Fblob)).Fnvectors)
	}
	return m_SQLITE_OK
}

type fpos_t = Tfpos_t

/*
** 2001-09-15
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This header file defines the interface that the SQLite library
** presents to client programs.  If a C-function, structure, datatype,
** or constant definition does not appear in this file, then it is
** not a published API of SQLite, is subject to change without
** notice, and should not be referenced by programs that use SQLite.
**
** Some of the definitions that are in this file are marked as
** "experimental".  Experimental interfaces are normally new
** features recently added to SQLite.  We do not anticipate changes
** to experimental interfaces but reserve the right to make minor changes
** if experience from use "in the wild" suggest such changes are prudent.
**
** The official C-language API documentation for SQLite is derived
** from comments in this file.  This file is the authoritative source
** on how SQLite interfaces are supposed to operate.
**
** The name of this file under configuration management is "sqlite.h.in".
** The makefile makes some minor changes to this file (such as inserting
** the version number) and changes its name to "sqlite3.h" as
** part of the build process.
 */

type jmp_buf = Tjmp_buf

type localeinfo_struct = Tlocaleinfo_struct

const m_BUFSIZ = 512

const m_CW_DEFAULT = "_CW_DEFAULT"

const m_DOMAIN = "_DOMAIN"

const m_DUMMYSTRUCTNAME = "s"

const m_DUMMYSTRUCTNAME1 = "s1"

const m_DUMMYSTRUCTNAME2 = "s2"

const m_DUMMYSTRUCTNAME3 = "s3"

const m_DUMMYSTRUCTNAME4 = "s4"

const m_DUMMYSTRUCTNAME5 = "s5"

const m_DUMMYUNIONNAME = "u"

const m_DUMMYUNIONNAME1 = "u1"

const m_DUMMYUNIONNAME2 = "u2"

const m_DUMMYUNIONNAME3 = "u3"

const m_DUMMYUNIONNAME4 = "u4"

const m_DUMMYUNIONNAME5 = "u5"

const m_DUMMYUNIONNAME6 = "u6"

const m_DUMMYUNIONNAME7 = "u7"

const m_DUMMYUNIONNAME8 = "u8"

const m_DUMMYUNIONNAME9 = "u9"

const m_EADDRINUSE = 100

const m_EADDRNOTAVAIL = 101

const m_EAFNOSUPPORT = 102

const m_EALREADY = 103

const m_EBADMSG = 104

const m_ECANCELED = 105

const m_ECONNABORTED = 106

const m_ECONNREFUSED = 107

const m_ECONNRESET = 108

const m_EDEADLK = 36

const m_EDESTADDRREQ = 109

const m_EHOSTUNREACH = 110

const m_EIDRM = 111

const m_EILSEQ = 42

const m_EINPROGRESS = 112

const m_EISCONN = 113

const m_ELOOP = 114

const m_EMSGSIZE = 115

const m_ENAMETOOLONG = 38

const m_ENETDOWN = 116

const m_ENETRESET = 117

const m_ENETUNREACH = 118

const m_ENOBUFS = 119

const m_ENODATA = 120

const m_ENOFILE = "ENOENT"

const m_ENOLCK = 39

const m_ENOLINK = 121

const m_ENOMSG = 122

const m_ENOPROTOOPT = 123

const m_ENOSR = 124

const m_ENOSTR = 125

const m_ENOSYS = 40

const m_ENOTCONN = 126

const m_ENOTEMPTY = 41

const m_ENOTRECOVERABLE = 127

const m_ENOTSOCK = 128

const m_ENOTSUP = 129

const m_EOPNOTSUPP = 130

const m_EOVERFLOW = 132

const m_EOWNERDEAD = 133

const m_EPROTO = 134

const m_EPROTONOSUPPORT = 135

const m_EPROTOTYPE = 136

const m_ETIME = 137

const m_ETIMEDOUT = 138

const m_ETXTBSY = 139

const m_EWOULDBLOCK = 140

const m_FILENAME_MAX = 260

const m_FP_NDENORM = "_FPCLASS_ND"

const m_FP_NINF = "_FPCLASS_NINF"

const m_FP_NNORM = "_FPCLASS_NN"

const m_FP_NZERO = "_FPCLASS_NZ"

const m_FP_PDENORM = "_FPCLASS_PD"

const m_FP_PINF = "_FPCLASS_PINF"

const m_FP_PNORM = "_FPCLASS_PN"

const m_FP_PZERO = "_FPCLASS_PZ"

const m_FP_QNAN = "_FPCLASS_QNAN"

const m_FP_SNAN = "_FPCLASS_SNAN"

const m_HUGE = "_HUGE"

const m_INT16_MAX = 32767

const m_INT32_MAX = 2147483647

const m_INT64_MAX = 9223372036854775807

const m_INT_FAST16_MAX = "INT16_MAX"

const m_INT_FAST16_MIN = "INT16_MIN"

const m_L_tmpnam_s = "L_tmpnam"

const m_MB_LEN_MAX = 5

const m_MCW_PC = "_MCW_PC"

const m_MINGW_HAS_DDK_H = 1

const m_MINGW_HAS_SECURE_API = 1

const m_NONAMELESSSTRUCT = 1

const m_NONAMELESSUNION = 1

const m_OVERFLOW = "_OVERFLOW"

const m_PATH_MAX = 260

const m_PC_24 = "_PC_24"

const m_PC_53 = "_PC_53"

const m_PC_64 = "_PC_64"

const m_PLOSS = "_PLOSS"

const m_PRIXMAX = "PRIX64"

const m_PRIdMAX = "PRId64"

const m_PRIiMAX = "PRIi64"

const m_PRIoMAX = "PRIo64"

const m_PRIuMAX = "PRIu64"

const m_PRIxMAX = "PRIx64"

const m_P_tmpdir = "_P_tmpdir"

const m_RAND_MAX = 0x7fff

const m_SCNd64 = "PRId64"

const m_SCNdFAST16 = "hd"

const m_SCNdFAST64 = "PRId64"

const m_SCNdLEAST64 = "PRId64"

const m_SCNdMAX = "PRId64"

const m_SCNi64 = "PRIi64"

const m_SCNiFAST16 = "hi"

const m_SCNiFAST64 = "PRIi64"

const m_SCNiLEAST64 = "PRIi64"

const m_SCNiMAX = "PRIi64"

const m_SCNo64 = "PRIo64"

const m_SCNoFAST16 = "ho"

const m_SCNoFAST64 = "PRIo64"

const m_SCNoLEAST64 = "PRIo64"

const m_SCNoMAX = "PRIo64"

const m_SCNu64 = "PRIu64"

const m_SCNuFAST16 = "hu"

const m_SCNuFAST64 = "PRIu64"

const m_SCNuLEAST64 = "PRIu64"

const m_SCNuMAX = "PRIu64"

const m_SCNx64 = "PRIx64"

const m_SCNxFAST16 = "hx"

const m_SCNxFAST64 = "PRIx64"

const m_SCNxLEAST64 = "PRIx64"

const m_SCNxMAX = "PRIx64"

const m_SING = "_SING"

const m_STDERR_FILENO = 2

const m_STDIN_FILENO = 0

const m_STDOUT_FILENO = 1

const m_STRUNCATE = 80

const m_SYS_OPEN = "_SYS_OPEN"

const m_TLOSS = "_TLOSS"

const m_TMP_MAX = 32767

const m_TMP_MAX_S = "TMP_MAX"

const m_UINT16_MAX = 65535

const m_UINT8_MAX = 255

const m_UINT_FAST16_MAX = "UINT16_MAX"

const m_UNDERFLOW = "_UNDERFLOW"

const m_USE___UUIDOF = 1

const m_WCHAR_MAX = 0xffff

const m_WCHAR_MIN = 0

const m_WIN32 = 1

const m_WINAPI = "__stdcall"

const m_WINNT = 1

const m_WINT_MAX = 0xffff

const m__ALLOCA_S_HEAP_MARKER = 56797

const m__ALLOCA_S_STACK_MARKER = 0xCCCC

const m__ALLOCA_S_THRESHOLD = 1024

const m__ANONYMOUS_STRUCT = "__MINGW_EXTENSION"

const m__ANONYMOUS_UNION = "__MINGW_EXTENSION"

const m__ARGMAX = 100

const m__CALL_REPORTFAULT = 0x2

const m__CMP_EQ_OQ = 0

const m__CMP_EQ_OS = 0x10

const m__CMP_EQ_UQ = 0x08

const m__CMP_EQ_US = 0x18

const m__CMP_FALSE_OQ = 0x0b

const m__CMP_FALSE_OS = 0x1b

const m__CMP_GE_OQ = 0x1d

const m__CMP_GE_OS = 0x0d

const m__CMP_GT_OQ = 0x1e

const m__CMP_GT_OS = 0x0e

const m__CMP_LE_OQ = 0x12

const m__CMP_LE_OS = 2

const m__CMP_LT_OQ = 0x11

const m__CMP_LT_OS = 1

const m__CMP_NEQ_OQ = 0x0c

const m__CMP_NEQ_OS = 0x1c

const m__CMP_NEQ_UQ = 4

const m__CMP_NEQ_US = 0x14

const m__CMP_NGE_UQ = 0x19

const m__CMP_NGE_US = 0x09

const m__CMP_NGT_UQ = 0x1a

const m__CMP_NGT_US = 0x0a

const m__CMP_NLE_UQ = 0x16

const m__CMP_NLE_US = 6

const m__CMP_NLT_UQ = 0x15

const m__CMP_NLT_US = 5

const m__CMP_ORD_Q = 7

const m__CMP_ORD_S = 0x17

const m__CMP_TRUE_UQ = 0x0f

const m__CMP_TRUE_US = 0x1f

const m__CMP_UNORD_Q = 3

const m__CMP_UNORD_S = 0x13

const m__CRTIMP2 = "_CRTIMP"

const m__CRTIMP_ALTERNATIVE = "_CRTIMP"

const m__CRTIMP_NOIA64 = "_CRTIMP"

const m__CRTIMP_PURE = "_CRTIMP"

const m__CRT_INTERNAL_LOCAL_PRINTF_OPTIONS = "_CRT_INTERNAL_PRINTF_LEGACY_WIDE_SPECIFIERS"

const m__CRT_INTERNAL_LOCAL_SCANF_OPTIONS = "_CRT_INTERNAL_SCANF_LEGACY_WIDE_SPECIFIERS"

const m__CRT_INTERNAL_PRINTF_LEGACY_MSVCRT_COMPATIBILITY = "0x0008U"

const m__CRT_INTERNAL_PRINTF_LEGACY_THREE_DIGIT_EXPONENTS = "0x0010U"

const m__CRT_INTERNAL_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION = "0x0001U"

const m__CRT_INTERNAL_PRINTF_LEGACY_WIDE_SPECIFIERS = "0x0004U"

const m__CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR = "0x0002U"

const m__CRT_INTERNAL_SCANF_LEGACY_MSVCRT_COMPATIBILITY = "0x0004U"

const m__CRT_INTERNAL_SCANF_LEGACY_WIDE_SPECIFIERS = "0x0002U"

const m__CRT_INTERNAL_SCANF_SECURECRT = "0x0001U"

const m__DN_FLUSH = 0x01000000

const m__DN_SAVE = 0x00000000

const m__DOMAIN = 1

const m__EM_DENORMAL = 0x00080000

const m__EM_INEXACT = 0x00000001

const m__EM_INVALID = 0x00000010

const m__EM_OVERFLOW = 0x00000004

const m__EM_UNDERFLOW = 0x00000002

const m__EM_ZERODIVIDE = 0x00000008

const m__FPCLASS_ND = 0x0010

const m__FPCLASS_NINF = 0x0004

const m__FPCLASS_NN = 0x0008

const m__FPCLASS_NZ = 0x0020

const m__FPCLASS_PD = 0x0080

const m__FPCLASS_PINF = 0x0200

const m__FPCLASS_PN = 0x0100

const m__FPCLASS_PZ = 0x0040

const m__FPCLASS_QNAN = 0x0002

const m__FPCLASS_SNAN = 0x0001

const m__FPE_DENORMAL = 0x82

const m__FPE_EXPLICITGEN = 0x8c

const m__FPE_INEXACT = 0x86

const m__FPE_INVALID = 0x81

const m__FPE_OVERFLOW = 0x84

const m__FPE_SQRTNEG = 0x88

const m__FPE_STACKOVERFLOW = 0x8a

const m__FPE_STACKUNDERFLOW = 0x8b

const m__FPE_UNDERFLOW = 0x85

const m__FPE_UNEMULATED = 0x87

const m__FPE_ZERODIVIDE = 0x83

const m__FREEENTRY = 0

const m__I16_MAX = 32767

const m__I32_MAX = 2147483647

const m__I64_MAX = "9223372036854775807ll"

const m__I8_MAX = 127

const m__IC_AFFINE = 0x00040000

const m__IC_PROJECTIVE = 0x00000000

const m__INTEGRAL_MAX_BITS = 64

const m__IOB_ENTRIES = 20

const m__IOEOF = 0x0010

const m__IOERR = 0x0020

const m__IOFBF = 0x0000

const m__IOLBF = 0x0040

const m__IOMYBUF = 0x0008

const m__IONBF = 0x0004

const m__IOREAD = 0x0001

const m__IORW = 0x0080

const m__IOSTRG = 0x0040

const m__IOWRT = 0x0002

const m__JBLEN = 16

const m__MAX_DIR = 256

const m__MAX_DRIVE = 3

const m__MAX_ENV = 32767

const m__MAX_EXT = 256

const m__MAX_FNAME = 256

const m__MAX_PATH = 260

const m__MAX_WAIT_MALLOC_CRT = 60000

const m__MCRTIMP = "_CRTIMP"

const m__MCW_DN = 0x03000000

const m__MCW_EM = 0x0008001F

const m__MCW_IC = 0x00040000

const m__MCW_PC = 0x00030000

const m__MCW_RC = 0x00000300

const m__MM_CMPINT_EQ = 0x0

const m__MM_CMPINT_GE = 0x5

const m__MM_CMPINT_GT = 0x6

const m__MM_CMPINT_LE = 0x2

const m__MM_CMPINT_LT = 0x1

const m__MM_CMPINT_NE = 0x4

const m__MM_CMPINT_NLE = 0x6

const m__MM_CMPINT_NLT = 0x5

const m__MM_CMPINT_UNUSED = 0x3

const m__MM_DENORMALS_ZERO_MASK = 0x0040

const m__MM_DENORMALS_ZERO_OFF = 0x0000

const m__MM_DENORMALS_ZERO_ON = 0x0040

const m__MM_EXCEPT_DENORM = 0x0002

const m__MM_EXCEPT_DIV_ZERO = 0x0004

const m__MM_EXCEPT_INEXACT = 0x0020

const m__MM_EXCEPT_INVALID = 0x0001

const m__MM_EXCEPT_MASK = 63

const m__MM_EXCEPT_OVERFLOW = 0x0008

const m__MM_EXCEPT_UNDERFLOW = 0x0010

const m__MM_FLUSH_ZERO_MASK = 32768

const m__MM_FLUSH_ZERO_OFF = 0x0000

const m__MM_FLUSH_ZERO_ON = 0x8000

const m__MM_FROUND_CUR_DIRECTION = 4

const m__MM_FROUND_NO_EXC = 0x08

const m__MM_FROUND_RAISE_EXC = 0

const m__MM_FROUND_TO_NEAREST_INT = 0x00

const m__MM_FROUND_TO_NEG_INF = 1

const m__MM_FROUND_TO_POS_INF = 2

const m__MM_FROUND_TO_ZERO = 0x03

const m__MM_MASK_DENORM = 0x0100

const m__MM_MASK_DIV_ZERO = 0x0200

const m__MM_MASK_INEXACT = 0x1000

const m__MM_MASK_INVALID = 0x0080

const m__MM_MASK_MASK = 8064

const m__MM_MASK_OVERFLOW = 0x0400

const m__MM_MASK_UNDERFLOW = 0x0800

const m__MM_ROUND_DOWN = 0x2000

const m__MM_ROUND_MASK = 24576

const m__MM_ROUND_NEAREST = 0x0000

const m__MM_ROUND_TOWARD_ZERO = 0x6000

const m__MM_ROUND_UP = 0x4000

const m__MRTIMP2 = "_CRTIMP"

const m__MSC_VER = 1

const m__NFILE = "_NSTREAM_"

const m__NLSCMPERROR = 2147483647

const m__NSTREAM_ = 512

const m__OLD_P_OVERLAY = 2

const m__OUT_TO_DEFAULT = 0

const m__OUT_TO_MSGBOX = 2

const m__OUT_TO_STDERR = 1

const m__OVERFLOW = 3

const m__PC_24 = 0x00020000

const m__PC_53 = 0x00010000

const m__PC_64 = 0x00000000

const m__PLOSS = 6

const m__P_DETACH = 4

const m__P_NOWAIT = 1

const m__P_NOWAITO = 3

const m__P_OVERLAY = 2

const m__P_WAIT = 0

const m__P_tmpdir = "\\\\"

const m__RC_CHOP = 0x00000300

const m__RC_DOWN = 0x00000100

const m__RC_NEAR = 0x00000000

const m__RC_UP = 0x00000200

const m__REPORT_ERRMODE = 3

const m__ReadBarrier = "_ReadWriteBarrier"

const m__SECURECRT_FILL_BUFFER_PATTERN = 0xFD

const m__SIDD_BIT_MASK = 0x00

const m__SIDD_CMP_EQUAL_ANY = 0x00

const m__SIDD_CMP_EQUAL_EACH = 0x08

const m__SIDD_CMP_EQUAL_ORDERED = 0x0c

const m__SIDD_CMP_RANGES = 0x04

const m__SIDD_LEAST_SIGNIFICANT = 0x00

const m__SIDD_MASKED_NEGATIVE_POLARITY = 0x30

const m__SIDD_MASKED_POSITIVE_POLARITY = 0x20

const m__SIDD_MOST_SIGNIFICANT = 0x40

const m__SIDD_NEGATIVE_POLARITY = 0x10

const m__SIDD_POSITIVE_POLARITY = 0x00

const m__SIDD_SBYTE_OPS = 0x02

const m__SIDD_SWORD_OPS = 0x03

const m__SIDD_UBYTE_OPS = 0x00

const m__SIDD_UNIT_MASK = 0x40

const m__SIDD_UWORD_OPS = 0x01

const m__SING = 2

const m__SW_SQRTNEG = 0x0080

const m__SW_STACKOVERFLOW = 0x0200

const m__SW_STACKUNDERFLOW = 0x0400

const m__SW_UNEMULATED = 0x0040

const m__SYS_OPEN = 20

const m__TLOSS = 5

const m__TWO_DIGIT_EXPONENT = 0x1

const m__UI16_MAX = "0xffffu"

const m__UI32_MAX = "0xffffffffu"

const m__UI64_MAX = "0xffffffffffffffffull"

const m__UI8_MAX = "0xffu"

const m__UNDERFLOW = 4

const m__USEDENTRY = 1

const m__WAIT_CHILD = 0

const m__WAIT_GRANDCHILD = 1

const m__WConst_return = "_CONST_RETURN"

const m__WIN32 = 1

const m__WIN32_WINNT = 0xa00

const m__WRITE_ABORT_MSG = 0x1

const m__WriteBarrier = "_ReadWriteBarrier"

const m___C89_NAMELESS = "__MINGW_EXTENSION"

const m___CRTDECL = "__cdecl"

const m___CRT_INLINE = "__inline"

const m___GNUC_MINOR__ = 0

const m___GNUC_WIDE_EXECUTION_CHARSET_NAME = "UTF-16LE"

const m___GNU_EXTENSION = "__MINGW_EXTENSION"

const m___GOT_SECURE_LIB__ = "__STDC_SECURE_LIB__"

const m___GXX_MERGED_TYPEINFO_NAMES = 0

const m___INT_FAST16_MAX__ = 0x7fff

const m___LONG32 = "long"

const m___MACHINEI = "__MACHINE"

const m___MACHINEIW64 = "__MACHINE"

const m___MACHINEX86X = "__MACHINE"

const m___MINGW32_MAJOR_VERSION = 3

const m___MINGW32_MINOR_VERSION = 11

const m___MINGW32__ = 1

const m___MINGW64_VERSION_BUGFIX = 0

const m___MINGW64_VERSION_MAJOR = 10

const m___MINGW64_VERSION_MINOR = 0

const m___MINGW64_VERSION_RC = 0

const m___MINGW64_VERSION_STATE = "alpha"

const m___MINGW_DEBUGBREAK_IMPL = 1

const m___MINGW_FORTIFY_LEVEL = 0

const m___MINGW_FORTIFY_VA_ARG = 0

const m___MINGW_FPCLASS_DEFINED = 1

const m___MINGW_HAVE_ANSI_C99_PRINTF = 1

const m___MINGW_HAVE_ANSI_C99_SCANF = 1

const m___MINGW_HAVE_WIDE_C99_PRINTF = 1

const m___MINGW_HAVE_WIDE_C99_SCANF = 1

const m___MINGW_MSVC2005_DEPREC_STR = "This POSIX function is deprecated beginning in Visual C++ 2005, use _CRT_NONSTDC_NO_DEPRECATE to disable deprecation"

const m___MINGW_SEC_WARN_STR = "This function or variable may be unsafe, use _CRT_SECURE_NO_WARNINGS to disable deprecation"

const m___MSVCRT_VERSION__ = 0x700

const m___MSVCRT__ = 1

const m___SIZEOF_WCHAR_T__ = 2

const m___SIZEOF_WINT_T__ = 2

const m___STDC_SECURE_LIB__ = 200411

const m___UINT_FAST16_MAX__ = 0xffff

const m___USE_MINGW_ANSI_STDIO = 1

const m___USE_MINGW_STRTOX = 1

const m___VERSION__ = "12-win32"

const m___WCHAR_MAX__ = 0xffff

const m___WCHAR_WIDTH__ = 16

const m___WIN32 = 1

const m___WIN32__ = 1

const m___WINNT = 1

const m___WINNT__ = 1

const m___WINT_MAX__ = 0xffff

const m___WINT_WIDTH__ = 16

const m___builtin_popcountl = "__popcnt64"

const m___builtin_vsnprintf = "__mingw_vsnprintf"

const m___builtin_vsprintf = "__mingw_vsprintf"

const m___int16 = "short"

const m___int32 = "int"

const m___int8 = "char"

const m___mingw_bos_ovr = "__mingw_ovr"

const m___mingw_choose_expr = "__builtin_choose_expr"

const m___setusermatherr = "__mingw_setusermatherr"

const m__clear87 = "_clearfp"

const m__copysignl = "copysignl"

const m__hypotl = "hypotl"

const m__kand_mask16 = "_mm512_kand"

const m__kandn_mask16 = "_mm512_kandn"

const m__knot_mask16 = "_mm512_knot"

const m__kor_mask16 = "_mm512_kor"

const m__kxnor_mask16 = "_mm512_kxnor"

const m__kxor_mask16 = "_mm512_kxor"

const m__mm512_undefined = "_mm512_undefined_ps"

const m__mm512_undefined_si512 = "_mm512_undefined_epi32"

const m__status87 = "_statusfp"

const m__wP_tmpdir = "\\\\"

const m_environ = "_environ"

const m_matherr = "_matherr"

const m_onexit_t = "_onexit_t"

const m_pclose = "_pclose"

const m_popen = "_popen"

const m_signature_AMD_ebx = 0x68747541

const m_signature_AMD_ecx = 0x444d4163

const m_signature_AMD_edx = 0x69746e65

const m_signature_CENTAUR_ebx = 0x746e6543

const m_signature_CENTAUR_ecx = 0x736c7561

const m_signature_CENTAUR_edx = 0x48727561

const m_signature_CYRIX_ebx = 0x69727943

const m_signature_CYRIX_ecx = 0x64616574

const m_signature_CYRIX_edx = 0x736e4978

const m_signature_INTEL_ebx = 0x756e6547

const m_signature_INTEL_ecx = 0x6c65746e

const m_signature_INTEL_edx = 0x49656e69

const m_signature_NEXGEN_ebx = 0x4778654e

const m_signature_NEXGEN_ecx = 0x6e657669

const m_signature_NEXGEN_edx = 0x72446e65

const m_signature_NSC_ebx = 0x646f6547

const m_signature_NSC_ecx = 0x43534e20

const m_signature_NSC_edx = 0x79622065

const m_signature_RISE_ebx = 0x65736952

const m_signature_RISE_ecx = 0x65736952

const m_signature_RISE_edx = 0x65736952

const m_signature_SIS_ebx = 0x20536953

const m_signature_SIS_ecx = 0x20536953

const m_signature_SIS_edx = 0x20536953

const m_signature_TM1_ebx = 0x6e617254

const m_signature_TM1_ecx = 0x55504361

const m_signature_TM1_edx = 0x74656d73

const m_signature_TM2_ebx = 0x756e6547

const m_signature_TM2_ecx = 0x3638784d

const m_signature_TM2_edx = 0x54656e69

const m_signature_UMC_ebx = 0x20434d55

const m_signature_UMC_ecx = 0x20434d55

const m_signature_UMC_edx = 0x20434d55

const m_signature_VIA_ebx = 0x20414956

const m_signature_VIA_ecx = 0x20414956

const m_signature_VIA_edx = 0x20414956

const m_signature_VORTEX_ebx = 0x74726f56

const m_signature_VORTEX_ecx = 0x436f5320

const m_signature_VORTEX_edx = 0x36387865

const m_sys_errlist = "_sys_errlist"

const m_sys_nerr = "_sys_nerr"

const m_wcswcs = "wcsstr"

const m_wpopen = "_wpopen"

type max_align_t = Tmax_align_t

type off32_t = Toff32_t

type pthreadlocinfo = Tpthreadlocinfo

type pthreadmbcinfo = Tpthreadmbcinfo

type t__bfloat16 = uint16

type t__mingw_flt_type_t = struct {
	Fval [0]uint32
	Fx   float32
}

type t__mmask16 = uint16

type t__mmask32 = uint32

type t__mmask64 = uint64

type t__mmask8 = uint8

type t__predefined_wchar_t = uint16

type t__time32_t = int32

type t__time64_t = int64

type tagLC_ID = TtagLC_ID

type threadlocaleinfostruct = Tthreadlocaleinfostruct

type threadlocinfo = Tthreadlocinfo

type wctype_t = Twctype_t

type wint_t = Twint_t
