// generated by wraplib.py
// --- begin functions to be implemented
#ifndef _WRAPLIB_API_CALL
#define _WRAPLIB_API_CALL
#endif
#ifndef _WRAPLIB_CALLBACK
#define _WRAPLIB_CALLBACK
#endif
#ifndef ON_ENTRY
#define ON_ENTRY(x)
#endif
static void* get_library_handle();
static void* resolve_library_func(void*, const char*);
namespace {
template <typename T>
T on_init_failed(int func_idx);
}
// --- end functions to be implemented
#include <cstddef>
#include <mutex>
extern "C" {
const char _WRAPLIB_API_CALL* nvrtcGetErrorString(nvrtcResult arg0);
nvrtcResult _WRAPLIB_API_CALL nvrtcVersion(int* arg0, int* arg1);
nvrtcResult _WRAPLIB_API_CALL nvrtcGetNumSupportedArchs(int* arg0);
nvrtcResult _WRAPLIB_API_CALL nvrtcGetSupportedArchs(int* arg0);
nvrtcResult _WRAPLIB_API_CALL nvrtcCreateProgram(nvrtcProgram* arg0,
                                                 const char* arg1,
                                                 const char* arg2, int arg3,
                                                 const char* const* arg4,
                                                 const char* const* arg5);
nvrtcResult _WRAPLIB_API_CALL nvrtcDestroyProgram(nvrtcProgram* arg0);
nvrtcResult _WRAPLIB_API_CALL nvrtcCompileProgram(nvrtcProgram arg0, int arg1,
                                                  const char* const* arg2);
nvrtcResult _WRAPLIB_API_CALL nvrtcGetPTXSize(nvrtcProgram arg0, size_t* arg1);
nvrtcResult _WRAPLIB_API_CALL nvrtcGetPTX(nvrtcProgram arg0, char* arg1);
nvrtcResult _WRAPLIB_API_CALL nvrtcGetCUBINSize(nvrtcProgram arg0,
                                                size_t* arg1);
nvrtcResult _WRAPLIB_API_CALL nvrtcGetCUBIN(nvrtcProgram arg0, char* arg1);
nvrtcResult _WRAPLIB_API_CALL nvrtcGetProgramLogSize(nvrtcProgram arg0,
                                                     size_t* arg1);
nvrtcResult _WRAPLIB_API_CALL nvrtcGetProgramLog(nvrtcProgram arg0, char* arg1);
nvrtcResult _WRAPLIB_API_CALL nvrtcAddNameExpression(nvrtcProgram arg0,
                                                     const char* const arg1);
nvrtcResult _WRAPLIB_API_CALL nvrtcGetLoweredName(nvrtcProgram arg0,
                                                  const char* const arg1,
                                                  const char** arg2);
}
static void load_library();
static const char _WRAPLIB_API_CALL* nvrtcGetErrorString_init(
        nvrtcResult arg0) {
    load_library();
    return nvrtcGetErrorString(arg0);
}
static const char _WRAPLIB_API_CALL* nvrtcGetErrorString_error(nvrtcResult) {
    return on_init_failed<const char*>(0);
}

static nvrtcResult _WRAPLIB_API_CALL nvrtcVersion_init(int* arg0, int* arg1) {
    load_library();
    return nvrtcVersion(arg0, arg1);
}
static nvrtcResult _WRAPLIB_API_CALL nvrtcVersion_error(int*, int*) {
    return on_init_failed<nvrtcResult>(1);
}

static nvrtcResult _WRAPLIB_API_CALL nvrtcGetNumSupportedArchs_init(int* arg0) {
    load_library();
    return nvrtcGetNumSupportedArchs(arg0);
}
static nvrtcResult _WRAPLIB_API_CALL nvrtcGetNumSupportedArchs_error(int*) {
    return on_init_failed<nvrtcResult>(2);
}

static nvrtcResult _WRAPLIB_API_CALL nvrtcGetSupportedArchs_init(int* arg0) {
    load_library();
    return nvrtcGetSupportedArchs(arg0);
}
static nvrtcResult _WRAPLIB_API_CALL nvrtcGetSupportedArchs_error(int*) {
    return on_init_failed<nvrtcResult>(3);
}

static nvrtcResult _WRAPLIB_API_CALL nvrtcCreateProgram_init(
        nvrtcProgram* arg0, const char* arg1, const char* arg2, int arg3,
        const char* const* arg4, const char* const* arg5) {
    load_library();
    return nvrtcCreateProgram(arg0, arg1, arg2, arg3, arg4, arg5);
}
static nvrtcResult _WRAPLIB_API_CALL
nvrtcCreateProgram_error(nvrtcProgram*, const char*, const char*, int,
                         const char* const*, const char* const*) {
    return on_init_failed<nvrtcResult>(4);
}

static nvrtcResult _WRAPLIB_API_CALL
nvrtcDestroyProgram_init(nvrtcProgram* arg0) {
    load_library();
    return nvrtcDestroyProgram(arg0);
}
static nvrtcResult _WRAPLIB_API_CALL nvrtcDestroyProgram_error(nvrtcProgram*) {
    return on_init_failed<nvrtcResult>(5);
}

static nvrtcResult _WRAPLIB_API_CALL
nvrtcCompileProgram_init(nvrtcProgram arg0, int arg1, const char* const* arg2) {
    load_library();
    return nvrtcCompileProgram(arg0, arg1, arg2);
}
static nvrtcResult _WRAPLIB_API_CALL
nvrtcCompileProgram_error(nvrtcProgram, int, const char* const*) {
    return on_init_failed<nvrtcResult>(6);
}

static nvrtcResult _WRAPLIB_API_CALL nvrtcGetPTXSize_init(nvrtcProgram arg0,
                                                          size_t* arg1) {
    load_library();
    return nvrtcGetPTXSize(arg0, arg1);
}
static nvrtcResult _WRAPLIB_API_CALL nvrtcGetPTXSize_error(nvrtcProgram,
                                                           size_t*) {
    return on_init_failed<nvrtcResult>(7);
}

static nvrtcResult _WRAPLIB_API_CALL nvrtcGetPTX_init(nvrtcProgram arg0,
                                                      char* arg1) {
    load_library();
    return nvrtcGetPTX(arg0, arg1);
}
static nvrtcResult _WRAPLIB_API_CALL nvrtcGetPTX_error(nvrtcProgram, char*) {
    return on_init_failed<nvrtcResult>(8);
}

static nvrtcResult _WRAPLIB_API_CALL nvrtcGetCUBINSize_init(nvrtcProgram arg0,
                                                            size_t* arg1) {
    load_library();
    return nvrtcGetCUBINSize(arg0, arg1);
}
static nvrtcResult _WRAPLIB_API_CALL nvrtcGetCUBINSize_error(nvrtcProgram,
                                                             size_t*) {
    return on_init_failed<nvrtcResult>(9);
}

static nvrtcResult _WRAPLIB_API_CALL nvrtcGetCUBIN_init(nvrtcProgram arg0,
                                                        char* arg1) {
    load_library();
    return nvrtcGetCUBIN(arg0, arg1);
}
static nvrtcResult _WRAPLIB_API_CALL nvrtcGetCUBIN_error(nvrtcProgram, char*) {
    return on_init_failed<nvrtcResult>(10);
}

static nvrtcResult _WRAPLIB_API_CALL
nvrtcGetProgramLogSize_init(nvrtcProgram arg0, size_t* arg1) {
    load_library();
    return nvrtcGetProgramLogSize(arg0, arg1);
}
static nvrtcResult _WRAPLIB_API_CALL nvrtcGetProgramLogSize_error(nvrtcProgram,
                                                                  size_t*) {
    return on_init_failed<nvrtcResult>(11);
}

static nvrtcResult _WRAPLIB_API_CALL nvrtcGetProgramLog_init(nvrtcProgram arg0,
                                                             char* arg1) {
    load_library();
    return nvrtcGetProgramLog(arg0, arg1);
}
static nvrtcResult _WRAPLIB_API_CALL nvrtcGetProgramLog_error(nvrtcProgram,
                                                              char*) {
    return on_init_failed<nvrtcResult>(12);
}

static nvrtcResult _WRAPLIB_API_CALL
nvrtcAddNameExpression_init(nvrtcProgram arg0, const char* const arg1) {
    load_library();
    return nvrtcAddNameExpression(arg0, arg1);
}
static nvrtcResult _WRAPLIB_API_CALL
nvrtcAddNameExpression_error(nvrtcProgram, const char* const) {
    return on_init_failed<nvrtcResult>(13);
}

static nvrtcResult _WRAPLIB_API_CALL nvrtcGetLoweredName_init(
        nvrtcProgram arg0, const char* const arg1, const char** arg2) {
    load_library();
    return nvrtcGetLoweredName(arg0, arg1, arg2);
}
static nvrtcResult _WRAPLIB_API_CALL
nvrtcGetLoweredName_error(nvrtcProgram, const char* const, const char**) {
    return on_init_failed<nvrtcResult>(14);
}
static constexpr size_t NR_FUNC = 15;
static void* g_func_table[NR_FUNC] = {(void*)(&nvrtcGetErrorString_init),
                                      (void*)(&nvrtcVersion_init),
                                      (void*)(&nvrtcGetNumSupportedArchs_init),
                                      (void*)(&nvrtcGetSupportedArchs_init),
                                      (void*)(&nvrtcCreateProgram_init),
                                      (void*)(&nvrtcDestroyProgram_init),
                                      (void*)(&nvrtcCompileProgram_init),
                                      (void*)(&nvrtcGetPTXSize_init),
                                      (void*)(&nvrtcGetPTX_init),
                                      (void*)(&nvrtcGetCUBINSize_init),
                                      (void*)(&nvrtcGetCUBIN_init),
                                      (void*)(&nvrtcGetProgramLogSize_init),
                                      (void*)(&nvrtcGetProgramLog_init),
                                      (void*)(&nvrtcAddNameExpression_init),
                                      (void*)(&nvrtcGetLoweredName_init)};
static void* g_func_table_error[NR_FUNC] = {
        (void*)(&nvrtcGetErrorString_error),
        (void*)(&nvrtcVersion_error),
        (void*)(&nvrtcGetNumSupportedArchs_error),
        (void*)(&nvrtcGetSupportedArchs_error),
        (void*)(&nvrtcCreateProgram_error),
        (void*)(&nvrtcDestroyProgram_error),
        (void*)(&nvrtcCompileProgram_error),
        (void*)(&nvrtcGetPTXSize_error),
        (void*)(&nvrtcGetPTX_error),
        (void*)(&nvrtcGetCUBINSize_error),
        (void*)(&nvrtcGetCUBIN_error),
        (void*)(&nvrtcGetProgramLogSize_error),
        (void*)(&nvrtcGetProgramLog_error),
        (void*)(&nvrtcAddNameExpression_error),
        (void*)(&nvrtcGetLoweredName_error)};
static const char* const g_func_name[NR_FUNC] = {"nvrtcGetErrorString",
                                                 "nvrtcVersion",
                                                 "nvrtcGetNumSupportedArchs",
                                                 "nvrtcGetSupportedArchs",
                                                 "nvrtcCreateProgram",
                                                 "nvrtcDestroyProgram",
                                                 "nvrtcCompileProgram",
                                                 "nvrtcGetPTXSize",
                                                 "nvrtcGetPTX",
                                                 "nvrtcGetCUBINSize",
                                                 "nvrtcGetCUBIN",
                                                 "nvrtcGetProgramLogSize",
                                                 "nvrtcGetProgramLog",
                                                 "nvrtcAddNameExpression",
                                                 "nvrtcGetLoweredName"};

static void load_library() {
    static bool done = false;
    static std::mutex mtx;
    std::lock_guard<std::mutex> lg{mtx};

    if (done)
        return;

    void* handle = get_library_handle();
    for (size_t i = 0; i < NR_FUNC; ++i) {
        void* func;
        if (!handle) {
            func = nullptr;
        } else {
            func = resolve_library_func(handle, g_func_name[i]);
        }
        if (!func) {
            func = g_func_table_error[i];
        }
        __atomic_store_n(g_func_table + i, func, __ATOMIC_RELAXED);
    }
    done = true;
}

const char _WRAPLIB_API_CALL* nvrtcGetErrorString(nvrtcResult arg0) {
    typedef const char*(_WRAPLIB_API_CALL * f_ptr_t)(nvrtcResult);
    ON_ENTRY(nvrtcGetErrorString);
    f_ptr_t f = (f_ptr_t)(g_func_table[0]);
    return f(arg0);
}
nvrtcResult _WRAPLIB_API_CALL nvrtcVersion(int* arg0, int* arg1) {
    typedef nvrtcResult(_WRAPLIB_API_CALL * f_ptr_t)(int*, int*);
    ON_ENTRY(nvrtcVersion);
    f_ptr_t f = (f_ptr_t)(g_func_table[1]);
    return f(arg0, arg1);
}
nvrtcResult _WRAPLIB_API_CALL nvrtcGetNumSupportedArchs(int* arg0) {
    typedef nvrtcResult(_WRAPLIB_API_CALL * f_ptr_t)(int*);
    ON_ENTRY(nvrtcGetNumSupportedArchs);
    f_ptr_t f = (f_ptr_t)(g_func_table[2]);
    return f(arg0);
}
nvrtcResult _WRAPLIB_API_CALL nvrtcGetSupportedArchs(int* arg0) {
    typedef nvrtcResult(_WRAPLIB_API_CALL * f_ptr_t)(int*);
    ON_ENTRY(nvrtcGetSupportedArchs);
    f_ptr_t f = (f_ptr_t)(g_func_table[3]);
    return f(arg0);
}
nvrtcResult _WRAPLIB_API_CALL nvrtcCreateProgram(nvrtcProgram* arg0,
                                                 const char* arg1,
                                                 const char* arg2, int arg3,
                                                 const char* const* arg4,
                                                 const char* const* arg5) {
    typedef nvrtcResult(_WRAPLIB_API_CALL * f_ptr_t)(
            nvrtcProgram*, const char*, const char*, int, const char* const*,
            const char* const*);
    ON_ENTRY(nvrtcCreateProgram);
    f_ptr_t f = (f_ptr_t)(g_func_table[4]);
    return f(arg0, arg1, arg2, arg3, arg4, arg5);
}
nvrtcResult _WRAPLIB_API_CALL nvrtcDestroyProgram(nvrtcProgram* arg0) {
    typedef nvrtcResult(_WRAPLIB_API_CALL * f_ptr_t)(nvrtcProgram*);
    ON_ENTRY(nvrtcDestroyProgram);
    f_ptr_t f = (f_ptr_t)(g_func_table[5]);
    return f(arg0);
}
nvrtcResult _WRAPLIB_API_CALL nvrtcCompileProgram(nvrtcProgram arg0, int arg1,
                                                  const char* const* arg2) {
    typedef nvrtcResult(_WRAPLIB_API_CALL * f_ptr_t)(nvrtcProgram, int,
                                                     const char* const*);
    ON_ENTRY(nvrtcCompileProgram);
    f_ptr_t f = (f_ptr_t)(g_func_table[6]);
    return f(arg0, arg1, arg2);
}
nvrtcResult _WRAPLIB_API_CALL nvrtcGetPTXSize(nvrtcProgram arg0, size_t* arg1) {
    typedef nvrtcResult(_WRAPLIB_API_CALL * f_ptr_t)(nvrtcProgram, size_t*);
    ON_ENTRY(nvrtcGetPTXSize);
    f_ptr_t f = (f_ptr_t)(g_func_table[7]);
    return f(arg0, arg1);
}
nvrtcResult _WRAPLIB_API_CALL nvrtcGetPTX(nvrtcProgram arg0, char* arg1) {
    typedef nvrtcResult(_WRAPLIB_API_CALL * f_ptr_t)(nvrtcProgram, char*);
    ON_ENTRY(nvrtcGetPTX);
    f_ptr_t f = (f_ptr_t)(g_func_table[8]);
    return f(arg0, arg1);
}
nvrtcResult _WRAPLIB_API_CALL nvrtcGetCUBINSize(nvrtcProgram arg0,
                                                size_t* arg1) {
    typedef nvrtcResult(_WRAPLIB_API_CALL * f_ptr_t)(nvrtcProgram, size_t*);
    ON_ENTRY(nvrtcGetCUBINSize);
    f_ptr_t f = (f_ptr_t)(g_func_table[9]);
    return f(arg0, arg1);
}
nvrtcResult _WRAPLIB_API_CALL nvrtcGetCUBIN(nvrtcProgram arg0, char* arg1) {
    typedef nvrtcResult(_WRAPLIB_API_CALL * f_ptr_t)(nvrtcProgram, char*);
    ON_ENTRY(nvrtcGetCUBIN);
    f_ptr_t f = (f_ptr_t)(g_func_table[10]);
    return f(arg0, arg1);
}
nvrtcResult _WRAPLIB_API_CALL nvrtcGetProgramLogSize(nvrtcProgram arg0,
                                                     size_t* arg1) {
    typedef nvrtcResult(_WRAPLIB_API_CALL * f_ptr_t)(nvrtcProgram, size_t*);
    ON_ENTRY(nvrtcGetProgramLogSize);
    f_ptr_t f = (f_ptr_t)(g_func_table[11]);
    return f(arg0, arg1);
}
nvrtcResult _WRAPLIB_API_CALL nvrtcGetProgramLog(nvrtcProgram arg0,
                                                 char* arg1) {
    typedef nvrtcResult(_WRAPLIB_API_CALL * f_ptr_t)(nvrtcProgram, char*);
    ON_ENTRY(nvrtcGetProgramLog);
    f_ptr_t f = (f_ptr_t)(g_func_table[12]);
    return f(arg0, arg1);
}
nvrtcResult _WRAPLIB_API_CALL nvrtcAddNameExpression(nvrtcProgram arg0,
                                                     const char* const arg1) {
    typedef nvrtcResult(_WRAPLIB_API_CALL * f_ptr_t)(nvrtcProgram,
                                                     const char* const);
    ON_ENTRY(nvrtcAddNameExpression);
    f_ptr_t f = (f_ptr_t)(g_func_table[13]);
    return f(arg0, arg1);
}
nvrtcResult _WRAPLIB_API_CALL nvrtcGetLoweredName(nvrtcProgram arg0,
                                                  const char* const arg1,
                                                  const char** arg2) {
    typedef nvrtcResult(_WRAPLIB_API_CALL * f_ptr_t)(
            nvrtcProgram, const char* const, const char**);
    ON_ENTRY(nvrtcGetLoweredName);
    f_ptr_t f = (f_ptr_t)(g_func_table[14]);
    return f(arg0, arg1, arg2);
}
