text:
module LibWasmer

using CEnum

# This file (`LibWasmer.jl` not `prologue.jl`) is automatically generated using
# Clang.jl and should not be edited manually. Take a look at the `gen/` folder
# if something is to be changed.

using Pkg.Artifacts
using Pkg.BinaryPlatforms

tripletnolibc(platform) = replace(triplet(platform), "-gnu" => "")
get_libwasmer_location(platform) =
    "wasmer-v$release_version-$(tripletnolibc(platform))-c-api"

function get_libwasmer_location()
    artifact_info = artifact_meta("libwasmer", joinpath(@__DIR__, "..", "Artifacts.toml"))
    artifact_info === nothing && return nothing

    parent_path = artifact_path(Base.SHA1(artifact_info["git-tree-sha1"]))
    return joinpath(
        parent_path,
        "lib/libwasmer"
    )
end

const libwasmer_key = "LIBWASMER_LOCATION"
const libwasmer = haskey(ENV, libwasmer_key) ?
    ENV[libwasmer_key] : get_libwasmer_location()

const intptr_t = Clong

const byte_t = Cchar

const wasm_byte_t = UInt8

mutable struct wasm_byte_vec_t
    size::Csize_t
    data::Ptr{wasm_byte_t}
end

function wasm_byte_vec_new(out, arg2, arg3)
    ccall((:wasm_byte_vec_new, libwasmer), Cvoid, (Ptr{wasm_byte_vec_t}, Csize_t, Ptr{wasm_byte_t}), out, arg2, arg3)
end

function wasm_byte_vec_new_empty(out)
    ccall((:wasm_byte_vec_new_empty, libwasmer), Cvoid, (Ptr{wasm_byte_vec_t},), out)
end

function wasm_byte_vec_new_uninitialized(out, arg2)
    ccall((:wasm_byte_vec_new_uninitialized, libwasmer), Cvoid, (Ptr{wasm_byte_vec_t}, Csize_t), out, arg2)
end

function wasm_byte_vec_copy(out, arg2)
    ccall((:wasm_byte_vec_copy, libwasmer), Cvoid, (Ptr{wasm_byte_vec_t}, Ptr{wasm_byte_vec_t}), out, arg2)
end

function wasm_byte_vec_delete(arg1)
    ccall((:wasm_byte_vec_delete, libwasmer), Cvoid, (Ptr{wasm_byte_vec_t},), arg1)
end

mutable struct wasm_ref_t end

mutable struct wasm_store_t end

# no prototype is found for this function at wasm.h:29:13, please use with caution
function assertions()
    ccall((:assertions, libwasmer), Cvoid, ())
end

const float32_t = Cfloat

const float64_t = Cdouble

const wasm_name_t = wasm_byte_vec_t

function wasm_name_new_from_string(out, s)
    ccall((:wasm_name_new_from_string, libwasmer), Cvoid, (Ptr{wasm_name_t}, Cstring), out, s)
end

function wasm_name_new_from_string_nt(out, s)
    ccall((:wasm_name_new_from_string_nt, libwasmer), Cvoid, (Ptr{wasm_name_t}, Cstring), out, s)
end

mutable struct wasm_config_t end

function wasm_config_delete(arg1)
    ccall((:wasm_config_delete, libwasmer), Cvoid, (Ptr{wasm_config_t},), arg1)
end

# no prototype is found for this function at wasm.h:127:36, please use with caution
function wasm_config_new()
    ccall((:wasm_config_new, libwasmer), Ptr{wasm_config_t}, ())
end

mutable struct wasm_engine_t end

function wasm_engine_delete(arg1)
    ccall((:wasm_engine_delete, libwasmer), Cvoid, (Ptr{wasm_engine_t},), arg1)
end

# no prototype is found for this function at wasm.h:136:36, please use with caution
function wasm_engine_new()
    ccall((:wasm_engine_new, libwasmer), Ptr{wasm_engine_t}, ())
end

function wasm_engine_new_with_config(arg1)
    ccall((:wasm_engine_new_with_config, libwasmer), Ptr{wasm_engine_t}, (Ptr{wasm_config_t},), arg1)
end

function wasm_store_delete(arg1)
    ccall((:wasm_store_delete, libwasmer), Cvoid, (Ptr{wasm_store_t},), arg1)
end

function wasm_store_new(arg1)
    ccall((:wasm_store_new, libwasmer), Ptr{wasm_store_t}, (Ptr{wasm_engine_t},), arg1)
end

const wasm_mutability_t = UInt8

@cenum wasm_mutability_enum::UInt32 begin
    WASM_CONST = 0
    WASM_VAR = 1
end

mutable struct wasm_limits_t
    min::UInt32
    max::UInt32
end

mutable struct wasm_valtype_t end

function wasm_valtype_delete(arg1)
    ccall((:wasm_valtype_delete, libwasmer), Cvoid, (Ptr{wasm_valtype_t},), arg1)
end

mutable struct wasm_valtype_vec_t
    size::Csize_t
    data::Ptr{Ptr{wasm_valtype_t}}
end

function wasm_valtype_vec_new_empty(out)
    ccall((:wasm_valtype_vec_new_empty, libwasmer), Cvoid, (Ptr{wasm_valtype_vec_t},), out)
end

function wasm_valtype_vec_new_uninitialized(out, arg2)
    ccall((:wasm_valtype_vec_new_uninitialized, libwasmer), Cvoid, (Ptr{wasm_valtype_vec_t}, Csize_t), out, arg2)
end

function wasm_valtype_vec_new(out, arg2, arg3)
    ccall((:wasm_valtype_vec_new, libwasmer), Cvoid, (Ptr{wasm_valtype_vec_t}, Csize_t, Ptr{Ptr{wasm_valtype_t}}), out, arg2, arg3)
end

function wasm_valtype_vec_copy(out, arg2)
    ccall((:wasm_valtype_vec_copy, libwasmer), Cvoid, (Ptr{wasm_valtype_vec_t}, Ptr{wasm_valtype_vec_t}), out, arg2)
end

function wasm_valtype_vec_delete(arg1)
    ccall((:wasm_valtype_vec_delete, libwasmer), Cvoid, (Ptr{wasm_valtype_vec_t},), arg1)
end

function wasm_valtype_copy(arg1)
    ccall((:wasm_valtype_copy, libwasmer), Ptr{wasm_valtype_t}, (Ptr{wasm_valtype_t},), arg1)
end

const wasm_valkind_t = UInt8

@cenum wasm_valkind_enum::UInt32 begin
    WASM_I32 = 0
    WASM_I64 = 1
    WASM_F32 = 2
    WASM_F64 = 3
    WASM_ANYREF = 128
    WASM_FUNCREF = 129
end

function wasm_valtype_new(arg1)
    ccall((:wasm_valtype_new, libwasmer), Ptr{wasm_valtype_t}, (wasm_valkind_t,), arg1)
end

function wasm_valtype_kind(arg1)
    ccall((:wasm_valtype_kind, libwasmer), wasm_valkind_t, (Ptr{wasm_valtype_t},), arg1)
end

function wasm_valkind_is_num(k)
    ccall((:wasm_valkind_is_num, libwasmer), Bool, (wasm_valkind_t,), k)
end

function wasm_valkind_is_ref(k)
    ccall((:wasm_valkind_is_ref, libwasmer), Bool, (wasm_valkind_t,), k)
end

function wasm_valtype_is_num(t)
    ccall((:wasm_valtype_is_num, libwasmer), Bool, (Ptr{wasm_valtype_t},), t)
end

function wasm_valtype_is_ref(t)
    ccall((:wasm_valtype_is_ref, libwasmer), Bool, (Ptr{wasm_valtype_t},), t)
end

mutable struct wasm_functype_t end

function wasm_functype_delete(arg1)
    ccall((:wasm_functype_delete, libwasmer), Cvoid, (Ptr{wasm_functype_t},), arg1)
end

mutable struct wasm_functype_vec_t
    size::Csize_t
    data::Ptr{Ptr{wasm_functype_t}}
end

function wasm_functype_vec_new_empty(out)
    ccall((:wasm_functype_vec_new_empty, libwasmer), Cvoid, (Ptr{wasm_functype_vec_t},), out)
end

function wasm_functype_vec_new_uninitialized(out, arg2)
    ccall((:wasm_functype_vec_new_uninitialized, libwasmer), Cvoid, (Ptr{wasm_functype_vec_t}, Csize_t), out, arg2)
end

function wasm_functype_vec_new(out, arg2, arg3)
    ccall((:wasm_functype_vec_new, libwasmer), Cvoid, (Ptr{wasm_functype_vec_t}, Csize_t, Ptr{Ptr{wasm_functype_t}}), out, arg2, arg3)
end

function wasm_functype_vec_copy(out, arg2)
    ccall((:wasm_functype_vec_copy, libwasmer), Cvoid, (Ptr{wasm_functype_vec_t}, Ptr{wasm_functype_vec_t}), out, arg2)
end

function wasm_functype_vec_delete(arg1)
    ccall((:wasm_functype_vec_delete, libwasmer), Cvoid, (Ptr{wasm_functype_vec_t},), arg1)
end

function wasm_functype_copy(arg1)
    ccall((:wasm_functype_copy, libwasmer), Ptr{wasm_functype_t}, (Ptr{wasm_functype_t},), arg1)
end

function wasm_functype_new(params, results)
    ccall((:wasm_functype_new, libwasmer), Ptr{wasm_functype_t}, (Ptr{wasm_valtype_vec_t}, Ptr{wasm_valtype_vec_t}), params, results)
end

function wasm_functype_params(arg1)
    ccall((:wasm_functype_params, libwasmer), Ptr{wasm_valtype_vec_t}, (Ptr{wasm_functype_t},), arg1)
end

function wasm_functype_results(arg1)
    ccall((:wasm_functype_results, libwasmer), Ptr{wasm_valtype_vec_t}, (Ptr{wasm_functype_t},), arg1)
end

mutable struct wasm_globaltype_t end

function wasm_globaltype_delete(arg1)
    ccall((:wasm_globaltype_delete, libwasmer), Cvoid, (Ptr{wasm_globaltype_t},), arg1)
end

mutable struct wasm_globaltype_vec_t
    size::Csize_t
    data::Ptr{Ptr{wasm_globaltype_t}}
end

function wasm_globaltype_vec_new_empty(out)
    ccall((:wasm_globaltype_vec_new_empty, libwasmer), Cvoid, (Ptr{wasm_globaltype_vec_t},), out)
end

function wasm_globaltype_vec_new_uninitialized(out, arg2)
    ccall((:wasm_globaltype_vec_new_uninitialized, libwasmer), Cvoid, (Ptr{wasm_globaltype_vec_t}, Csize_t), out, arg2)
end

function wasm_globaltype_vec_new(out, arg2, arg3)
    ccall((:wasm_globaltype_vec_new, libwasmer), Cvoid, (Ptr{wasm_globaltype_vec_t}, Csize_t, Ptr{Ptr{wasm_globaltype_t}}), out, arg2, arg3)
end

function wasm_globaltype_vec_copy(out, arg2)
    ccall((:wasm_globaltype_vec_copy, libwasmer), Cvoid, (Ptr{wasm_globaltype_vec_t}, Ptr{wasm_globaltype_vec_t}), out, arg2)
end

function wasm_globaltype_vec_delete(arg1)
    ccall((:wasm_globaltype_vec_delete, libwasmer), Cvoid, (Ptr{wasm_globaltype_vec_t},), arg1)
end

function wasm_globaltype_copy(arg1)
    ccall((:wasm_globaltype_copy, libwasmer), Ptr{wasm_globaltype_t}, (Ptr{wasm_globaltype_t},), arg1)
end

function wasm_globaltype_new(arg1, arg2)
    ccall((:wasm_globaltype_new, libwasmer), Ptr{wasm_globaltype_t}, (Ptr{wasm_valtype_t}, wasm_mutability_t), arg1, arg2)
end

function wasm_globaltype_content(arg1)
    ccall((:wasm_globaltype_content, libwasmer), Ptr{wasm_valtype_t}, (Ptr{wasm_globaltype_t},), arg1)
end

function wasm_globaltype_mutability(arg1)
    ccall((:wasm_globaltype_mutability, libwasmer), wasm_mutability_t, (Ptr{wasm_globaltype_t},), arg1)
end

mutable struct wasm_tabletype_t end

function wasm_tabletype_delete(arg1)
    ccall((:wasm_tabletype_delete, libwasmer), Cvoid, (Ptr{wasm_tabletype_t},), arg1)
end

mutable struct wasm_tabletype_vec_t
    size::Csize_t
    data::Ptr{Ptr{wasm_tabletype_t}}
end

function wasm_tabletype_vec_new_empty(out)
    ccall((:wasm_tabletype_vec_new_empty, libwasmer), Cvoid, (Ptr{wasm_tabletype_vec_t},), out)
end

function wasm_tabletype_vec_new_uninitialized(out, arg2)
    ccall((:wasm_tabletype_vec_new_uninitialized, libwasmer), Cvoid, (Ptr{wasm_tabletype_vec_t}, Csize_t), out, arg2)
end

function wasm_tabletype_vec_new(out, arg2, arg3)
    ccall((:wasm_tabletype_vec_new, libwasmer), Cvoid, (Ptr{wasm_tabletype_vec_t}, Csize_t, Ptr{Ptr{wasm_tabletype_t}}), out, arg2, arg3)
end

function wasm_tabletype_vec_copy(out, arg2)
    ccall((:wasm_tabletype_vec_copy, libwasmer), Cvoid, (Ptr{wasm_tabletype_vec_t}, Ptr{wasm_tabletype_vec_t}), out, arg2)
end

function wasm_tabletype_vec_delete(arg1)
    ccall((:wasm_tabletype_vec_delete, libwasmer), Cvoid, (Ptr{wasm_tabletype_vec_t},), arg1)
end

function wasm_tabletype_copy(arg1)
    ccall((:wasm_tabletype_copy, libwasmer), Ptr{wasm_tabletype_t}, (Ptr{wasm_tabletype_t},), arg1)
end

function wasm_tabletype_new(arg1, arg2)
    ccall((:wasm_tabletype_new, libwasmer), Ptr{wasm_tabletype_t}, (Ptr{wasm_valtype_t}, Ptr{wasm_limits_t}), arg1, arg2)
end

function wasm_tabletype_element(arg1)
    ccall((:wasm_tabletype_element, libwasmer), Ptr{wasm_valtype_t}, (Ptr{wasm_tabletype_t},), arg1)
end

function wasm_tabletype_limits(arg1)
    ccall((:wasm_tabletype_limits, libwasmer), Ptr{wasm_limits_t}, (Ptr{wasm_tabletype_t},), arg1)
end

mutable struct wasm_memorytype_t end

function wasm_memorytype_delete(arg1)
    ccall((:wasm_memorytype_delete, libwasmer), Cvoid, (Ptr{wasm_memorytype_t},), arg1)
end

mutable struct wasm_memorytype_vec_t
    size::Csize_t
    data::Ptr{Ptr{wasm_memorytype_t}}
end

function wasm_memorytype_vec_new_empty(out)
    ccall((:wasm_memorytype_vec_new_empty, libwasmer), Cvoid, (Ptr{wasm_memorytype_vec_t},), out)
end

function wasm_memorytype_vec_new_uninitialized(out, arg2)
    ccall((:wasm_memorytype_vec_new_uninitialized, libwasmer), Cvoid, (Ptr{wasm_memorytype_vec_t}, Csize_t), out, arg2)
end

function wasm_memorytype_vec_new(out, arg2, arg3)
    ccall((:wasm_memorytype_vec_new, libwasmer), Cvoid, (Ptr{wasm_memorytype_vec_t}, Csize_t, Ptr{Ptr{wasm_memorytype_t}}), out, arg2, arg3)
end

function wasm_memorytype_vec_copy(out, arg2)
    ccall((:wasm_memorytype_vec_copy, libwasmer), Cvoid, (Ptr{wasm_memorytype_vec_t}, Ptr{wasm_memorytype_vec_t}), out, arg2)
end

function wasm_memorytype_vec_delete(arg1)
    ccall((:wasm_memorytype_vec_delete, libwasmer), Cvoid, (Ptr{wasm_memorytype_vec_t},), arg1)
end

function wasm_memorytype_copy(arg1)
    ccall((:wasm_memorytype_copy, libwasmer), Ptr{wasm_memorytype_t}, (Ptr{wasm_memorytype_t},), arg1)
end

function wasm_memorytype_new(arg1)
    ccall((:wasm_memorytype_new, libwasmer), Ptr{wasm_memorytype_t}, (Ptr{wasm_limits_t},), arg1)
end

function wasm_memorytype_limits(arg1)
    ccall((:wasm_memorytype_limits, libwasmer), Ptr{wasm_limits_t}, (Ptr{wasm_memorytype_t},), arg1)
end

mutable struct wasm_externtype_t end

function wasm_externtype_delete(arg1)
    ccall((:wasm_externtype_delete, libwasmer), Cvoid, (Ptr{wasm_externtype_t},), arg1)
end

mutable struct wasm_externtype_vec_t
    size::Csize_t
    data::Ptr{Ptr{wasm_externtype_t}}
end

function wasm_externtype_vec_new_empty(out)
    ccall((:wasm_externtype_vec_new_empty, libwasmer), Cvoid, (Ptr{wasm_externtype_vec_t},), out)
end

function wasm_externtype_vec_new_uninitialized(out, arg2)
    ccall((:wasm_externtype_vec_new_uninitialized, libwasmer), Cvoid, (Ptr{wasm_externtype_vec_t}, Csize_t), out, arg2)
end

function wasm_externtype_vec_new(out, arg2, arg3)
    ccall((:wasm_externtype_vec_new, libwasmer), Cvoid, (Ptr{wasm_externtype_vec_t}, Csize_t, Ptr{Ptr{wasm_externtype_t}}), out, arg2, arg3)
end

function wasm_externtype_vec_copy(out, arg2)
    ccall((:wasm_externtype_vec_copy, libwasmer), Cvoid, (Ptr{wasm_externtype_vec_t}, Ptr{wasm_externtype_vec_t}), out, arg2)
end

function wasm_externtype_vec_delete(arg1)
    ccall((:wasm_externtype_vec_delete, libwasmer), Cvoid, (Ptr{wasm_externtype_vec_t},), arg1)
end

function wasm_externtype_copy(arg1)
    ccall((:wasm_externtype_copy, libwasmer), Ptr{wasm_externtype_t}, (Ptr{wasm_externtype_t},), arg1)
end

const wasm_externkind_t = UInt8

@cenum wasm_externkind_enum::UInt32 begin
    WASM_EXTERN_FUNC = 0
    WASM_EXTERN_GLOBAL = 1
    WASM_EXTERN_TABLE = 2
    WASM_EXTERN_MEMORY = 3
end

function wasm_externtype_kind(arg1)
    ccall((:wasm_externtype_kind, libwasmer), wasm_externkind_t, (Ptr{wasm_externtype_t},), arg1)
end

function wasm_functype_as_externtype(arg1)
    ccall((:wasm_functype_as_externtype, libwasmer), Ptr{wasm_externtype_t}, (Ptr{wasm_functype_t},), arg1)
end

function wasm_globaltype_as_externtype(arg1)
    ccall((:wasm_globaltype_as_externtype, libwasmer), Ptr{wasm_externtype_t}, (Ptr{wasm_globaltype_t},), arg1)
end

function wasm_tabletype_as_externtype(arg1)
    ccall((:wasm_tabletype_as_externtype, libwasmer), Ptr{wasm_externtype_t}, (Ptr{wasm_tabletype_t},), arg1)
end

function wasm_memorytype_as_externtype(arg1)
    ccall((:wasm_memorytype_as_externtype, libwasmer), Ptr{wasm_externtype_t}, (Ptr{wasm_memorytype_t},), arg1)
end

function wasm_externtype_as_functype(arg1)
    ccall((:wasm_externtype_as_functype, libwasmer), Ptr{wasm_functype_t}, (Ptr{wasm_externtype_t},), arg1)
end

function wasm_externtype_as_globaltype(arg1)
    ccall((:wasm_externtype_as_globaltype, libwasmer), Ptr{wasm_globaltype_t}, (Ptr{wasm_externtype_t},), arg1)
end

function wasm_externtype_as_tabletype(arg1)
    ccall((:wasm_externtype_as_tabletype, libwasmer), Ptr{wasm_tabletype_t}, (Ptr{wasm_externtype_t},), arg1)
end

function wasm_externtype_as_memorytype(arg1)
    ccall((:wasm_externtype_as_memorytype, libwasmer), Ptr{wasm_memorytype_t}, (Ptr{wasm_externtype_t},), arg1)
end

function wasm_functype_as_externtype_const(arg1)
    ccall((:wasm_functype_as_externtype_const, libwasmer), Ptr{wasm_externtype_t}, (Ptr{wasm_functype_t},), arg1)
end

function wasm_globaltype_as_externtype_const(arg1)
    ccall((:wasm_globaltype_as_externtype_const, libwasmer), Ptr{wasm_externtype_t}, (Ptr{wasm_globaltype_t},), arg1)
end

function wasm_tabletype_as_externtype_const(arg1)
    ccall((:wasm_tabletype_as_externtype_const, libwasmer), Ptr{wasm_externtype_t}, (Ptr{wasm_tabletype_t},), arg1)
end

function wasm_memorytype_as_externtype_const(arg1)
    ccall((:wasm_memorytype_as_externtype_const, libwasmer), Ptr{wasm_externtype_t}, (Ptr{wasm_memorytype_t},), arg1)
end

function wasm_externtype_as_functype_const(arg1)
    ccall((:wasm_externtype_as_functype_const, libwasmer), Ptr{wasm_functype_t}, (Ptr{wasm_externtype_t},), arg1)
end

function wasm_externtype_as_globaltype_const(arg1)
    ccall((:wasm_externtype_as_globaltype_const, libwasmer), Ptr{wasm_globaltype_t}, (Ptr{wasm_externtype_t},), arg1)
end

function wasm_externtype_as_tabletype_const(arg1)
    ccall((:wasm_externtype_as_tabletype_const, libwasmer), Ptr{wasm_tabletype_t}, (Ptr{wasm_externtype_t},), arg1)
end

function wasm_externtype_as_memorytype_const(arg1)
    ccall((:wasm_externtype_as_memorytype_const, libwasmer), Ptr{wasm_memorytype_t}, (Ptr{wasm_externtype_t},), arg1)
end

mutable struct wasm_importtype_t end

function wasm_importtype_delete(arg1)
    ccall((:wasm_importtype_delete, libwasmer), Cvoid, (Ptr{wasm_importtype_t},), arg1)
end

mutable struct wasm_importtype_vec_t
    size::Csize_t
    data::Ptr{Ptr{wasm_importtype_t}}
end

function wasm_importtype_vec_new_empty(out)
    ccall((:wasm_importtype_vec_new_empty, libwasmer), Cvoid, (Ptr{wasm_importtype_vec_t},), out)
end

function wasm_importtype_vec_new_uninitialized(out, arg2)
    ccall((:wasm_importtype_vec_new_uninitialized, libwasmer), Cvoid, (Ptr{wasm_importtype_vec_t}, Csize_t), out, arg2)
end

function wasm_importtype_vec_new(out, arg2, arg3)
    ccall((:wasm_importtype_vec_new, libwasmer), Cvoid, (Ptr{wasm_importtype_vec_t}, Csize_t, Ptr{Ptr{wasm_importtype_t}}), out, arg2, arg3)
end

function wasm_importtype_vec_copy(out, arg2)
    ccall((:wasm_importtype_vec_copy, libwasmer), Cvoid, (Ptr{wasm_importtype_vec_t}, Ptr{wasm_importtype_vec_t}), out, arg2)
end

function wasm_importtype_vec_delete(arg1)
    ccall((:wasm_importtype_vec_delete, libwasmer), Cvoid, (Ptr{wasm_importtype_vec_t},), arg1)
end

function wasm_importtype_copy(arg1)
    ccall((:wasm_importtype_copy, libwasmer), Ptr{wasm_importtype_t}, (Ptr{wasm_importtype_t},), arg1)
end

function wasm_importtype_new(_module, name, arg3)
    ccall((:wasm_importtype_new, libwasmer), Ptr{wasm_importtype_t}, (Ptr{wasm_name_t}, Ptr{wasm_name_t}, Ptr{wasm_externtype_t}), _module, name, arg3)
end

function wasm_importtype_module(arg1)
    ccall((:wasm_importtype_module, libwasmer), Ptr{wasm_name_t}, (Ptr{wasm_importtype_t},), arg1)
end

function wasm_importtype_name(arg1)
    ccall((:wasm_importtype_name, libwasmer), Ptr{wasm_name_t}, (Ptr{wasm_importtype_t},), arg1)
end

function wasm_importtype_type(arg1)
    ccall((:wasm_importtype_type, libwasmer), Ptr{wasm_externtype_t}, (Ptr{wasm_importtype_t},), arg1)
end

mutable struct wasm_exporttype_t end

function wasm_exporttype_delete(arg1)
    ccall((:wasm_exporttype_delete, libwasmer), Cvoid, (Ptr{wasm_exporttype_t},), arg1)
end

mutable struct wasm_exporttype_vec_t
    size::Csize_t
    data::Ptr{Ptr{wasm_exporttype_t}}
end

function wasm_exporttype_vec_new_empty(out)
    ccall((:wasm_exporttype_vec_new_empty, libwasmer), Cvoid, (Ptr{wasm_exporttype_vec_t},), out)
end

function wasm_exporttype_vec_new_uninitialized(out, arg2)
    ccall((:wasm_exporttype_vec_new_uninitialized, libwasmer), Cvoid, (Ptr{wasm_exporttype_vec_t}, Csize_t), out, arg2)
end

function wasm_exporttype_vec_new(out, arg2, arg3)
    ccall((:wasm_exporttype_vec_new, libwasmer), Cvoid, (Ptr{wasm_exporttype_vec_t}, Csize_t, Ptr{Ptr{wasm_exporttype_t}}), out, arg2, arg3)
end

function wasm_exporttype_vec_copy(out, arg2)
    ccall((:wasm_exporttype_vec_copy, libwasmer), Cvoid, (Ptr{wasm_exporttype_vec_t}, Ptr{wasm_exporttype_vec_t}), out, arg2)
end

function wasm_exporttype_vec_delete(arg1)
    ccall((:wasm_exporttype_vec_delete, libwasmer), Cvoid, (Ptr{wasm_exporttype_vec_t},), arg1)
end

function wasm_exporttype_copy(arg1)
    ccall((:wasm_exporttype_copy, libwasmer), Ptr{wasm_exporttype_t}, (Ptr{wasm_exporttype_t},), arg1)
end

function wasm_exporttype_new(arg1, arg2)
    ccall((:wasm_exporttype_new, libwasmer), Ptr{wasm_exporttype_t}, (Ptr{wasm_name_t}, Ptr{wasm_externtype_t}), arg1, arg2)
end

function wasm_exporttype_name(arg1)
    ccall((:wasm_exporttype_name, libwasmer), Ptr{wasm_name_t}, (Ptr{wasm_exporttype_t},), arg1)
end

function wasm_exporttype_type(arg1)
    ccall((:wasm_exporttype_type, libwasmer), Ptr{wasm_externtype_t}, (Ptr{wasm_exporttype_t},), arg1)
end

struct __JL_Ctag_18
    data::NTuple{8, UInt8}
end

function Base.getproperty(x::Ptr{__JL_Ctag_18}, f::Symbol)
    f === :i32 && return Ptr{Int32}(x + 0)
    f === :i64 && return Ptr{Int64}(x + 0)
    f === :f32 && return Ptr{float32_t}(x + 0)
    f === :f64 && return Ptr{float64_t}(x + 0)
    f === :ref && return Ptr{Ptr{wasm_ref_t}}(x + 0)
    return getfield(x, f)
end

function Base.getproperty(x::__JL_Ctag_18, f::Symbol)
    r = Ref{__JL_Ctag_18}(x)
    ptr = Base.unsafe_convert(Ptr{__JL_Ctag_18}, r)
    fptr = getproperty(ptr, f)
    GC.@preserve r unsafe_load(fptr)
end

function Base.setproperty!(x::Ptr{__JL_Ctag_18}, f::Symbol, v)
    unsafe_store!(getproperty(x, f), v)
end

struct wasm_val_t
    data::NTuple{16, UInt8}
end

function Base.getproperty(x::Ptr{wasm_val_t}, f::Symbol)
    f === :kind && return Ptr{wasm_valkind_t}(x + 0)
    f === :of && return Ptr{__JL_Ctag_18}(x + 8)
    return getfield(x, f)
end

function Base.getproperty(x::wasm_val_t, f::Symbol)
    r = Ref{wasm_val_t}(x)
    ptr = Base.unsafe_convert(Ptr{wasm_val_t}, r)
    fptr = getproperty(ptr, f)
    GC.@preserve r unsafe_load(fptr)
end

function Base.setproperty!(x::Ptr{wasm_val_t}, f::Symbol, v)
    unsafe_store!(getproperty(x, f), v)
end

function wasm_val_delete(v)
    ccall((:wasm_val_delete, libwasmer), Cvoid, (Ptr{wasm_val_t},), v)
end

function wasm_val_copy(out, arg2)
    ccall((:wasm_val_copy, libwasmer), Cvoid, (Ptr{wasm_val_t}, Ptr{wasm_val_t}), out, arg2)
end

mutable struct wasm_val_vec_t
    size::Csize_t
    data::Ptr{wasm_val_t}
end

function wasm_val_vec_new_empty(out)
    ccall((:wasm_val_vec_new_empty, libwasmer), Cvoid, (Ptr{wasm_val_vec_t},), out)
end

function wasm_val_vec_new_uninitialized(out, arg2)
    ccall((:wasm_val_vec_new_uninitialized, libwasmer), Cvoid, (Ptr{wasm_val_vec_t}, Csize_t), out, arg2)
end

function wasm_val_vec_new(out, arg2, arg3)
    ccall((:wasm_val_vec_new, libwasmer), Cvoid, (Ptr{wasm_val_vec_t}, Csize_t, Ptr{wasm_val_t}), out, arg2, arg3)
end

function wasm_val_vec_copy(out, arg2)
    ccall((:wasm_val_vec_copy, libwasmer), Cvoid, (Ptr{wasm_val_vec_t}, Ptr{wasm_val_vec_t}), out, arg2)
end

function wasm_val_vec_delete(arg1)
    ccall((:wasm_val_vec_delete, libwasmer), Cvoid, (Ptr{wasm_val_vec_t},), arg1)
end

function wasm_ref_delete(arg1)
    ccall((:wasm_ref_delete, libwasmer), Cvoid, (Ptr{wasm_ref_t},), arg1)
end

function wasm_ref_copy(arg1)
    ccall((:wasm_ref_copy, libwasmer), Ptr{wasm_ref_t}, (Ptr{wasm_ref_t},), arg1)
end

function wasm_ref_same(arg1, arg2)
    ccall((:wasm_ref_same, libwasmer), Bool, (Ptr{wasm_ref_t}, Ptr{wasm_ref_t}), arg1, arg2)
end

function wasm_ref_get_host_info(arg1)
    ccall((:wasm_ref_get_host_info, libwasmer), Ptr{Cvoid}, (Ptr{wasm_ref_t},), arg1)
end

function wasm_ref_set_host_info(arg1, arg2)
    ccall((:wasm_ref_set_host_info, libwasmer), Cvoid, (Ptr{wasm_ref_t}, Ptr{Cvoid}), arg1, arg2)
end

function wasm_ref_set_host_info_with_finalizer(arg1, arg2, arg3)
    ccall((:wasm_ref_set_host_info_with_finalizer, libwasmer), Cvoid, (Ptr{wasm_ref_t}, Ptr{Cvoid}, Ptr{Cvoid}), arg1, arg2, arg3)
end

mutable struct wasm_frame_t end

function wasm_frame_delete(arg1)
    ccall((:wasm_frame_delete, libwasmer), Cvoid, (Ptr{wasm_frame_t},), arg1)
end

mutable struct wasm_frame_vec_t
    size::Csize_t
    data::Ptr{Ptr{wasm_frame_t}}
end

function wasm_frame_vec_new_empty(out)
    ccall((:wasm_frame_vec_new_empty, libwasmer), Cvoid, (Ptr{wasm_frame_vec_t},), out)
end

function wasm_frame_vec_new_uninitialized(out, arg2)
    ccall((:wasm_frame_vec_new_uninitialized, libwasmer), Cvoid, (Ptr{wasm_frame_vec_t}, Csize_t), out, arg2)
end

function wasm_frame_vec_new(out, arg2, arg3)
    ccall((:wasm_frame_vec_new, libwasmer), Cvoid, (Ptr{wasm_frame_vec_t}, Csize_t, Ptr{Ptr{wasm_frame_t}}), out, arg2, arg3)
end

function wasm_frame_vec_copy(out, arg2)
    ccall((:wasm_frame_vec_copy, libwasmer), Cvoid, (Ptr{wasm_frame_vec_t}, Ptr{wasm_frame_vec_t}), out, arg2)
end

function wasm_frame_vec_delete(arg1)
    ccall((:wasm_frame_vec_delete, libwasmer), Cvoid, (Ptr{wasm_frame_vec_t},), arg1)
end

function wasm_frame_copy(arg1)
    ccall((:wasm_frame_copy, libwasmer), Ptr{wasm_frame_t}, (Ptr{wasm_frame_t},), arg1)
end

mutable struct wasm_instance_t end

function wasm_frame_instance(arg1)
    ccall((:wasm_frame_instance, libwasmer), Ptr{wasm_instance_t}, (Ptr{wasm_frame_t},), arg1)
end

function wasm_frame_func_index(arg1)
    ccall((:wasm_frame_func_index, libwasmer), UInt32, (Ptr{wasm_frame_t},), arg1)
end

function wasm_frame_func_offset(arg1)
    ccall((:wasm_frame_func_offset, libwasmer), Csize_t, (Ptr{wasm_frame_t},), arg1)
end

function wasm_frame_module_offset(arg1)
    ccall((:wasm_frame_module_offset, libwasmer), Csize_t, (Ptr{wasm_frame_t},), arg1)
end

const wasm_message_t = wasm_name_t

mutable struct wasm_trap_t end

function wasm_trap_delete(arg1)
    ccall((:wasm_trap_delete, libwasmer), Cvoid, (Ptr{wasm_trap_t},), arg1)
end

function wasm_trap_copy(arg1)
    ccall((:wasm_trap_copy, libwasmer), Ptr{wasm_trap_t}, (Ptr{wasm_trap_t},), arg1)
end

function wasm_trap_same(arg1, arg2)
    ccall((:wasm_trap_same, libwasmer), Bool, (Ptr{wasm_trap_t}, Ptr{wasm_trap_t}), arg1, arg2)
end

function wasm_trap_get_host_info(arg1)
    ccall((:wasm_trap_get_host_info, libwasmer), Ptr{Cvoid}, (Ptr{wasm_trap_t},), arg1)
end

function wasm_trap_set_host_info(arg1, arg2)
    ccall((:wasm_trap_set_host_info, libwasmer), Cvoid, (Ptr{wasm_trap_t}, Ptr{Cvoid}), arg1, arg2)
end

function wasm_trap_set_host_info_with_finalizer(arg1, arg2, arg3)
    ccall((:wasm_trap_set_host_info_with_finalizer, libwasmer), Cvoid, (Ptr{wasm_trap_t}, Ptr{Cvoid}, Ptr{Cvoid}), arg1, arg2, arg3)
end

function wasm_trap_as_ref(arg1)
    ccall((:wasm_trap_as_ref, libwasmer), Ptr{wasm_ref_t}, (Ptr{wasm_trap_t},), arg1)
end

function wasm_ref_as_trap(arg1)
    ccall((:wasm_ref_as_trap, libwasmer), Ptr{wasm_trap_t}, (Ptr{wasm_ref_t},), arg1)
end

function wasm_trap_as_ref_const(arg1)
    ccall((:wasm_trap_as_ref_const, libwasmer), Ptr{wasm_ref_t}, (Ptr{wasm_trap_t},), arg1)
end

function wasm_ref_as_trap_const(arg1)
    ccall((:wasm_ref_as_trap_const, libwasmer), Ptr{wasm_trap_t}, (Ptr{wasm_ref_t},), arg1)
end

function wasm_trap_new(store, arg2)
    ccall((:wasm_trap_new, libwasmer), Ptr{wasm_trap_t}, (Ptr{wasm_store_t}, Ptr{wasm_message_t}), store, arg2)
end

function wasm_trap_message(arg1, out)
    ccall((:wasm_trap_message, libwasmer), Cvoid, (Ptr{wasm_trap_t}, Ptr{wasm_message_t}), arg1, out)
end

function wasm_trap_origin(arg1)
    ccall((:wasm_trap_origin, libwasmer), Ptr{wasm_frame_t}, (Ptr{wasm_trap_t},), arg1)
end

function wasm_trap_trace(arg1, out)
    ccall((:wasm_trap_trace, libwasmer), Cvoid, (Ptr{wasm_trap_t}, Ptr{wasm_frame_vec_t}), arg1, out)
end

mutable struct wasm_foreign_t end

function wasm_foreign_delete(arg1)
    ccall((:wasm_foreign_delete, libwasmer), Cvoid, (Ptr{wasm_foreign_t},), arg1)
end

function wasm_foreign_copy(arg1)
    ccall((:wasm_foreign_copy, libwasmer), Ptr{wasm_foreign_t}, (Ptr{wasm_foreign_t},), arg1)
end

function wasm_foreign_same(arg1, arg2)
    ccall((:wasm_foreign_same, libwasmer), Bool, (Ptr{wasm_foreign_t}, Ptr{wasm_foreign_t}), arg1, arg2)
end

function wasm_foreign_get_host_info(arg1)
    ccall((:wasm_foreign_get_host_info, libwasmer), Ptr{Cvoid}, (Ptr{wasm_foreign_t},), arg1)
end

function wasm_foreign_set_host_info(arg1, arg2)
    ccall((:wasm_foreign_set_host_info, libwasmer), Cvoid, (Ptr{wasm_foreign_t}, Ptr{Cvoid}), arg1, arg2)
end

function wasm_foreign_set_host_info_with_finalizer(arg1, arg2, arg3)
    ccall((:wasm_foreign_set_host_info_with_finalizer, libwasmer), Cvoid, (Ptr{wasm_foreign_t}, Ptr{Cvoid}, Ptr{Cvoid}), arg1, arg2, arg3)
end

function wasm_foreign_as_ref(arg1)
    ccall((:wasm_foreign_as_ref, libwasmer), Ptr{wasm_ref_t}, (Ptr{wasm_foreign_t},), arg1)
end

function wasm_ref_as_foreign(arg1)
    ccall((:wasm_ref_as_foreign, libwasmer), Ptr{wasm_foreign_t}, (Ptr{wasm_ref_t},), arg1)
end

function wasm_foreign_as_ref_const(arg1)
    ccall((:wasm_foreign_as_ref_const, libwasmer), Ptr{wasm_ref_t}, (Ptr{wasm_foreign_t},), arg1)
end

function wasm_ref_as_foreign_const(arg1)
    ccall((:wasm_ref_as_foreign_const, libwasmer), Ptr{wasm_foreign_t}, (Ptr{wasm_ref_t},), arg1)
end

function wasm_foreign_new(arg1)
    ccall((:wasm_foreign_new, libwasmer), Ptr{wasm_foreign_t}, (Ptr{wasm_store_t},), arg1)
end

mutable struct wasm_module_t end

function wasm_module_delete(arg1)
    ccall((:wasm_module_delete, libwasmer), Cvoid, (Ptr{wasm_module_t},), arg1)
end

function wasm_module_copy(arg1)
    ccall((:wasm_module_copy, libwasmer), Ptr{wasm_module_t}, (Ptr{wasm_module_t},), arg1)
end

function wasm_module_same(arg1, arg2)
    ccall((:wasm_module_same, libwasmer), Bool, (Ptr{wasm_module_t}, Ptr{wasm_module_t}), arg1, arg2)
end

function wasm_module_get_host_info(arg1)
    ccall((:wasm_module_get_host_info, libwasmer), Ptr{Cvoid}, (Ptr{wasm_module_t},), arg1)
end

function wasm_module_set_host_info(arg1, arg2)
    ccall((:wasm_module_set_host_info, libwasmer), Cvoid, (Ptr{wasm_module_t}, Ptr{Cvoid}), arg1, arg2)
end

function wasm_module_set_host_info_with_finalizer(arg1, arg2, arg3)
    ccall((:wasm_module_set_host_info_with_finalizer, libwasmer), Cvoid, (Ptr{wasm_module_t}, Ptr{Cvoid}, Ptr{Cvoid}), arg1, arg2, arg3)
end

function wasm_module_as_ref(arg1)
    ccall((:wasm_module_as_ref, libwasmer), Ptr{wasm_ref_t}, (Ptr{wasm_module_t},), arg1)
end

function wasm_ref_as_module(arg1)
    ccall((:wasm_ref_as_module, libwasmer), Ptr{wasm_module_t}, (Ptr{wasm_ref_t},), arg1)
end

function wasm_module_as_ref_const(arg1)
    ccall((:wasm_module_as_ref_const, libwasmer), Ptr{wasm_ref_t}, (Ptr{wasm_module_t},), arg1)
end

function wasm_ref_as_module_const(arg1)
    ccall((:wasm_ref_as_module_const, libwasmer), Ptr{wasm_module_t}, (Ptr{wasm_ref_t},), arg1)
end

mutable struct wasm_shared_module_t end

function wasm_shared_module_delete(arg1)
    ccall((:wasm_shared_module_delete, libwasmer), Cvoid, (Ptr{wasm_shared_module_t},), arg1)
end

function wasm_module_share(arg1)
    ccall((:wasm_module_share, libwasmer), Ptr{wasm_shared_module_t}, (Ptr{wasm_module_t},), arg1)
end

function wasm_module_obtain(arg1, arg2)
    ccall((:wasm_module_obtain, libwasmer), Ptr{wasm_module_t}, (Ptr{wasm_store_t}, Ptr{wasm_shared_module_t}), arg1, arg2)
end

function wasm_module_new(arg1, binary)
    ccall((:wasm_module_new, libwasmer), Ptr{wasm_module_t}, (Ptr{wasm_store_t}, Ptr{wasm_byte_vec_t}), arg1, binary)
end

function wasm_module_validate(arg1, binary)
    ccall((:wasm_module_validate, libwasmer), Bool, (Ptr{wasm_store_t}, Ptr{wasm_byte_vec_t}), arg1, binary)
end

function wasm_module_imports(arg1, out)
    ccall((:wasm_module_imports, libwasmer), Cvoid, (Ptr{wasm_module_t}, Ptr{wasm_importtype_vec_t}), arg1, out)
end

function wasm_module_exports(arg1, out)
    ccall((:wasm_module_exports, libwasmer), Cvoid, (Ptr{wasm_module_t}, Ptr{wasm_exporttype_vec_t}), arg1, out)
end

function wasm_module_serialize(arg1, out)
    ccall((:wasm_module_serialize, libwasmer), Cvoid, (Ptr{wasm_module_t}, Ptr{wasm_byte_vec_t}), arg1, out)
end

function wasm_module_deserialize(arg1, arg2)
    ccall((:wasm_module_deserialize, libwasmer), Ptr{wasm_module_t}, (Ptr{wasm_store_t}, Ptr{wasm_byte_vec_t}), arg1, arg2)
end

mutable struct wasm_func_t end

function wasm_func_delete(arg1)
    ccall((:wasm_func_delete, libwasmer), Cvoid, (Ptr{wasm_func_t},), arg1)
end

function wasm_func_copy(arg1)
    ccall((:wasm_func_copy, libwasmer), Ptr{wasm_func_t}, (Ptr{wasm_func_t},), arg1)
end

function wasm_func_same(arg1, arg2)
    ccall((:wasm_func_same, libwasmer), Bool, (Ptr{wasm_func_t}, Ptr{wasm_func_t}), arg1, arg2)
end

function wasm_func_get_host_info(arg1)
    ccall((:wasm_func_get_host_info, libwasmer), Ptr{Cvoid}, (Ptr{wasm_func_t},), arg1)
end

function wasm_func_set_host_info(arg1, arg2)
    ccall((:wasm_func_set_host_info, libwasmer), Cvoid, (Ptr{wasm_func_t}, Ptr{Cvoid}), arg1, arg2)
end

function wasm_func_set_host_info_with_finalizer(arg1, arg2, arg3)
    ccall((:wasm_func_set_host_info_with_finalizer, libwasmer), Cvoid, (Ptr{wasm_func_t}, Ptr{Cvoid}, Ptr{Cvoid}), arg1, arg2, arg3)
end

function wasm_func_as_ref(arg1)
    ccall((:wasm_func_as_ref, libwasmer), Ptr{wasm_ref_t}, (Ptr{wasm_func_t},), arg1)
end

function wasm_ref_as_func(arg1)
    ccall((:wasm_ref_as_func, libwasmer), Ptr{wasm_func_t}, (Ptr{wasm_ref_t},), arg1)
end

function wasm_func_as_ref_const(arg1)
    ccall((:wasm_func_as_ref_const, libwasmer), Ptr{wasm_ref_t}, (Ptr{wasm_func_t},), arg1)
end

function wasm_ref_as_func_const(arg1)
    ccall((:wasm_ref_as_func_const, libwasmer), Ptr{wasm_func_t}, (Ptr{wasm_ref_t},), arg1)
end

# typedef own wasm_trap_t * ( * wasm_func_callback_t ) ( const wasm_val_vec_t * args , own wasm_val_vec_t * results )
const wasm_func_callback_t = Ptr{Cvoid}

# typedef own wasm_trap_t * ( * wasm_func_callback_with_env_t ) ( void * env , const wasm_val_vec_t * args , wasm_val_vec_t * results )
const wasm_func_callback_with_env_t = Ptr{Cvoid}

function wasm_func_new(arg1, arg2, arg3)
    ccall((:wasm_func_new, libwasmer), Ptr{wasm_func_t}, (Ptr{wasm_store_t}, Ptr{wasm_functype_t}, wasm_func_callback_t), arg1, arg2, arg3)
end

function wasm_func_new_with_env(arg1, type, arg3, env, finalizer)
    ccall((:wasm_func_new_with_env, libwasmer), Ptr{wasm_func_t}, (Ptr{wasm_store_t}, Ptr{wasm_functype_t}, wasm_func_callback_with_env_t, Ptr{Cvoid}, Ptr{Cvoid}), arg1, type, arg3, env, finalizer)
end

function wasm_func_type(arg1)
    ccall((:wasm_func_type, libwasmer), Ptr{wasm_functype_t}, (Ptr{wasm_func_t},), arg1)
end

function wasm_func_param_arity(arg1)
    ccall((:wasm_func_param_arity, libwasmer), Csize_t, (Ptr{wasm_func_t},), arg1)
end

function wasm_func_result_arity(arg1)
    ccall((:wasm_func_result_arity, libwasmer), Csize_t, (Ptr{wasm_func_t},), arg1)
end

function wasm_func_call(arg1, args, results)
    ccall((:wasm_func_call, libwasmer), Ptr{wasm_trap_t}, (Ptr{wasm_func_t}, Ptr{wasm_val_vec_t}, Ptr{wasm_val_vec_t}), arg1, args, results)
end

mutable struct wasm_global_t end

function wasm_global_delete(arg1)
    ccall((:wasm_global_delete, libwasmer), Cvoid, (Ptr{wasm_global_t},), arg1)
end

function wasm_global_copy(arg1)
    ccall((:wasm_global_copy, libwasmer), Ptr{wasm_global_t}, (Ptr{wasm_global_t},), arg1)
end

function wasm_global_same(arg1, arg2)
    ccall((:wasm_global_same, libwasmer), Bool, (Ptr{wasm_global_t}, Ptr{wasm_global_t}), arg1, arg2)
end

function wasm_global_get_host_info(arg1)
    ccall((:wasm_global_get_host_info, libwasmer), Ptr{Cvoid}, (Ptr{wasm_global_t},), arg1)
end

function wasm_global_set_host_info(arg1, arg2)
    ccall((:wasm_global_set_host_info, libwasmer), Cvoid, (Ptr{wasm_global_t}, Ptr{Cvoid}), arg1, arg2)
end

function wasm_global_set_host_info_with_finalizer(arg1, arg2, arg3)
    ccall((:wasm_global_set_host_info_with_finalizer, libwasmer), Cvoid, (Ptr{wasm_global_t}, Ptr{Cvoid}, Ptr{Cvoid}), arg1, arg2, arg3)
end

function wasm_global_as_ref(arg1)
    ccall((:wasm_global_as_ref, libwasmer), Ptr{wasm_ref_t}, (Ptr{wasm_global_t},), arg1)
end

function wasm_ref_as_global(arg1)
    ccall((:wasm_ref_as_global, libwasmer), Ptr{wasm_global_t}, (Ptr{wasm_ref_t},), arg1)
end

function wasm_global_as_ref_const(arg1)
    ccall((:wasm_global_as_ref_const, libwasmer), Ptr{wasm_ref_t}, (Ptr{wasm_global_t},), arg1)
end

function wasm_ref_as_global_const(arg1)
    ccall((:wasm_ref_as_global_const, libwasmer), Ptr{wasm_global_t}, (Ptr{wasm_ref_t},), arg1)
end

function wasm_global_new(arg1, arg2, arg3)
    ccall((:wasm_global_new, libwasmer), Ptr{wasm_global_t}, (Ptr{wasm_store_t}, Ptr{wasm_globaltype_t}, Ptr{wasm_val_t}), arg1, arg2, arg3)
end

function wasm_global_type(arg1)
    ccall((:wasm_global_type, libwasmer), Ptr{wasm_globaltype_t}, (Ptr{wasm_global_t},), arg1)
end

function wasm_global_get(arg1, out)
    ccall((:wasm_global_get, libwasmer), Cvoid, (Ptr{wasm_global_t}, Ptr{wasm_val_t}), arg1, out)
end

function wasm_global_set(arg1, arg2)
    ccall((:wasm_global_set, libwasmer), Cvoid, (Ptr{wasm_global_t}, Ptr{wasm_val_t}), arg1, arg2)
end

mutable struct wasm_table_t end

function wasm_table_delete(arg1)
    ccall((:wasm_table_delete, libwasmer), Cvoid, (Ptr{wasm_table_t},), arg1)
end

function wasm_table_copy(arg1)
    ccall((:wasm_table_copy, libwasmer), Ptr{wasm_table_t}, (Ptr{wasm_table_t},), arg1)
end

function wasm_table_same(arg1, arg2)
    ccall((:wasm_table_same, libwasmer), Bool, (Ptr{wasm_table_t}, Ptr{wasm_table_t}), arg1, arg2)
end

function wasm_table_get_host_info(arg1)
    ccall((:wasm_table_get_host_info, libwasmer), Ptr{Cvoid}, (Ptr{wasm_table_t},), arg1)
end

function wasm_table_set_host_info(arg1, arg2)
    ccall((:wasm_table_set_host_info, libwasmer), Cvoid, (Ptr{wasm_table_t}, Ptr{Cvoid}), arg1, arg2)
end

function wasm_table_set_host_info_with_finalizer(arg1, arg2, arg3)
    ccall((:wasm_table_set_host_info_with_finalizer, libwasmer), Cvoid, (Ptr{wasm_table_t}, Ptr{Cvoid}, Ptr{Cvoid}), arg1, arg2, arg3)
end

function wasm_table_as_ref(arg1)
    ccall((:wasm_table_as_ref, libwasmer), Ptr{wasm_ref_t}, (Ptr{wasm_table_t},), arg1)
end

function wasm_ref_as_table(arg1)
    ccall((:wasm_ref_as_table, libwasmer), Ptr{wasm_table_t}, (Ptr{wasm_ref_t},), arg1)
end

function wasm_table_as_ref_const(arg1)
    ccall((:wasm_table_as_ref_const, libwasmer), Ptr{wasm_ref_t}, (Ptr{wasm_table_t},), arg1)
end

function wasm_ref_as_table_const(arg1)
    ccall((:wasm_ref_as_table_const, libwasmer), Ptr{wasm_table_t}, (Ptr{wasm_ref_t},), arg1)
end

const wasm_table_size_t = UInt32

function wasm_table_new(arg1, arg2, init)
    ccall((:wasm_table_new, libwasmer), Ptr{wasm_table_t}, (Ptr{wasm_store_t}, Ptr{wasm_tabletype_t}, Ptr{wasm_ref_t}), arg1, arg2, init)
end

function wasm_table_type(arg1)
    ccall((:wasm_table_type, libwasmer), Ptr{wasm_tabletype_t}, (Ptr{wasm_table_t},), arg1)
end

function wasm_table_get(arg1, index)
    ccall((:wasm_table_get, libwasmer), Ptr{wasm_ref_t}, (Ptr{wasm_table_t}, wasm_table_size_t), arg1, index)
end

function wasm_table_set(arg1, index, arg3)
    ccall((:wasm_table_set, libwasmer), Bool, (Ptr{wasm_table_t}, wasm_table_size_t, Ptr{wasm_ref_t}), arg1, index, arg3)
end

function wasm_table_size(arg1)
    ccall((:wasm_table_size, libwasmer), wasm_table_size_t, (Ptr{wasm_table_t},), arg1)
end

function wasm_table_grow(arg1, delta, init)
    ccall((:wasm_table_grow, libwasmer), Bool, (Ptr{wasm_table_t}, wasm_table_size_t, Ptr{wasm_ref_t}), arg1, delta, init)
end

mutable struct wasm_memory_t end

function wasm_memory_delete(arg1)
    ccall((:wasm_memory_delete, libwasmer), Cvoid, (Ptr{wasm_memory_t},), arg1)
end

function wasm_memory_copy(arg1)
    ccall((:wasm_memory_copy, libwasmer), Ptr{wasm_memory_t}, (Ptr{wasm_memory_t},), arg1)
end

function wasm_memory_same(arg1, arg2)
    ccall((:wasm_memory_same, libwasmer), Bool, (Ptr{wasm_memory_t}, Ptr{wasm_memory_t}), arg1, arg2)
end

function wasm_memory_get_host_info(arg1)
    ccall((:wasm_memory_get_host_info, libwasmer), Ptr{Cvoid}, (Ptr{wasm_memory_t},), arg1)
end

function wasm_memory_set_host_info(arg1, arg2)
    ccall((:wasm_memory_set_host_info, libwasmer), Cvoid, (Ptr{wasm_memory_t}, Ptr{Cvoid}), arg1, arg2)
end

function wasm_memory_set_host_info_with_finalizer(arg1, arg2, arg3)
    ccall((:wasm_memory_set_host_info_with_finalizer, libwasmer), Cvoid, (Ptr{wasm_memory_t}, Ptr{Cvoid}, Ptr{Cvoid}), arg1, arg2, arg3)
end

function wasm_memory_as_ref(arg1)
    ccall((:wasm_memory_as_ref, libwasmer), Ptr{wasm_ref_t}, (Ptr{wasm_memory_t},), arg1)
end

function wasm_ref_as_memory(arg1)
    ccall((:wasm_ref_as_memory, libwasmer), Ptr{wasm_memory_t}, (Ptr{wasm_ref_t},), arg1)
end

function wasm_memory_as_ref_const(arg1)
    ccall((:wasm_memory_as_ref_const, libwasmer), Ptr{wasm_ref_t}, (Ptr{wasm_memory_t},), arg1)
end

function wasm_ref_as_memory_const(arg1)
    ccall((:wasm_ref_as_memory_const, libwasmer), Ptr{wasm_memory_t}, (Ptr{wasm_ref_t},), arg1)
end

const wasm_memory_pages_t = UInt32

function wasm_memory_new(arg1, arg2)
    ccall((:wasm_memory_new, libwasmer), Ptr{wasm_memory_t}, (Ptr{wasm_store_t}, Ptr{wasm_memorytype_t}), arg1, arg2)
end

function wasm_memory_type(arg1)
    ccall((:wasm_memory_type, libwasmer), Ptr{wasm_memorytype_t}, (Ptr{wasm_memory_t},), arg1)
end

function wasm_memory_data(arg1)
    ccall((:wasm_memory_data, libwasmer), Ptr{byte_t}, (Ptr{wasm_memory_t},), arg1)
end

function wasm_memory_data_size(arg1)
    ccall((:wasm_memory_data_size, libwasmer), Csize_t, (Ptr{wasm_memory_t},), arg1)
end

function wasm_memory_size(arg1)
    ccall((:wasm_memory_size, libwasmer), wasm_memory_pages_t, (Ptr{wasm_memory_t},), arg1)
end

function wasm_memory_grow(arg1, delta)
    ccall((:wasm_memory_grow, libwasmer), Bool, (Ptr{wasm_memory_t}, wasm_memory_pages_t), arg1, delta)
end

mutable struct wasm_extern_t end

function wasm_extern_delete(arg1)
    ccall((:wasm_extern_delete, libwasmer), Cvoid, (Ptr{wasm_extern_t},), arg1)
end

function wasm_extern_copy(arg1)
    ccall((:wasm_extern_copy, libwasmer), Ptr{wasm_extern_t}, (Ptr{wasm_extern_t},), arg1)
end

function wasm_extern_same(arg1, arg2)
    ccall((:wasm_extern_same, libwasmer), Bool, (Ptr{wasm_extern_t}, Ptr{wasm_extern_t}), arg1, arg2)
end

function wasm_extern_get_host_info(arg1)
    ccall((:wasm_extern_get_host_info, libwasmer), Ptr{Cvoid}, (Ptr{wasm_extern_t},), arg1)
end

function wasm_extern_set_host_info(arg1, arg2)
    ccall((:wasm_extern_set_host_info, libwasmer), Cvoid, (Ptr{wasm_extern_t}, Ptr{Cvoid}), arg1, arg2)
end

function wasm_extern_set_host_info_with_finalizer(arg1, arg2, arg3)
    ccall((:wasm_extern_set_host_info_with_finalizer, libwasmer), Cvoid, (Ptr{wasm_extern_t}, Ptr{Cvoid}, Ptr{Cvoid}), arg1, arg2, arg3)
end

function wasm_extern_as_ref(arg1)
    ccall((:wasm_extern_as_ref, libwasmer), Ptr{wasm_ref_t}, (Ptr{wasm_extern_t},), arg1)
end

function wasm_ref_as_extern(arg1)
    ccall((:wasm_ref_as_extern, libwasmer), Ptr{wasm_extern_t}, (Ptr{wasm_ref_t},), arg1)
end

function wasm_extern_as_ref_const(arg1)
    ccall((:wasm_extern_as_ref_const, libwasmer), Ptr{wasm_ref_t}, (Ptr{wasm_extern_t},), arg1)
end

function wasm_ref_as_extern_const(arg1)
    ccall((:wasm_ref_as_extern_const, libwasmer), Ptr{wasm_extern_t}, (Ptr{wasm_ref_t},), arg1)
end

mutable struct wasm_extern_vec_t
    size::Csize_t
    data::Ptr{Ptr{wasm_extern_t}}
end

function wasm_extern_vec_new_empty(out)
    ccall((:wasm_extern_vec_new_empty, libwasmer), Cvoid, (Ptr{wasm_extern_vec_t},), out)
end

function wasm_extern_vec_new_uninitialized(out, arg2)
    ccall((:wasm_extern_vec_new_uninitialized, libwasmer), Cvoid, (Ptr{wasm_extern_vec_t}, Csize_t), out, arg2)
end

function wasm_extern_vec_new(out, arg2, arg3)
    ccall((:wasm_extern_vec_new, libwasmer), Cvoid, (Ptr{wasm_extern_vec_t}, Csize_t, Ptr{Ptr{wasm_extern_t}}), out, arg2, arg3)
end

function wasm_extern_vec_copy(out, arg2)
    ccall((:wasm_extern_vec_copy, libwasmer), Cvoid, (Ptr{wasm_extern_vec_t}, Ptr{wasm_extern_vec_t}), out, arg2)
end

function wasm_extern_vec_delete(arg1)
    ccall((:wasm_extern_vec_delete, libwasmer), Cvoid, (Ptr{wasm_extern_vec_t},), arg1)
end

function wasm_extern_kind(arg1)
    ccall((:wasm_extern_kind, libwasmer), wasm_externkind_t, (Ptr{wasm_extern_t},), arg1)
end

function wasm_extern_type(arg1)
    ccall((:wasm_extern_type, libwasmer), Ptr{wasm_externtype_t}, (Ptr{wasm_extern_t},), arg1)
end

function wasm_func_as_extern(arg1)
    ccall((:wasm_func_as_extern, libwasmer), Ptr{wasm_extern_t}, (Ptr{wasm_func_t},), arg1)
end

function wasm_global_as_extern(arg1)
    ccall((:wasm_global_as_extern, libwasmer), Ptr{wasm_extern_t}, (Ptr{wasm_global_t},), arg1)
end

function wasm_table_as_extern(arg1)
    ccall((:wasm_table_as_extern, libwasmer), Ptr{wasm_extern_t}, (Ptr{wasm_table_t},), arg1)
end

function wasm_memory_as_extern(arg1)
    ccall((:wasm_memory_as_extern, libwasmer), Ptr{wasm_extern_t}, (Ptr{wasm_memory_t},), arg1)
end

function wasm_extern_as_func(arg1)
    ccall((:wasm_extern_as_func, libwasmer), Ptr{wasm_func_t}, (Ptr{wasm_extern_t},), arg1)
end

function wasm_extern_as_global(arg1)
    ccall((:wasm_extern_as_global, libwasmer), Ptr{wasm_global_t}, (Ptr{wasm_extern_t},), arg1)
end

function wasm_extern_as_table(arg1)
    ccall((:wasm_extern_as_table, libwasmer), Ptr{wasm_table_t}, (Ptr{wasm_extern_t},), arg1)
end

function wasm_extern_as_memory(arg1)
    ccall((:wasm_extern_as_memory, libwasmer), Ptr{wasm_memory_t}, (Ptr{wasm_extern_t},), arg1)
end

function wasm_func_as_extern_const(arg1)
    ccall((:wasm_func_as_extern_const, libwasmer), Ptr{wasm_extern_t}, (Ptr{wasm_func_t},), arg1)
end

function wasm_global_as_extern_const(arg1)
    ccall((:wasm_global_as_extern_const, libwasmer), Ptr{wasm_extern_t}, (Ptr{wasm_global_t},), arg1)
end

function wasm_table_as_extern_const(arg1)
    ccall((:wasm_table_as_extern_const, libwasmer), Ptr{wasm_extern_t}, (Ptr{wasm_table_t},), arg1)
end

function wasm_memory_as_extern_const(arg1)
    ccall((:wasm_memory_as_extern_const, libwasmer), Ptr{wasm_extern_t}, (Ptr{wasm_memory_t},), arg1)
end

function wasm_extern_as_func_const(arg1)
    ccall((:wasm_extern_as_func_const, libwasmer), Ptr{wasm_func_t}, (Ptr{wasm_extern_t},), arg1)
end

function wasm_extern_as_global_const(arg1)
    ccall((:wasm_extern_as_global_const, libwasmer), Ptr{wasm_global_t}, (Ptr{wasm_extern_t},), arg1)
end

function wasm_extern_as_table_const(arg1)
    ccall((:wasm_extern_as_table_const, libwasmer), Ptr{wasm_table_t}, (Ptr{wasm_extern_t},), arg1)
end

function wasm_extern_as_memory_const(arg1)
    ccall((:wasm_extern_as_memory_const, libwasmer), Ptr{wasm_memory_t}, (Ptr{wasm_extern_t},), arg1)
end

function wasm_instance_delete(arg1)
    ccall((:wasm_instance_delete, libwasmer), Cvoid, (Ptr{wasm_instance_t},), arg1)
end

function wasm_instance_copy(arg1)
    ccall((:wasm_instance_copy, libwasmer), Ptr{wasm_instance_t}, (Ptr{wasm_instance_t},), arg1)
end

function wasm_instance_same(arg1, arg2)
    ccall((:wasm_instance_same, libwasmer), Bool, (Ptr{wasm_instance_t}, Ptr{wasm_instance_t}), arg1, arg2)
end

function wasm_instance_get_host_info(arg1)
    ccall((:wasm_instance_get_host_info, libwasmer), Ptr{Cvoid}, (Ptr{wasm_instance_t},), arg1)
end

function wasm_instance_set_host_info(arg1, arg2)
    ccall((:wasm_instance_set_host_info, libwasmer), Cvoid, (Ptr{wasm_instance_t}, Ptr{Cvoid}), arg1, arg2)
end

function wasm_instance_set_host_info_with_finalizer(arg1, arg2, arg3)
    ccall((:wasm_instance_set_host_info_with_finalizer, libwasmer), Cvoid, (Ptr{wasm_instance_t}, Ptr{Cvoid}, Ptr{Cvoid}), arg1, arg2, arg3)
end

function wasm_instance_as_ref(arg1)
    ccall((:wasm_instance_as_ref, libwasmer), Ptr{wasm_ref_t}, (Ptr{wasm_instance_t},), arg1)
end

function wasm_ref_as_instance(arg1)
    ccall((:wasm_ref_as_instance, libwasmer), Ptr{wasm_instance_t}, (Ptr{wasm_ref_t},), arg1)
end

function wasm_instance_as_ref_const(arg1)
    ccall((:wasm_instance_as_ref_const, libwasmer), Ptr{wasm_ref_t}, (Ptr{wasm_instance_t},), arg1)
end

function wasm_ref_as_instance_const(arg1)
    ccall((:wasm_ref_as_instance_const, libwasmer), Ptr{wasm_instance_t}, (Ptr{wasm_ref_t},), arg1)
end

function wasm_instance_new(arg1, arg2, imports, arg4)
    ccall((:wasm_instance_new, libwasmer), Ptr{wasm_instance_t}, (Ptr{wasm_store_t}, Ptr{wasm_module_t}, Ptr{wasm_extern_vec_t}, Ptr{Ptr{wasm_trap_t}}), arg1, arg2, imports, arg4)
end

function wasm_instance_exports(arg1, out)
    ccall((:wasm_instance_exports, libwasmer), Cvoid, (Ptr{wasm_instance_t}, Ptr{wasm_extern_vec_t}), arg1, out)
end

# no prototype is found for this function at wasm.h:537:35, please use with caution
function wasm_valtype_new_i32()
    ccall((:wasm_valtype_new_i32, libwasmer), Ptr{wasm_valtype_t}, ())
end

# no prototype is found for this function at wasm.h:540:35, please use with caution
function wasm_valtype_new_i64()
    ccall((:wasm_valtype_new_i64, libwasmer), Ptr{wasm_valtype_t}, ())
end

# no prototype is found for this function at wasm.h:543:35, please use with caution
function wasm_valtype_new_f32()
    ccall((:wasm_valtype_new_f32, libwasmer), Ptr{wasm_valtype_t}, ())
end

# no prototype is found for this function at wasm.h:546:35, please use with caution
function wasm_valtype_new_f64()
    ccall((:wasm_valtype_new_f64, libwasmer), Ptr{wasm_valtype_t}, ())
end

# no prototype is found for this function at wasm.h:550:35, please use with caution
function wasm_valtype_new_anyref()
    ccall((:wasm_valtype_new_anyref, libwasmer), Ptr{wasm_valtype_t}, ())
end

# no prototype is found for this function at wasm.h:553:35, please use with caution
function wasm_valtype_new_funcref()
    ccall((:wasm_valtype_new_funcref, libwasmer), Ptr{wasm_valtype_t}, ())
end

# no prototype is found for this function at wasm.h:560:36, please use with caution
function wasm_functype_new_0_0()
    ccall((:wasm_functype_new_0_0, libwasmer), Ptr{wasm_functype_t}, ())
end

function wasm_functype_new_1_0(p)
    ccall((:wasm_functype_new_1_0, libwasmer), Ptr{wasm_functype_t}, (Ptr{wasm_valtype_t},), p)
end

function wasm_functype_new_2_0(p1, p2)
    ccall((:wasm_functype_new_2_0, libwasmer), Ptr{wasm_functype_t}, (Ptr{wasm_valtype_t}, Ptr{wasm_valtype_t}), p1, p2)
end

function wasm_functype_new_3_0(p1, p2, p3)
    ccall((:wasm_functype_new_3_0, libwasmer), Ptr{wasm_functype_t}, (Ptr{wasm_valtype_t}, Ptr{wasm_valtype_t}, Ptr{wasm_valtype_t}), p1, p2, p3)
end

function wasm_functype_new_0_1(r)
    ccall((:wasm_functype_new_0_1, libwasmer), Ptr{wasm_functype_t}, (Ptr{wasm_valtype_t},), r)
end

function wasm_functype_new_1_1(p, r)
    ccall((:wasm_functype_new_1_1, libwasmer), Ptr{wasm_functype_t}, (Ptr{wasm_valtype_t}, Ptr{wasm_valtype_t}), p, r)
end

function wasm_functype_new_2_1(p1, p2, r)
    ccall((:wasm_functype_new_2_1, libwasmer), Ptr{wasm_functype_t}, (Ptr{wasm_valtype_t}, Ptr{wasm_valtype_t}, Ptr{wasm_valtype_t}), p1, p2, r)
end

function wasm_functype_new_3_1(p1, p2, p3, r)
    ccall((:wasm_functype_new_3_1, libwasmer), Ptr{wasm_functype_t}, (Ptr{wasm_valtype_t}, Ptr{wasm_valtype_t}, Ptr{wasm_valtype_t}, Ptr{wasm_valtype_t}), p1, p2, p3, r)
end

function wasm_functype_new_0_2(r1, r2)
    ccall((:wasm_functype_new_0_2, libwasmer), Ptr{wasm_functype_t}, (Ptr{wasm_valtype_t}, Ptr{wasm_valtype_t}), r1, r2)
end

function wasm_functype_new_1_2(p, r1, r2)
    ccall((:wasm_functype_new_1_2, libwasmer), Ptr{wasm_functype_t}, (Ptr{wasm_valtype_t}, Ptr{wasm_valtype_t}, Ptr{wasm_valtype_t}), p, r1, r2)
end

function wasm_functype_new_2_2(p1, p2, r1, r2)
    ccall((:wasm_functype_new_2_2, libwasmer), Ptr{wasm_functype_t}, (Ptr{wasm_valtype_t}, Ptr{wasm_valtype_t}, Ptr{wasm_valtype_t}, Ptr{wasm_valtype_t}), p1, p2, r1, r2)
end

function wasm_functype_new_3_2(p1, p2, p3, r1, r2)
    ccall((:wasm_functype_new_3_2, libwasmer), Ptr{wasm_functype_t}, (Ptr{wasm_valtype_t}, Ptr{wasm_valtype_t}, Ptr{wasm_valtype_t}, Ptr{wasm_valtype_t}, Ptr{wasm_valtype_t}), p1, p2, p3, r1, r2)
end

function wasm_val_init_ptr(out, p)
    ccall((:wasm_val_init_ptr, libwasmer), Cvoid, (Ptr{wasm_val_t}, Ptr{Cvoid}), out, p)
end

function wasm_val_ptr(val)
    ccall((:wasm_val_ptr, libwasmer), Ptr{Cvoid}, (Ptr{wasm_val_t},), val)
end

@cenum wasi_version_t::Int32 begin
    INVALID_VERSION = -1
    LATEST = 0
    SNAPSHOT0 = 1
    SNAPSHOT1 = 2
end

@cenum wasmer_compiler_t::UInt32 begin
    CRANELIFT = 0
    LLVM = 1
    SINGLEPASS = 2
end

@cenum wasmer_engine_t::UInt32 begin
    UNIVERSAL = 0
    DYLIB = 1
    STATICLIB = 2
end

@cenum wasmer_parser_operator_t::UInt32 begin
    Unreachable = 0
    Nop = 1
    Block = 2
    Loop = 3
    If = 4
    Else = 5
    Try = 6
    Catch = 7
    CatchAll = 8
    Delegate = 9
    Throw = 10
    Rethrow = 11
    Unwind = 12
    End = 13
    Br = 14
    BrIf = 15
    BrTable = 16
    Return = 17
    Call = 18
    CallIndirect = 19
    ReturnCall = 20
    ReturnCallIndirect = 21
    Drop = 22
    Select = 23
    TypedSelect = 24
    LocalGet = 25
    LocalSet = 26
    LocalTee = 27
    GlobalGet = 28
    GlobalSet = 29
    I32Load = 30
    I64Load = 31
    F32Load = 32
    F64Load = 33
    I32Load8S = 34
    I32Load8U = 35
    I32Load16S = 36
    I32Load16U = 37
    I64Load8S = 38
    I64Load8U = 39
    I64Load16S = 40
    I64Load16U = 41
    I64Load32S = 42
    I64Load32U = 43
    I32Store = 44
    I64Store = 45
    F32Store = 46
    F64Store = 47
    I32Store8 = 48
    I32Store16 = 49
    I64Store8 = 50
    I64Store16 = 51
    I64Store32 = 52
    MemorySize = 53
    MemoryGrow = 54
    I32Const = 55
    I64Const = 56
    F32Const = 57
    F64Const = 58
    RefNull = 59
    RefIsNull = 60
    RefFunc = 61
    I32Eqz = 62
    I32Eq = 63
    I32Ne = 64
    I32LtS = 65
    I32LtU = 66
    I32GtS = 67
    I32GtU = 68
    I32LeS = 69
    I32LeU = 70
    I32GeS = 71
    I32GeU = 72
    I64Eqz = 73
    I64Eq = 74
    I64Ne = 75
    I64LtS = 76
    I64LtU = 77
    I64GtS = 78
    I64GtU = 79
    I64LeS = 80
    I64LeU = 81
    I64GeS = 82
    I64GeU = 83
    F32Eq = 84
    F32Ne = 85
    F32Lt = 86
    F32Gt = 87
    F32Le = 88
    F32Ge = 89
    F64Eq = 90
    F64Ne = 91
    F64Lt = 92
    F64Gt = 93
    F64Le = 94
    F64Ge = 95
    I32Clz = 96
    I32Ctz = 97
    I32Popcnt = 98
    I32Add = 99
    I32Sub = 100
    I32Mul = 101
    I32DivS = 102
    I32DivU = 103
    I32RemS = 104
    I32RemU = 105
    I32And = 106
    I32Or = 107
    I32Xor = 108
    I32Shl = 109
    I32ShrS = 110
    I32ShrU = 111
    I32Rotl = 112
    I32Rotr = 113
    I64Clz = 114
    I64Ctz = 115
    I64Popcnt = 116
    I64Add = 117
    I64Sub = 118
    I64Mul = 119
    I64DivS = 120
    I64DivU = 121
    I64RemS = 122
    I64RemU = 123
    I64And = 124
    I64Or = 125
    I64Xor = 126
    I64Shl = 127
    I64ShrS = 128
    I64ShrU = 129
    I64Rotl = 130
    I64Rotr = 131
    F32Abs = 132
    F32Neg = 133
    F32Ceil = 134
    F32Floor = 135
    F32Trunc = 136
    F32Nearest = 137
    F32Sqrt = 138
    F32Add = 139
    F32Sub = 140
    F32Mul = 141
    F32Div = 142
    F32Min = 143
    F32Max = 144
    F32Copysign = 145
    F64Abs = 146
    F64Neg = 147
    F64Ceil = 148
    F64Floor = 149
    F64Trunc = 150
    F64Nearest = 151
    F64Sqrt = 152
    F64Add = 153
    F64Sub = 154
    F64Mul = 155
    F64Div = 156
    F64Min = 157
    F64Max = 158
    F64Copysign = 159
    I32WrapI64 = 160
    I32TruncF32S = 161
    I32TruncF32U = 162
    I32TruncF64S = 163
    I32TruncF64U = 164
    I64ExtendI32S = 165
    I64ExtendI32U = 166
    I64TruncF32S = 167
    I64TruncF32U = 168
    I64TruncF64S = 169
    I64TruncF64U = 170
    F32ConvertI32S = 171
    F32ConvertI32U = 172
    F32ConvertI64S = 173
    F32ConvertI64U = 174
    F32DemoteF64 = 175
    F64ConvertI32S = 176
    F64ConvertI32U = 177
    F64ConvertI64S = 178
    F64ConvertI64U = 179
    F64PromoteF32 = 180
    I32ReinterpretF32 = 181
    I64ReinterpretF64 = 182
    F32ReinterpretI32 = 183
    F64ReinterpretI64 = 184
    I32Extend8S = 185
    I32Extend16S = 186
    I64Extend8S = 187
    I64Extend16S = 188
    I64Extend32S = 189
    I32TruncSatF32S = 190
    I32TruncSatF32U = 191
    I32TruncSatF64S = 192
    I32TruncSatF64U = 193
    I64TruncSatF32S = 194
    I64TruncSatF32U = 195
    I64TruncSatF64S = 196
    I64TruncSatF64U = 197
    MemoryInit = 198
    DataDrop = 199
    MemoryCopy = 200
    MemoryFill = 201
    TableInit = 202
    ElemDrop = 203
    TableCopy = 204
    TableFill = 205
    TableGet = 206
    TableSet = 207
    TableGrow = 208
    TableSize = 209
    MemoryAtomicNotify = 210
    MemoryAtomicWait32 = 211
    MemoryAtomicWait64 = 212
    AtomicFence = 213
    I32AtomicLoad = 214
    I64AtomicLoad = 215
    I32AtomicLoad8U = 216
    I32AtomicLoad16U = 217
    I64AtomicLoad8U = 218
    I64AtomicLoad16U = 219
    I64AtomicLoad32U = 220
    I32AtomicStore = 221
    I64AtomicStore = 222
    I32AtomicStore8 = 223
    I32AtomicStore16 = 224
    I64AtomicStore8 = 225
    I64AtomicStore16 = 226
    I64AtomicStore32 = 227
    I32AtomicRmwAdd = 228
    I64AtomicRmwAdd = 229
    I32AtomicRmw8AddU = 230
    I32AtomicRmw16AddU = 231
    I64AtomicRmw8AddU = 232
    I64AtomicRmw16AddU = 233
    I64AtomicRmw32AddU = 234
    I32AtomicRmwSub = 235
    I64AtomicRmwSub = 236
    I32AtomicRmw8SubU = 237
    I32AtomicRmw16SubU = 238
    I64AtomicRmw8SubU = 239
    I64AtomicRmw16SubU = 240
    I64AtomicRmw32SubU = 241
    I32AtomicRmwAnd = 242
    I64AtomicRmwAnd = 243
    I32AtomicRmw8AndU = 244
    I32AtomicRmw16AndU = 245
    I64AtomicRmw8AndU = 246
    I64AtomicRmw16AndU = 247
    I64AtomicRmw32AndU = 248
    I32AtomicRmwOr = 249
    I64AtomicRmwOr = 250
    I32AtomicRmw8OrU = 251
    I32AtomicRmw16OrU = 252
    I64AtomicRmw8OrU = 253
    I64AtomicRmw16OrU = 254
    I64AtomicRmw32OrU = 255
    I32AtomicRmwXor = 256
    I64AtomicRmwXor = 257
    I32AtomicRmw8XorU = 258
    I32AtomicRmw16XorU = 259
    I64AtomicRmw8XorU = 260
    I64AtomicRmw16XorU = 261
    I64AtomicRmw32XorU = 262
    I32AtomicRmwXchg = 263
    I64AtomicRmwXchg = 264
    I32AtomicRmw8XchgU = 265
    I32AtomicRmw16XchgU = 266
    I64AtomicRmw8XchgU = 267
    I64AtomicRmw16XchgU = 268
    I64AtomicRmw32XchgU = 269
    I32AtomicRmwCmpxchg = 270
    I64AtomicRmwCmpxchg = 271
    I32AtomicRmw8CmpxchgU = 272
    I32AtomicRmw16CmpxchgU = 273
    I64AtomicRmw8CmpxchgU = 274
    I64AtomicRmw16CmpxchgU = 275
    I64AtomicRmw32CmpxchgU = 276
    V128Load = 277
    V128Store = 278
    V128Const = 279
    I8x16Splat = 280
    I8x16ExtractLaneS = 281
    I8x16ExtractLaneU = 282
    I8x16ReplaceLane = 283
    I16x8Splat = 284
    I16x8ExtractLaneS = 285
    I16x8ExtractLaneU = 286
    I16x8ReplaceLane = 287
    I32x4Splat = 288
    I32x4ExtractLane = 289
    I32x4ReplaceLane = 290
    I64x2Splat = 291
    I64x2ExtractLane = 292
    I64x2ReplaceLane = 293
    F32x4Splat = 294
    F32x4ExtractLane = 295
    F32x4ReplaceLane = 296
    F64x2Splat = 297
    F64x2ExtractLane = 298
    F64x2ReplaceLane = 299
    I8x16Eq = 300
    I8x16Ne = 301
    I8x16LtS = 302
    I8x16LtU = 303
    I8x16GtS = 304
    I8x16GtU = 305
    I8x16LeS = 306
    I8x16LeU = 307
    I8x16GeS = 308
    I8x16GeU = 309
    I16x8Eq = 310
    I16x8Ne = 311
    I16x8LtS = 312
    I16x8LtU = 313
    I16x8GtS = 314
    I16x8GtU = 315
    I16x8LeS = 316
    I16x8LeU = 317
    I16x8GeS = 318
    I16x8GeU = 319
    I32x4Eq = 320
    I32x4Ne = 321
    I32x4LtS = 322
    I32x4LtU = 323
    I32x4GtS = 324
    I32x4GtU = 325
    I32x4LeS = 326
    I32x4LeU = 327
    I32x4GeS = 328
    I32x4GeU = 329
    I64x2Eq = 330
    I64x2Ne = 331
    I64x2LtS = 332
    I64x2GtS = 333
    I64x2LeS = 334
    I64x2GeS = 335
    F32x4Eq = 336
    F32x4Ne = 337
    F32x4Lt = 338
    F32x4Gt = 339
    F32x4Le = 340
    F32x4Ge = 341
    F64x2Eq = 342
    F64x2Ne = 343
    F64x2Lt = 344
    F64x2Gt = 345
    F64x2Le = 346
    F64x2Ge = 347
    V128Not = 348
    V128And = 349
    V128AndNot = 350
    V128Or = 351
    V128Xor = 352
    V128Bitselect = 353
    V128AnyTrue = 354
    I8x16Abs = 355
    I8x16Neg = 356
    I8x16AllTrue = 357
    I8x16Bitmask = 358
    I8x16Shl = 359
    I8x16ShrS = 360
    I8x16ShrU = 361
    I8x16Add = 362
    I8x16AddSatS = 363
    I8x16AddSatU = 364
    I8x16Sub = 365
    I8x16SubSatS = 366
    I8x16SubSatU = 367
    I8x16MinS = 368
    I8x16MinU = 369
    I8x16MaxS = 370
    I8x16MaxU = 371
    I8x16Popcnt = 372
    I16x8Abs = 373
    I16x8Neg = 374
    I16x8AllTrue = 375
    I16x8Bitmask = 376
    I16x8Shl = 377
    I16x8ShrS = 378
    I16x8ShrU = 379
    I16x8Add = 380
    I16x8AddSatS = 381
    I16x8AddSatU = 382
    I16x8Sub = 383
    I16x8SubSatS = 384
    I16x8SubSatU = 385
    I16x8Mul = 386
    I16x8MinS = 387
    I16x8MinU = 388
    I16x8MaxS = 389
    I16x8MaxU = 390
    I16x8ExtAddPairwiseI8x16S = 391
    I16x8ExtAddPairwiseI8x16U = 392
    I32x4Abs = 393
    I32x4Neg = 394
    I32x4AllTrue = 395
    I32x4Bitmask = 396
    I32x4Shl = 397
    I32x4ShrS = 398
    I32x4ShrU = 399
    I32x4Add = 400
    I32x4Sub = 401
    I32x4Mul = 402
    I32x4MinS = 403
    I32x4MinU = 404
    I32x4MaxS = 405
    I32x4MaxU = 406
    I32x4DotI16x8S = 407
    I32x4ExtAddPairwiseI16x8S = 408
    I32x4ExtAddPairwiseI16x8U = 409
    I64x2Abs = 410
    I64x2Neg = 411
    I64x2AllTrue = 412
    I64x2Bitmask = 413
    I64x2Shl = 414
    I64x2ShrS = 415
    I64x2ShrU = 416
    I64x2Add = 417
    I64x2Sub = 418
    I64x2Mul = 419
    F32x4Ceil = 420
    F32x4Floor = 421
    F32x4Trunc = 422
    F32x4Nearest = 423
    F64x2Ceil = 424
    F64x2Floor = 425
    F64x2Trunc = 426
    F64x2Nearest = 427
    F32x4Abs = 428
    F32x4Neg = 429
    F32x4Sqrt = 430
    F32x4Add = 431
    F32x4Sub = 432
    F32x4Mul = 433
    F32x4Div = 434
    F32x4Min = 435
    F32x4Max = 436
    F32x4PMin = 437
    F32x4PMax = 438
    F64x2Abs = 439
    F64x2Neg = 440
    F64x2Sqrt = 441
    F64x2Add = 442
    F64x2Sub = 443
    F64x2Mul = 444
    F64x2Div = 445
    F64x2Min = 446
    F64x2Max = 447
    F64x2PMin = 448
    F64x2PMax = 449
    I32x4TruncSatF32x4S = 450
    I32x4TruncSatF32x4U = 451
    F32x4ConvertI32x4S = 452
    F32x4ConvertI32x4U = 453
    I8x16Swizzle = 454
    I8x16Shuffle = 455
    V128Load8Splat = 456
    V128Load16Splat = 457
    V128Load32Splat = 458
    V128Load32Zero = 459
    V128Load64Splat = 460
    V128Load64Zero = 461
    I8x16NarrowI16x8S = 462
    I8x16NarrowI16x8U = 463
    I16x8NarrowI32x4S = 464
    I16x8NarrowI32x4U = 465
    I16x8ExtendLowI8x16S = 466
    I16x8ExtendHighI8x16S = 467
    I16x8ExtendLowI8x16U = 468
    I16x8ExtendHighI8x16U = 469
    I32x4ExtendLowI16x8S = 470
    I32x4ExtendHighI16x8S = 471
    I32x4ExtendLowI16x8U = 472
    I32x4ExtendHighI16x8U = 473
    I64x2ExtendLowI32x4S = 474
    I64x2ExtendHighI32x4S = 475
    I64x2ExtendLowI32x4U = 476
    I64x2ExtendHighI32x4U = 477
    I16x8ExtMulLowI8x16S = 478
    I16x8ExtMulHighI8x16S = 479
    I16x8ExtMulLowI8x16U = 480
    I16x8ExtMulHighI8x16U = 481
    I32x4ExtMulLowI16x8S = 482
    I32x4ExtMulHighI16x8S = 483
    I32x4ExtMulLowI16x8U = 484
    I32x4ExtMulHighI16x8U = 485
    I64x2ExtMulLowI32x4S = 486
    I64x2ExtMulHighI32x4S = 487
    I64x2ExtMulLowI32x4U = 488
    I64x2ExtMulHighI32x4U = 489
    V128Load8x8S = 490
    V128Load8x8U = 491
    V128Load16x4S = 492
    V128Load16x4U = 493
    V128Load32x2S = 494
    V128Load32x2U = 495
    V128Load8Lane = 496
    V128Load16Lane = 497
    V128Load32Lane = 498
    V128Load64Lane = 499
    V128Store8Lane = 500
    V128Store16Lane = 501
    V128Store32Lane = 502
    V128Store64Lane = 503
    I8x16RoundingAverageU = 504
    I16x8RoundingAverageU = 505
    I16x8Q15MulrSatS = 506
    F32x4DemoteF64x2Zero = 507
    F64x2PromoteLowF32x4 = 508
    F64x2ConvertLowI32x4S = 509
    F64x2ConvertLowI32x4U = 510
    I32x4TruncSatF64x2SZero = 511
    I32x4TruncSatF64x2UZero = 512
end

mutable struct wasi_config_t end

mutable struct wasi_env_t end

mutable struct wasmer_cpu_features_t end

mutable struct wasmer_features_t end

mutable struct wasmer_metering_t end

mutable struct wasmer_middleware_t end

mutable struct wasmer_named_extern_t end

mutable struct wasmer_target_t end

mutable struct wasmer_triple_t end

mutable struct wasmer_named_extern_vec_t
    size::Csize_t
    data::Ptr{Ptr{wasmer_named_extern_t}}
end

# typedef uint64_t ( * wasmer_metering_cost_function_t ) ( enum wasmer_parser_operator_t wasm_operator )
const wasmer_metering_cost_function_t = Ptr{Cvoid}

function wasi_config_arg(config, arg)
    ccall((:wasi_config_arg, libwasmer), Cvoid, (Ptr{wasi_config_t}, Cstring), config, arg)
end

function wasi_config_capture_stderr(config)
    ccall((:wasi_config_capture_stderr, libwasmer), Cvoid, (Ptr{wasi_config_t},), config)
end

function wasi_config_capture_stdout(config)
    ccall((:wasi_config_capture_stdout, libwasmer), Cvoid, (Ptr{wasi_config_t},), config)
end

function wasi_config_env(config, key, value)
    ccall((:wasi_config_env, libwasmer), Cvoid, (Ptr{wasi_config_t}, Cstring, Cstring), config, key, value)
end

function wasi_config_inherit_stderr(config)
    ccall((:wasi_config_inherit_stderr, libwasmer), Cvoid, (Ptr{wasi_config_t},), config)
end

function wasi_config_inherit_stdin(config)
    ccall((:wasi_config_inherit_stdin, libwasmer), Cvoid, (Ptr{wasi_config_t},), config)
end

function wasi_config_inherit_stdout(config)
    ccall((:wasi_config_inherit_stdout, libwasmer), Cvoid, (Ptr{wasi_config_t},), config)
end

function wasi_config_mapdir(config, alias, dir)
    ccall((:wasi_config_mapdir, libwasmer), Bool, (Ptr{wasi_config_t}, Cstring, Cstring), config, alias, dir)
end

function wasi_config_new(program_name)
    ccall((:wasi_config_new, libwasmer), Ptr{wasi_config_t}, (Cstring,), program_name)
end

function wasi_config_preopen_dir(config, dir)
    ccall((:wasi_config_preopen_dir, libwasmer), Bool, (Ptr{wasi_config_t}, Cstring), config, dir)
end

function wasi_env_delete(_state)
    ccall((:wasi_env_delete, libwasmer), Cvoid, (Ptr{wasi_env_t},), _state)
end

function wasi_env_new(config)
    ccall((:wasi_env_new, libwasmer), Ptr{wasi_env_t}, (Ptr{wasi_config_t},), config)
end

function wasi_env_read_stderr(env, buffer, buffer_len)
    ccall((:wasi_env_read_stderr, libwasmer), intptr_t, (Ptr{wasi_env_t}, Cstring, Csize_t), env, buffer, buffer_len)
end

function wasi_env_read_stdout(env, buffer, buffer_len)
    ccall((:wasi_env_read_stdout, libwasmer), intptr_t, (Ptr{wasi_env_t}, Cstring, Csize_t), env, buffer, buffer_len)
end

function wasi_get_imports(store, _module, wasi_env, imports)
    ccall((:wasi_get_imports, libwasmer), Bool, (Ptr{wasm_store_t}, Ptr{wasm_module_t}, Ptr{wasi_env_t}, Ptr{wasm_extern_vec_t}), store, _module, wasi_env, imports)
end

function wasi_get_start_function(instance)
    ccall((:wasi_get_start_function, libwasmer), Ptr{wasm_func_t}, (Ptr{wasm_instance_t},), instance)
end

function wasi_get_unordered_imports(store, _module, wasi_env, imports)
    ccall((:wasi_get_unordered_imports, libwasmer), Bool, (Ptr{wasm_store_t}, Ptr{wasm_module_t}, Ptr{wasi_env_t}, Ptr{wasmer_named_extern_vec_t}), store, _module, wasi_env, imports)
end

function wasi_get_wasi_version(_module)
    ccall((:wasi_get_wasi_version, libwasmer), wasi_version_t, (Ptr{wasm_module_t},), _module)
end

function wasm_config_canonicalize_nans(config, enable)
    ccall((:wasm_config_canonicalize_nans, libwasmer), Cvoid, (Ptr{wasm_config_t}, Bool), config, enable)
end

function wasm_config_push_middleware(config, middleware)
    ccall((:wasm_config_push_middleware, libwasmer), Cvoid, (Ptr{wasm_config_t}, Ptr{wasmer_middleware_t}), config, middleware)
end

function wasm_config_set_compiler(config, compiler)
    ccall((:wasm_config_set_compiler, libwasmer), Cvoid, (Ptr{wasm_config_t}, wasmer_compiler_t), config, compiler)
end

function wasm_config_set_engine(config, engine)
    ccall((:wasm_config_set_engine, libwasmer), Cvoid, (Ptr{wasm_config_t}, wasmer_engine_t), config, engine)
end

function wasm_config_set_features(config, features)
    ccall((:wasm_config_set_features, libwasmer), Cvoid, (Ptr{wasm_config_t}, Ptr{wasmer_features_t}), config, features)
end

function wasm_config_set_target(config, target)
    ccall((:wasm_config_set_target, libwasmer), Cvoid, (Ptr{wasm_config_t}, Ptr{wasmer_target_t}), config, target)
end

function wasmer_cpu_features_add(cpu_features, feature)
    ccall((:wasmer_cpu_features_add, libwasmer), Bool, (Ptr{wasmer_cpu_features_t}, Ptr{wasm_name_t}), cpu_features, feature)
end

function wasmer_cpu_features_delete(_cpu_features)
    ccall((:wasmer_cpu_features_delete, libwasmer), Cvoid, (Ptr{wasmer_cpu_features_t},), _cpu_features)
end

function wasmer_cpu_features_new()
    ccall((:wasmer_cpu_features_new, libwasmer), Ptr{wasmer_cpu_features_t}, ())
end

function wasmer_features_bulk_memory(features, enable)
    ccall((:wasmer_features_bulk_memory, libwasmer), Bool, (Ptr{wasmer_features_t}, Bool), features, enable)
end

function wasmer_features_delete(_features)
    ccall((:wasmer_features_delete, libwasmer), Cvoid, (Ptr{wasmer_features_t},), _features)
end

function wasmer_features_memory64(features, enable)
    ccall((:wasmer_features_memory64, libwasmer), Bool, (Ptr{wasmer_features_t}, Bool), features, enable)
end

function wasmer_features_module_linking(features, enable)
    ccall((:wasmer_features_module_linking, libwasmer), Bool, (Ptr{wasmer_features_t}, Bool), features, enable)
end

function wasmer_features_multi_memory(features, enable)
    ccall((:wasmer_features_multi_memory, libwasmer), Bool, (Ptr{wasmer_features_t}, Bool), features, enable)
end

function wasmer_features_multi_value(features, enable)
    ccall((:wasmer_features_multi_value, libwasmer), Bool, (Ptr{wasmer_features_t}, Bool), features, enable)
end

function wasmer_features_new()
    ccall((:wasmer_features_new, libwasmer), Ptr{wasmer_features_t}, ())
end

function wasmer_features_reference_types(features, enable)
    ccall((:wasmer_features_reference_types, libwasmer), Bool, (Ptr{wasmer_features_t}, Bool), features, enable)
end

function wasmer_features_simd(features, enable)
    ccall((:wasmer_features_simd, libwasmer), Bool, (Ptr{wasmer_features_t}, Bool), features, enable)
end

function wasmer_features_tail_call(features, enable)
    ccall((:wasmer_features_tail_call, libwasmer), Bool, (Ptr{wasmer_features_t}, Bool), features, enable)
end

function wasmer_features_threads(features, enable)
    ccall((:wasmer_features_threads, libwasmer), Bool, (Ptr{wasmer_features_t}, Bool), features, enable)
end

function wasmer_is_compiler_available(compiler)
    ccall((:wasmer_is_compiler_available, libwasmer), Bool, (wasmer_compiler_t,), compiler)
end

function wasmer_is_engine_available(engine)
    ccall((:wasmer_is_engine_available, libwasmer), Bool, (wasmer_engine_t,), engine)
end

function wasmer_is_headless()
    ccall((:wasmer_is_headless, libwasmer), Bool, ())
end

function wasmer_last_error_length()
    ccall((:wasmer_last_error_length, libwasmer), Cint, ())
end

function wasmer_last_error_message(buffer, length)
    ccall((:wasmer_last_error_message, libwasmer), Cint, (Cstring, Cint), buffer, length)
end

function wasmer_metering_as_middleware(metering)
    ccall((:wasmer_metering_as_middleware, libwasmer), Ptr{wasmer_middleware_t}, (Ptr{wasmer_metering_t},), metering)
end

function wasmer_metering_delete(_metering)
    ccall((:wasmer_metering_delete, libwasmer), Cvoid, (Ptr{wasmer_metering_t},), _metering)
end

function wasmer_metering_get_remaining_points(instance)
    ccall((:wasmer_metering_get_remaining_points, libwasmer), UInt64, (Ptr{wasm_instance_t},), instance)
end

function wasmer_metering_new(initial_limit, cost_function)
    ccall((:wasmer_metering_new, libwasmer), Ptr{wasmer_metering_t}, (UInt64, wasmer_metering_cost_function_t), initial_limit, cost_function)
end

function wasmer_metering_points_are_exhausted(instance)
    ccall((:wasmer_metering_points_are_exhausted, libwasmer), Bool, (Ptr{wasm_instance_t},), instance)
end

function wasmer_metering_set_remaining_points(instance, new_limit)
    ccall((:wasmer_metering_set_remaining_points, libwasmer), Cvoid, (Ptr{wasm_instance_t}, UInt64), instance, new_limit)
end

function wasmer_module_name(_module, out)
    ccall((:wasmer_module_name, libwasmer), Cvoid, (Ptr{wasm_module_t}, Ptr{wasm_name_t}), _module, out)
end

function wasmer_module_set_name(_module, name)
    ccall((:wasmer_module_set_name, libwasmer), Bool, (Ptr{wasm_module_t}, Ptr{wasm_name_t}), _module, name)
end

function wasmer_named_extern_module(named_extern)
    ccall((:wasmer_named_extern_module, libwasmer), Ptr{wasm_name_t}, (Ptr{wasmer_named_extern_t},), named_extern)
end

function wasmer_named_extern_name(named_extern)
    ccall((:wasmer_named_extern_name, libwasmer), Ptr{wasm_name_t}, (Ptr{wasmer_named_extern_t},), named_extern)
end

function wasmer_named_extern_unwrap(named_extern)
    ccall((:wasmer_named_extern_unwrap, libwasmer), Ptr{wasm_extern_t}, (Ptr{wasmer_named_extern_t},), named_extern)
end

function wasmer_named_extern_vec_copy(out_ptr, in_ptr)
    ccall((:wasmer_named_extern_vec_copy, libwasmer), Cvoid, (Ptr{wasmer_named_extern_vec_t}, Ptr{wasmer_named_extern_vec_t}), out_ptr, in_ptr)
end

function wasmer_named_extern_vec_delete(ptr)
    ccall((:wasmer_named_extern_vec_delete, libwasmer), Cvoid, (Ptr{wasmer_named_extern_vec_t},), ptr)
end

function wasmer_named_extern_vec_new(out, length, init)
    ccall((:wasmer_named_extern_vec_new, libwasmer), Cvoid, (Ptr{wasmer_named_extern_vec_t}, Csize_t, Ptr{Ptr{wasmer_named_extern_t}}), out, length, init)
end

function wasmer_named_extern_vec_new_empty(out)
    ccall((:wasmer_named_extern_vec_new_empty, libwasmer), Cvoid, (Ptr{wasmer_named_extern_vec_t},), out)
end

function wasmer_named_extern_vec_new_uninitialized(out, length)
    ccall((:wasmer_named_extern_vec_new_uninitialized, libwasmer), Cvoid, (Ptr{wasmer_named_extern_vec_t}, Csize_t), out, length)
end

function wasmer_target_delete(_target)
    ccall((:wasmer_target_delete, libwasmer), Cvoid, (Ptr{wasmer_target_t},), _target)
end

function wasmer_target_new(triple, cpu_features)
    ccall((:wasmer_target_new, libwasmer), Ptr{wasmer_target_t}, (Ptr{wasmer_triple_t}, Ptr{wasmer_cpu_features_t}), triple, cpu_features)
end

function wasmer_triple_delete(_triple)
    ccall((:wasmer_triple_delete, libwasmer), Cvoid, (Ptr{wasmer_triple_t},), _triple)
end

function wasmer_triple_new(triple)
    ccall((:wasmer_triple_new, libwasmer), Ptr{wasmer_triple_t}, (Ptr{wasm_name_t},), triple)
end

function wasmer_triple_new_from_host()
    ccall((:wasmer_triple_new_from_host, libwasmer), Ptr{wasmer_triple_t}, ())
end

function wasmer_version()
    ccall((:wasmer_version, libwasmer), Cstring, ())
end

function wasmer_version_major()
    ccall((:wasmer_version_major, libwasmer), UInt8, ())
end

function wasmer_version_minor()
    ccall((:wasmer_version_minor, libwasmer), UInt8, ())
end

function wasmer_version_patch()
    ccall((:wasmer_version_patch, libwasmer), UInt8, ())
end

function wasmer_version_pre()
    ccall((:wasmer_version_pre, libwasmer), Cstring, ())
end

function wat2wasm(wat, out)
    ccall((:wat2wasm, libwasmer), Cvoid, (Ptr{wasm_byte_vec_t}, Ptr{wasm_byte_vec_t}), wat, out)
end

const WASMER_VERSION = "2.1.1"

const WASMER_VERSION_MAJOR = 2

const WASMER_VERSION_MINOR = 1

const WASMER_VERSION_PATCH = 1

const WASMER_VERSION_PRE = ""

const wasm_name = wasm_byte_vec_t

const wasm_name_new = wasm_byte_vec_new

const wasm_name_new_empty = wasm_byte_vec_new_empty

const wasm_name_new_new_uninitialized = wasm_byte_vec_new_uninitialized

const wasm_name_copy = wasm_byte_vec_copy

const wasm_name_delete = wasm_byte_vec_delete

const WASM_EMPTY_VEC = nothing

# Skipping MacroDefinition: WASM_INIT_VAL { . kind = WASM_ANYREF , . of = { . ref = NULL } }

# exports
const PREFIXES = ["libwasm", "wasm_", "WASM_", "wasi_"]
for name in names(@__MODULE__; all=true), prefix in PREFIXES
    if startswith(string(name), prefix)
        @eval export $name
    end
end

end # module


text:
using SimpleDirectMediaLayer
const SDL = SimpleDirectMediaLayer

mutable struct Window           # Mutable so we can register a finalizer
  win
  renderer
  framebuffer
  pixels
  xsize
  ysize
end

function SDL_create(xsize, ysize)
  win = SDL.CreateWindow("CHIP8.jl",
                         Int32(100),
                         Int32(100),
                         Int32(xsize),
                         Int32(ysize),
                         UInt32(SDL.WINDOW_SHOWN))

  renderer = SDL.CreateRenderer(win,
                                Int32(-1),
                                UInt32(SDL.RENDERER_ACCELERATED | SDL.RENDERER_PRESENTVSYNC))

  framebuffer = framebuffer = SDL.CreateTexture(renderer,
                                                SDL.PIXELFORMAT_ARGB8888,
                                                Int32(SDL.TEXTUREACCESS_STREAMING),
                                                Int32(xsize),
                                                Int32(ysize))

  pixels = Matrix{UInt32}(undef, xsize, ysize)

  w = Window(win, renderer, framebuffer, pixels, xsize, ysize)

  # Close window if no references are left. Otherwise nasty stuff happens
  finalizer(destroy, w)

  return w
end

"""
`_render_pixels(w::Window)`

Renders the content of the pixel buffer in w to the screen
"""
function _render_pixels(w::Window)
  SDL.UpdateTexture(w.framebuffer,
                    C_NULL,
                    w.pixels,
                    Int32(w.xsize*sizeof(eltype(w.pixels))))

  SDL.RenderClear(w.renderer)
  SDL.RenderCopy(w.renderer, w.framebuffer , C_NULL, C_NULL)
  SDL.RenderPresent(w.renderer)
end

"""
`render_chip8_disp_buffer(ch8::Chip8, w::Window; scale::Integer)`

Renders the content of the display buffer of ch8 to the window w

ch8::Chip8     ... The chip8 system to render from

w::Window      ... The window to render to

scale::Integer ... One pixel of the diplay buffer should be how many pixels
                   on the screen (if not specified is calculated using display
                   buffer and screen size)
"""
function render_chip8_disp_buffer(ch8::Chip8, w::Window; scale::Integer = size(w.pixels, 1)÷size(ch8.disp, 1))
  white = 0xFFFFFF
  black = 0x000000

  for x in 0:size(ch8.disp,1)-1
    for y in 0:size(ch8.disp,2)-1
      w.pixels[x*scale+1:(x+1)*scale, y*scale+1:(y+1)*scale] .= ch8.disp[x+1, y+1] ? white : black
    end
  end

  _render_pixels(w)
end

destroy(w::Window) = SDL.DestroyWindow(w.win)

ext: jl


text:
import Ipopt, Hyperopt
using Nonconvex, LinearAlgebra, Test

f(x::AbstractVector) = sqrt(x[2])
g(x::AbstractVector, a, b) = (a*x[1] + b)^3 - x[2]

alg = HyperoptAlg(IpoptAlg())

@testset "Sampler - $spl_name" for (spl_name, spl) in [
    ("RandomSampler", RandomSampler()),
    ("Hyperband", Hyperband(R=100, η=3, inner=RandomSampler())),
    ("LHSampler", LHSampler()),
    ("CLHSampler", CLHSampler()),
    ("GPSampler", GPSampler()),
]
    if spl_name == "Hyperband"
        options = HyperoptOptions(
            sub_options = max_iter -> IpoptOptions(first_order = true, max_iter = max_iter),
            sampler = spl,
        )
    else
        options = HyperoptOptions(
            sub_options = IpoptOptions(first_order = true),
            sampler = spl,
        )
    end
    m = Model(f)
    addvar!(m, [0.0, 0.0], [10.0, 10.0])
    add_ineq_constraint!(m, x -> g(x, 2, 0))
    add_ineq_constraint!(m, x -> g(x, -1, 1))

    r = Nonconvex.optimize(m, alg, [1.234, 2.345], options = options)
    @test abs(r.minimum - sqrt(8/27)) < 1e-6
    @test norm(r.minimizer - [1/3, 8/27]) < 1e-6
end


text:
"""
    variable_domain(var::JuMP.VariableRef)

Computes the valid domain of a given JuMP variable taking into account bounds
and the varaible's implicit bounds (e.g. binary).
"""
function variable_domain(var::JuMP.VariableRef)

  lb = -Inf
  (JuMP.has_lower_bound(var)) && (lb = JuMP.lower_bound(var))
  (JuMP.is_binary(var)) && (lb = max(lb, 0.0))

  ub = Inf
  (JuMP.has_upper_bound(var)) && (ub = JuMP.upper_bound(var))
  (JuMP.is_binary(var)) && (ub = min(ub, 1.0))

  return (lower_bound=lb, upper_bound=ub)

end

"""
    relaxation_bilinear(m::JuMP.Model, xy::JuMP.VariableRef, x::JuMP.VariableRef, y::JuMP.VariableRef)

general relaxation of binlinear term (McCormick), which can be used to obtain specific variants in partiuclar cases of variables (like binary)
```
z >= JuMP.lower_bound(x)*y + JuMP.lower_bound(y)*x - JuMP.lower_bound(x)*JuMP.lower_bound(y)
z >= JuMP.upper_bound(x)*y + JuMP.upper_bound(y)*x - JuMP.upper_bound(x)*JuMP.upper_bound(y)
z <= JuMP.lower_bound(x)*y + JuMP.upper_bound(y)*x - JuMP.lower_bound(x)*JuMP.upper_bound(y)
z <= JuMP.upper_bound(x)*y + JuMP.lower_bound(y)*x - JuMP.upper_bound(x)*JuMP.lower_bound(y)
```
"""
function relaxation_bilinear(m::JuMP.Model, xy::JuMP.VariableRef, x::JuMP.VariableRef, y::JuMP.VariableRef)
    lb_x, ub_x = variable_domain(x)
    lb_y, ub_y = variable_domain(y)

    (isapprox(lb_x, 0, atol = 1E-6)) && (lb_x = 0)
    (isapprox(lb_y, 0, atol = 1E-6)) && (lb_y = 0)
    (isapprox(lb_x, 1, atol = 1E-6)) && (lb_x = 1)
    (isapprox(lb_y, 1, atol = 1E-6)) && (lb_y = 1)

    (isapprox(ub_x, 0, atol = 1E-6)) && (ub_x = 0)
    (isapprox(ub_y, 0, atol = 1E-6)) && (ub_y = 0)
    (isapprox(ub_x, 1, atol = 1E-6)) && (ub_x = 1)
    (isapprox(ub_y, 1, atol = 1E-6)) && (ub_y = 1)

    if (lb_x == 0) && (ub_x == 1) && ((lb_y != 0) || (ub_y != 1))

      JuMP.@constraint(m, xy >= lb_y*x)
      JuMP.@constraint(m, xy >= y + ub_y*x - ub_y)
      JuMP.@constraint(m, xy <= ub_y*x)
      JuMP.@constraint(m, xy <= y + lb_y*x - lb_y)

    elseif (lb_y == 0) && (ub_y == 1) && ((lb_x != 0) || (ub_x != 1))

      JuMP.@constraint(m, xy >= lb_x*y)
      JuMP.@constraint(m, xy >= ub_x*y + x - ub_x)
      JuMP.@constraint(m, xy <= lb_x*y + x - lb_x)
      JuMP.@constraint(m, xy <= ub_x*y)

    elseif (lb_x == 0) && (ub_x == 1) && (lb_y == 0) && (ub_y == 1)

      JuMP.@constraint(m, xy <= x)
      JuMP.@constraint(m, xy <= y)
      JuMP.@constraint(m, xy >= x + y - 1)

    else
      JuMP.@constraint(m, xy >= lb_x*y + lb_y*x - lb_x*lb_y)
      JuMP.@constraint(m, xy >= ub_x*y + ub_y*x - ub_x*ub_y)
      JuMP.@constraint(m, xy <= lb_x*y + ub_y*x - lb_x*ub_y)
      JuMP.@constraint(m, xy <= ub_x*y + lb_y*x - ub_x*lb_y)

    end

    return m
  end


text:
struct FullOrbitPath{T<:Number}
    dt::Union{T,Vector{T}}
    r::Vector{T}
    phi::Vector{T}
    z::Vector{T}
    vr::Vector{T}
    vphi::Vector{T}
    vz::Vector{T}
end

mutable struct FullOrbitStatus
    errcode::Int
end
FullOrbitStatus() = FullOrbitStatus(1)

function FullOrbitPath(T::DataType=Float64)
    FullOrbitPath(zero(T),T[],T[],T[],T[],T[],T[])
end

Base.length(op::FullOrbitPath) = length(op.r)

function borispush(M, m, q, v, u, dt)
        x = u[1]
        y = u[2]
        z = u[3]

        q_m_half_dt = (0.5*dt*q*e0/m)

        B, E = fields(M,x,y,z)

        t = q_m_half_dt*B

        half_acc = q_m_half_dt*E
        v_minus = v .+ half_acc
        v_minus_x_t = cross(v_minus,t)
        v_prime = v_minus + v_minus_x_t

        s = (2.0/(1+dot(t,t)))*t
        v_prime_x_s = cross(v_prime,s)
        v_plus = v_minus + v_prime_x_s

        v = v_plus .+ half_acc

        return v
end

"""
    integrate(M, pc::Particle; dt=0.01, tmax=1000) -> FullOrbitPath, stat

Integrate the particle up to tmax normalized to the cyclotron_period with time step dt is a fraction of a cyclotron period. Default tmax is 1000
"""
function integrate(M::AbstractEquilibrium, pc::Particle; dt= 0.01, tmax = 1000)

    if lorentz_factor(pc) > 1.05
        @warn "Relativistic Full Orbit has not been implemented: Lorentz factor > 1.05"
    end

    T_c = cyclotron_period(M,pc)
    dt_sec = dt*T_c
    tmax_sec = tmax*T_c
    t = 0:dt:tmax

    nstep = length(t)
    x_arr = zeros(nstep)
    y_arr = zeros(nstep)
    z_arr = zeros(nstep)
    vx_arr = zeros(nstep+1)
    vy_arr = zeros(nstep+1)
    vz_arr = zeros(nstep+1)

    sp, cp = sincos(pc.phi)
    u = SVector{3}([pc.r*cp,pc.r*sp,pc.z])
    v = SVector{3}([pc.vr*cp - pc.vt*sp,pc.vr*sp + pc.vt*cp,pc.vz])
    x_arr[1] = u[1]
    y_arr[1] = u[2]
    z_arr[1] = u[3]
    v = borispush(M,pc.m,pc.q,v,u,-0.5*dt_sec)
    vx_arr[1] = v[1]
    vy_arr[1] = v[2]
    vz_arr[1] = v[3]
    for i=2:nstep
        v = borispush(M,pc.m,pc.q,v,u,dt_sec)
        x_arr[i] = x_arr[i-1] + v[1]*dt_sec
        y_arr[i] = y_arr[i-1] + v[2]*dt_sec
        z_arr[i] = z_arr[i-1] + v[3]*dt_sec
        u  = SVector{3}(x_arr[i],y_arr[i],z_arr[i])
        vx_arr[i] = v[1]
        vy_arr[i] = v[2]
        vz_arr[i] = v[3]
    end
    v = borispush(M,pc.m,pc.q,v,u,0.5*dt_sec)
    vx_arr[end] = v[1]
    vy_arr[end] = v[2]
    vz_arr[end] = v[3]

    r_arr = sqrt.(x_arr.^2 .+ y_arr.^2)
    phi_arr = atan.(y_arr,x_arr)
    sp = sin.(phi_arr)
    cp = cos.(phi_arr)
    #velocity is 0.5 step behind position
    vr_arr = [0.5*(vx_arr[i]+vx_arr[i+1])*cp[i] .+ 0.5*(vy_arr[i] + vy_arr[i+1])*sp[i] for i=1:nstep]
    vphi_arr = [-0.5*(vx_arr[i]+vx_arr[i+1])*sp[i] .+ 0.5*(vy_arr[i] + vy_arr[i+1])*cp[i] for i=1:nstep]
    vz_arr = [0.5(vz_arr[i] + vz_arr[i+1]) for i=1:nstep]

    return FullOrbitPath(dt_sec, r_arr, phi_arr,z_arr,vr_arr,vphi_arr,vz_arr), FullOrbitStatus(0)
end

"""
    get_full_orbit(M, pc::Particle; dt=T_c/100, tmax=1000*T_c) -> FullOrbitPath, stat

Integrate the full orbit up to tmax (μs) with time step dt (μs). Default tmax is 1000*cyclotron_period.
"""
function get_full_orbit(M::AbstractEquilibrium, pc::Particle; kwargs...)
    return integrate(M, pc; kwargs...)
end

"""
    get_full_orbit(M, gcp::GCParticle; dt=T_c/100, tmax=1000*T_c) -> FullOrbitPath, stat

Integrate the full orbit up to tmax (μs) with time step dt (μs). Default tmax is 1000*cyclotron_period.
"""
function get_full_orbit(M::AbstractEquilibrium, gcp::GCParticle; gamma = 0.0, verbose=false, kwargs...)

    v = velocity(M, gcp, gamma)

    r_gyro = gyro_step(M, gcp, gamma)

    verbose && println("|r_gyro|: $(norm(r_gyro))")

    r_p = SVector{3}(gcp.r, zero(gcp.r), gcp.z) .- r_gyro

    r = norm(r_p[1:2])
    phi = atan(r_p[2],r_p[1])
    z = r_p[3]
    sp,cp = sincos(phi)
    vr = v[1]*cp + v[2]*sp
    vphi = -v[1]*sp + v[2]*cp
    vz = v[3]

    pc = Particle(r,phi,z,vr,vphi,vz,gcp.m,gcp.q)

    return integrate(M, pc::Particle; kwargs...)
end

function hits_wall(M, pc::Particle, wall; dt=1e-3, tmax=100)

    dt_sec = dt*1e-6
    t = 0:dt:tmax
    nstep = length(t)

    sp,cp = sincos(pc.phi)
    u = SVector{3}([pc.r*cp,pc.r*sp,z])
    v = SVector{3}([pc.vr*cp - pc.vt*sp, pc.vr*sp + pc.vt*cp,pc.vz])
    hit = false
    v = borispush(M,pc.m,pc.q,v,u,-0.5*dt_sec)
    T = 0.0
    for i=1:nstep
        v = borispush(M,pc.m,pc.q,v,u,dt_sec)
        u = u .+ v*dt_sec
        rr = sqrt(u[1]^2 + u[2]^2)
        zz = u[3]
        if ~in_vessel(wall,(rr,zz))
            hit = true
            break
        end
        T += dt_sec
    end

    return hit, T
end


text:
###############################################################
# structs used by the C side
###############################################################

# /* Definition of constants for identification of constraint types. */
@enum ConstraintType begin
    CMGR_CT_MIN_ROUTES        = 101
    CMGR_CT_NODE_DEGREE       = 102  # /* Degree = 2 for each customer. */
    CMGR_CT_CAP               = 103  # /* Capacity constraint. */
    CMGR_CT_GENCAP            = 104  # /* Generalized capacity constraint. */
    # CMGR_CT_FCI               = 104  # /* For public version. */ # duplicate
    CMGR_CT_TWOMATCHING       = 105
    CMGR_CT_COMB              = 106
    CMGR_CT_STR_COMB          = 107  # /* Strengthened comb. */
    CMGR_CT_HYPOTOUR          = 108
    CMGR_CT_EXT_HYPOTOUR      = 109
    CMGR_CT_MSTAR             = 110  # /* Homogeneous multistar. */
    CMGR_CT_WMSTAR            = 111  # /* Weak multistar. */
    CMGR_CT_DJCUT             = 112  # /* Disjunctive cut. */
    CMGR_CT_GOMORY            = 113  # /* By variable numbers */
    CMGR_CT_TWOEDGES_HYPOTOUR = 114  # /* 2EH inequality */
    CMGR_BT_CLIQUE_DOWN       = 201  # /* x(S:S) <= RHS */
    CMGR_BT_CLIQUE_UP         = 202  # /* x(S:S) >= RHS */
    CMGR_BT_STAR_DOWN         = 301  # /* x(i:F) <=RHS */
    CMGR_BT_STAR_UP           = 302  # /* x(i:F) >=RHS */
    CMGR_CT_SLB               = 401  # /* x(F) >= RHS. Simple lower bound */
end

mutable struct CnstrRecord
    Ctype       :: Cint
    Key         :: Cint
    IntListSize :: Cint
    IntList     :: Ptr{Cint}
    ExtListSize :: Cint
    ExtList     :: Ptr{Cint}
    CListSize   :: Cint
    CList       :: Ptr{Cint}
    CoeffList   :: Ptr{Cdouble}
    A           :: Cint
    B           :: Cint
    L           :: Cint
    RHS         :: Cdouble
    BranchLevel :: Cint
    GlobalNr    :: Cint
end

CnstrPointer = Ptr{CnstrRecord}
CnstrPointerList = Ptr{CnstrPointer}

mutable struct CnstrMgrRecord
    CPL         :: CnstrPointerList
    Dim         :: Cint
    Size        :: Cint
end

CnstrMgrPointer = Ptr{CnstrMgrRecord}

###############################################################
# structs used by the Julia side
###############################################################

mutable struct CutRecord
    Ctype       :: ConstraintType
    Key         :: Int
    IntList     :: Vector{Int}
    ExtList     :: Vector{Int}
    CList       :: Vector{Int}
    CoeffList   :: Vector{Float64}
    A           :: Int
    B           :: Int
    L           :: Int
    RHS         :: Float64
    BranchLevel :: Int
    GlobalNr    :: Int

    function CutRecord(cr::CnstrRecord)
        # CVRPSEP.c uses 1-based indexing,
        # with 0 position filled with an unused value
        # hence, all Size + 1
        # then, [2:end]
        int_list = Int[]
        ext_list = Int[]
        c_list = Int[]
        coeff_list = Float64[]

        if cr.IntList != C_NULL && cr.IntListSize > 0
            c_int_list = unsafe_wrap(Array, cr.IntList, cr.IntListSize + 1)
            int_list = c_int_list[2:end]
        end

        if cr.ExtList != C_NULL && cr.ExtListSize > 0
            c_ext_list = unsafe_wrap(Array, cr.ExtList, cr.ExtListSize + 1)
            ext_list = c_ext_list[2:end]
        end

        if cr.CList != C_NULL && cr.CListSize > 0
            c_list = unsafe_wrap(Array, cr.CList, cr.CListSize + 1)[2:end]
        end

        ctype = ConstraintType(Int(cr.Ctype))
        if cr.CoeffList != C_NULL && cr.IntListSize > 0 #&& ctype == CMGR_CT_HYPOTOUR
            coeff_list = unsafe_wrap(Array, cr.CoeffList, cr.IntListSize + 1)[2:end]
            @show typeof(coeff_list)
        end

        new(
            ctype,
            cr.Key,
            int_list,
            ext_list,
            c_list,
            coeff_list,
            cr.A,
            cr.B,
            cr.L,
            cr.RHS,
            cr.BranchLevel,
            cr.GlobalNr
        )
    end
end

function convert_CMP(cmp::CnstrMgrPointer)
    cmr = unsafe_load(cmp)
    cpl = unsafe_wrap(Array, cmr.CPL, cmr.Size)

    ret = Vector{CutRecord}(undef, length(cpl))
    for i in 1:length(cpl)
        cr = unsafe_load(cpl[i])
        ret[i] = CutRecord(cr)
    end
    return ret
end

mutable struct CutManager
    new_cuts::Vector{CutRecord}
    is_integer_and_feasible::Bool
    violation::Float64
    cmp::CnstrMgrPointer
    function CutManager()
        new(CutRecord[], false, Inf, init_CMP())
    end
end


text:
## AbstractTrees interface

AbstractTrees.children(node::Node) = node.foldchildren ? typeof(node)[] : node.children

AbstractTrees.printnode(io::IO, node::Node) = print(io, node.foldchildren ? "+ " : "  ", node.data)


text:
using LinearAlgebra: tr, mul!, dot, Diagonal
using ComponentArrays: ComponentVector
using Distributions: Normal
using NQCDynamics: RingPolymers
using NQCModels: nstates
using NQCDistributions: PureState, Diabatic

"""
    NRPMD{T} <: DynamicsMethods.Method

Nonadiabatic ring polymer molecular dynamics
Uses Meyer-Miller-Stock-Thoss mapping variables for electronic degrees of freedom and
ring polymer formalism for nuclear degrees of freedom.

```jldoctest
RingPolymerSimulation{NRPMD}(Atoms(:H), DoubleWell(), 10)

# output

RingPolymerSimulation{NRPMD{Float64}}:

  Atoms{Float64}([:H], [1], [1837.4715941070515])

  DoubleWell{Int64, Int64, Int64, Int64}
  mass: Int64 1
  ω: Int64 1
  γ: Int64 1
  Δ: Int64 1

  with 10 beads.
```
"""
struct NRPMD{T} <: DynamicsMethods.Method
    γ::T
    temp_q::Vector{T}
    temp_p::Vector{T}
    function NRPMD{T}(n_states::Integer, γ) where {T}
        new{T}(γ, zeros(n_states), zeros(n_states))
    end
end

function NQCDynamics.RingPolymerSimulation{NRPMD}(atoms::Atoms{T}, model::Model, n_beads::Integer; γ=0.5, kwargs...) where {T}
    NQCDynamics.RingPolymerSimulation(atoms, model, NRPMD{T}(NQCModels.nstates(model), γ), n_beads; kwargs...)
end

function DynamicsMethods.DynamicsVariables(sim::RingPolymerSimulation{<:NRPMD}, v, r, electronic::PureState{Diabatic})
    F = NQCModels.nstates(sim)
    n_beads = length(sim.beads)

    θ = rand(F, n_beads) .* 2π
    qmap = cos.(θ)
    pmap = sin.(θ)
    for i=1:F
        if i == electronic.state
            qmap[i, :] .*= sqrt(2 + 2sim.method.γ)
            pmap[i, :] .*= sqrt(2 + 2sim.method.γ)
        else
            qmap[i, :] .*= sqrt(2sim.method.γ)
            pmap[i, :] .*= sqrt(2sim.method.γ)
        end
    end

    return ComponentVector(v=v, r=r, pmap=pmap, qmap=qmap)
end

function DynamicsMethods.motion!(du, u, sim::RingPolymerSimulation{<:NRPMD}, t)
    dr = DynamicsUtils.get_positions(du)
    dv = DynamicsUtils.get_velocities(du)
    r = DynamicsUtils.get_positions(u)
    v = DynamicsUtils.get_velocities(u)
    DynamicsUtils.velocity!(dr, v, r, sim, t)
    acceleration!(dv, u, sim)
    set_mapping_force!(du, u, sim)
end

function acceleration!(dv, u, sim::RingPolymerSimulation{<:NRPMD})

    Calculators.evaluate_derivative!(sim.calculator, DynamicsUtils.get_positions(u))
    for I in CartesianIndices(dv)
        qmap = get_mapping_positions(u, I[3])
        pmap = get_mapping_momenta(u, I[3])
        D = sim.calculator.derivative[I]
        D̄ = tr(D) / nstates(sim)
        Dtraceless = D - Diagonal(fill(D̄, nstates(sim)))
        mul!(sim.method.temp_q, Dtraceless, qmap)
        mul!(sim.method.temp_p, Dtraceless, pmap)
        dv[I] = dot(qmap, sim.method.temp_q)
        dv[I] += dot(pmap, sim.method.temp_p)
        dv[I] += 2D̄
    end
    lmul!(-1/2, dv)
    DynamicsUtils.divide_by_mass!(dv, sim.atoms.masses)

    DynamicsUtils.apply_interbead_coupling!(dv, DynamicsUtils.get_positions(u), sim)
end

function set_mapping_force!(du, u, sim::RingPolymerSimulation{<:NRPMD})

    Calculators.evaluate_potential!(sim.calculator, DynamicsUtils.get_positions(u))
    for i in range(sim.beads)
        V = sim.calculator.potential[i]
        V̄ = tr(V) / nstates(sim)
        Vtraceless = V - Diagonal(fill(V̄, nstates(sim)))
        mul!(get_mapping_positions(du, i), Vtraceless, get_mapping_momenta(u, i))
        mul!(get_mapping_momenta(du, i), Vtraceless, get_mapping_positions(u, i))
        lmul!(-1, get_mapping_momenta(du, i))
    end
end

function Estimators.diabatic_population(sim::RingPolymerSimulation{<:NRPMD}, u)
    K = NQCModels.nstates(sim)
    population = zeros(K)
    for i in 1:RingPolymers.nbeads(sim)
        qmap = get_mapping_positions(u, i)
        pmap = get_mapping_momenta(u, i)
        for j in axes(qmap, 1)
            population[j] += (qmap[j]^2 + pmap[j]^2) / 2 - sim.method.γ
        end
    end
    return population / RingPolymers.nbeads(sim)
end

function DynamicsUtils.classical_hamiltonian(sim::RingPolymerSimulation{<:NRPMD}, u)
    r = DynamicsUtils.get_positions(u)
    v = DynamicsUtils.get_velocities(u)

    spring = RingPolymers.get_spring_energy(sim.beads, sim.atoms.masses, r)
    kinetic = DynamicsUtils.classical_kinetic_energy(sim, v)

    potential = zero(eltype(u))
    Calculators.evaluate_potential!(sim.calculator, r)
    for i in range(sim.beads)
        V = sim.calculator.potential[i]
        V̄ = tr(V) / nstates(sim)
        Vtraceless = V - Diagonal(fill(V̄, nstates(sim)))
        qmap = get_mapping_positions(u, i)
        pmap = get_mapping_momenta(u, i)
        potential += 0.5 * (pmap'Vtraceless*pmap + qmap'Vtraceless*qmap) + V̄
    end

    return kinetic + spring + potential
end


text:
# We need to implement some functionality for the ApproxFun constructor to work
real(::Type{Dual{T}}) where {T} = Dual{ApproxFun.real(T)}

# Dual number support. Should there be realpart and dualpart of Space and Domain?
DualNumbers.realpart(f::Fun{S,T}) where {S,T<:Dual} = Fun(space(f),realpart(coefficients(f)))
DualNumbers.dualpart(f::Fun{S,T}) where {S,T<:Dual} = Fun(space(f),dualpart(coefficients(f)))

DualNumbers.realpart(d::Segment{<:Dual}) = Segment(realpart(leftendpoint(d)),realpart(rightendpoint(d)))

indomain(x::Number, d::Segment{<:Dual}) = in(x,realpart(d))
indomain(x::Dual, d::Segment{<:Dual}) = in(realpart(x),realpart(d))
isempty(d::Segment{<:Dual}) = isempty(realpart(d))

valsdomain_type_promote(::Type{Dual{T}},::Type{V}) where {T<:Real,V<:Real} =
    Dual{promote_type(T,V)},promote_type(T,V)
valsdomain_type_promote(::Type{Dual{T}},::Type{V}) where {T<:Complex,V<:Real} =
    Dual{promote_type(T,V)},promote_type(real(T),V)
valsdomain_type_promote(::Type{Dual{T}},::Type{Complex{V}}) where {T<:Real,V<:Real} =
    Dual{promote_type(T,V)},Complex{promote_type(T,V)}
valsdomain_type_promote(::Type{Dual{T}},::Type{Complex{V}}) where {T<:Complex,V<:Real} =
    Dual{promote_type(T,Complex{V})},Complex{promote_type(real(T),V)}

plan_chebyshevtransform!(x::Vector{T};kind::Integer=1) where {T<:Dual} =
    error("In-place variant not implemented for Dual")

plan_ichebyshevtransform!(x::Vector{T};kind::Integer=1) where {T<:Dual} =
    error("In-place variant not implemented for Dual")

function plan_chebyshevtransform(v::Vector{D};kind::Integer=1) where D<:Dual
    plan = plan_chebyshevtransform(realpart.(v);kind=kind)
    ChebyshevTransformPlan{D,kind,false,typeof(plan)}(plan)
end

function plan_ichebyshevtransform(v::Vector{D};kind::Integer=1) where D<:Dual
    plan = plan_ichebyshevtransform(realpart.(v);kind=kind)
    IChebyshevTransformPlan{D,kind,false,typeof(plan)}(plan)
end

*(P::ChebyshevTransformPlan{D,k,false},v::Vector{D}) where {k,D<:Dual} =
    dual.(P.plan*realpart.(v),P.plan*dualpart.(v))

#TODO: Hardy{false}
for (OP,TransPlan) in ((:plan_transform,:TransformPlan),(:plan_itransform,:ITransformPlan)),
        TYP in  (:Fourier,:Laurent,:SinSpace)
    @eval begin
        function $OP(sp::$TYP{D},x::Vector{T}) where {T<:Dual,D<:Domain}
            plan = $OP(sp,realpart.(x))
            $TransPlan{T,typeof(sp),false,typeof(plan)}(sp,plan)
        end
        *(P::$TransPlan{T,$TYP{D},false},x::Vector{T}) where {T<:Dual,D<:Domain} =
            dual(P.plan*realpart.(x),P.plan*dualpart.(x))
    end
end

chop!(f::Fun,d::Dual)=chop!(f,realpart(d))

function simplifycfs!(cfs::Vector{DD},tol::Float64=4E-16) where DD<:Dual
    for k=length(cfs):-2:2
        if maximum(abs,realpart.(cfs[k-1:k])) > maximum(abs,dualpart.(cfs[k-1:k]))*tol
            return resize!(cfs,k)
        end
    end
    resize!(cfs,3)
end

function dualFun(f,S,n)
    pts=points(S,n) + Dual{Float64}[dual(0.,rand(Bool)) for k=1:n]
    Fun(transform(S,map(f,pts)),S)
end

function dualcfsFun(f,S)
    T = float(eltype(domain(S)))
    if T <: Complex
        T = T.parameters[1] #get underlying real representation
    end
    r=checkpoints(S)
    f0=f(first(r))

    if isa(f0,AbstractArray) && size(S) ≠ size(f0)
        return dualcfsFun(f,Space(fill(S,size(f0))))
    end

    tol =T==Any ? 100eps() : 100eps(T)

    fr=typeof(f0)[f(x) for x=r]

    for logn = 4:20
        n=2^logn

        cf=dualFun(f,S,n)

        if maximum(abs,realpart(cf.coefficients[end-8:end]))<maximum(abs,dualpart(cf.coefficients[end-8:end]))*tol &&
                                all(k->norm(cf(r[k])-fr[k],1)<1E-4,1:length(r))
            return Fun(S,realpart(simplifycfs!(cf.coefficients,tol*length(cf))))
        end
    end
    @warn "Maximum length "*string(2^20+1)*" reached"

    Fun(f,S,2^21)
end