/*
 * Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
 *
 * SPDX-License-Identifier: MIT
 */
/* ============================================================================
 * hip_capture_generated.cpp  -  AUTO-GENERATED by gen_hrr_api_args.py
 *
 * DO NOT EDIT MANUALLY.
 * Regenerate with:
 *     python gen_hrr_api_args.py
 *
 * Contains:
 *   - capture_hipFoo() shim for every HIP API not in MANUAL_CAPTURE_APIS
 *   - hip_capture_build_table()          overrides all runtime dispatch slots
 *   - hip_capture_build_compiler_table() overrides all compiler dispatch slots
 *
 * MANUAL_CAPTURE_APIS (kernel launches, memcpy blob capture, module load,
 * fat binary registration) are implemented by hand in hip_capture.cpp;
 * the generated shims for those are simple pass-throughs.
 *
 * Every generated shim:
 *   1. Calls the real function via g_real_table / g_real_compiler_table
 *   2. If the call succeeded (hipError_t return) or always (void return):
 *      - Fills hrr_args_hipFoo ret + all args (hdr stamped by write_event_raw)
 *      - Calls writer::write_event_raw() which stamps thread_id/sequence_id
 * No hip_capture_enabled() check — shims are only installed when capture is active.
 * ============================================================================
 */

// This file is compiled as part of amdhip64; it #includes internal headers.
#include "hip_capture.h"
#include "hip_capture_writer.h"

// hrr_api_args.h lives in the same directory (hipamd/src/hrr/)
#include "hrr_api_args.h"

#include "hip/amd_detail/hip_api_trace.hpp"

#include <atomic>
#include <cstdint>
#include <cstring>

// These global tables are defined (non-static) in hip_capture.cpp
extern HipDispatchTable         g_real_table;
extern HipDispatchTable         g_cap_table;
extern std::atomic<bool>        g_installed;
extern std::atomic<bool>        g_table_built;
extern HipCompilerDispatchTable g_real_compiler_table;
extern std::atomic<bool>        g_compiler_installed;

namespace hip {
const HipDispatchTable*         GetHipDispatchTable();
const HipCompilerDispatchTable* GetHipCompilerDispatchTable();
}


// ============================================================
// Capture shims
// ============================================================

// Generated shim
static hipError_t capture___hipPopCallConfiguration(dim3* gridDim, dim3* blockDim, size_t* sharedMem, hipStream_t* stream) {
  hipError_t r = g_real_compiler_table.__hipPopCallConfiguration_fn(gridDim, blockDim, sharedMem, stream);
  if (r == hipSuccess) {
    hrr_args___hipPopCallConfiguration a{};
    a.ret         = static_cast<int32_t>(r);
    a.gridDim = reinterpret_cast<uint64_t>(gridDim);
    a.blockDim = reinterpret_cast<uint64_t>(blockDim);
    a.sharedMem = reinterpret_cast<uint64_t>(sharedMem);
    if (stream) a.stream = reinterpret_cast<uint64_t>(*stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPPOPCALLCONFIGURATION, &a.hdr, sizeof(a));
  }
  return r;
}



// Generated shim
static void capture___hipRegisterFunction(void** modules, const void* hostFunction, char* deviceFunction, const char* deviceName, unsigned int threadLimit, uint3* tid, uint3* bid, dim3* blockDim, dim3* gridDim, int* wSize) {
  g_real_compiler_table.__hipRegisterFunction_fn(modules, hostFunction, deviceFunction, deviceName, threadLimit, tid, bid, blockDim, gridDim, wSize);
  {
    hrr_args___hipRegisterFunction a{};
    a.hostFunction = reinterpret_cast<uint64_t>(hostFunction);
    a.deviceFunction = reinterpret_cast<uint64_t>(deviceFunction);
    a.deviceName = reinterpret_cast<uint64_t>(deviceName);
    a.threadLimit = static_cast<decltype(a.threadLimit)>(threadLimit);
    a.tid = reinterpret_cast<uint64_t>(tid);
    a.bid = reinterpret_cast<uint64_t>(bid);
    a.blockDim = reinterpret_cast<uint64_t>(blockDim);
    a.gridDim = reinterpret_cast<uint64_t>(gridDim);
    a.wSize = reinterpret_cast<uint64_t>(wSize);
    if (modules) a.modules = reinterpret_cast<uint64_t>(*modules);
    hrr_cap::writer::write_event_raw(HRR_API_HIPREGISTERFUNCTION, &a.hdr, sizeof(a));
  }
}

// Generated shim
static void capture___hipRegisterManagedVar(void* hipModule, void** pointer, void* init_value, const char* name, size_t size, unsigned align) {
  g_real_compiler_table.__hipRegisterManagedVar_fn(hipModule, pointer, init_value, name, size, align);
  {
    hrr_args___hipRegisterManagedVar a{};
    a.hipModule = reinterpret_cast<uint64_t>(hipModule);
    a.init_value = reinterpret_cast<uint64_t>(init_value);
    a.name = reinterpret_cast<uint64_t>(name);
    a.size = static_cast<decltype(a.size)>(size);
    a.align = static_cast<decltype(a.align)>(align);
    if (pointer) a.pointer = reinterpret_cast<uint64_t>(*pointer);
    hrr_cap::writer::write_event_raw(HRR_API_HIPREGISTERMANAGEDVAR, &a.hdr, sizeof(a));
  }
}

// Generated shim
static void capture___hipRegisterSurface(void** modules, void* var, char* hostVar, char* deviceVar, int type, int ext) {
  g_real_compiler_table.__hipRegisterSurface_fn(modules, var, hostVar, deviceVar, type, ext);
  {
    hrr_args___hipRegisterSurface a{};
    a.var = reinterpret_cast<uint64_t>(var);
    a.hostVar = reinterpret_cast<uint64_t>(hostVar);
    a.deviceVar = reinterpret_cast<uint64_t>(deviceVar);
    a.type = static_cast<decltype(a.type)>(type);
    a.ext = static_cast<decltype(a.ext)>(ext);
    if (modules) a.modules = reinterpret_cast<uint64_t>(*modules);
    hrr_cap::writer::write_event_raw(HRR_API_HIPREGISTERSURFACE, &a.hdr, sizeof(a));
  }
}

// Generated shim
static void capture___hipRegisterTexture(void** modules, void* var, char* hostVar, char* deviceVar, int type, int norm, int ext) {
  g_real_compiler_table.__hipRegisterTexture_fn(modules, var, hostVar, deviceVar, type, norm, ext);
  {
    hrr_args___hipRegisterTexture a{};
    a.var = reinterpret_cast<uint64_t>(var);
    a.hostVar = reinterpret_cast<uint64_t>(hostVar);
    a.deviceVar = reinterpret_cast<uint64_t>(deviceVar);
    a.type = static_cast<decltype(a.type)>(type);
    a.norm = static_cast<decltype(a.norm)>(norm);
    a.ext = static_cast<decltype(a.ext)>(ext);
    if (modules) a.modules = reinterpret_cast<uint64_t>(*modules);
    hrr_cap::writer::write_event_raw(HRR_API_HIPREGISTERTEXTURE, &a.hdr, sizeof(a));
  }
}

// Generated shim
static void capture___hipRegisterVar(void** modules, void* var, char* hostVar, char* deviceVar, int ext, size_t size, int constant, int global) {
  g_real_compiler_table.__hipRegisterVar_fn(modules, var, hostVar, deviceVar, ext, size, constant, global);
  {
    hrr_args___hipRegisterVar a{};
    a.var = reinterpret_cast<uint64_t>(var);
    a.hostVar = reinterpret_cast<uint64_t>(hostVar);
    a.deviceVar = reinterpret_cast<uint64_t>(deviceVar);
    a.ext = static_cast<decltype(a.ext)>(ext);
    a.size = static_cast<decltype(a.size)>(size);
    a.constant = static_cast<decltype(a.constant)>(constant);
    a.global = static_cast<decltype(a.global)>(global);
    if (modules) a.modules = reinterpret_cast<uint64_t>(*modules);
    hrr_cap::writer::write_event_raw(HRR_API_HIPREGISTERVAR, &a.hdr, sizeof(a));
  }
}


// Generated shim
static const char* capture_hipApiName(uint32_t id) {
  const char* r = g_real_table.hipApiName_fn(id);
  {
    hrr_args_hipApiName a{};
    a.ret = reinterpret_cast<uint64_t>(r);
    a.id = static_cast<decltype(a.id)>(id);
    hrr_cap::writer::write_event_raw(HRR_API_HIPAPINAME, &a.hdr, sizeof(a));
  }
  return r;
}


// Generated shim
static hipError_t capture_hipArray3DGetDescriptor(HIP_ARRAY3D_DESCRIPTOR* pArrayDescriptor, hipArray_t array) {
  hipError_t r = g_real_table.hipArray3DGetDescriptor_fn(pArrayDescriptor, array);
  if (r == hipSuccess) {
    hrr_args_hipArray3DGetDescriptor a{};
    a.ret         = static_cast<int32_t>(r);
    a.pArrayDescriptor = reinterpret_cast<uint64_t>(pArrayDescriptor);
    a.array = reinterpret_cast<uint64_t>(array);
    hrr_cap::writer::write_event_raw(HRR_API_HIPARRAY3DGETDESCRIPTOR, &a.hdr, sizeof(a));
  }
  return r;
}


// Generated shim
static hipError_t capture_hipArrayDestroy(hipArray_t array) {
  hipError_t r = g_real_table.hipArrayDestroy_fn(array);
  if (r == hipSuccess) {
    hrr_args_hipArrayDestroy a{};
    a.ret         = static_cast<int32_t>(r);
    a.array = reinterpret_cast<uint64_t>(array);
    hrr_cap::writer::write_event_raw(HRR_API_HIPARRAYDESTROY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipArrayGetDescriptor(HIP_ARRAY_DESCRIPTOR* pArrayDescriptor, hipArray_t array) {
  hipError_t r = g_real_table.hipArrayGetDescriptor_fn(pArrayDescriptor, array);
  if (r == hipSuccess) {
    hrr_args_hipArrayGetDescriptor a{};
    a.ret         = static_cast<int32_t>(r);
    a.pArrayDescriptor = reinterpret_cast<uint64_t>(pArrayDescriptor);
    a.array = reinterpret_cast<uint64_t>(array);
    hrr_cap::writer::write_event_raw(HRR_API_HIPARRAYGETDESCRIPTOR, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipArrayGetInfo(hipChannelFormatDesc* desc, hipExtent* extent, unsigned int* flags, hipArray_t array) {
  hipError_t r = g_real_table.hipArrayGetInfo_fn(desc, extent, flags, array);
  if (r == hipSuccess) {
    hrr_args_hipArrayGetInfo a{};
    a.ret         = static_cast<int32_t>(r);
    a.desc = 0;  // non-castable type skipped
    a.extent = 0;  // non-castable type skipped
    a.flags = reinterpret_cast<uint64_t>(flags);
    a.array = reinterpret_cast<uint64_t>(array);
    hrr_cap::writer::write_event_raw(HRR_API_HIPARRAYGETINFO, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipBindTexture(size_t* offset, const textureReference* tex, const void* devPtr, const hipChannelFormatDesc* desc, size_t size) {
  hipError_t r = g_real_table.hipBindTexture_fn(offset, tex, devPtr, desc, size);
  if (r == hipSuccess) {
    hrr_args_hipBindTexture a{};
    a.ret         = static_cast<int32_t>(r);
    a.offset = reinterpret_cast<uint64_t>(offset);
    a.tex = reinterpret_cast<uint64_t>(tex);
    a.devPtr = reinterpret_cast<uint64_t>(devPtr);
    a.desc = 0;  // non-castable type skipped
    a.size = static_cast<decltype(a.size)>(size);
    hrr_cap::writer::write_event_raw(HRR_API_HIPBINDTEXTURE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipBindTexture2D(size_t* offset, const textureReference* tex, const void* devPtr, const hipChannelFormatDesc* desc, size_t width, size_t height, size_t pitch) {
  hipError_t r = g_real_table.hipBindTexture2D_fn(offset, tex, devPtr, desc, width, height, pitch);
  if (r == hipSuccess) {
    hrr_args_hipBindTexture2D a{};
    a.ret         = static_cast<int32_t>(r);
    a.offset = reinterpret_cast<uint64_t>(offset);
    a.tex = reinterpret_cast<uint64_t>(tex);
    a.devPtr = reinterpret_cast<uint64_t>(devPtr);
    a.desc = 0;  // non-castable type skipped
    a.width = static_cast<decltype(a.width)>(width);
    a.height = static_cast<decltype(a.height)>(height);
    a.pitch = static_cast<decltype(a.pitch)>(pitch);
    hrr_cap::writer::write_event_raw(HRR_API_HIPBINDTEXTURE2D, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipBindTextureToArray(const textureReference* tex, hipArray_const_t array, const hipChannelFormatDesc* desc) {
  hipError_t r = g_real_table.hipBindTextureToArray_fn(tex, array, desc);
  if (r == hipSuccess) {
    hrr_args_hipBindTextureToArray a{};
    a.ret         = static_cast<int32_t>(r);
    a.tex = reinterpret_cast<uint64_t>(tex);
    a.array = reinterpret_cast<uint64_t>(array);
    a.desc = 0;  // non-castable type skipped
    hrr_cap::writer::write_event_raw(HRR_API_HIPBINDTEXTURETOARRAY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipBindTextureToMipmappedArray(const textureReference* tex, hipMipmappedArray_const_t mipmappedArray, const hipChannelFormatDesc* desc) {
  hipError_t r = g_real_table.hipBindTextureToMipmappedArray_fn(tex, mipmappedArray, desc);
  if (r == hipSuccess) {
    hrr_args_hipBindTextureToMipmappedArray a{};
    a.ret         = static_cast<int32_t>(r);
    a.tex = reinterpret_cast<uint64_t>(tex);
    a.mipmappedArray = reinterpret_cast<uint64_t>(mipmappedArray);
    a.desc = 0;  // non-castable type skipped
    hrr_cap::writer::write_event_raw(HRR_API_HIPBINDTEXTURETOMIPMAPPEDARRAY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipChooseDevice(int* device, const hipDeviceProp_t* prop) {
  hipError_t r = g_real_table.hipChooseDevice_fn(device, prop);
  if (r == hipSuccess) {
    hrr_args_hipChooseDevice a{};
    a.ret         = static_cast<int32_t>(r);
    a.device = reinterpret_cast<uint64_t>(device);
    a.prop = reinterpret_cast<uint64_t>(prop);
    hrr_cap::writer::write_event_raw(HRR_API_HIPCHOOSEDEVICE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipChooseDeviceR0000(int* device, const hipDeviceProp_tR0000* properties) {
  hipError_t r = g_real_table.hipChooseDeviceR0000_fn(device, properties);
  if (r == hipSuccess) {
    hrr_args_hipChooseDeviceR0000 a{};
    a.ret         = static_cast<int32_t>(r);
    a.device = reinterpret_cast<uint64_t>(device);
    a.properties = reinterpret_cast<uint64_t>(properties);
    hrr_cap::writer::write_event_raw(HRR_API_HIPCHOOSEDEVICER0000, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipConfigureCall(dim3 gridDim, dim3 blockDim, size_t sharedMem, hipStream_t stream) {
  hipError_t r = g_real_table.hipConfigureCall_fn(gridDim, blockDim, sharedMem, stream);
  if (r == hipSuccess) {
    hrr_args_hipConfigureCall a{};
    a.ret         = static_cast<int32_t>(r);
    a.gridDim_x = gridDim.x;
    a.gridDim_y = gridDim.y;
    a.gridDim_z = gridDim.z;
    a.blockDim_x = blockDim.x;
    a.blockDim_y = blockDim.y;
    a.blockDim_z = blockDim.z;
    a.sharedMem = static_cast<decltype(a.sharedMem)>(sharedMem);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPCONFIGURECALL, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipCreateSurfaceObject(hipSurfaceObject_t* pSurfObject, const hipResourceDesc* pResDesc) {
  hipError_t r = g_real_table.hipCreateSurfaceObject_fn(pSurfObject, pResDesc);
  if (r == hipSuccess) {
    hrr_args_hipCreateSurfaceObject a{};
    a.ret         = static_cast<int32_t>(r);
    a.pResDesc = reinterpret_cast<uint64_t>(pResDesc);
    if (pSurfObject) a.pSurfObject = reinterpret_cast<uint64_t>(*pSurfObject);
    hrr_cap::writer::write_event_raw(HRR_API_HIPCREATESURFACEOBJECT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipCreateTextureObject(hipTextureObject_t* pTexObject, const hipResourceDesc* pResDesc, const hipTextureDesc* pTexDesc, const struct hipResourceViewDesc* pResViewDesc) {
  hipError_t r = g_real_table.hipCreateTextureObject_fn(pTexObject, pResDesc, pTexDesc, pResViewDesc);
  if (r == hipSuccess) {
    hrr_args_hipCreateTextureObject a{};
    a.ret         = static_cast<int32_t>(r);
    a.pResDesc = reinterpret_cast<uint64_t>(pResDesc);
    a.pTexDesc = reinterpret_cast<uint64_t>(pTexDesc);
    a.pResViewDesc = reinterpret_cast<uint64_t>(pResViewDesc);
    if (pTexObject) a.pTexObject = reinterpret_cast<uint64_t>(*pTexObject);
    hrr_cap::writer::write_event_raw(HRR_API_HIPCREATETEXTUREOBJECT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipCtxCreate(hipCtx_t* ctx, unsigned int flags, hipDevice_t device) {
  hipError_t r = g_real_table.hipCtxCreate_fn(ctx, flags, device);
  if (r == hipSuccess) {
    hrr_args_hipCtxCreate a{};
    a.ret         = static_cast<int32_t>(r);
    a.flags = static_cast<decltype(a.flags)>(flags);
    a.device = static_cast<uint64_t>(static_cast<int>(device));
    if (ctx) a.ctx = reinterpret_cast<uint64_t>(*ctx);
    hrr_cap::writer::write_event_raw(HRR_API_HIPCTXCREATE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipCtxDestroy(hipCtx_t ctx) {
  hipError_t r = g_real_table.hipCtxDestroy_fn(ctx);
  if (r == hipSuccess) {
    hrr_args_hipCtxDestroy a{};
    a.ret         = static_cast<int32_t>(r);
    a.ctx = reinterpret_cast<uint64_t>(ctx);
    hrr_cap::writer::write_event_raw(HRR_API_HIPCTXDESTROY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipCtxDisablePeerAccess(hipCtx_t peerCtx) {
  hipError_t r = g_real_table.hipCtxDisablePeerAccess_fn(peerCtx);
  if (r == hipSuccess) {
    hrr_args_hipCtxDisablePeerAccess a{};
    a.ret         = static_cast<int32_t>(r);
    a.peerCtx = reinterpret_cast<uint64_t>(peerCtx);
    hrr_cap::writer::write_event_raw(HRR_API_HIPCTXDISABLEPEERACCESS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipCtxEnablePeerAccess(hipCtx_t peerCtx, unsigned int flags) {
  hipError_t r = g_real_table.hipCtxEnablePeerAccess_fn(peerCtx, flags);
  if (r == hipSuccess) {
    hrr_args_hipCtxEnablePeerAccess a{};
    a.ret         = static_cast<int32_t>(r);
    a.peerCtx = reinterpret_cast<uint64_t>(peerCtx);
    a.flags = static_cast<decltype(a.flags)>(flags);
    hrr_cap::writer::write_event_raw(HRR_API_HIPCTXENABLEPEERACCESS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipCtxGetApiVersion(hipCtx_t ctx, unsigned int* apiVersion) {
  hipError_t r = g_real_table.hipCtxGetApiVersion_fn(ctx, apiVersion);
  if (r == hipSuccess) {
    hrr_args_hipCtxGetApiVersion a{};
    a.ret         = static_cast<int32_t>(r);
    a.ctx = reinterpret_cast<uint64_t>(ctx);
    a.apiVersion = reinterpret_cast<uint64_t>(apiVersion);
    hrr_cap::writer::write_event_raw(HRR_API_HIPCTXGETAPIVERSION, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipCtxGetCacheConfig(hipFuncCache_t* cacheConfig) {
  hipError_t r = g_real_table.hipCtxGetCacheConfig_fn(cacheConfig);
  if (r == hipSuccess) {
    hrr_args_hipCtxGetCacheConfig a{};
    a.ret         = static_cast<int32_t>(r);
    a.cacheConfig = reinterpret_cast<uint64_t>(cacheConfig);
    hrr_cap::writer::write_event_raw(HRR_API_HIPCTXGETCACHECONFIG, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipCtxGetCurrent(hipCtx_t* ctx) {
  hipError_t r = g_real_table.hipCtxGetCurrent_fn(ctx);
  if (r == hipSuccess) {
    hrr_args_hipCtxGetCurrent a{};
    a.ret         = static_cast<int32_t>(r);
    if (ctx) a.ctx = reinterpret_cast<uint64_t>(*ctx);
    hrr_cap::writer::write_event_raw(HRR_API_HIPCTXGETCURRENT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipCtxGetDevice(hipDevice_t* device) {
  hipError_t r = g_real_table.hipCtxGetDevice_fn(device);
  if (r == hipSuccess) {
    hrr_args_hipCtxGetDevice a{};
    a.ret         = static_cast<int32_t>(r);
    if (device) a.device = static_cast<uint64_t>(static_cast<int>(*device));
    hrr_cap::writer::write_event_raw(HRR_API_HIPCTXGETDEVICE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipCtxGetFlags(unsigned int* flags) {
  hipError_t r = g_real_table.hipCtxGetFlags_fn(flags);
  if (r == hipSuccess) {
    hrr_args_hipCtxGetFlags a{};
    a.ret         = static_cast<int32_t>(r);
    a.flags = reinterpret_cast<uint64_t>(flags);
    hrr_cap::writer::write_event_raw(HRR_API_HIPCTXGETFLAGS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipCtxGetSharedMemConfig(hipSharedMemConfig* pConfig) {
  hipError_t r = g_real_table.hipCtxGetSharedMemConfig_fn(pConfig);
  if (r == hipSuccess) {
    hrr_args_hipCtxGetSharedMemConfig a{};
    a.ret         = static_cast<int32_t>(r);
    a.pConfig = reinterpret_cast<uint64_t>(pConfig);
    hrr_cap::writer::write_event_raw(HRR_API_HIPCTXGETSHAREDMEMCONFIG, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipCtxPopCurrent(hipCtx_t* ctx) {
  hipError_t r = g_real_table.hipCtxPopCurrent_fn(ctx);
  if (r == hipSuccess) {
    hrr_args_hipCtxPopCurrent a{};
    a.ret         = static_cast<int32_t>(r);
    if (ctx) a.ctx = reinterpret_cast<uint64_t>(*ctx);
    hrr_cap::writer::write_event_raw(HRR_API_HIPCTXPOPCURRENT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipCtxPushCurrent(hipCtx_t ctx) {
  hipError_t r = g_real_table.hipCtxPushCurrent_fn(ctx);
  if (r == hipSuccess) {
    hrr_args_hipCtxPushCurrent a{};
    a.ret         = static_cast<int32_t>(r);
    a.ctx = reinterpret_cast<uint64_t>(ctx);
    hrr_cap::writer::write_event_raw(HRR_API_HIPCTXPUSHCURRENT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipCtxSetCacheConfig(hipFuncCache_t cacheConfig) {
  hipError_t r = g_real_table.hipCtxSetCacheConfig_fn(cacheConfig);
  if (r == hipSuccess) {
    hrr_args_hipCtxSetCacheConfig a{};
    a.ret         = static_cast<int32_t>(r);
    a.cacheConfig = static_cast<decltype(a.cacheConfig)>(cacheConfig);
    hrr_cap::writer::write_event_raw(HRR_API_HIPCTXSETCACHECONFIG, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipCtxSetCurrent(hipCtx_t ctx) {
  hipError_t r = g_real_table.hipCtxSetCurrent_fn(ctx);
  if (r == hipSuccess) {
    hrr_args_hipCtxSetCurrent a{};
    a.ret         = static_cast<int32_t>(r);
    a.ctx = reinterpret_cast<uint64_t>(ctx);
    hrr_cap::writer::write_event_raw(HRR_API_HIPCTXSETCURRENT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipCtxSetSharedMemConfig(hipSharedMemConfig config) {
  hipError_t r = g_real_table.hipCtxSetSharedMemConfig_fn(config);
  if (r == hipSuccess) {
    hrr_args_hipCtxSetSharedMemConfig a{};
    a.ret         = static_cast<int32_t>(r);
    a.config = static_cast<decltype(a.config)>(config);
    hrr_cap::writer::write_event_raw(HRR_API_HIPCTXSETSHAREDMEMCONFIG, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipCtxSynchronize(void) {
  hipError_t r = g_real_table.hipCtxSynchronize_fn();
  if (r == hipSuccess) {
    hrr_args_hipCtxSynchronize a{};
    a.ret         = static_cast<int32_t>(r);
    hrr_cap::writer::write_event_raw(HRR_API_HIPCTXSYNCHRONIZE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDestroyExternalMemory(hipExternalMemory_t extMem) {
  hipError_t r = g_real_table.hipDestroyExternalMemory_fn(extMem);
  if (r == hipSuccess) {
    hrr_args_hipDestroyExternalMemory a{};
    a.ret         = static_cast<int32_t>(r);
    a.extMem = reinterpret_cast<uint64_t>(extMem);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDESTROYEXTERNALMEMORY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDestroyExternalSemaphore(hipExternalSemaphore_t extSem) {
  hipError_t r = g_real_table.hipDestroyExternalSemaphore_fn(extSem);
  if (r == hipSuccess) {
    hrr_args_hipDestroyExternalSemaphore a{};
    a.ret         = static_cast<int32_t>(r);
    a.extSem = reinterpret_cast<uint64_t>(extSem);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDESTROYEXTERNALSEMAPHORE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDestroySurfaceObject(hipSurfaceObject_t surfaceObject) {
  hipError_t r = g_real_table.hipDestroySurfaceObject_fn(surfaceObject);
  if (r == hipSuccess) {
    hrr_args_hipDestroySurfaceObject a{};
    a.ret         = static_cast<int32_t>(r);
    a.surfaceObject = reinterpret_cast<uint64_t>(surfaceObject);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDESTROYSURFACEOBJECT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDestroyTextureObject(hipTextureObject_t textureObject) {
  hipError_t r = g_real_table.hipDestroyTextureObject_fn(textureObject);
  if (r == hipSuccess) {
    hrr_args_hipDestroyTextureObject a{};
    a.ret         = static_cast<int32_t>(r);
    a.textureObject = reinterpret_cast<uint64_t>(textureObject);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDESTROYTEXTUREOBJECT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDeviceCanAccessPeer(int* canAccessPeer, int deviceId, int peerDeviceId) {
  hipError_t r = g_real_table.hipDeviceCanAccessPeer_fn(canAccessPeer, deviceId, peerDeviceId);
  if (r == hipSuccess) {
    hrr_args_hipDeviceCanAccessPeer a{};
    a.ret         = static_cast<int32_t>(r);
    a.canAccessPeer = reinterpret_cast<uint64_t>(canAccessPeer);
    a.deviceId = static_cast<decltype(a.deviceId)>(deviceId);
    a.peerDeviceId = static_cast<decltype(a.peerDeviceId)>(peerDeviceId);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVICECANACCESSPEER, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDeviceComputeCapability(int* major, int* minor, hipDevice_t device) {
  hipError_t r = g_real_table.hipDeviceComputeCapability_fn(major, minor, device);
  if (r == hipSuccess) {
    hrr_args_hipDeviceComputeCapability a{};
    a.ret         = static_cast<int32_t>(r);
    a.major = reinterpret_cast<uint64_t>(major);
    a.minor = reinterpret_cast<uint64_t>(minor);
    a.device = static_cast<uint64_t>(static_cast<int>(device));
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVICECOMPUTECAPABILITY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDeviceDisablePeerAccess(int peerDeviceId) {
  hipError_t r = g_real_table.hipDeviceDisablePeerAccess_fn(peerDeviceId);
  if (r == hipSuccess) {
    hrr_args_hipDeviceDisablePeerAccess a{};
    a.ret         = static_cast<int32_t>(r);
    a.peerDeviceId = static_cast<decltype(a.peerDeviceId)>(peerDeviceId);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVICEDISABLEPEERACCESS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDeviceEnablePeerAccess(int peerDeviceId, unsigned int flags) {
  hipError_t r = g_real_table.hipDeviceEnablePeerAccess_fn(peerDeviceId, flags);
  if (r == hipSuccess) {
    hrr_args_hipDeviceEnablePeerAccess a{};
    a.ret         = static_cast<int32_t>(r);
    a.peerDeviceId = static_cast<decltype(a.peerDeviceId)>(peerDeviceId);
    a.flags = static_cast<decltype(a.flags)>(flags);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVICEENABLEPEERACCESS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDeviceGet(hipDevice_t* device, int ordinal) {
  hipError_t r = g_real_table.hipDeviceGet_fn(device, ordinal);
  if (r == hipSuccess) {
    hrr_args_hipDeviceGet a{};
    a.ret         = static_cast<int32_t>(r);
    a.ordinal = static_cast<decltype(a.ordinal)>(ordinal);
    if (device) a.device = static_cast<uint64_t>(static_cast<int>(*device));
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVICEGET, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDeviceGetAttribute(int* pi, hipDeviceAttribute_t attr, int deviceId) {
  hipError_t r = g_real_table.hipDeviceGetAttribute_fn(pi, attr, deviceId);
  if (r == hipSuccess) {
    hrr_args_hipDeviceGetAttribute a{};
    a.ret         = static_cast<int32_t>(r);
    a.pi = reinterpret_cast<uint64_t>(pi);
    a.attr = static_cast<decltype(a.attr)>(attr);
    a.deviceId = static_cast<decltype(a.deviceId)>(deviceId);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVICEGETATTRIBUTE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDeviceGetByPCIBusId(int* device, const char* pciBusId) {
  hipError_t r = g_real_table.hipDeviceGetByPCIBusId_fn(device, pciBusId);
  if (r == hipSuccess) {
    hrr_args_hipDeviceGetByPCIBusId a{};
    a.ret         = static_cast<int32_t>(r);
    a.device = reinterpret_cast<uint64_t>(device);
    a.pciBusId = reinterpret_cast<uint64_t>(pciBusId);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVICEGETBYPCIBUSID, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDeviceGetCacheConfig(hipFuncCache_t* cacheConfig) {
  hipError_t r = g_real_table.hipDeviceGetCacheConfig_fn(cacheConfig);
  if (r == hipSuccess) {
    hrr_args_hipDeviceGetCacheConfig a{};
    a.ret         = static_cast<int32_t>(r);
    a.cacheConfig = reinterpret_cast<uint64_t>(cacheConfig);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVICEGETCACHECONFIG, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDeviceGetDefaultMemPool(hipMemPool_t* mem_pool, int device) {
  hipError_t r = g_real_table.hipDeviceGetDefaultMemPool_fn(mem_pool, device);
  if (r == hipSuccess) {
    hrr_args_hipDeviceGetDefaultMemPool a{};
    a.ret         = static_cast<int32_t>(r);
    a.device = static_cast<decltype(a.device)>(device);
    if (mem_pool) a.mem_pool = reinterpret_cast<uint64_t>(*mem_pool);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVICEGETDEFAULTMEMPOOL, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDeviceGetGraphMemAttribute(int device, hipGraphMemAttributeType attr, void* value) {
  hipError_t r = g_real_table.hipDeviceGetGraphMemAttribute_fn(device, attr, value);
  if (r == hipSuccess) {
    hrr_args_hipDeviceGetGraphMemAttribute a{};
    a.ret         = static_cast<int32_t>(r);
    a.device = static_cast<decltype(a.device)>(device);
    a.attr = static_cast<decltype(a.attr)>(attr);
    a.value = reinterpret_cast<uint64_t>(value);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVICEGETGRAPHMEMATTRIBUTE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDeviceGetLimit(size_t* pValue, enum hipLimit_t limit) {
  hipError_t r = g_real_table.hipDeviceGetLimit_fn(pValue, limit);
  if (r == hipSuccess) {
    hrr_args_hipDeviceGetLimit a{};
    a.ret         = static_cast<int32_t>(r);
    a.pValue = reinterpret_cast<uint64_t>(pValue);
    a.limit = static_cast<decltype(a.limit)>(limit);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVICEGETLIMIT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDeviceGetMemPool(hipMemPool_t* mem_pool, int device) {
  hipError_t r = g_real_table.hipDeviceGetMemPool_fn(mem_pool, device);
  if (r == hipSuccess) {
    hrr_args_hipDeviceGetMemPool a{};
    a.ret         = static_cast<int32_t>(r);
    a.device = static_cast<decltype(a.device)>(device);
    if (mem_pool) a.mem_pool = reinterpret_cast<uint64_t>(*mem_pool);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVICEGETMEMPOOL, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDeviceGetName(char* name, int len, hipDevice_t device) {
  hipError_t r = g_real_table.hipDeviceGetName_fn(name, len, device);
  if (r == hipSuccess) {
    hrr_args_hipDeviceGetName a{};
    a.ret         = static_cast<int32_t>(r);
    a.name = reinterpret_cast<uint64_t>(name);
    a.len = static_cast<decltype(a.len)>(len);
    a.device = static_cast<uint64_t>(static_cast<int>(device));
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVICEGETNAME, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDeviceGetP2PAttribute(int* value, hipDeviceP2PAttr attr, int srcDevice, int dstDevice) {
  hipError_t r = g_real_table.hipDeviceGetP2PAttribute_fn(value, attr, srcDevice, dstDevice);
  if (r == hipSuccess) {
    hrr_args_hipDeviceGetP2PAttribute a{};
    a.ret         = static_cast<int32_t>(r);
    a.value = reinterpret_cast<uint64_t>(value);
    a.attr = static_cast<decltype(a.attr)>(attr);
    a.srcDevice = static_cast<decltype(a.srcDevice)>(srcDevice);
    a.dstDevice = static_cast<decltype(a.dstDevice)>(dstDevice);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVICEGETP2PATTRIBUTE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDeviceGetPCIBusId(char* pciBusId, int len, int device) {
  hipError_t r = g_real_table.hipDeviceGetPCIBusId_fn(pciBusId, len, device);
  if (r == hipSuccess) {
    hrr_args_hipDeviceGetPCIBusId a{};
    a.ret         = static_cast<int32_t>(r);
    a.pciBusId = reinterpret_cast<uint64_t>(pciBusId);
    a.len = static_cast<decltype(a.len)>(len);
    a.device = static_cast<decltype(a.device)>(device);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVICEGETPCIBUSID, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDeviceGetSharedMemConfig(hipSharedMemConfig* pConfig) {
  hipError_t r = g_real_table.hipDeviceGetSharedMemConfig_fn(pConfig);
  if (r == hipSuccess) {
    hrr_args_hipDeviceGetSharedMemConfig a{};
    a.ret         = static_cast<int32_t>(r);
    a.pConfig = reinterpret_cast<uint64_t>(pConfig);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVICEGETSHAREDMEMCONFIG, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDeviceGetStreamPriorityRange(int* leastPriority, int* greatestPriority) {
  hipError_t r = g_real_table.hipDeviceGetStreamPriorityRange_fn(leastPriority, greatestPriority);
  if (r == hipSuccess) {
    hrr_args_hipDeviceGetStreamPriorityRange a{};
    a.ret         = static_cast<int32_t>(r);
    a.leastPriority = reinterpret_cast<uint64_t>(leastPriority);
    a.greatestPriority = reinterpret_cast<uint64_t>(greatestPriority);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVICEGETSTREAMPRIORITYRANGE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDeviceGetUuid(hipUUID* uuid, hipDevice_t device) {
  hipError_t r = g_real_table.hipDeviceGetUuid_fn(uuid, device);
  if (r == hipSuccess) {
    hrr_args_hipDeviceGetUuid a{};
    a.ret         = static_cast<int32_t>(r);
    a.uuid = reinterpret_cast<uint64_t>(uuid);
    a.device = static_cast<uint64_t>(static_cast<int>(device));
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVICEGETUUID, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDeviceGraphMemTrim(int device) {
  hipError_t r = g_real_table.hipDeviceGraphMemTrim_fn(device);
  if (r == hipSuccess) {
    hrr_args_hipDeviceGraphMemTrim a{};
    a.ret         = static_cast<int32_t>(r);
    a.device = static_cast<decltype(a.device)>(device);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVICEGRAPHMEMTRIM, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDevicePrimaryCtxGetState(hipDevice_t dev, unsigned int* flags, int* active) {
  hipError_t r = g_real_table.hipDevicePrimaryCtxGetState_fn(dev, flags, active);
  if (r == hipSuccess) {
    hrr_args_hipDevicePrimaryCtxGetState a{};
    a.ret         = static_cast<int32_t>(r);
    a.dev = static_cast<uint64_t>(static_cast<int>(dev));
    a.flags = reinterpret_cast<uint64_t>(flags);
    a.active = reinterpret_cast<uint64_t>(active);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVICEPRIMARYCTXGETSTATE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDevicePrimaryCtxRelease(hipDevice_t dev) {
  hipError_t r = g_real_table.hipDevicePrimaryCtxRelease_fn(dev);
  if (r == hipSuccess) {
    hrr_args_hipDevicePrimaryCtxRelease a{};
    a.ret         = static_cast<int32_t>(r);
    a.dev = static_cast<uint64_t>(static_cast<int>(dev));
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVICEPRIMARYCTXRELEASE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDevicePrimaryCtxReset(hipDevice_t dev) {
  hipError_t r = g_real_table.hipDevicePrimaryCtxReset_fn(dev);
  if (r == hipSuccess) {
    hrr_args_hipDevicePrimaryCtxReset a{};
    a.ret         = static_cast<int32_t>(r);
    a.dev = static_cast<uint64_t>(static_cast<int>(dev));
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVICEPRIMARYCTXRESET, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDevicePrimaryCtxRetain(hipCtx_t* pctx, hipDevice_t dev) {
  hipError_t r = g_real_table.hipDevicePrimaryCtxRetain_fn(pctx, dev);
  if (r == hipSuccess) {
    hrr_args_hipDevicePrimaryCtxRetain a{};
    a.ret         = static_cast<int32_t>(r);
    a.dev = static_cast<uint64_t>(static_cast<int>(dev));
    if (pctx) a.pctx = reinterpret_cast<uint64_t>(*pctx);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVICEPRIMARYCTXRETAIN, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDevicePrimaryCtxSetFlags(hipDevice_t dev, unsigned int flags) {
  hipError_t r = g_real_table.hipDevicePrimaryCtxSetFlags_fn(dev, flags);
  if (r == hipSuccess) {
    hrr_args_hipDevicePrimaryCtxSetFlags a{};
    a.ret         = static_cast<int32_t>(r);
    a.dev = static_cast<uint64_t>(static_cast<int>(dev));
    a.flags = static_cast<decltype(a.flags)>(flags);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVICEPRIMARYCTXSETFLAGS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDeviceReset(void) {
  hipError_t r = g_real_table.hipDeviceReset_fn();
  if (r == hipSuccess) {
    hrr_args_hipDeviceReset a{};
    a.ret         = static_cast<int32_t>(r);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVICERESET, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDeviceSetCacheConfig(hipFuncCache_t cacheConfig) {
  hipError_t r = g_real_table.hipDeviceSetCacheConfig_fn(cacheConfig);
  if (r == hipSuccess) {
    hrr_args_hipDeviceSetCacheConfig a{};
    a.ret         = static_cast<int32_t>(r);
    a.cacheConfig = static_cast<decltype(a.cacheConfig)>(cacheConfig);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVICESETCACHECONFIG, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDeviceSetGraphMemAttribute(int device, hipGraphMemAttributeType attr, void* value) {
  hipError_t r = g_real_table.hipDeviceSetGraphMemAttribute_fn(device, attr, value);
  if (r == hipSuccess) {
    hrr_args_hipDeviceSetGraphMemAttribute a{};
    a.ret         = static_cast<int32_t>(r);
    a.device = static_cast<decltype(a.device)>(device);
    a.attr = static_cast<decltype(a.attr)>(attr);
    a.value = reinterpret_cast<uint64_t>(value);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVICESETGRAPHMEMATTRIBUTE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDeviceSetLimit(enum hipLimit_t limit, size_t value) {
  hipError_t r = g_real_table.hipDeviceSetLimit_fn(limit, value);
  if (r == hipSuccess) {
    hrr_args_hipDeviceSetLimit a{};
    a.ret         = static_cast<int32_t>(r);
    a.limit = static_cast<decltype(a.limit)>(limit);
    a.value = static_cast<decltype(a.value)>(value);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVICESETLIMIT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDeviceSetMemPool(int device, hipMemPool_t mem_pool) {
  hipError_t r = g_real_table.hipDeviceSetMemPool_fn(device, mem_pool);
  if (r == hipSuccess) {
    hrr_args_hipDeviceSetMemPool a{};
    a.ret         = static_cast<int32_t>(r);
    a.device = static_cast<decltype(a.device)>(device);
    a.mem_pool = reinterpret_cast<uint64_t>(mem_pool);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVICESETMEMPOOL, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDeviceSetSharedMemConfig(hipSharedMemConfig config) {
  hipError_t r = g_real_table.hipDeviceSetSharedMemConfig_fn(config);
  if (r == hipSuccess) {
    hrr_args_hipDeviceSetSharedMemConfig a{};
    a.ret         = static_cast<int32_t>(r);
    a.config = static_cast<decltype(a.config)>(config);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVICESETSHAREDMEMCONFIG, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDeviceSynchronize(void) {
  hipError_t r = g_real_table.hipDeviceSynchronize_fn();
  if (r == hipSuccess) {
    hrr_args_hipDeviceSynchronize a{};
    a.ret         = static_cast<int32_t>(r);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVICESYNCHRONIZE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDeviceTotalMem(size_t* bytes, hipDevice_t device) {
  hipError_t r = g_real_table.hipDeviceTotalMem_fn(bytes, device);
  if (r == hipSuccess) {
    hrr_args_hipDeviceTotalMem a{};
    a.ret         = static_cast<int32_t>(r);
    a.bytes = reinterpret_cast<uint64_t>(bytes);
    a.device = static_cast<uint64_t>(static_cast<int>(device));
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVICETOTALMEM, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDriverGetVersion(int* driverVersion) {
  hipError_t r = g_real_table.hipDriverGetVersion_fn(driverVersion);
  if (r == hipSuccess) {
    hrr_args_hipDriverGetVersion a{};
    a.ret         = static_cast<int32_t>(r);
    a.driverVersion = reinterpret_cast<uint64_t>(driverVersion);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDRIVERGETVERSION, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDrvGetErrorName(hipError_t hipError, const char** errorString) {
  hipError_t r = g_real_table.hipDrvGetErrorName_fn(hipError, errorString);
  if (r == hipSuccess) {
    hrr_args_hipDrvGetErrorName a{};
    a.ret         = static_cast<int32_t>(r);
    a.hipError = static_cast<decltype(a.hipError)>(hipError);
    if (errorString) a.errorString = reinterpret_cast<uint64_t>(*errorString);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDRVGETERRORNAME, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDrvGetErrorString(hipError_t hipError, const char** errorString) {
  hipError_t r = g_real_table.hipDrvGetErrorString_fn(hipError, errorString);
  if (r == hipSuccess) {
    hrr_args_hipDrvGetErrorString a{};
    a.ret         = static_cast<int32_t>(r);
    a.hipError = static_cast<decltype(a.hipError)>(hipError);
    if (errorString) a.errorString = reinterpret_cast<uint64_t>(*errorString);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDRVGETERRORSTRING, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDrvGraphAddMemcpyNode(hipGraphNode_t* phGraphNode, hipGraph_t hGraph, const hipGraphNode_t* dependencies, size_t numDependencies, const HIP_MEMCPY3D* copyParams, hipCtx_t ctx) {
  hipError_t r = g_real_table.hipDrvGraphAddMemcpyNode_fn(phGraphNode, hGraph, dependencies, numDependencies, copyParams, ctx);
  if (r == hipSuccess) {
    hrr_args_hipDrvGraphAddMemcpyNode a{};
    a.ret         = static_cast<int32_t>(r);
    a.hGraph = reinterpret_cast<uint64_t>(hGraph);
    a.numDependencies = static_cast<decltype(a.numDependencies)>(numDependencies);
    a.copyParams = reinterpret_cast<uint64_t>(copyParams);
    a.ctx = reinterpret_cast<uint64_t>(ctx);
    if (phGraphNode) a.phGraphNode = reinterpret_cast<uint64_t>(*phGraphNode);
    if (dependencies) a.dependencies = reinterpret_cast<uint64_t>(*dependencies);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDRVGRAPHADDMEMCPYNODE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDrvMemcpy2DUnaligned(const hip_Memcpy2D* pCopy) {
  hipError_t r = g_real_table.hipDrvMemcpy2DUnaligned_fn(pCopy);
  if (r == hipSuccess) {
    hrr_args_hipDrvMemcpy2DUnaligned a{};
    a.ret         = static_cast<int32_t>(r);
    a.pCopy = reinterpret_cast<uint64_t>(pCopy);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDRVMEMCPY2DUNALIGNED, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDrvMemcpy3D(const HIP_MEMCPY3D* pCopy) {
  hipError_t r = g_real_table.hipDrvMemcpy3D_fn(pCopy);
  if (r == hipSuccess) {
    hrr_args_hipDrvMemcpy3D a{};
    a.ret         = static_cast<int32_t>(r);
    a.pCopy = reinterpret_cast<uint64_t>(pCopy);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDRVMEMCPY3D, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDrvMemcpy3DAsync(const HIP_MEMCPY3D* pCopy, hipStream_t stream) {
  hipError_t r = g_real_table.hipDrvMemcpy3DAsync_fn(pCopy, stream);
  if (r == hipSuccess) {
    hrr_args_hipDrvMemcpy3DAsync a{};
    a.ret         = static_cast<int32_t>(r);
    a.pCopy = reinterpret_cast<uint64_t>(pCopy);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDRVMEMCPY3DASYNC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDrvPointerGetAttributes(unsigned int numAttributes, hipPointer_attribute* attributes, void** data, hipDeviceptr_t ptr) {
  hipError_t r = g_real_table.hipDrvPointerGetAttributes_fn(numAttributes, attributes, data, ptr);
  if (r == hipSuccess) {
    hrr_args_hipDrvPointerGetAttributes a{};
    a.ret         = static_cast<int32_t>(r);
    a.numAttributes = static_cast<decltype(a.numAttributes)>(numAttributes);
    a.attributes = reinterpret_cast<uint64_t>(attributes);
    a.ptr = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(ptr));
    if (data) a.data = reinterpret_cast<uint64_t>(*data);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDRVPOINTERGETATTRIBUTES, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipEventCreate(hipEvent_t* event) {
  hipError_t r = g_real_table.hipEventCreate_fn(event);
  if (r == hipSuccess) {
    hrr_args_hipEventCreate a{};
    a.ret         = static_cast<int32_t>(r);
    if (event) a.event = reinterpret_cast<uint64_t>(*event);
    hrr_cap::writer::write_event_raw(HRR_API_HIPEVENTCREATE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipEventCreateWithFlags(hipEvent_t* event, unsigned flags) {
  hipError_t r = g_real_table.hipEventCreateWithFlags_fn(event, flags);
  if (r == hipSuccess) {
    hrr_args_hipEventCreateWithFlags a{};
    a.ret         = static_cast<int32_t>(r);
    a.flags = static_cast<decltype(a.flags)>(flags);
    if (event) a.event = reinterpret_cast<uint64_t>(*event);
    hrr_cap::writer::write_event_raw(HRR_API_HIPEVENTCREATEWITHFLAGS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipEventDestroy(hipEvent_t event) {
  hipError_t r = g_real_table.hipEventDestroy_fn(event);
  if (r == hipSuccess) {
    hrr_args_hipEventDestroy a{};
    a.ret         = static_cast<int32_t>(r);
    a.event = reinterpret_cast<uint64_t>(event);
    hrr_cap::writer::write_event_raw(HRR_API_HIPEVENTDESTROY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipEventElapsedTime(float* ms, hipEvent_t start, hipEvent_t stop) {
  hipError_t r = g_real_table.hipEventElapsedTime_fn(ms, start, stop);
  if (r == hipSuccess) {
    hrr_args_hipEventElapsedTime a{};
    a.ret         = static_cast<int32_t>(r);
    a.ms = reinterpret_cast<uint64_t>(ms);
    a.start = reinterpret_cast<uint64_t>(start);
    a.stop = reinterpret_cast<uint64_t>(stop);
    hrr_cap::writer::write_event_raw(HRR_API_HIPEVENTELAPSEDTIME, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipEventQuery(hipEvent_t event) {
  hipError_t r = g_real_table.hipEventQuery_fn(event);
  if (r == hipSuccess) {
    hrr_args_hipEventQuery a{};
    a.ret         = static_cast<int32_t>(r);
    a.event = reinterpret_cast<uint64_t>(event);
    hrr_cap::writer::write_event_raw(HRR_API_HIPEVENTQUERY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipEventRecord(hipEvent_t event, hipStream_t stream) {
  hipError_t r = g_real_table.hipEventRecord_fn(event, stream);
  if (r == hipSuccess) {
    hrr_args_hipEventRecord a{};
    a.ret         = static_cast<int32_t>(r);
    a.event = reinterpret_cast<uint64_t>(event);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPEVENTRECORD, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipEventSynchronize(hipEvent_t event) {
  hipError_t r = g_real_table.hipEventSynchronize_fn(event);
  if (r == hipSuccess) {
    hrr_args_hipEventSynchronize a{};
    a.ret         = static_cast<int32_t>(r);
    a.event = reinterpret_cast<uint64_t>(event);
    hrr_cap::writer::write_event_raw(HRR_API_HIPEVENTSYNCHRONIZE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipExtGetLinkTypeAndHopCount(int device1, int device2, uint32_t* linktype, uint32_t* hopcount) {
  hipError_t r = g_real_table.hipExtGetLinkTypeAndHopCount_fn(device1, device2, linktype, hopcount);
  if (r == hipSuccess) {
    hrr_args_hipExtGetLinkTypeAndHopCount a{};
    a.ret         = static_cast<int32_t>(r);
    a.device1 = static_cast<decltype(a.device1)>(device1);
    a.device2 = static_cast<decltype(a.device2)>(device2);
    a.linktype = reinterpret_cast<uint64_t>(linktype);
    a.hopcount = reinterpret_cast<uint64_t>(hopcount);
    hrr_cap::writer::write_event_raw(HRR_API_HIPEXTGETLINKTYPEANDHOPCOUNT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipExtLaunchKernel(const void* function_address, dim3 numBlocks, dim3 dimBlocks, void** args, size_t sharedMemBytes, hipStream_t stream, hipEvent_t startEvent, hipEvent_t stopEvent, int flags) {
  hipError_t r = g_real_table.hipExtLaunchKernel_fn(function_address, numBlocks, dimBlocks, args, sharedMemBytes, stream, startEvent, stopEvent, flags);
  if (r == hipSuccess) {
    hrr_args_hipExtLaunchKernel a{};
    a.ret         = static_cast<int32_t>(r);
    a.function_address = reinterpret_cast<uint64_t>(function_address);
    a.numBlocks_x = numBlocks.x;
    a.numBlocks_y = numBlocks.y;
    a.numBlocks_z = numBlocks.z;
    a.dimBlocks_x = dimBlocks.x;
    a.dimBlocks_y = dimBlocks.y;
    a.dimBlocks_z = dimBlocks.z;
    a.sharedMemBytes = static_cast<decltype(a.sharedMemBytes)>(sharedMemBytes);
    a.stream = reinterpret_cast<uint64_t>(stream);
    a.startEvent = reinterpret_cast<uint64_t>(startEvent);
    a.stopEvent = reinterpret_cast<uint64_t>(stopEvent);
    a.flags = static_cast<decltype(a.flags)>(flags);
    if (args) a.args = reinterpret_cast<uint64_t>(*args);
    hrr_cap::writer::write_event_raw(HRR_API_HIPEXTLAUNCHKERNEL, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipExtLaunchMultiKernelMultiDevice(hipLaunchParams* launchParamsList, int numDevices, unsigned int flags) {
  hipError_t r = g_real_table.hipExtLaunchMultiKernelMultiDevice_fn(launchParamsList, numDevices, flags);
  if (r == hipSuccess) {
    hrr_args_hipExtLaunchMultiKernelMultiDevice a{};
    a.ret         = static_cast<int32_t>(r);
    a.launchParamsList = reinterpret_cast<uint64_t>(launchParamsList);
    a.numDevices = static_cast<decltype(a.numDevices)>(numDevices);
    a.flags = static_cast<decltype(a.flags)>(flags);
    hrr_cap::writer::write_event_raw(HRR_API_HIPEXTLAUNCHMULTIKERNELMULTIDEVICE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipExtMallocWithFlags(void** ptr, size_t sizeBytes, unsigned int flags) {
  hipError_t r = g_real_table.hipExtMallocWithFlags_fn(ptr, sizeBytes, flags);
  if (r == hipSuccess) {
    hrr_args_hipExtMallocWithFlags a{};
    a.ret         = static_cast<int32_t>(r);
    a.sizeBytes = static_cast<decltype(a.sizeBytes)>(sizeBytes);
    a.flags = static_cast<decltype(a.flags)>(flags);
    if (ptr) a.ptr = reinterpret_cast<uint64_t>(*ptr);
    hrr_cap::writer::write_event_raw(HRR_API_HIPEXTMALLOCWITHFLAGS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipExtStreamCreateWithCUMask(hipStream_t* stream, uint32_t cuMaskSize, const uint32_t* cuMask) {
  hipError_t r = g_real_table.hipExtStreamCreateWithCUMask_fn(stream, cuMaskSize, cuMask);
  if (r == hipSuccess) {
    hrr_args_hipExtStreamCreateWithCUMask a{};
    a.ret         = static_cast<int32_t>(r);
    a.cuMaskSize = static_cast<decltype(a.cuMaskSize)>(cuMaskSize);
    a.cuMask = reinterpret_cast<uint64_t>(cuMask);
    if (stream) a.stream = reinterpret_cast<uint64_t>(*stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPEXTSTREAMCREATEWITHCUMASK, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipExtStreamGetCUMask(hipStream_t stream, uint32_t cuMaskSize, uint32_t* cuMask) {
  hipError_t r = g_real_table.hipExtStreamGetCUMask_fn(stream, cuMaskSize, cuMask);
  if (r == hipSuccess) {
    hrr_args_hipExtStreamGetCUMask a{};
    a.ret         = static_cast<int32_t>(r);
    a.stream = reinterpret_cast<uint64_t>(stream);
    a.cuMaskSize = static_cast<decltype(a.cuMaskSize)>(cuMaskSize);
    a.cuMask = reinterpret_cast<uint64_t>(cuMask);
    hrr_cap::writer::write_event_raw(HRR_API_HIPEXTSTREAMGETCUMASK, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipExternalMemoryGetMappedBuffer(void** devPtr, hipExternalMemory_t extMem, const hipExternalMemoryBufferDesc* bufferDesc) {
  hipError_t r = g_real_table.hipExternalMemoryGetMappedBuffer_fn(devPtr, extMem, bufferDesc);
  if (r == hipSuccess) {
    hrr_args_hipExternalMemoryGetMappedBuffer a{};
    a.ret         = static_cast<int32_t>(r);
    a.extMem = reinterpret_cast<uint64_t>(extMem);
    a.bufferDesc = reinterpret_cast<uint64_t>(bufferDesc);
    if (devPtr) a.devPtr = reinterpret_cast<uint64_t>(*devPtr);
    hrr_cap::writer::write_event_raw(HRR_API_HIPEXTERNALMEMORYGETMAPPEDBUFFER, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipFree(void* ptr) {
  hipError_t r = g_real_table.hipFree_fn(ptr);
  if (r == hipSuccess) {
    hrr_args_hipFree a{};
    a.ret         = static_cast<int32_t>(r);
    a.ptr = reinterpret_cast<uint64_t>(ptr);
    hrr_cap::writer::write_event_raw(HRR_API_HIPFREE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipFreeArray(hipArray_t array) {
  hipError_t r = g_real_table.hipFreeArray_fn(array);
  if (r == hipSuccess) {
    hrr_args_hipFreeArray a{};
    a.ret         = static_cast<int32_t>(r);
    a.array = reinterpret_cast<uint64_t>(array);
    hrr_cap::writer::write_event_raw(HRR_API_HIPFREEARRAY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipFreeAsync(void* dev_ptr, hipStream_t stream) {
  hipError_t r = g_real_table.hipFreeAsync_fn(dev_ptr, stream);
  if (r == hipSuccess) {
    hrr_args_hipFreeAsync a{};
    a.ret         = static_cast<int32_t>(r);
    a.dev_ptr = reinterpret_cast<uint64_t>(dev_ptr);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPFREEASYNC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipFreeHost(void* ptr) {
  hipError_t r = g_real_table.hipFreeHost_fn(ptr);
  if (r == hipSuccess) {
    hrr_args_hipFreeHost a{};
    a.ret         = static_cast<int32_t>(r);
    a.ptr = reinterpret_cast<uint64_t>(ptr);
    hrr_cap::writer::write_event_raw(HRR_API_HIPFREEHOST, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipFreeMipmappedArray(hipMipmappedArray_t mipmappedArray) {
  hipError_t r = g_real_table.hipFreeMipmappedArray_fn(mipmappedArray);
  if (r == hipSuccess) {
    hrr_args_hipFreeMipmappedArray a{};
    a.ret         = static_cast<int32_t>(r);
    a.mipmappedArray = reinterpret_cast<uint64_t>(mipmappedArray);
    hrr_cap::writer::write_event_raw(HRR_API_HIPFREEMIPMAPPEDARRAY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipFuncGetAttribute(int* value, hipFunction_attribute attrib, hipFunction_t hfunc) {
  hipError_t r = g_real_table.hipFuncGetAttribute_fn(value, attrib, hfunc);
  if (r == hipSuccess) {
    hrr_args_hipFuncGetAttribute a{};
    a.ret         = static_cast<int32_t>(r);
    a.value = reinterpret_cast<uint64_t>(value);
    a.attrib = static_cast<decltype(a.attrib)>(attrib);
    a.hfunc = reinterpret_cast<uint64_t>(hfunc);
    hrr_cap::writer::write_event_raw(HRR_API_HIPFUNCGETATTRIBUTE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipFuncGetAttributes(struct hipFuncAttributes* attr, const void* func) {
  hipError_t r = g_real_table.hipFuncGetAttributes_fn(attr, func);
  if (r == hipSuccess) {
    hrr_args_hipFuncGetAttributes a{};
    a.ret         = static_cast<int32_t>(r);
    a.attr = reinterpret_cast<uint64_t>(attr);
    a.func = reinterpret_cast<uint64_t>(func);
    hrr_cap::writer::write_event_raw(HRR_API_HIPFUNCGETATTRIBUTES, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipFuncSetAttribute(const void* func, hipFuncAttribute attr, int value) {
  hipError_t r = g_real_table.hipFuncSetAttribute_fn(func, attr, value);
  if (r == hipSuccess) {
    hrr_args_hipFuncSetAttribute a{};
    a.ret         = static_cast<int32_t>(r);
    a.func = reinterpret_cast<uint64_t>(func);
    a.attr = static_cast<decltype(a.attr)>(attr);
    a.value = static_cast<decltype(a.value)>(value);
    hrr_cap::writer::write_event_raw(HRR_API_HIPFUNCSETATTRIBUTE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipFuncSetCacheConfig(const void* func, hipFuncCache_t config) {
  hipError_t r = g_real_table.hipFuncSetCacheConfig_fn(func, config);
  if (r == hipSuccess) {
    hrr_args_hipFuncSetCacheConfig a{};
    a.ret         = static_cast<int32_t>(r);
    a.func = reinterpret_cast<uint64_t>(func);
    a.config = static_cast<decltype(a.config)>(config);
    hrr_cap::writer::write_event_raw(HRR_API_HIPFUNCSETCACHECONFIG, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipFuncSetSharedMemConfig(const void* func, hipSharedMemConfig config) {
  hipError_t r = g_real_table.hipFuncSetSharedMemConfig_fn(func, config);
  if (r == hipSuccess) {
    hrr_args_hipFuncSetSharedMemConfig a{};
    a.ret         = static_cast<int32_t>(r);
    a.func = reinterpret_cast<uint64_t>(func);
    a.config = static_cast<decltype(a.config)>(config);
    hrr_cap::writer::write_event_raw(HRR_API_HIPFUNCSETSHAREDMEMCONFIG, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGLGetDevices(unsigned int* pHipDeviceCount, int* pHipDevices, unsigned int hipDeviceCount, hipGLDeviceList deviceList) {
  hipError_t r = g_real_table.hipGLGetDevices_fn(pHipDeviceCount, pHipDevices, hipDeviceCount, deviceList);
  if (r == hipSuccess) {
    hrr_args_hipGLGetDevices a{};
    a.ret         = static_cast<int32_t>(r);
    a.pHipDeviceCount = reinterpret_cast<uint64_t>(pHipDeviceCount);
    a.pHipDevices = reinterpret_cast<uint64_t>(pHipDevices);
    a.hipDeviceCount = static_cast<decltype(a.hipDeviceCount)>(hipDeviceCount);
    a.deviceList = static_cast<decltype(a.deviceList)>(deviceList);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGLGETDEVICES, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGetChannelDesc(hipChannelFormatDesc* desc, hipArray_const_t array) {
  hipError_t r = g_real_table.hipGetChannelDesc_fn(desc, array);
  if (r == hipSuccess) {
    hrr_args_hipGetChannelDesc a{};
    a.ret         = static_cast<int32_t>(r);
    a.desc = 0;  // non-castable type skipped
    a.array = reinterpret_cast<uint64_t>(array);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGETCHANNELDESC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGetDevice(int* deviceId) {
  hipError_t r = g_real_table.hipGetDevice_fn(deviceId);
  if (r == hipSuccess) {
    hrr_args_hipGetDevice a{};
    a.ret         = static_cast<int32_t>(r);
    a.deviceId = reinterpret_cast<uint64_t>(deviceId);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGETDEVICE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGetDeviceCount(int* count) {
  hipError_t r = g_real_table.hipGetDeviceCount_fn(count);
  if (r == hipSuccess) {
    hrr_args_hipGetDeviceCount a{};
    a.ret         = static_cast<int32_t>(r);
    a.count = reinterpret_cast<uint64_t>(count);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGETDEVICECOUNT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGetDeviceFlags(unsigned int* flags) {
  hipError_t r = g_real_table.hipGetDeviceFlags_fn(flags);
  if (r == hipSuccess) {
    hrr_args_hipGetDeviceFlags a{};
    a.ret         = static_cast<int32_t>(r);
    a.flags = reinterpret_cast<uint64_t>(flags);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGETDEVICEFLAGS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGetDevicePropertiesR0600(hipDeviceProp_tR0600* prop, int device) {
  hipError_t r = g_real_table.hipGetDevicePropertiesR0600_fn(prop, device);
  if (r == hipSuccess) {
    hrr_args_hipGetDevicePropertiesR0600 a{};
    a.ret         = static_cast<int32_t>(r);
    a.prop = reinterpret_cast<uint64_t>(prop);
    a.device = static_cast<decltype(a.device)>(device);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGETDEVICEPROPERTIESR0600, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGetDevicePropertiesR0000(hipDeviceProp_tR0000* prop, int device) {
  hipError_t r = g_real_table.hipGetDevicePropertiesR0000_fn(prop, device);
  if (r == hipSuccess) {
    hrr_args_hipGetDevicePropertiesR0000 a{};
    a.ret         = static_cast<int32_t>(r);
    a.prop = reinterpret_cast<uint64_t>(prop);
    a.device = static_cast<decltype(a.device)>(device);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGETDEVICEPROPERTIESR0000, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static const char* capture_hipGetErrorName(hipError_t hip_error) {
  const char* r = g_real_table.hipGetErrorName_fn(hip_error);
  {
    hrr_args_hipGetErrorName a{};
    a.ret = reinterpret_cast<uint64_t>(r);
    a.hip_error = static_cast<decltype(a.hip_error)>(hip_error);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGETERRORNAME, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static const char* capture_hipGetErrorString(hipError_t hipError) {
  const char* r = g_real_table.hipGetErrorString_fn(hipError);
  {
    hrr_args_hipGetErrorString a{};
    a.ret = reinterpret_cast<uint64_t>(r);
    a.hipError = static_cast<decltype(a.hipError)>(hipError);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGETERRORSTRING, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGetLastError(void) {
  hipError_t r = g_real_table.hipGetLastError_fn();
  if (r == hipSuccess) {
    hrr_args_hipGetLastError a{};
    a.ret         = static_cast<int32_t>(r);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGETLASTERROR, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGetMipmappedArrayLevel(hipArray_t* levelArray, hipMipmappedArray_const_t mipmappedArray, unsigned int level) {
  hipError_t r = g_real_table.hipGetMipmappedArrayLevel_fn(levelArray, mipmappedArray, level);
  if (r == hipSuccess) {
    hrr_args_hipGetMipmappedArrayLevel a{};
    a.ret         = static_cast<int32_t>(r);
    a.mipmappedArray = reinterpret_cast<uint64_t>(mipmappedArray);
    a.level = static_cast<decltype(a.level)>(level);
    if (levelArray) a.levelArray = reinterpret_cast<uint64_t>(*levelArray);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGETMIPMAPPEDARRAYLEVEL, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGetSymbolAddress(void** devPtr, const void* symbol) {
  hipError_t r = g_real_table.hipGetSymbolAddress_fn(devPtr, symbol);
  if (r == hipSuccess) {
    hrr_args_hipGetSymbolAddress a{};
    a.ret         = static_cast<int32_t>(r);
    a.symbol = reinterpret_cast<uint64_t>(symbol);
    if (devPtr) a.devPtr = reinterpret_cast<uint64_t>(*devPtr);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGETSYMBOLADDRESS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGetSymbolSize(size_t* size, const void* symbol) {
  hipError_t r = g_real_table.hipGetSymbolSize_fn(size, symbol);
  if (r == hipSuccess) {
    hrr_args_hipGetSymbolSize a{};
    a.ret         = static_cast<int32_t>(r);
    a.size = reinterpret_cast<uint64_t>(size);
    a.symbol = reinterpret_cast<uint64_t>(symbol);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGETSYMBOLSIZE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGetTextureAlignmentOffset(size_t* offset, const textureReference* texref) {
  hipError_t r = g_real_table.hipGetTextureAlignmentOffset_fn(offset, texref);
  if (r == hipSuccess) {
    hrr_args_hipGetTextureAlignmentOffset a{};
    a.ret         = static_cast<int32_t>(r);
    a.offset = reinterpret_cast<uint64_t>(offset);
    a.texref = reinterpret_cast<uint64_t>(texref);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGETTEXTUREALIGNMENTOFFSET, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGetTextureObjectResourceDesc(hipResourceDesc* pResDesc, hipTextureObject_t textureObject) {
  hipError_t r = g_real_table.hipGetTextureObjectResourceDesc_fn(pResDesc, textureObject);
  if (r == hipSuccess) {
    hrr_args_hipGetTextureObjectResourceDesc a{};
    a.ret         = static_cast<int32_t>(r);
    a.pResDesc = reinterpret_cast<uint64_t>(pResDesc);
    a.textureObject = reinterpret_cast<uint64_t>(textureObject);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGETTEXTUREOBJECTRESOURCEDESC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGetTextureObjectResourceViewDesc(struct hipResourceViewDesc* pResViewDesc, hipTextureObject_t textureObject) {
  hipError_t r = g_real_table.hipGetTextureObjectResourceViewDesc_fn(pResViewDesc, textureObject);
  if (r == hipSuccess) {
    hrr_args_hipGetTextureObjectResourceViewDesc a{};
    a.ret         = static_cast<int32_t>(r);
    a.pResViewDesc = reinterpret_cast<uint64_t>(pResViewDesc);
    a.textureObject = reinterpret_cast<uint64_t>(textureObject);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGETTEXTUREOBJECTRESOURCEVIEWDESC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGetTextureObjectTextureDesc(hipTextureDesc* pTexDesc, hipTextureObject_t textureObject) {
  hipError_t r = g_real_table.hipGetTextureObjectTextureDesc_fn(pTexDesc, textureObject);
  if (r == hipSuccess) {
    hrr_args_hipGetTextureObjectTextureDesc a{};
    a.ret         = static_cast<int32_t>(r);
    a.pTexDesc = reinterpret_cast<uint64_t>(pTexDesc);
    a.textureObject = reinterpret_cast<uint64_t>(textureObject);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGETTEXTUREOBJECTTEXTUREDESC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGetTextureReference(const textureReference** texref, const void* symbol) {
  hipError_t r = g_real_table.hipGetTextureReference_fn(texref, symbol);
  if (r == hipSuccess) {
    hrr_args_hipGetTextureReference a{};
    a.ret         = static_cast<int32_t>(r);
    a.symbol = reinterpret_cast<uint64_t>(symbol);
    if (texref) a.texref = reinterpret_cast<uint64_t>(*texref);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGETTEXTUREREFERENCE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphAddChildGraphNode(hipGraphNode_t* pGraphNode, hipGraph_t graph, const hipGraphNode_t* pDependencies, size_t numDependencies, hipGraph_t childGraph) {
  hipError_t r = g_real_table.hipGraphAddChildGraphNode_fn(pGraphNode, graph, pDependencies, numDependencies, childGraph);
  if (r == hipSuccess) {
    hrr_args_hipGraphAddChildGraphNode a{};
    a.ret         = static_cast<int32_t>(r);
    a.graph = reinterpret_cast<uint64_t>(graph);
    a.numDependencies = static_cast<decltype(a.numDependencies)>(numDependencies);
    a.childGraph = reinterpret_cast<uint64_t>(childGraph);
    if (pGraphNode) a.pGraphNode = reinterpret_cast<uint64_t>(*pGraphNode);
    if (pDependencies) a.pDependencies = reinterpret_cast<uint64_t>(*pDependencies);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHADDCHILDGRAPHNODE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphAddDependencies(hipGraph_t graph, const hipGraphNode_t* from, const hipGraphNode_t* to, size_t numDependencies) {
  hipError_t r = g_real_table.hipGraphAddDependencies_fn(graph, from, to, numDependencies);
  if (r == hipSuccess) {
    hrr_args_hipGraphAddDependencies a{};
    a.ret         = static_cast<int32_t>(r);
    a.graph = reinterpret_cast<uint64_t>(graph);
    a.numDependencies = static_cast<decltype(a.numDependencies)>(numDependencies);
    if (from) a.from = reinterpret_cast<uint64_t>(*from);
    if (to) a.to = reinterpret_cast<uint64_t>(*to);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHADDDEPENDENCIES, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphAddEmptyNode(hipGraphNode_t* pGraphNode, hipGraph_t graph, const hipGraphNode_t* pDependencies, size_t numDependencies) {
  hipError_t r = g_real_table.hipGraphAddEmptyNode_fn(pGraphNode, graph, pDependencies, numDependencies);
  if (r == hipSuccess) {
    hrr_args_hipGraphAddEmptyNode a{};
    a.ret         = static_cast<int32_t>(r);
    a.graph = reinterpret_cast<uint64_t>(graph);
    a.numDependencies = static_cast<decltype(a.numDependencies)>(numDependencies);
    if (pGraphNode) a.pGraphNode = reinterpret_cast<uint64_t>(*pGraphNode);
    if (pDependencies) a.pDependencies = reinterpret_cast<uint64_t>(*pDependencies);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHADDEMPTYNODE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphAddEventRecordNode(hipGraphNode_t* pGraphNode, hipGraph_t graph, const hipGraphNode_t* pDependencies, size_t numDependencies, hipEvent_t event) {
  hipError_t r = g_real_table.hipGraphAddEventRecordNode_fn(pGraphNode, graph, pDependencies, numDependencies, event);
  if (r == hipSuccess) {
    hrr_args_hipGraphAddEventRecordNode a{};
    a.ret         = static_cast<int32_t>(r);
    a.graph = reinterpret_cast<uint64_t>(graph);
    a.numDependencies = static_cast<decltype(a.numDependencies)>(numDependencies);
    a.event = reinterpret_cast<uint64_t>(event);
    if (pGraphNode) a.pGraphNode = reinterpret_cast<uint64_t>(*pGraphNode);
    if (pDependencies) a.pDependencies = reinterpret_cast<uint64_t>(*pDependencies);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHADDEVENTRECORDNODE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphAddEventWaitNode(hipGraphNode_t* pGraphNode, hipGraph_t graph, const hipGraphNode_t* pDependencies, size_t numDependencies, hipEvent_t event) {
  hipError_t r = g_real_table.hipGraphAddEventWaitNode_fn(pGraphNode, graph, pDependencies, numDependencies, event);
  if (r == hipSuccess) {
    hrr_args_hipGraphAddEventWaitNode a{};
    a.ret         = static_cast<int32_t>(r);
    a.graph = reinterpret_cast<uint64_t>(graph);
    a.numDependencies = static_cast<decltype(a.numDependencies)>(numDependencies);
    a.event = reinterpret_cast<uint64_t>(event);
    if (pGraphNode) a.pGraphNode = reinterpret_cast<uint64_t>(*pGraphNode);
    if (pDependencies) a.pDependencies = reinterpret_cast<uint64_t>(*pDependencies);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHADDEVENTWAITNODE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphAddHostNode(hipGraphNode_t* pGraphNode, hipGraph_t graph, const hipGraphNode_t* pDependencies, size_t numDependencies, const hipHostNodeParams* pNodeParams) {
  hipError_t r = g_real_table.hipGraphAddHostNode_fn(pGraphNode, graph, pDependencies, numDependencies, pNodeParams);
  if (r == hipSuccess) {
    hrr_args_hipGraphAddHostNode a{};
    a.ret         = static_cast<int32_t>(r);
    a.graph = reinterpret_cast<uint64_t>(graph);
    a.numDependencies = static_cast<decltype(a.numDependencies)>(numDependencies);
    a.pNodeParams = reinterpret_cast<uint64_t>(pNodeParams);
    if (pGraphNode) a.pGraphNode = reinterpret_cast<uint64_t>(*pGraphNode);
    if (pDependencies) a.pDependencies = reinterpret_cast<uint64_t>(*pDependencies);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHADDHOSTNODE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphAddKernelNode(hipGraphNode_t* pGraphNode, hipGraph_t graph, const hipGraphNode_t* pDependencies, size_t numDependencies, const hipKernelNodeParams* pNodeParams) {
  hipError_t r = g_real_table.hipGraphAddKernelNode_fn(pGraphNode, graph, pDependencies, numDependencies, pNodeParams);
  if (r == hipSuccess) {
    hrr_args_hipGraphAddKernelNode a{};
    a.ret         = static_cast<int32_t>(r);
    a.graph = reinterpret_cast<uint64_t>(graph);
    a.numDependencies = static_cast<decltype(a.numDependencies)>(numDependencies);
    a.pNodeParams = reinterpret_cast<uint64_t>(pNodeParams);
    if (pGraphNode) a.pGraphNode = reinterpret_cast<uint64_t>(*pGraphNode);
    if (pDependencies) a.pDependencies = reinterpret_cast<uint64_t>(*pDependencies);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHADDKERNELNODE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphAddMemAllocNode(hipGraphNode_t* pGraphNode, hipGraph_t graph, const hipGraphNode_t* pDependencies, size_t numDependencies, hipMemAllocNodeParams* pNodeParams) {
  hipError_t r = g_real_table.hipGraphAddMemAllocNode_fn(pGraphNode, graph, pDependencies, numDependencies, pNodeParams);
  if (r == hipSuccess) {
    hrr_args_hipGraphAddMemAllocNode a{};
    a.ret         = static_cast<int32_t>(r);
    a.graph = reinterpret_cast<uint64_t>(graph);
    a.numDependencies = static_cast<decltype(a.numDependencies)>(numDependencies);
    a.pNodeParams = reinterpret_cast<uint64_t>(pNodeParams);
    if (pGraphNode) a.pGraphNode = reinterpret_cast<uint64_t>(*pGraphNode);
    if (pDependencies) a.pDependencies = reinterpret_cast<uint64_t>(*pDependencies);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHADDMEMALLOCNODE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphAddMemFreeNode(hipGraphNode_t* pGraphNode, hipGraph_t graph, const hipGraphNode_t* pDependencies, size_t numDependencies, void* dev_ptr) {
  hipError_t r = g_real_table.hipGraphAddMemFreeNode_fn(pGraphNode, graph, pDependencies, numDependencies, dev_ptr);
  if (r == hipSuccess) {
    hrr_args_hipGraphAddMemFreeNode a{};
    a.ret         = static_cast<int32_t>(r);
    a.graph = reinterpret_cast<uint64_t>(graph);
    a.numDependencies = static_cast<decltype(a.numDependencies)>(numDependencies);
    a.dev_ptr = reinterpret_cast<uint64_t>(dev_ptr);
    if (pGraphNode) a.pGraphNode = reinterpret_cast<uint64_t>(*pGraphNode);
    if (pDependencies) a.pDependencies = reinterpret_cast<uint64_t>(*pDependencies);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHADDMEMFREENODE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphAddMemcpyNode(hipGraphNode_t* pGraphNode, hipGraph_t graph, const hipGraphNode_t* pDependencies, size_t numDependencies, const hipMemcpy3DParms* pCopyParams) {
  hipError_t r = g_real_table.hipGraphAddMemcpyNode_fn(pGraphNode, graph, pDependencies, numDependencies, pCopyParams);
  if (r == hipSuccess) {
    hrr_args_hipGraphAddMemcpyNode a{};
    a.ret         = static_cast<int32_t>(r);
    a.graph = reinterpret_cast<uint64_t>(graph);
    a.numDependencies = static_cast<decltype(a.numDependencies)>(numDependencies);
    a.pCopyParams = reinterpret_cast<uint64_t>(pCopyParams);
    if (pGraphNode) a.pGraphNode = reinterpret_cast<uint64_t>(*pGraphNode);
    if (pDependencies) a.pDependencies = reinterpret_cast<uint64_t>(*pDependencies);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHADDMEMCPYNODE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphAddMemcpyNode1D(hipGraphNode_t* pGraphNode, hipGraph_t graph, const hipGraphNode_t* pDependencies, size_t numDependencies, void* dst, const void* src, size_t count, hipMemcpyKind kind) {
  hipError_t r = g_real_table.hipGraphAddMemcpyNode1D_fn(pGraphNode, graph, pDependencies, numDependencies, dst, src, count, kind);
  if (r == hipSuccess) {
    hrr_args_hipGraphAddMemcpyNode1D a{};
    a.ret         = static_cast<int32_t>(r);
    a.graph = reinterpret_cast<uint64_t>(graph);
    a.numDependencies = static_cast<decltype(a.numDependencies)>(numDependencies);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.src = reinterpret_cast<uint64_t>(src);
    a.count = static_cast<decltype(a.count)>(count);
    a.kind = static_cast<decltype(a.kind)>(kind);
    if (pGraphNode) a.pGraphNode = reinterpret_cast<uint64_t>(*pGraphNode);
    if (pDependencies) a.pDependencies = reinterpret_cast<uint64_t>(*pDependencies);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHADDMEMCPYNODE1D, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphAddMemcpyNodeFromSymbol(hipGraphNode_t* pGraphNode, hipGraph_t graph, const hipGraphNode_t* pDependencies, size_t numDependencies, void* dst, const void* symbol, size_t count, size_t offset, hipMemcpyKind kind) {
  hipError_t r = g_real_table.hipGraphAddMemcpyNodeFromSymbol_fn(pGraphNode, graph, pDependencies, numDependencies, dst, symbol, count, offset, kind);
  if (r == hipSuccess) {
    hrr_args_hipGraphAddMemcpyNodeFromSymbol a{};
    a.ret         = static_cast<int32_t>(r);
    a.graph = reinterpret_cast<uint64_t>(graph);
    a.numDependencies = static_cast<decltype(a.numDependencies)>(numDependencies);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.symbol = reinterpret_cast<uint64_t>(symbol);
    a.count = static_cast<decltype(a.count)>(count);
    a.offset = static_cast<decltype(a.offset)>(offset);
    a.kind = static_cast<decltype(a.kind)>(kind);
    if (pGraphNode) a.pGraphNode = reinterpret_cast<uint64_t>(*pGraphNode);
    if (pDependencies) a.pDependencies = reinterpret_cast<uint64_t>(*pDependencies);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHADDMEMCPYNODEFROMSYMBOL, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphAddMemcpyNodeToSymbol(hipGraphNode_t* pGraphNode, hipGraph_t graph, const hipGraphNode_t* pDependencies, size_t numDependencies, const void* symbol, const void* src, size_t count, size_t offset, hipMemcpyKind kind) {
  hipError_t r = g_real_table.hipGraphAddMemcpyNodeToSymbol_fn(pGraphNode, graph, pDependencies, numDependencies, symbol, src, count, offset, kind);
  if (r == hipSuccess) {
    hrr_args_hipGraphAddMemcpyNodeToSymbol a{};
    a.ret         = static_cast<int32_t>(r);
    a.graph = reinterpret_cast<uint64_t>(graph);
    a.numDependencies = static_cast<decltype(a.numDependencies)>(numDependencies);
    a.symbol = reinterpret_cast<uint64_t>(symbol);
    a.src = reinterpret_cast<uint64_t>(src);
    a.count = static_cast<decltype(a.count)>(count);
    a.offset = static_cast<decltype(a.offset)>(offset);
    a.kind = static_cast<decltype(a.kind)>(kind);
    if (pGraphNode) a.pGraphNode = reinterpret_cast<uint64_t>(*pGraphNode);
    if (pDependencies) a.pDependencies = reinterpret_cast<uint64_t>(*pDependencies);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHADDMEMCPYNODETOSYMBOL, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphAddMemsetNode(hipGraphNode_t* pGraphNode, hipGraph_t graph, const hipGraphNode_t* pDependencies, size_t numDependencies, const hipMemsetParams* pMemsetParams) {
  hipError_t r = g_real_table.hipGraphAddMemsetNode_fn(pGraphNode, graph, pDependencies, numDependencies, pMemsetParams);
  if (r == hipSuccess) {
    hrr_args_hipGraphAddMemsetNode a{};
    a.ret         = static_cast<int32_t>(r);
    a.graph = reinterpret_cast<uint64_t>(graph);
    a.numDependencies = static_cast<decltype(a.numDependencies)>(numDependencies);
    a.pMemsetParams = reinterpret_cast<uint64_t>(pMemsetParams);
    if (pGraphNode) a.pGraphNode = reinterpret_cast<uint64_t>(*pGraphNode);
    if (pDependencies) a.pDependencies = reinterpret_cast<uint64_t>(*pDependencies);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHADDMEMSETNODE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphChildGraphNodeGetGraph(hipGraphNode_t node, hipGraph_t* pGraph) {
  hipError_t r = g_real_table.hipGraphChildGraphNodeGetGraph_fn(node, pGraph);
  if (r == hipSuccess) {
    hrr_args_hipGraphChildGraphNodeGetGraph a{};
    a.ret         = static_cast<int32_t>(r);
    a.node = reinterpret_cast<uint64_t>(node);
    if (pGraph) a.pGraph = reinterpret_cast<uint64_t>(*pGraph);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHCHILDGRAPHNODEGETGRAPH, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphClone(hipGraph_t* pGraphClone, hipGraph_t originalGraph) {
  hipError_t r = g_real_table.hipGraphClone_fn(pGraphClone, originalGraph);
  if (r == hipSuccess) {
    hrr_args_hipGraphClone a{};
    a.ret         = static_cast<int32_t>(r);
    a.originalGraph = reinterpret_cast<uint64_t>(originalGraph);
    if (pGraphClone) a.pGraphClone = reinterpret_cast<uint64_t>(*pGraphClone);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHCLONE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphCreate(hipGraph_t* pGraph, unsigned int flags) {
  hipError_t r = g_real_table.hipGraphCreate_fn(pGraph, flags);
  if (r == hipSuccess) {
    hrr_args_hipGraphCreate a{};
    a.ret         = static_cast<int32_t>(r);
    a.flags = static_cast<decltype(a.flags)>(flags);
    if (pGraph) a.pGraph = reinterpret_cast<uint64_t>(*pGraph);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHCREATE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphDebugDotPrint(hipGraph_t graph, const char* path, unsigned int flags) {
  hipError_t r = g_real_table.hipGraphDebugDotPrint_fn(graph, path, flags);
  if (r == hipSuccess) {
    hrr_args_hipGraphDebugDotPrint a{};
    a.ret         = static_cast<int32_t>(r);
    a.graph = reinterpret_cast<uint64_t>(graph);
    a.path = reinterpret_cast<uint64_t>(path);
    a.flags = static_cast<decltype(a.flags)>(flags);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHDEBUGDOTPRINT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphDestroy(hipGraph_t graph) {
  hipError_t r = g_real_table.hipGraphDestroy_fn(graph);
  if (r == hipSuccess) {
    hrr_args_hipGraphDestroy a{};
    a.ret         = static_cast<int32_t>(r);
    a.graph = reinterpret_cast<uint64_t>(graph);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHDESTROY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphDestroyNode(hipGraphNode_t node) {
  hipError_t r = g_real_table.hipGraphDestroyNode_fn(node);
  if (r == hipSuccess) {
    hrr_args_hipGraphDestroyNode a{};
    a.ret         = static_cast<int32_t>(r);
    a.node = reinterpret_cast<uint64_t>(node);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHDESTROYNODE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphEventRecordNodeGetEvent(hipGraphNode_t node, hipEvent_t* event_out) {
  hipError_t r = g_real_table.hipGraphEventRecordNodeGetEvent_fn(node, event_out);
  if (r == hipSuccess) {
    hrr_args_hipGraphEventRecordNodeGetEvent a{};
    a.ret         = static_cast<int32_t>(r);
    a.node = reinterpret_cast<uint64_t>(node);
    if (event_out) a.event_out = reinterpret_cast<uint64_t>(*event_out);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHEVENTRECORDNODEGETEVENT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphEventRecordNodeSetEvent(hipGraphNode_t node, hipEvent_t event) {
  hipError_t r = g_real_table.hipGraphEventRecordNodeSetEvent_fn(node, event);
  if (r == hipSuccess) {
    hrr_args_hipGraphEventRecordNodeSetEvent a{};
    a.ret         = static_cast<int32_t>(r);
    a.node = reinterpret_cast<uint64_t>(node);
    a.event = reinterpret_cast<uint64_t>(event);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHEVENTRECORDNODESETEVENT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphEventWaitNodeGetEvent(hipGraphNode_t node, hipEvent_t* event_out) {
  hipError_t r = g_real_table.hipGraphEventWaitNodeGetEvent_fn(node, event_out);
  if (r == hipSuccess) {
    hrr_args_hipGraphEventWaitNodeGetEvent a{};
    a.ret         = static_cast<int32_t>(r);
    a.node = reinterpret_cast<uint64_t>(node);
    if (event_out) a.event_out = reinterpret_cast<uint64_t>(*event_out);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHEVENTWAITNODEGETEVENT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphEventWaitNodeSetEvent(hipGraphNode_t node, hipEvent_t event) {
  hipError_t r = g_real_table.hipGraphEventWaitNodeSetEvent_fn(node, event);
  if (r == hipSuccess) {
    hrr_args_hipGraphEventWaitNodeSetEvent a{};
    a.ret         = static_cast<int32_t>(r);
    a.node = reinterpret_cast<uint64_t>(node);
    a.event = reinterpret_cast<uint64_t>(event);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHEVENTWAITNODESETEVENT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphExecChildGraphNodeSetParams(hipGraphExec_t hGraphExec, hipGraphNode_t node, hipGraph_t childGraph) {
  hipError_t r = g_real_table.hipGraphExecChildGraphNodeSetParams_fn(hGraphExec, node, childGraph);
  if (r == hipSuccess) {
    hrr_args_hipGraphExecChildGraphNodeSetParams a{};
    a.ret         = static_cast<int32_t>(r);
    a.hGraphExec = reinterpret_cast<uint64_t>(hGraphExec);
    a.node = reinterpret_cast<uint64_t>(node);
    a.childGraph = reinterpret_cast<uint64_t>(childGraph);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHEXECCHILDGRAPHNODESETPARAMS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphExecDestroy(hipGraphExec_t graphExec) {
  hipError_t r = g_real_table.hipGraphExecDestroy_fn(graphExec);
  if (r == hipSuccess) {
    hrr_args_hipGraphExecDestroy a{};
    a.ret         = static_cast<int32_t>(r);
    a.graphExec = reinterpret_cast<uint64_t>(graphExec);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHEXECDESTROY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphExecEventRecordNodeSetEvent(hipGraphExec_t hGraphExec, hipGraphNode_t hNode, hipEvent_t event) {
  hipError_t r = g_real_table.hipGraphExecEventRecordNodeSetEvent_fn(hGraphExec, hNode, event);
  if (r == hipSuccess) {
    hrr_args_hipGraphExecEventRecordNodeSetEvent a{};
    a.ret         = static_cast<int32_t>(r);
    a.hGraphExec = reinterpret_cast<uint64_t>(hGraphExec);
    a.hNode = reinterpret_cast<uint64_t>(hNode);
    a.event = reinterpret_cast<uint64_t>(event);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHEXECEVENTRECORDNODESETEVENT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphExecEventWaitNodeSetEvent(hipGraphExec_t hGraphExec, hipGraphNode_t hNode, hipEvent_t event) {
  hipError_t r = g_real_table.hipGraphExecEventWaitNodeSetEvent_fn(hGraphExec, hNode, event);
  if (r == hipSuccess) {
    hrr_args_hipGraphExecEventWaitNodeSetEvent a{};
    a.ret         = static_cast<int32_t>(r);
    a.hGraphExec = reinterpret_cast<uint64_t>(hGraphExec);
    a.hNode = reinterpret_cast<uint64_t>(hNode);
    a.event = reinterpret_cast<uint64_t>(event);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHEXECEVENTWAITNODESETEVENT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphExecHostNodeSetParams(hipGraphExec_t hGraphExec, hipGraphNode_t node, const hipHostNodeParams* pNodeParams) {
  hipError_t r = g_real_table.hipGraphExecHostNodeSetParams_fn(hGraphExec, node, pNodeParams);
  if (r == hipSuccess) {
    hrr_args_hipGraphExecHostNodeSetParams a{};
    a.ret         = static_cast<int32_t>(r);
    a.hGraphExec = reinterpret_cast<uint64_t>(hGraphExec);
    a.node = reinterpret_cast<uint64_t>(node);
    a.pNodeParams = reinterpret_cast<uint64_t>(pNodeParams);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHEXECHOSTNODESETPARAMS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphExecKernelNodeSetParams(hipGraphExec_t hGraphExec, hipGraphNode_t node, const hipKernelNodeParams* pNodeParams) {
  hipError_t r = g_real_table.hipGraphExecKernelNodeSetParams_fn(hGraphExec, node, pNodeParams);
  if (r == hipSuccess) {
    hrr_args_hipGraphExecKernelNodeSetParams a{};
    a.ret         = static_cast<int32_t>(r);
    a.hGraphExec = reinterpret_cast<uint64_t>(hGraphExec);
    a.node = reinterpret_cast<uint64_t>(node);
    a.pNodeParams = reinterpret_cast<uint64_t>(pNodeParams);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHEXECKERNELNODESETPARAMS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphExecMemcpyNodeSetParams(hipGraphExec_t hGraphExec, hipGraphNode_t node, hipMemcpy3DParms* pNodeParams) {
  hipError_t r = g_real_table.hipGraphExecMemcpyNodeSetParams_fn(hGraphExec, node, pNodeParams);
  if (r == hipSuccess) {
    hrr_args_hipGraphExecMemcpyNodeSetParams a{};
    a.ret         = static_cast<int32_t>(r);
    a.hGraphExec = reinterpret_cast<uint64_t>(hGraphExec);
    a.node = reinterpret_cast<uint64_t>(node);
    a.pNodeParams = reinterpret_cast<uint64_t>(pNodeParams);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHEXECMEMCPYNODESETPARAMS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphExecMemcpyNodeSetParams1D(hipGraphExec_t hGraphExec, hipGraphNode_t node, void* dst, const void* src, size_t count, hipMemcpyKind kind) {
  hipError_t r = g_real_table.hipGraphExecMemcpyNodeSetParams1D_fn(hGraphExec, node, dst, src, count, kind);
  if (r == hipSuccess) {
    hrr_args_hipGraphExecMemcpyNodeSetParams1D a{};
    a.ret         = static_cast<int32_t>(r);
    a.hGraphExec = reinterpret_cast<uint64_t>(hGraphExec);
    a.node = reinterpret_cast<uint64_t>(node);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.src = reinterpret_cast<uint64_t>(src);
    a.count = static_cast<decltype(a.count)>(count);
    a.kind = static_cast<decltype(a.kind)>(kind);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHEXECMEMCPYNODESETPARAMS1D, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphExecMemcpyNodeSetParamsFromSymbol(hipGraphExec_t hGraphExec, hipGraphNode_t node, void* dst, const void* symbol, size_t count, size_t offset, hipMemcpyKind kind) {
  hipError_t r = g_real_table.hipGraphExecMemcpyNodeSetParamsFromSymbol_fn(hGraphExec, node, dst, symbol, count, offset, kind);
  if (r == hipSuccess) {
    hrr_args_hipGraphExecMemcpyNodeSetParamsFromSymbol a{};
    a.ret         = static_cast<int32_t>(r);
    a.hGraphExec = reinterpret_cast<uint64_t>(hGraphExec);
    a.node = reinterpret_cast<uint64_t>(node);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.symbol = reinterpret_cast<uint64_t>(symbol);
    a.count = static_cast<decltype(a.count)>(count);
    a.offset = static_cast<decltype(a.offset)>(offset);
    a.kind = static_cast<decltype(a.kind)>(kind);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHEXECMEMCPYNODESETPARAMSFROMSYMBOL, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphExecMemcpyNodeSetParamsToSymbol(hipGraphExec_t hGraphExec, hipGraphNode_t node, const void* symbol, const void* src, size_t count, size_t offset, hipMemcpyKind kind) {
  hipError_t r = g_real_table.hipGraphExecMemcpyNodeSetParamsToSymbol_fn(hGraphExec, node, symbol, src, count, offset, kind);
  if (r == hipSuccess) {
    hrr_args_hipGraphExecMemcpyNodeSetParamsToSymbol a{};
    a.ret         = static_cast<int32_t>(r);
    a.hGraphExec = reinterpret_cast<uint64_t>(hGraphExec);
    a.node = reinterpret_cast<uint64_t>(node);
    a.symbol = reinterpret_cast<uint64_t>(symbol);
    a.src = reinterpret_cast<uint64_t>(src);
    a.count = static_cast<decltype(a.count)>(count);
    a.offset = static_cast<decltype(a.offset)>(offset);
    a.kind = static_cast<decltype(a.kind)>(kind);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHEXECMEMCPYNODESETPARAMSTOSYMBOL, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphExecMemsetNodeSetParams(hipGraphExec_t hGraphExec, hipGraphNode_t node, const hipMemsetParams* pNodeParams) {
  hipError_t r = g_real_table.hipGraphExecMemsetNodeSetParams_fn(hGraphExec, node, pNodeParams);
  if (r == hipSuccess) {
    hrr_args_hipGraphExecMemsetNodeSetParams a{};
    a.ret         = static_cast<int32_t>(r);
    a.hGraphExec = reinterpret_cast<uint64_t>(hGraphExec);
    a.node = reinterpret_cast<uint64_t>(node);
    a.pNodeParams = reinterpret_cast<uint64_t>(pNodeParams);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHEXECMEMSETNODESETPARAMS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphExecUpdate(hipGraphExec_t hGraphExec, hipGraph_t hGraph, hipGraphNode_t* hErrorNode_out, hipGraphExecUpdateResult* updateResult_out) {
  hipError_t r = g_real_table.hipGraphExecUpdate_fn(hGraphExec, hGraph, hErrorNode_out, updateResult_out);
  if (r == hipSuccess) {
    hrr_args_hipGraphExecUpdate a{};
    a.ret         = static_cast<int32_t>(r);
    a.hGraphExec = reinterpret_cast<uint64_t>(hGraphExec);
    a.hGraph = reinterpret_cast<uint64_t>(hGraph);
    a.updateResult_out = reinterpret_cast<uint64_t>(updateResult_out);
    if (hErrorNode_out) a.hErrorNode_out = reinterpret_cast<uint64_t>(*hErrorNode_out);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHEXECUPDATE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphGetEdges(hipGraph_t graph, hipGraphNode_t* from, hipGraphNode_t* to, size_t* numEdges) {
  hipError_t r = g_real_table.hipGraphGetEdges_fn(graph, from, to, numEdges);
  if (r == hipSuccess) {
    hrr_args_hipGraphGetEdges a{};
    a.ret         = static_cast<int32_t>(r);
    a.graph = reinterpret_cast<uint64_t>(graph);
    a.numEdges = reinterpret_cast<uint64_t>(numEdges);
    if (from) a.from = reinterpret_cast<uint64_t>(*from);
    if (to) a.to = reinterpret_cast<uint64_t>(*to);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHGETEDGES, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphGetNodes(hipGraph_t graph, hipGraphNode_t* nodes, size_t* numNodes) {
  hipError_t r = g_real_table.hipGraphGetNodes_fn(graph, nodes, numNodes);
  if (r == hipSuccess) {
    hrr_args_hipGraphGetNodes a{};
    a.ret         = static_cast<int32_t>(r);
    a.graph = reinterpret_cast<uint64_t>(graph);
    a.numNodes = reinterpret_cast<uint64_t>(numNodes);
    if (nodes) a.nodes = reinterpret_cast<uint64_t>(*nodes);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHGETNODES, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphGetRootNodes(hipGraph_t graph, hipGraphNode_t* pRootNodes, size_t* pNumRootNodes) {
  hipError_t r = g_real_table.hipGraphGetRootNodes_fn(graph, pRootNodes, pNumRootNodes);
  if (r == hipSuccess) {
    hrr_args_hipGraphGetRootNodes a{};
    a.ret         = static_cast<int32_t>(r);
    a.graph = reinterpret_cast<uint64_t>(graph);
    a.pNumRootNodes = reinterpret_cast<uint64_t>(pNumRootNodes);
    if (pRootNodes) a.pRootNodes = reinterpret_cast<uint64_t>(*pRootNodes);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHGETROOTNODES, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphHostNodeGetParams(hipGraphNode_t node, hipHostNodeParams* pNodeParams) {
  hipError_t r = g_real_table.hipGraphHostNodeGetParams_fn(node, pNodeParams);
  if (r == hipSuccess) {
    hrr_args_hipGraphHostNodeGetParams a{};
    a.ret         = static_cast<int32_t>(r);
    a.node = reinterpret_cast<uint64_t>(node);
    a.pNodeParams = reinterpret_cast<uint64_t>(pNodeParams);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHHOSTNODEGETPARAMS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphHostNodeSetParams(hipGraphNode_t node, const hipHostNodeParams* pNodeParams) {
  hipError_t r = g_real_table.hipGraphHostNodeSetParams_fn(node, pNodeParams);
  if (r == hipSuccess) {
    hrr_args_hipGraphHostNodeSetParams a{};
    a.ret         = static_cast<int32_t>(r);
    a.node = reinterpret_cast<uint64_t>(node);
    a.pNodeParams = reinterpret_cast<uint64_t>(pNodeParams);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHHOSTNODESETPARAMS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphInstantiate(hipGraphExec_t* pGraphExec, hipGraph_t graph, hipGraphNode_t* pErrorNode, char* pLogBuffer, size_t bufferSize) {
  hipError_t r = g_real_table.hipGraphInstantiate_fn(pGraphExec, graph, pErrorNode, pLogBuffer, bufferSize);
  if (r == hipSuccess) {
    hrr_args_hipGraphInstantiate a{};
    a.ret         = static_cast<int32_t>(r);
    a.graph = reinterpret_cast<uint64_t>(graph);
    a.pLogBuffer = reinterpret_cast<uint64_t>(pLogBuffer);
    a.bufferSize = static_cast<decltype(a.bufferSize)>(bufferSize);
    if (pGraphExec) a.pGraphExec = reinterpret_cast<uint64_t>(*pGraphExec);
    if (pErrorNode) a.pErrorNode = reinterpret_cast<uint64_t>(*pErrorNode);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHINSTANTIATE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphInstantiateWithFlags(hipGraphExec_t* pGraphExec, hipGraph_t graph, unsigned long long flags) {
  hipError_t r = g_real_table.hipGraphInstantiateWithFlags_fn(pGraphExec, graph, flags);
  if (r == hipSuccess) {
    hrr_args_hipGraphInstantiateWithFlags a{};
    a.ret         = static_cast<int32_t>(r);
    a.graph = reinterpret_cast<uint64_t>(graph);
    a.flags = static_cast<decltype(a.flags)>(flags);
    if (pGraphExec) a.pGraphExec = reinterpret_cast<uint64_t>(*pGraphExec);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHINSTANTIATEWITHFLAGS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphKernelNodeCopyAttributes(hipGraphNode_t hSrc, hipGraphNode_t hDst) {
  hipError_t r = g_real_table.hipGraphKernelNodeCopyAttributes_fn(hSrc, hDst);
  if (r == hipSuccess) {
    hrr_args_hipGraphKernelNodeCopyAttributes a{};
    a.ret         = static_cast<int32_t>(r);
    a.hSrc = reinterpret_cast<uint64_t>(hSrc);
    a.hDst = reinterpret_cast<uint64_t>(hDst);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHKERNELNODECOPYATTRIBUTES, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphKernelNodeGetAttribute(hipGraphNode_t hNode, hipKernelNodeAttrID attr, hipKernelNodeAttrValue* value) {
  hipError_t r = g_real_table.hipGraphKernelNodeGetAttribute_fn(hNode, attr, value);
  if (r == hipSuccess) {
    hrr_args_hipGraphKernelNodeGetAttribute a{};
    a.ret         = static_cast<int32_t>(r);
    a.hNode = reinterpret_cast<uint64_t>(hNode);
    a.attr = static_cast<decltype(a.attr)>(attr);
    a.value = reinterpret_cast<uint64_t>(value);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHKERNELNODEGETATTRIBUTE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphKernelNodeGetParams(hipGraphNode_t node, hipKernelNodeParams* pNodeParams) {
  hipError_t r = g_real_table.hipGraphKernelNodeGetParams_fn(node, pNodeParams);
  if (r == hipSuccess) {
    hrr_args_hipGraphKernelNodeGetParams a{};
    a.ret         = static_cast<int32_t>(r);
    a.node = reinterpret_cast<uint64_t>(node);
    a.pNodeParams = reinterpret_cast<uint64_t>(pNodeParams);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHKERNELNODEGETPARAMS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphKernelNodeSetAttribute(hipGraphNode_t hNode, hipKernelNodeAttrID attr, const hipKernelNodeAttrValue* value) {
  hipError_t r = g_real_table.hipGraphKernelNodeSetAttribute_fn(hNode, attr, value);
  if (r == hipSuccess) {
    hrr_args_hipGraphKernelNodeSetAttribute a{};
    a.ret         = static_cast<int32_t>(r);
    a.hNode = reinterpret_cast<uint64_t>(hNode);
    a.attr = static_cast<decltype(a.attr)>(attr);
    a.value = reinterpret_cast<uint64_t>(value);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHKERNELNODESETATTRIBUTE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphKernelNodeSetParams(hipGraphNode_t node, const hipKernelNodeParams* pNodeParams) {
  hipError_t r = g_real_table.hipGraphKernelNodeSetParams_fn(node, pNodeParams);
  if (r == hipSuccess) {
    hrr_args_hipGraphKernelNodeSetParams a{};
    a.ret         = static_cast<int32_t>(r);
    a.node = reinterpret_cast<uint64_t>(node);
    a.pNodeParams = reinterpret_cast<uint64_t>(pNodeParams);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHKERNELNODESETPARAMS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphLaunch(hipGraphExec_t graphExec, hipStream_t stream) {
  hipError_t r = g_real_table.hipGraphLaunch_fn(graphExec, stream);
  if (r == hipSuccess) {
    hrr_args_hipGraphLaunch a{};
    a.ret         = static_cast<int32_t>(r);
    a.graphExec = reinterpret_cast<uint64_t>(graphExec);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHLAUNCH, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphMemAllocNodeGetParams(hipGraphNode_t node, hipMemAllocNodeParams* pNodeParams) {
  hipError_t r = g_real_table.hipGraphMemAllocNodeGetParams_fn(node, pNodeParams);
  if (r == hipSuccess) {
    hrr_args_hipGraphMemAllocNodeGetParams a{};
    a.ret         = static_cast<int32_t>(r);
    a.node = reinterpret_cast<uint64_t>(node);
    a.pNodeParams = reinterpret_cast<uint64_t>(pNodeParams);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHMEMALLOCNODEGETPARAMS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphMemFreeNodeGetParams(hipGraphNode_t node, void* dev_ptr) {
  hipError_t r = g_real_table.hipGraphMemFreeNodeGetParams_fn(node, dev_ptr);
  if (r == hipSuccess) {
    hrr_args_hipGraphMemFreeNodeGetParams a{};
    a.ret         = static_cast<int32_t>(r);
    a.node = reinterpret_cast<uint64_t>(node);
    a.dev_ptr = reinterpret_cast<uint64_t>(dev_ptr);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHMEMFREENODEGETPARAMS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphMemcpyNodeGetParams(hipGraphNode_t node, hipMemcpy3DParms* pNodeParams) {
  hipError_t r = g_real_table.hipGraphMemcpyNodeGetParams_fn(node, pNodeParams);
  if (r == hipSuccess) {
    hrr_args_hipGraphMemcpyNodeGetParams a{};
    a.ret         = static_cast<int32_t>(r);
    a.node = reinterpret_cast<uint64_t>(node);
    a.pNodeParams = reinterpret_cast<uint64_t>(pNodeParams);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHMEMCPYNODEGETPARAMS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphMemcpyNodeSetParams(hipGraphNode_t node, const hipMemcpy3DParms* pNodeParams) {
  hipError_t r = g_real_table.hipGraphMemcpyNodeSetParams_fn(node, pNodeParams);
  if (r == hipSuccess) {
    hrr_args_hipGraphMemcpyNodeSetParams a{};
    a.ret         = static_cast<int32_t>(r);
    a.node = reinterpret_cast<uint64_t>(node);
    a.pNodeParams = reinterpret_cast<uint64_t>(pNodeParams);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHMEMCPYNODESETPARAMS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphMemcpyNodeSetParams1D(hipGraphNode_t node, void* dst, const void* src, size_t count, hipMemcpyKind kind) {
  hipError_t r = g_real_table.hipGraphMemcpyNodeSetParams1D_fn(node, dst, src, count, kind);
  if (r == hipSuccess) {
    hrr_args_hipGraphMemcpyNodeSetParams1D a{};
    a.ret         = static_cast<int32_t>(r);
    a.node = reinterpret_cast<uint64_t>(node);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.src = reinterpret_cast<uint64_t>(src);
    a.count = static_cast<decltype(a.count)>(count);
    a.kind = static_cast<decltype(a.kind)>(kind);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHMEMCPYNODESETPARAMS1D, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphMemcpyNodeSetParamsFromSymbol(hipGraphNode_t node, void* dst, const void* symbol, size_t count, size_t offset, hipMemcpyKind kind) {
  hipError_t r = g_real_table.hipGraphMemcpyNodeSetParamsFromSymbol_fn(node, dst, symbol, count, offset, kind);
  if (r == hipSuccess) {
    hrr_args_hipGraphMemcpyNodeSetParamsFromSymbol a{};
    a.ret         = static_cast<int32_t>(r);
    a.node = reinterpret_cast<uint64_t>(node);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.symbol = reinterpret_cast<uint64_t>(symbol);
    a.count = static_cast<decltype(a.count)>(count);
    a.offset = static_cast<decltype(a.offset)>(offset);
    a.kind = static_cast<decltype(a.kind)>(kind);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHMEMCPYNODESETPARAMSFROMSYMBOL, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphMemcpyNodeSetParamsToSymbol(hipGraphNode_t node, const void* symbol, const void* src, size_t count, size_t offset, hipMemcpyKind kind) {
  hipError_t r = g_real_table.hipGraphMemcpyNodeSetParamsToSymbol_fn(node, symbol, src, count, offset, kind);
  if (r == hipSuccess) {
    hrr_args_hipGraphMemcpyNodeSetParamsToSymbol a{};
    a.ret         = static_cast<int32_t>(r);
    a.node = reinterpret_cast<uint64_t>(node);
    a.symbol = reinterpret_cast<uint64_t>(symbol);
    a.src = reinterpret_cast<uint64_t>(src);
    a.count = static_cast<decltype(a.count)>(count);
    a.offset = static_cast<decltype(a.offset)>(offset);
    a.kind = static_cast<decltype(a.kind)>(kind);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHMEMCPYNODESETPARAMSTOSYMBOL, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphMemsetNodeGetParams(hipGraphNode_t node, hipMemsetParams* pNodeParams) {
  hipError_t r = g_real_table.hipGraphMemsetNodeGetParams_fn(node, pNodeParams);
  if (r == hipSuccess) {
    hrr_args_hipGraphMemsetNodeGetParams a{};
    a.ret         = static_cast<int32_t>(r);
    a.node = reinterpret_cast<uint64_t>(node);
    a.pNodeParams = reinterpret_cast<uint64_t>(pNodeParams);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHMEMSETNODEGETPARAMS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphMemsetNodeSetParams(hipGraphNode_t node, const hipMemsetParams* pNodeParams) {
  hipError_t r = g_real_table.hipGraphMemsetNodeSetParams_fn(node, pNodeParams);
  if (r == hipSuccess) {
    hrr_args_hipGraphMemsetNodeSetParams a{};
    a.ret         = static_cast<int32_t>(r);
    a.node = reinterpret_cast<uint64_t>(node);
    a.pNodeParams = reinterpret_cast<uint64_t>(pNodeParams);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHMEMSETNODESETPARAMS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphNodeFindInClone(hipGraphNode_t* pNode, hipGraphNode_t originalNode, hipGraph_t clonedGraph) {
  hipError_t r = g_real_table.hipGraphNodeFindInClone_fn(pNode, originalNode, clonedGraph);
  if (r == hipSuccess) {
    hrr_args_hipGraphNodeFindInClone a{};
    a.ret         = static_cast<int32_t>(r);
    a.originalNode = reinterpret_cast<uint64_t>(originalNode);
    a.clonedGraph = reinterpret_cast<uint64_t>(clonedGraph);
    if (pNode) a.pNode = reinterpret_cast<uint64_t>(*pNode);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHNODEFINDINCLONE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphNodeGetDependencies(hipGraphNode_t node, hipGraphNode_t* pDependencies, size_t* pNumDependencies) {
  hipError_t r = g_real_table.hipGraphNodeGetDependencies_fn(node, pDependencies, pNumDependencies);
  if (r == hipSuccess) {
    hrr_args_hipGraphNodeGetDependencies a{};
    a.ret         = static_cast<int32_t>(r);
    a.node = reinterpret_cast<uint64_t>(node);
    a.pNumDependencies = reinterpret_cast<uint64_t>(pNumDependencies);
    if (pDependencies) a.pDependencies = reinterpret_cast<uint64_t>(*pDependencies);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHNODEGETDEPENDENCIES, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphNodeGetDependentNodes(hipGraphNode_t node, hipGraphNode_t* pDependentNodes, size_t* pNumDependentNodes) {
  hipError_t r = g_real_table.hipGraphNodeGetDependentNodes_fn(node, pDependentNodes, pNumDependentNodes);
  if (r == hipSuccess) {
    hrr_args_hipGraphNodeGetDependentNodes a{};
    a.ret         = static_cast<int32_t>(r);
    a.node = reinterpret_cast<uint64_t>(node);
    a.pNumDependentNodes = reinterpret_cast<uint64_t>(pNumDependentNodes);
    if (pDependentNodes) a.pDependentNodes = reinterpret_cast<uint64_t>(*pDependentNodes);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHNODEGETDEPENDENTNODES, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphNodeGetEnabled(hipGraphExec_t hGraphExec, hipGraphNode_t hNode, unsigned int* isEnabled) {
  hipError_t r = g_real_table.hipGraphNodeGetEnabled_fn(hGraphExec, hNode, isEnabled);
  if (r == hipSuccess) {
    hrr_args_hipGraphNodeGetEnabled a{};
    a.ret         = static_cast<int32_t>(r);
    a.hGraphExec = reinterpret_cast<uint64_t>(hGraphExec);
    a.hNode = reinterpret_cast<uint64_t>(hNode);
    a.isEnabled = reinterpret_cast<uint64_t>(isEnabled);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHNODEGETENABLED, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphNodeGetType(hipGraphNode_t node, hipGraphNodeType* pType) {
  hipError_t r = g_real_table.hipGraphNodeGetType_fn(node, pType);
  if (r == hipSuccess) {
    hrr_args_hipGraphNodeGetType a{};
    a.ret         = static_cast<int32_t>(r);
    a.node = reinterpret_cast<uint64_t>(node);
    a.pType = reinterpret_cast<uint64_t>(pType);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHNODEGETTYPE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphNodeSetEnabled(hipGraphExec_t hGraphExec, hipGraphNode_t hNode, unsigned int isEnabled) {
  hipError_t r = g_real_table.hipGraphNodeSetEnabled_fn(hGraphExec, hNode, isEnabled);
  if (r == hipSuccess) {
    hrr_args_hipGraphNodeSetEnabled a{};
    a.ret         = static_cast<int32_t>(r);
    a.hGraphExec = reinterpret_cast<uint64_t>(hGraphExec);
    a.hNode = reinterpret_cast<uint64_t>(hNode);
    a.isEnabled = static_cast<decltype(a.isEnabled)>(isEnabled);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHNODESETENABLED, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphReleaseUserObject(hipGraph_t graph, hipUserObject_t object, unsigned int count) {
  hipError_t r = g_real_table.hipGraphReleaseUserObject_fn(graph, object, count);
  if (r == hipSuccess) {
    hrr_args_hipGraphReleaseUserObject a{};
    a.ret         = static_cast<int32_t>(r);
    a.graph = reinterpret_cast<uint64_t>(graph);
    a.object = reinterpret_cast<uint64_t>(object);
    a.count = static_cast<decltype(a.count)>(count);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHRELEASEUSEROBJECT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphRemoveDependencies(hipGraph_t graph, const hipGraphNode_t* from, const hipGraphNode_t* to, size_t numDependencies) {
  hipError_t r = g_real_table.hipGraphRemoveDependencies_fn(graph, from, to, numDependencies);
  if (r == hipSuccess) {
    hrr_args_hipGraphRemoveDependencies a{};
    a.ret         = static_cast<int32_t>(r);
    a.graph = reinterpret_cast<uint64_t>(graph);
    a.numDependencies = static_cast<decltype(a.numDependencies)>(numDependencies);
    if (from) a.from = reinterpret_cast<uint64_t>(*from);
    if (to) a.to = reinterpret_cast<uint64_t>(*to);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHREMOVEDEPENDENCIES, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphRetainUserObject(hipGraph_t graph, hipUserObject_t object, unsigned int count, unsigned int flags) {
  hipError_t r = g_real_table.hipGraphRetainUserObject_fn(graph, object, count, flags);
  if (r == hipSuccess) {
    hrr_args_hipGraphRetainUserObject a{};
    a.ret         = static_cast<int32_t>(r);
    a.graph = reinterpret_cast<uint64_t>(graph);
    a.object = reinterpret_cast<uint64_t>(object);
    a.count = static_cast<decltype(a.count)>(count);
    a.flags = static_cast<decltype(a.flags)>(flags);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHRETAINUSEROBJECT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphUpload(hipGraphExec_t graphExec, hipStream_t stream) {
  hipError_t r = g_real_table.hipGraphUpload_fn(graphExec, stream);
  if (r == hipSuccess) {
    hrr_args_hipGraphUpload a{};
    a.ret         = static_cast<int32_t>(r);
    a.graphExec = reinterpret_cast<uint64_t>(graphExec);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHUPLOAD, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphicsGLRegisterBuffer(hipGraphicsResource** resource, GLuint buffer, unsigned int flags) {
  hipError_t r = g_real_table.hipGraphicsGLRegisterBuffer_fn(resource, buffer, flags);
  if (r == hipSuccess) {
    hrr_args_hipGraphicsGLRegisterBuffer a{};
    a.ret         = static_cast<int32_t>(r);
    a.buffer = static_cast<decltype(a.buffer)>(buffer);
    a.flags = static_cast<decltype(a.flags)>(flags);
    if (resource) a.resource = reinterpret_cast<uint64_t>(*resource);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHICSGLREGISTERBUFFER, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphicsGLRegisterImage(hipGraphicsResource** resource, GLuint image, GLenum target, unsigned int flags) {
  hipError_t r = g_real_table.hipGraphicsGLRegisterImage_fn(resource, image, target, flags);
  if (r == hipSuccess) {
    hrr_args_hipGraphicsGLRegisterImage a{};
    a.ret         = static_cast<int32_t>(r);
    a.image = static_cast<decltype(a.image)>(image);
    a.target = static_cast<decltype(a.target)>(target);
    a.flags = static_cast<decltype(a.flags)>(flags);
    if (resource) a.resource = reinterpret_cast<uint64_t>(*resource);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHICSGLREGISTERIMAGE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphicsMapResources(int count, hipGraphicsResource_t* resources, hipStream_t stream) {
  hipError_t r = g_real_table.hipGraphicsMapResources_fn(count, resources, stream);
  if (r == hipSuccess) {
    hrr_args_hipGraphicsMapResources a{};
    a.ret         = static_cast<int32_t>(r);
    a.count = static_cast<decltype(a.count)>(count);
    a.resources = 0;  // non-castable type skipped
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHICSMAPRESOURCES, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphicsResourceGetMappedPointer(void** devPtr, size_t* size, hipGraphicsResource_t resource) {
  hipError_t r = g_real_table.hipGraphicsResourceGetMappedPointer_fn(devPtr, size, resource);
  if (r == hipSuccess) {
    hrr_args_hipGraphicsResourceGetMappedPointer a{};
    a.ret         = static_cast<int32_t>(r);
    a.size = reinterpret_cast<uint64_t>(size);
    a.resource = 0;  // non-castable type skipped
    if (devPtr) a.devPtr = reinterpret_cast<uint64_t>(*devPtr);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHICSRESOURCEGETMAPPEDPOINTER, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphicsSubResourceGetMappedArray(hipArray_t* array, hipGraphicsResource_t resource, unsigned int arrayIndex, unsigned int mipLevel) {
  hipError_t r = g_real_table.hipGraphicsSubResourceGetMappedArray_fn(array, resource, arrayIndex, mipLevel);
  if (r == hipSuccess) {
    hrr_args_hipGraphicsSubResourceGetMappedArray a{};
    a.ret         = static_cast<int32_t>(r);
    a.resource = 0;  // non-castable type skipped
    a.arrayIndex = static_cast<decltype(a.arrayIndex)>(arrayIndex);
    a.mipLevel = static_cast<decltype(a.mipLevel)>(mipLevel);
    if (array) a.array = reinterpret_cast<uint64_t>(*array);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHICSSUBRESOURCEGETMAPPEDARRAY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphicsUnmapResources(int count, hipGraphicsResource_t* resources, hipStream_t stream) {
  hipError_t r = g_real_table.hipGraphicsUnmapResources_fn(count, resources, stream);
  if (r == hipSuccess) {
    hrr_args_hipGraphicsUnmapResources a{};
    a.ret         = static_cast<int32_t>(r);
    a.count = static_cast<decltype(a.count)>(count);
    a.resources = 0;  // non-castable type skipped
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHICSUNMAPRESOURCES, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphicsUnregisterResource(hipGraphicsResource_t resource) {
  hipError_t r = g_real_table.hipGraphicsUnregisterResource_fn(resource);
  if (r == hipSuccess) {
    hrr_args_hipGraphicsUnregisterResource a{};
    a.ret         = static_cast<int32_t>(r);
    a.resource = 0;  // non-castable type skipped
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHICSUNREGISTERRESOURCE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipHostAlloc(void** ptr, size_t size, unsigned int flags) {
  hipError_t r = g_real_table.hipHostAlloc_fn(ptr, size, flags);
  if (r == hipSuccess) {
    hrr_args_hipHostAlloc a{};
    a.ret         = static_cast<int32_t>(r);
    a.size = static_cast<decltype(a.size)>(size);
    a.flags = static_cast<decltype(a.flags)>(flags);
    if (ptr) a.ptr = reinterpret_cast<uint64_t>(*ptr);
    hrr_cap::writer::write_event_raw(HRR_API_HIPHOSTALLOC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipHostFree(void* ptr) {
  hipError_t r = g_real_table.hipHostFree_fn(ptr);
  if (r == hipSuccess) {
    hrr_args_hipHostFree a{};
    a.ret         = static_cast<int32_t>(r);
    a.ptr = reinterpret_cast<uint64_t>(ptr);
    hrr_cap::writer::write_event_raw(HRR_API_HIPHOSTFREE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipHostGetDevicePointer(void** devPtr, void* hstPtr, unsigned int flags) {
  hipError_t r = g_real_table.hipHostGetDevicePointer_fn(devPtr, hstPtr, flags);
  if (r == hipSuccess) {
    hrr_args_hipHostGetDevicePointer a{};
    a.ret         = static_cast<int32_t>(r);
    a.hstPtr = reinterpret_cast<uint64_t>(hstPtr);
    a.flags = static_cast<decltype(a.flags)>(flags);
    if (devPtr) a.devPtr = reinterpret_cast<uint64_t>(*devPtr);
    hrr_cap::writer::write_event_raw(HRR_API_HIPHOSTGETDEVICEPOINTER, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipHostGetFlags(unsigned int* flagsPtr, void* hostPtr) {
  hipError_t r = g_real_table.hipHostGetFlags_fn(flagsPtr, hostPtr);
  if (r == hipSuccess) {
    hrr_args_hipHostGetFlags a{};
    a.ret         = static_cast<int32_t>(r);
    a.flagsPtr = reinterpret_cast<uint64_t>(flagsPtr);
    a.hostPtr = reinterpret_cast<uint64_t>(hostPtr);
    hrr_cap::writer::write_event_raw(HRR_API_HIPHOSTGETFLAGS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipHostMalloc(void** ptr, size_t size, unsigned int flags) {
  hipError_t r = g_real_table.hipHostMalloc_fn(ptr, size, flags);
  if (r == hipSuccess) {
    hrr_args_hipHostMalloc a{};
    a.ret         = static_cast<int32_t>(r);
    a.size = static_cast<decltype(a.size)>(size);
    a.flags = static_cast<decltype(a.flags)>(flags);
    if (ptr) a.ptr = reinterpret_cast<uint64_t>(*ptr);
    hrr_cap::writer::write_event_raw(HRR_API_HIPHOSTMALLOC, &a.hdr, sizeof(a));
  }
  return r;
}



// Generated shim
static hipError_t capture_hipImportExternalMemory(hipExternalMemory_t* extMem_out, const hipExternalMemoryHandleDesc* memHandleDesc) {
  hipError_t r = g_real_table.hipImportExternalMemory_fn(extMem_out, memHandleDesc);
  if (r == hipSuccess) {
    hrr_args_hipImportExternalMemory a{};
    a.ret         = static_cast<int32_t>(r);
    a.extMem_out = reinterpret_cast<uint64_t>(extMem_out);
    a.memHandleDesc = reinterpret_cast<uint64_t>(memHandleDesc);
    hrr_cap::writer::write_event_raw(HRR_API_HIPIMPORTEXTERNALMEMORY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipImportExternalSemaphore(hipExternalSemaphore_t* extSem_out, const hipExternalSemaphoreHandleDesc* semHandleDesc) {
  hipError_t r = g_real_table.hipImportExternalSemaphore_fn(extSem_out, semHandleDesc);
  if (r == hipSuccess) {
    hrr_args_hipImportExternalSemaphore a{};
    a.ret         = static_cast<int32_t>(r);
    a.extSem_out = reinterpret_cast<uint64_t>(extSem_out);
    a.semHandleDesc = reinterpret_cast<uint64_t>(semHandleDesc);
    hrr_cap::writer::write_event_raw(HRR_API_HIPIMPORTEXTERNALSEMAPHORE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipInit(unsigned int flags) {
  hipError_t r = g_real_table.hipInit_fn(flags);
  if (r == hipSuccess) {
    hrr_args_hipInit a{};
    a.ret         = static_cast<int32_t>(r);
    a.flags = static_cast<decltype(a.flags)>(flags);
    hrr_cap::writer::write_event_raw(HRR_API_HIPINIT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipIpcCloseMemHandle(void* devPtr) {
  hipError_t r = g_real_table.hipIpcCloseMemHandle_fn(devPtr);
  if (r == hipSuccess) {
    hrr_args_hipIpcCloseMemHandle a{};
    a.ret         = static_cast<int32_t>(r);
    a.devPtr = reinterpret_cast<uint64_t>(devPtr);
    hrr_cap::writer::write_event_raw(HRR_API_HIPIPCCLOSEMEMHANDLE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipIpcGetEventHandle(hipIpcEventHandle_t* handle, hipEvent_t event) {
  hipError_t r = g_real_table.hipIpcGetEventHandle_fn(handle, event);
  if (r == hipSuccess) {
    hrr_args_hipIpcGetEventHandle a{};
    a.ret         = static_cast<int32_t>(r);
    a.handle = 0;  // non-castable type skipped
    a.event = reinterpret_cast<uint64_t>(event);
    hrr_cap::writer::write_event_raw(HRR_API_HIPIPCGETEVENTHANDLE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipIpcGetMemHandle(hipIpcMemHandle_t* handle, void* devPtr) {
  hipError_t r = g_real_table.hipIpcGetMemHandle_fn(handle, devPtr);
  if (r == hipSuccess) {
    hrr_args_hipIpcGetMemHandle a{};
    a.ret         = static_cast<int32_t>(r);
    a.handle = 0;  // non-castable type skipped
    a.devPtr = reinterpret_cast<uint64_t>(devPtr);
    hrr_cap::writer::write_event_raw(HRR_API_HIPIPCGETMEMHANDLE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipIpcOpenEventHandle(hipEvent_t* event, hipIpcEventHandle_t handle) {
  hipError_t r = g_real_table.hipIpcOpenEventHandle_fn(event, handle);
  if (r == hipSuccess) {
    hrr_args_hipIpcOpenEventHandle a{};
    a.ret         = static_cast<int32_t>(r);
    a.handle = 0;  // non-castable type skipped
    if (event) a.event = reinterpret_cast<uint64_t>(*event);
    hrr_cap::writer::write_event_raw(HRR_API_HIPIPCOPENEVENTHANDLE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipIpcOpenMemHandle(void** devPtr, hipIpcMemHandle_t handle, unsigned int flags) {
  hipError_t r = g_real_table.hipIpcOpenMemHandle_fn(devPtr, handle, flags);
  if (r == hipSuccess) {
    hrr_args_hipIpcOpenMemHandle a{};
    a.ret         = static_cast<int32_t>(r);
    a.handle = 0;  // non-castable type skipped
    a.flags = static_cast<decltype(a.flags)>(flags);
    if (devPtr) a.devPtr = reinterpret_cast<uint64_t>(*devPtr);
    hrr_cap::writer::write_event_raw(HRR_API_HIPIPCOPENMEMHANDLE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static const char* capture_hipKernelNameRef(const hipFunction_t f) {
  const char* r = g_real_table.hipKernelNameRef_fn(f);
  {
    hrr_args_hipKernelNameRef a{};
    a.ret = reinterpret_cast<uint64_t>(r);
    a.f = reinterpret_cast<uint64_t>(f);
    hrr_cap::writer::write_event_raw(HRR_API_HIPKERNELNAMEREF, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static const char* capture_hipKernelNameRefByPtr(const void* hostFunction, hipStream_t stream) {
  const char* r = g_real_table.hipKernelNameRefByPtr_fn(hostFunction, stream);
  {
    hrr_args_hipKernelNameRefByPtr a{};
    a.ret = reinterpret_cast<uint64_t>(r);
    a.hostFunction = reinterpret_cast<uint64_t>(hostFunction);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPKERNELNAMEREFBYPTR, &a.hdr, sizeof(a));
  }
  return r;
}


// Generated shim
static hipError_t capture_hipLaunchCooperativeKernel(const void* f, dim3 gridDim, dim3 blockDimX, void** kernelParams, unsigned int sharedMemBytes, hipStream_t stream) {
  hipError_t r = g_real_table.hipLaunchCooperativeKernel_fn(f, gridDim, blockDimX, kernelParams, sharedMemBytes, stream);
  if (r == hipSuccess) {
    hrr_args_hipLaunchCooperativeKernel a{};
    a.ret         = static_cast<int32_t>(r);
    a.f = reinterpret_cast<uint64_t>(f);
    a.gridDim_x = gridDim.x;
    a.gridDim_y = gridDim.y;
    a.gridDim_z = gridDim.z;
    a.blockDimX_x = blockDimX.x;
    a.blockDimX_y = blockDimX.y;
    a.blockDimX_z = blockDimX.z;
    a.sharedMemBytes = static_cast<decltype(a.sharedMemBytes)>(sharedMemBytes);
    a.stream = reinterpret_cast<uint64_t>(stream);
    if (kernelParams) a.kernelParams = reinterpret_cast<uint64_t>(*kernelParams);
    hrr_cap::writer::write_event_raw(HRR_API_HIPLAUNCHCOOPERATIVEKERNEL, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipLaunchCooperativeKernelMultiDevice(hipLaunchParams* launchParamsList, int numDevices, unsigned int flags) {
  hipError_t r = g_real_table.hipLaunchCooperativeKernelMultiDevice_fn(launchParamsList, numDevices, flags);
  if (r == hipSuccess) {
    hrr_args_hipLaunchCooperativeKernelMultiDevice a{};
    a.ret         = static_cast<int32_t>(r);
    a.launchParamsList = reinterpret_cast<uint64_t>(launchParamsList);
    a.numDevices = static_cast<decltype(a.numDevices)>(numDevices);
    a.flags = static_cast<decltype(a.flags)>(flags);
    hrr_cap::writer::write_event_raw(HRR_API_HIPLAUNCHCOOPERATIVEKERNELMULTIDEVICE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipLaunchHostFunc(hipStream_t stream, hipHostFn_t fn, void* userData) {
  hipError_t r = g_real_table.hipLaunchHostFunc_fn(stream, fn, userData);
  if (r == hipSuccess) {
    hrr_args_hipLaunchHostFunc a{};
    a.ret         = static_cast<int32_t>(r);
    a.stream = reinterpret_cast<uint64_t>(stream);
    a.fn = 0;  // non-castable type skipped
    a.userData = reinterpret_cast<uint64_t>(userData);
    hrr_cap::writer::write_event_raw(HRR_API_HIPLAUNCHHOSTFUNC, &a.hdr, sizeof(a));
  }
  return r;
}


// Generated shim
static hipError_t capture_hipMalloc(void** ptr, size_t size) {
  hipError_t r = g_real_table.hipMalloc_fn(ptr, size);
  if (r == hipSuccess) {
    hrr_args_hipMalloc a{};
    a.ret         = static_cast<int32_t>(r);
    a.size = static_cast<decltype(a.size)>(size);
    if (ptr) a.ptr = reinterpret_cast<uint64_t>(*ptr);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMALLOC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMalloc3D(hipPitchedPtr* pitchedDevPtr, hipExtent extent) {
  hipError_t r = g_real_table.hipMalloc3D_fn(pitchedDevPtr, extent);
  if (r == hipSuccess) {
    hrr_args_hipMalloc3D a{};
    a.ret         = static_cast<int32_t>(r);
    a.pitchedDevPtr = 0;  // non-castable type skipped
    a.extent = 0;  // non-castable type skipped
    hrr_cap::writer::write_event_raw(HRR_API_HIPMALLOC3D, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMalloc3DArray(hipArray_t* array, const struct hipChannelFormatDesc* desc, struct hipExtent extent, unsigned int flags) {
  hipError_t r = g_real_table.hipMalloc3DArray_fn(array, desc, extent, flags);
  if (r == hipSuccess) {
    hrr_args_hipMalloc3DArray a{};
    a.ret         = static_cast<int32_t>(r);
    a.desc = 0;  // non-castable type skipped
    a.extent = 0;  // non-castable type skipped
    a.flags = static_cast<decltype(a.flags)>(flags);
    if (array) a.array = reinterpret_cast<uint64_t>(*array);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMALLOC3DARRAY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMallocArray(hipArray_t* array, const hipChannelFormatDesc* desc, size_t width, size_t height, unsigned int flags) {
  hipError_t r = g_real_table.hipMallocArray_fn(array, desc, width, height, flags);
  if (r == hipSuccess) {
    hrr_args_hipMallocArray a{};
    a.ret         = static_cast<int32_t>(r);
    a.desc = 0;  // non-castable type skipped
    a.width = static_cast<decltype(a.width)>(width);
    a.height = static_cast<decltype(a.height)>(height);
    a.flags = static_cast<decltype(a.flags)>(flags);
    if (array) a.array = reinterpret_cast<uint64_t>(*array);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMALLOCARRAY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMallocAsync(void** dev_ptr, size_t size, hipStream_t stream) {
  hipError_t r = g_real_table.hipMallocAsync_fn(dev_ptr, size, stream);
  if (r == hipSuccess) {
    hrr_args_hipMallocAsync a{};
    a.ret         = static_cast<int32_t>(r);
    a.size = static_cast<decltype(a.size)>(size);
    a.stream = reinterpret_cast<uint64_t>(stream);
    if (dev_ptr) a.dev_ptr = reinterpret_cast<uint64_t>(*dev_ptr);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMALLOCASYNC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMallocFromPoolAsync(void** dev_ptr, size_t size, hipMemPool_t mem_pool, hipStream_t stream) {
  hipError_t r = g_real_table.hipMallocFromPoolAsync_fn(dev_ptr, size, mem_pool, stream);
  if (r == hipSuccess) {
    hrr_args_hipMallocFromPoolAsync a{};
    a.ret         = static_cast<int32_t>(r);
    a.size = static_cast<decltype(a.size)>(size);
    a.mem_pool = reinterpret_cast<uint64_t>(mem_pool);
    a.stream = reinterpret_cast<uint64_t>(stream);
    if (dev_ptr) a.dev_ptr = reinterpret_cast<uint64_t>(*dev_ptr);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMALLOCFROMPOOLASYNC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMallocHost(void** ptr, size_t size) {
  hipError_t r = g_real_table.hipMallocHost_fn(ptr, size);
  if (r == hipSuccess) {
    hrr_args_hipMallocHost a{};
    a.ret         = static_cast<int32_t>(r);
    a.size = static_cast<decltype(a.size)>(size);
    if (ptr) a.ptr = reinterpret_cast<uint64_t>(*ptr);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMALLOCHOST, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMallocManaged(void** dev_ptr, size_t size, unsigned int flags) {
  hipError_t r = g_real_table.hipMallocManaged_fn(dev_ptr, size, flags);
  if (r == hipSuccess) {
    hrr_args_hipMallocManaged a{};
    a.ret         = static_cast<int32_t>(r);
    a.size = static_cast<decltype(a.size)>(size);
    a.flags = static_cast<decltype(a.flags)>(flags);
    if (dev_ptr) a.dev_ptr = reinterpret_cast<uint64_t>(*dev_ptr);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMALLOCMANAGED, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMallocMipmappedArray(hipMipmappedArray_t* mipmappedArray, const struct hipChannelFormatDesc* desc, struct hipExtent extent, unsigned int numLevels, unsigned int flags) {
  hipError_t r = g_real_table.hipMallocMipmappedArray_fn(mipmappedArray, desc, extent, numLevels, flags);
  if (r == hipSuccess) {
    hrr_args_hipMallocMipmappedArray a{};
    a.ret         = static_cast<int32_t>(r);
    a.desc = 0;  // non-castable type skipped
    a.extent = 0;  // non-castable type skipped
    a.numLevels = static_cast<decltype(a.numLevels)>(numLevels);
    a.flags = static_cast<decltype(a.flags)>(flags);
    if (mipmappedArray) a.mipmappedArray = reinterpret_cast<uint64_t>(*mipmappedArray);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMALLOCMIPMAPPEDARRAY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMallocPitch(void** ptr, size_t* pitch, size_t width, size_t height) {
  hipError_t r = g_real_table.hipMallocPitch_fn(ptr, pitch, width, height);
  if (r == hipSuccess) {
    hrr_args_hipMallocPitch a{};
    a.ret         = static_cast<int32_t>(r);
    a.pitch = reinterpret_cast<uint64_t>(pitch);
    a.width = static_cast<decltype(a.width)>(width);
    a.height = static_cast<decltype(a.height)>(height);
    if (ptr) a.ptr = reinterpret_cast<uint64_t>(*ptr);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMALLOCPITCH, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemAddressFree(void* devPtr, size_t size) {
  hipError_t r = g_real_table.hipMemAddressFree_fn(devPtr, size);
  if (r == hipSuccess) {
    hrr_args_hipMemAddressFree a{};
    a.ret         = static_cast<int32_t>(r);
    a.devPtr = reinterpret_cast<uint64_t>(devPtr);
    a.size = static_cast<decltype(a.size)>(size);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMADDRESSFREE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemAddressReserve(void** ptr, size_t size, size_t alignment, void* addr, unsigned long long flags) {
  hipError_t r = g_real_table.hipMemAddressReserve_fn(ptr, size, alignment, addr, flags);
  if (r == hipSuccess) {
    hrr_args_hipMemAddressReserve a{};
    a.ret         = static_cast<int32_t>(r);
    a.size = static_cast<decltype(a.size)>(size);
    a.alignment = static_cast<decltype(a.alignment)>(alignment);
    a.addr = reinterpret_cast<uint64_t>(addr);
    a.flags = static_cast<decltype(a.flags)>(flags);
    if (ptr) a.ptr = reinterpret_cast<uint64_t>(*ptr);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMADDRESSRESERVE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemAdvise(const void* dev_ptr, size_t count, hipMemoryAdvise advice, int device) {
  hipError_t r = g_real_table.hipMemAdvise_fn(dev_ptr, count, advice, device);
  if (r == hipSuccess) {
    hrr_args_hipMemAdvise a{};
    a.ret         = static_cast<int32_t>(r);
    a.dev_ptr = reinterpret_cast<uint64_t>(dev_ptr);
    a.count = static_cast<decltype(a.count)>(count);
    a.advice = static_cast<decltype(a.advice)>(advice);
    a.device = static_cast<decltype(a.device)>(device);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMADVISE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemAdvise_v2(const void* dev_ptr, size_t count, hipMemoryAdvise advice, hipMemLocation device) {
  hipError_t r = g_real_table.hipMemAdvise_v2_fn(dev_ptr, count, advice, device);
  if (r == hipSuccess) {
    hrr_args_hipMemAdvise_v2 a{};
    a.ret         = static_cast<int32_t>(r);
    a.dev_ptr = reinterpret_cast<uint64_t>(dev_ptr);
    a.count = static_cast<decltype(a.count)>(count);
    a.advice = static_cast<decltype(a.advice)>(advice);
    a.device = 0;  // non-castable type skipped
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMADVISE_V2, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemAllocHost(void** ptr, size_t size) {
  hipError_t r = g_real_table.hipMemAllocHost_fn(ptr, size);
  if (r == hipSuccess) {
    hrr_args_hipMemAllocHost a{};
    a.ret         = static_cast<int32_t>(r);
    a.size = static_cast<decltype(a.size)>(size);
    if (ptr) a.ptr = reinterpret_cast<uint64_t>(*ptr);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMALLOCHOST, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemAllocPitch(hipDeviceptr_t* dptr, size_t* pitch, size_t widthInBytes, size_t height, unsigned int elementSizeBytes) {
  hipError_t r = g_real_table.hipMemAllocPitch_fn(dptr, pitch, widthInBytes, height, elementSizeBytes);
  if (r == hipSuccess) {
    hrr_args_hipMemAllocPitch a{};
    a.ret         = static_cast<int32_t>(r);
    a.dptr = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(dptr));
    a.pitch = reinterpret_cast<uint64_t>(pitch);
    a.widthInBytes = static_cast<decltype(a.widthInBytes)>(widthInBytes);
    a.height = static_cast<decltype(a.height)>(height);
    a.elementSizeBytes = static_cast<decltype(a.elementSizeBytes)>(elementSizeBytes);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMALLOCPITCH, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemCreate(hipMemGenericAllocationHandle_t* handle, size_t size, const hipMemAllocationProp* prop, unsigned long long flags) {
  hipError_t r = g_real_table.hipMemCreate_fn(handle, size, prop, flags);
  if (r == hipSuccess) {
    hrr_args_hipMemCreate a{};
    a.ret         = static_cast<int32_t>(r);
    a.size = static_cast<decltype(a.size)>(size);
    a.prop = reinterpret_cast<uint64_t>(prop);
    a.flags = static_cast<decltype(a.flags)>(flags);
    if (handle) a.handle = reinterpret_cast<uint64_t>(*handle);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCREATE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemExportToShareableHandle(void* shareableHandle, hipMemGenericAllocationHandle_t handle, hipMemAllocationHandleType handleType, unsigned long long flags) {
  hipError_t r = g_real_table.hipMemExportToShareableHandle_fn(shareableHandle, handle, handleType, flags);
  if (r == hipSuccess) {
    hrr_args_hipMemExportToShareableHandle a{};
    a.ret         = static_cast<int32_t>(r);
    a.shareableHandle = reinterpret_cast<uint64_t>(shareableHandle);
    a.handle = reinterpret_cast<uint64_t>(handle);
    a.handleType = static_cast<decltype(a.handleType)>(handleType);
    a.flags = static_cast<decltype(a.flags)>(flags);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMEXPORTTOSHAREABLEHANDLE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemGetAccess(unsigned long long* flags, const hipMemLocation* location, void* ptr) {
  hipError_t r = g_real_table.hipMemGetAccess_fn(flags, location, ptr);
  if (r == hipSuccess) {
    hrr_args_hipMemGetAccess a{};
    a.ret         = static_cast<int32_t>(r);
    a.flags = reinterpret_cast<uint64_t>(flags);
    a.location = 0;  // non-castable type skipped
    a.ptr = reinterpret_cast<uint64_t>(ptr);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMGETACCESS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemGetAddressRange(hipDeviceptr_t* pbase, size_t* psize, hipDeviceptr_t dptr) {
  hipError_t r = g_real_table.hipMemGetAddressRange_fn(pbase, psize, dptr);
  if (r == hipSuccess) {
    hrr_args_hipMemGetAddressRange a{};
    a.ret         = static_cast<int32_t>(r);
    a.pbase = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(pbase));
    a.psize = reinterpret_cast<uint64_t>(psize);
    a.dptr = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(dptr));
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMGETADDRESSRANGE, &a.hdr, sizeof(a));
  }
  return r;
}


// Generated shim
static hipError_t capture_hipMemGetAllocationPropertiesFromHandle(hipMemAllocationProp* prop, hipMemGenericAllocationHandle_t handle) {
  hipError_t r = g_real_table.hipMemGetAllocationPropertiesFromHandle_fn(prop, handle);
  if (r == hipSuccess) {
    hrr_args_hipMemGetAllocationPropertiesFromHandle a{};
    a.ret         = static_cast<int32_t>(r);
    a.prop = reinterpret_cast<uint64_t>(prop);
    a.handle = reinterpret_cast<uint64_t>(handle);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMGETALLOCATIONPROPERTIESFROMHANDLE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemGetInfo(size_t* free, size_t* total) {
  hipError_t r = g_real_table.hipMemGetInfo_fn(free, total);
  if (r == hipSuccess) {
    hrr_args_hipMemGetInfo a{};
    a.ret         = static_cast<int32_t>(r);
    a.free = reinterpret_cast<uint64_t>(free);
    a.total = reinterpret_cast<uint64_t>(total);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMGETINFO, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemImportFromShareableHandle(hipMemGenericAllocationHandle_t* handle, void* osHandle, hipMemAllocationHandleType shHandleType) {
  hipError_t r = g_real_table.hipMemImportFromShareableHandle_fn(handle, osHandle, shHandleType);
  if (r == hipSuccess) {
    hrr_args_hipMemImportFromShareableHandle a{};
    a.ret         = static_cast<int32_t>(r);
    a.osHandle = reinterpret_cast<uint64_t>(osHandle);
    a.shHandleType = static_cast<decltype(a.shHandleType)>(shHandleType);
    if (handle) a.handle = reinterpret_cast<uint64_t>(*handle);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMIMPORTFROMSHAREABLEHANDLE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemMap(void* ptr, size_t size, size_t offset, hipMemGenericAllocationHandle_t handle, unsigned long long flags) {
  hipError_t r = g_real_table.hipMemMap_fn(ptr, size, offset, handle, flags);
  if (r == hipSuccess) {
    hrr_args_hipMemMap a{};
    a.ret         = static_cast<int32_t>(r);
    a.ptr = reinterpret_cast<uint64_t>(ptr);
    a.size = static_cast<decltype(a.size)>(size);
    a.offset = static_cast<decltype(a.offset)>(offset);
    a.handle = reinterpret_cast<uint64_t>(handle);
    a.flags = static_cast<decltype(a.flags)>(flags);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMMAP, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemMapArrayAsync(hipArrayMapInfo* mapInfoList, unsigned int count, hipStream_t stream) {
  hipError_t r = g_real_table.hipMemMapArrayAsync_fn(mapInfoList, count, stream);
  if (r == hipSuccess) {
    hrr_args_hipMemMapArrayAsync a{};
    a.ret         = static_cast<int32_t>(r);
    a.mapInfoList = reinterpret_cast<uint64_t>(mapInfoList);
    a.count = static_cast<decltype(a.count)>(count);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMMAPARRAYASYNC, &a.hdr, sizeof(a));
  }
  return r;
}


// Generated shim
static hipError_t capture_hipMemPoolDestroy(hipMemPool_t mem_pool) {
  hipError_t r = g_real_table.hipMemPoolDestroy_fn(mem_pool);
  if (r == hipSuccess) {
    hrr_args_hipMemPoolDestroy a{};
    a.ret         = static_cast<int32_t>(r);
    a.mem_pool = reinterpret_cast<uint64_t>(mem_pool);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMPOOLDESTROY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemPoolExportPointer(hipMemPoolPtrExportData* export_data, void* dev_ptr) {
  hipError_t r = g_real_table.hipMemPoolExportPointer_fn(export_data, dev_ptr);
  if (r == hipSuccess) {
    hrr_args_hipMemPoolExportPointer a{};
    a.ret         = static_cast<int32_t>(r);
    a.export_data = reinterpret_cast<uint64_t>(export_data);
    a.dev_ptr = reinterpret_cast<uint64_t>(dev_ptr);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMPOOLEXPORTPOINTER, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemPoolExportToShareableHandle(void* shared_handle, hipMemPool_t mem_pool, hipMemAllocationHandleType handle_type, unsigned int flags) {
  hipError_t r = g_real_table.hipMemPoolExportToShareableHandle_fn(shared_handle, mem_pool, handle_type, flags);
  if (r == hipSuccess) {
    hrr_args_hipMemPoolExportToShareableHandle a{};
    a.ret         = static_cast<int32_t>(r);
    a.shared_handle = reinterpret_cast<uint64_t>(shared_handle);
    a.mem_pool = reinterpret_cast<uint64_t>(mem_pool);
    a.handle_type = static_cast<decltype(a.handle_type)>(handle_type);
    a.flags = static_cast<decltype(a.flags)>(flags);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMPOOLEXPORTTOSHAREABLEHANDLE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemPoolGetAccess(hipMemAccessFlags* flags, hipMemPool_t mem_pool, hipMemLocation* location) {
  hipError_t r = g_real_table.hipMemPoolGetAccess_fn(flags, mem_pool, location);
  if (r == hipSuccess) {
    hrr_args_hipMemPoolGetAccess a{};
    a.ret         = static_cast<int32_t>(r);
    a.flags = reinterpret_cast<uint64_t>(flags);
    a.mem_pool = reinterpret_cast<uint64_t>(mem_pool);
    a.location = 0;  // non-castable type skipped
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMPOOLGETACCESS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemPoolGetAttribute(hipMemPool_t mem_pool, hipMemPoolAttr attr, void* value) {
  hipError_t r = g_real_table.hipMemPoolGetAttribute_fn(mem_pool, attr, value);
  if (r == hipSuccess) {
    hrr_args_hipMemPoolGetAttribute a{};
    a.ret         = static_cast<int32_t>(r);
    a.mem_pool = reinterpret_cast<uint64_t>(mem_pool);
    a.attr = static_cast<decltype(a.attr)>(attr);
    a.value = reinterpret_cast<uint64_t>(value);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMPOOLGETATTRIBUTE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemPoolImportFromShareableHandle(hipMemPool_t* mem_pool, void* shared_handle, hipMemAllocationHandleType handle_type, unsigned int flags) {
  hipError_t r = g_real_table.hipMemPoolImportFromShareableHandle_fn(mem_pool, shared_handle, handle_type, flags);
  if (r == hipSuccess) {
    hrr_args_hipMemPoolImportFromShareableHandle a{};
    a.ret         = static_cast<int32_t>(r);
    a.shared_handle = reinterpret_cast<uint64_t>(shared_handle);
    a.handle_type = static_cast<decltype(a.handle_type)>(handle_type);
    a.flags = static_cast<decltype(a.flags)>(flags);
    if (mem_pool) a.mem_pool = reinterpret_cast<uint64_t>(*mem_pool);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMPOOLIMPORTFROMSHAREABLEHANDLE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemPoolImportPointer(void** dev_ptr, hipMemPool_t mem_pool, hipMemPoolPtrExportData* export_data) {
  hipError_t r = g_real_table.hipMemPoolImportPointer_fn(dev_ptr, mem_pool, export_data);
  if (r == hipSuccess) {
    hrr_args_hipMemPoolImportPointer a{};
    a.ret         = static_cast<int32_t>(r);
    a.mem_pool = reinterpret_cast<uint64_t>(mem_pool);
    a.export_data = reinterpret_cast<uint64_t>(export_data);
    if (dev_ptr) a.dev_ptr = reinterpret_cast<uint64_t>(*dev_ptr);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMPOOLIMPORTPOINTER, &a.hdr, sizeof(a));
  }
  return r;
}



// Generated shim
static hipError_t capture_hipMemPoolTrimTo(hipMemPool_t mem_pool, size_t min_bytes_to_hold) {
  hipError_t r = g_real_table.hipMemPoolTrimTo_fn(mem_pool, min_bytes_to_hold);
  if (r == hipSuccess) {
    hrr_args_hipMemPoolTrimTo a{};
    a.ret         = static_cast<int32_t>(r);
    a.mem_pool = reinterpret_cast<uint64_t>(mem_pool);
    a.min_bytes_to_hold = static_cast<decltype(a.min_bytes_to_hold)>(min_bytes_to_hold);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMPOOLTRIMTO, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemPrefetchAsync(const void* dev_ptr, size_t count, int device, hipStream_t stream) {
  hipError_t r = g_real_table.hipMemPrefetchAsync_fn(dev_ptr, count, device, stream);
  if (r == hipSuccess) {
    hrr_args_hipMemPrefetchAsync a{};
    a.ret         = static_cast<int32_t>(r);
    a.dev_ptr = reinterpret_cast<uint64_t>(dev_ptr);
    a.count = static_cast<decltype(a.count)>(count);
    a.device = static_cast<decltype(a.device)>(device);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMPREFETCHASYNC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemPrefetchAsync_v2(const void* dev_ptr, size_t count, hipMemLocation location, unsigned int flags, hipStream_t stream) {
  hipError_t r = g_real_table.hipMemPrefetchAsync_v2_fn(dev_ptr, count, location, flags, stream);
  if (r == hipSuccess) {
    hrr_args_hipMemPrefetchAsync_v2 a{};
    a.ret         = static_cast<int32_t>(r);
    a.dev_ptr = reinterpret_cast<uint64_t>(dev_ptr);
    a.count = static_cast<decltype(a.count)>(count);
    a.location = 0;  // non-castable type skipped
    a.flags = static_cast<decltype(a.flags)>(flags);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMPREFETCHASYNC_V2, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemPrefetchBatchAsync(void** dev_ptrs, size_t* sizes, size_t count, hipMemLocation* prefetch_locs, size_t* prefetch_loc_idxs, size_t num_prefetch_locs, unsigned long long flags, hipStream_t stream) {
  hipError_t r = g_real_table.hipMemPrefetchBatchAsync_fn(dev_ptrs, sizes, count, prefetch_locs, prefetch_loc_idxs, num_prefetch_locs, flags, stream);
  if (r == hipSuccess) {
    hrr_args_hipMemPrefetchBatchAsync a{};
    a.ret         = static_cast<int32_t>(r);
    a.sizes = reinterpret_cast<uint64_t>(sizes);
    a.count = static_cast<decltype(a.count)>(count);
    a.prefetch_locs = 0;  // non-castable type skipped
    a.prefetch_loc_idxs = reinterpret_cast<uint64_t>(prefetch_loc_idxs);
    a.num_prefetch_locs = static_cast<decltype(a.num_prefetch_locs)>(num_prefetch_locs);
    a.flags = static_cast<decltype(a.flags)>(flags);
    a.stream = reinterpret_cast<uint64_t>(stream);
    if (dev_ptrs) a.dev_ptrs = reinterpret_cast<uint64_t>(*dev_ptrs);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMPREFETCHBATCHASYNC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemDiscardBatchAsync(void** dev_ptrs, size_t* sizes, size_t count, unsigned long long flags, hipStream_t stream) {
  hipError_t r = g_real_table.hipMemDiscardBatchAsync_fn(dev_ptrs, sizes, count, flags, stream);
  if (r == hipSuccess) {
    hrr_args_hipMemDiscardBatchAsync a{};
    a.ret         = static_cast<int32_t>(r);
    a.sizes = reinterpret_cast<uint64_t>(sizes);
    a.count = static_cast<decltype(a.count)>(count);
    a.flags = static_cast<decltype(a.flags)>(flags);
    a.stream = reinterpret_cast<uint64_t>(stream);
    if (dev_ptrs) a.dev_ptrs = reinterpret_cast<uint64_t>(*dev_ptrs);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMDISCARDBATCHASYNC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDrvMemDiscardBatchAsync(hipDeviceptr_t* dptrs, size_t* sizes, size_t count, unsigned long long flags, hipStream_t stream) {
  hipError_t r = g_real_table.hipDrvMemDiscardBatchAsync_fn(dptrs, sizes, count, flags, stream);
  if (r == hipSuccess) {
    hrr_args_hipDrvMemDiscardBatchAsync a{};
    a.ret         = static_cast<int32_t>(r);
    a.dptrs = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(dptrs));
    a.sizes = reinterpret_cast<uint64_t>(sizes);
    a.count = static_cast<decltype(a.count)>(count);
    a.flags = static_cast<decltype(a.flags)>(flags);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDRVMEMDISCARDBATCHASYNC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemDiscardAndPrefetchBatchAsync(void** dptrs, size_t* sizes, size_t count, hipMemLocation* prefetchLocs, size_t* prefetchLocIdxs, size_t numPrefetchLocs, unsigned long long flags, hipStream_t stream) {
  hipError_t r = g_real_table.hipMemDiscardAndPrefetchBatchAsync_fn(dptrs, sizes, count, prefetchLocs, prefetchLocIdxs, numPrefetchLocs, flags, stream);
  if (r == hipSuccess) {
    hrr_args_hipMemDiscardAndPrefetchBatchAsync a{};
    a.ret         = static_cast<int32_t>(r);
    a.sizes = reinterpret_cast<uint64_t>(sizes);
    a.count = static_cast<decltype(a.count)>(count);
    a.prefetchLocs = 0;  // non-castable type skipped
    a.prefetchLocIdxs = reinterpret_cast<uint64_t>(prefetchLocIdxs);
    a.numPrefetchLocs = static_cast<decltype(a.numPrefetchLocs)>(numPrefetchLocs);
    a.flags = static_cast<decltype(a.flags)>(flags);
    a.stream = reinterpret_cast<uint64_t>(stream);
    if (dptrs) a.dptrs = reinterpret_cast<uint64_t>(*dptrs);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMDISCARDANDPREFETCHBATCHASYNC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDrvMemDiscardAndPrefetchBatchAsync(hipDeviceptr_t* dptrs, size_t* sizes, size_t count, hipMemLocation* prefetchLocs, size_t* prefetchLocIdxs, size_t numPrefetchLocs, unsigned long long flags, hipStream_t stream) {
  hipError_t r = g_real_table.hipDrvMemDiscardAndPrefetchBatchAsync_fn(dptrs, sizes, count, prefetchLocs, prefetchLocIdxs, numPrefetchLocs, flags, stream);
  if (r == hipSuccess) {
    hrr_args_hipDrvMemDiscardAndPrefetchBatchAsync a{};
    a.ret         = static_cast<int32_t>(r);
    a.dptrs = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(dptrs));
    a.sizes = reinterpret_cast<uint64_t>(sizes);
    a.count = static_cast<decltype(a.count)>(count);
    a.prefetchLocs = 0;  // non-castable type skipped
    a.prefetchLocIdxs = reinterpret_cast<uint64_t>(prefetchLocIdxs);
    a.numPrefetchLocs = static_cast<decltype(a.numPrefetchLocs)>(numPrefetchLocs);
    a.flags = static_cast<decltype(a.flags)>(flags);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDRVMEMDISCARDANDPREFETCHBATCHASYNC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemPtrGetInfo(void* ptr, size_t* size) {
  hipError_t r = g_real_table.hipMemPtrGetInfo_fn(ptr, size);
  if (r == hipSuccess) {
    hrr_args_hipMemPtrGetInfo a{};
    a.ret         = static_cast<int32_t>(r);
    a.ptr = reinterpret_cast<uint64_t>(ptr);
    a.size = reinterpret_cast<uint64_t>(size);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMPTRGETINFO, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemRangeGetAttribute(void* data, size_t data_size, hipMemRangeAttribute attribute, const void* dev_ptr, size_t count) {
  hipError_t r = g_real_table.hipMemRangeGetAttribute_fn(data, data_size, attribute, dev_ptr, count);
  if (r == hipSuccess) {
    hrr_args_hipMemRangeGetAttribute a{};
    a.ret         = static_cast<int32_t>(r);
    a.data = reinterpret_cast<uint64_t>(data);
    a.data_size = static_cast<decltype(a.data_size)>(data_size);
    a.attribute = static_cast<decltype(a.attribute)>(attribute);
    a.dev_ptr = reinterpret_cast<uint64_t>(dev_ptr);
    a.count = static_cast<decltype(a.count)>(count);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMRANGEGETATTRIBUTE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemRangeGetAttributes(void** data, size_t* data_sizes, hipMemRangeAttribute* attributes, size_t num_attributes, const void* dev_ptr, size_t count) {
  hipError_t r = g_real_table.hipMemRangeGetAttributes_fn(data, data_sizes, attributes, num_attributes, dev_ptr, count);
  if (r == hipSuccess) {
    hrr_args_hipMemRangeGetAttributes a{};
    a.ret         = static_cast<int32_t>(r);
    a.data_sizes = reinterpret_cast<uint64_t>(data_sizes);
    a.attributes = reinterpret_cast<uint64_t>(attributes);
    a.num_attributes = static_cast<decltype(a.num_attributes)>(num_attributes);
    a.dev_ptr = reinterpret_cast<uint64_t>(dev_ptr);
    a.count = static_cast<decltype(a.count)>(count);
    if (data) a.data = reinterpret_cast<uint64_t>(*data);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMRANGEGETATTRIBUTES, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemRelease(hipMemGenericAllocationHandle_t handle) {
  hipError_t r = g_real_table.hipMemRelease_fn(handle);
  if (r == hipSuccess) {
    hrr_args_hipMemRelease a{};
    a.ret         = static_cast<int32_t>(r);
    a.handle = reinterpret_cast<uint64_t>(handle);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMRELEASE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemRetainAllocationHandle(hipMemGenericAllocationHandle_t* handle, void* addr) {
  hipError_t r = g_real_table.hipMemRetainAllocationHandle_fn(handle, addr);
  if (r == hipSuccess) {
    hrr_args_hipMemRetainAllocationHandle a{};
    a.ret         = static_cast<int32_t>(r);
    a.addr = reinterpret_cast<uint64_t>(addr);
    if (handle) a.handle = reinterpret_cast<uint64_t>(*handle);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMRETAINALLOCATIONHANDLE, &a.hdr, sizeof(a));
  }
  return r;
}


// Generated shim
static hipError_t capture_hipMemUnmap(void* ptr, size_t size) {
  hipError_t r = g_real_table.hipMemUnmap_fn(ptr, size);
  if (r == hipSuccess) {
    hrr_args_hipMemUnmap a{};
    a.ret         = static_cast<int32_t>(r);
    a.ptr = reinterpret_cast<uint64_t>(ptr);
    a.size = static_cast<decltype(a.size)>(size);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMUNMAP, &a.hdr, sizeof(a));
  }
  return r;
}


// Generated shim
static hipError_t capture_hipMemcpy2D(void* dst, size_t dpitch, const void* src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind) {
  hipError_t r = g_real_table.hipMemcpy2D_fn(dst, dpitch, src, spitch, width, height, kind);
  if (r == hipSuccess) {
    hrr_args_hipMemcpy2D a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.dpitch = static_cast<decltype(a.dpitch)>(dpitch);
    a.src = reinterpret_cast<uint64_t>(src);
    a.spitch = static_cast<decltype(a.spitch)>(spitch);
    a.width = static_cast<decltype(a.width)>(width);
    a.height = static_cast<decltype(a.height)>(height);
    a.kind = static_cast<decltype(a.kind)>(kind);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPY2D, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpy2DAsync(void* dst, size_t dpitch, const void* src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind, hipStream_t stream) {
  hipError_t r = g_real_table.hipMemcpy2DAsync_fn(dst, dpitch, src, spitch, width, height, kind, stream);
  if (r == hipSuccess) {
    hrr_args_hipMemcpy2DAsync a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.dpitch = static_cast<decltype(a.dpitch)>(dpitch);
    a.src = reinterpret_cast<uint64_t>(src);
    a.spitch = static_cast<decltype(a.spitch)>(spitch);
    a.width = static_cast<decltype(a.width)>(width);
    a.height = static_cast<decltype(a.height)>(height);
    a.kind = static_cast<decltype(a.kind)>(kind);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPY2DASYNC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpy2DFromArray(void* dst, size_t dpitch, hipArray_const_t src, size_t wOffset, size_t hOffset, size_t width, size_t height, hipMemcpyKind kind) {
  hipError_t r = g_real_table.hipMemcpy2DFromArray_fn(dst, dpitch, src, wOffset, hOffset, width, height, kind);
  if (r == hipSuccess) {
    hrr_args_hipMemcpy2DFromArray a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.dpitch = static_cast<decltype(a.dpitch)>(dpitch);
    a.src = reinterpret_cast<uint64_t>(src);
    a.wOffset = static_cast<decltype(a.wOffset)>(wOffset);
    a.hOffset = static_cast<decltype(a.hOffset)>(hOffset);
    a.width = static_cast<decltype(a.width)>(width);
    a.height = static_cast<decltype(a.height)>(height);
    a.kind = static_cast<decltype(a.kind)>(kind);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPY2DFROMARRAY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpy2DFromArrayAsync(void* dst, size_t dpitch, hipArray_const_t src, size_t wOffset, size_t hOffset, size_t width, size_t height, hipMemcpyKind kind, hipStream_t stream) {
  hipError_t r = g_real_table.hipMemcpy2DFromArrayAsync_fn(dst, dpitch, src, wOffset, hOffset, width, height, kind, stream);
  if (r == hipSuccess) {
    hrr_args_hipMemcpy2DFromArrayAsync a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.dpitch = static_cast<decltype(a.dpitch)>(dpitch);
    a.src = reinterpret_cast<uint64_t>(src);
    a.wOffset = static_cast<decltype(a.wOffset)>(wOffset);
    a.hOffset = static_cast<decltype(a.hOffset)>(hOffset);
    a.width = static_cast<decltype(a.width)>(width);
    a.height = static_cast<decltype(a.height)>(height);
    a.kind = static_cast<decltype(a.kind)>(kind);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPY2DFROMARRAYASYNC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpy2DToArray(hipArray_t dst, size_t wOffset, size_t hOffset, const void* src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind) {
  hipError_t r = g_real_table.hipMemcpy2DToArray_fn(dst, wOffset, hOffset, src, spitch, width, height, kind);
  if (r == hipSuccess) {
    hrr_args_hipMemcpy2DToArray a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.wOffset = static_cast<decltype(a.wOffset)>(wOffset);
    a.hOffset = static_cast<decltype(a.hOffset)>(hOffset);
    a.src = reinterpret_cast<uint64_t>(src);
    a.spitch = static_cast<decltype(a.spitch)>(spitch);
    a.width = static_cast<decltype(a.width)>(width);
    a.height = static_cast<decltype(a.height)>(height);
    a.kind = static_cast<decltype(a.kind)>(kind);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPY2DTOARRAY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpy2DToArrayAsync(hipArray_t dst, size_t wOffset, size_t hOffset, const void* src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind, hipStream_t stream) {
  hipError_t r = g_real_table.hipMemcpy2DToArrayAsync_fn(dst, wOffset, hOffset, src, spitch, width, height, kind, stream);
  if (r == hipSuccess) {
    hrr_args_hipMemcpy2DToArrayAsync a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.wOffset = static_cast<decltype(a.wOffset)>(wOffset);
    a.hOffset = static_cast<decltype(a.hOffset)>(hOffset);
    a.src = reinterpret_cast<uint64_t>(src);
    a.spitch = static_cast<decltype(a.spitch)>(spitch);
    a.width = static_cast<decltype(a.width)>(width);
    a.height = static_cast<decltype(a.height)>(height);
    a.kind = static_cast<decltype(a.kind)>(kind);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPY2DTOARRAYASYNC, &a.hdr, sizeof(a));
  }
  return r;
}




// Generated shim
static hipError_t capture_hipMemcpyAtoH(void* dst, hipArray_t srcArray, size_t srcOffset, size_t count) {
  hipError_t r = g_real_table.hipMemcpyAtoH_fn(dst, srcArray, srcOffset, count);
  if (r == hipSuccess) {
    hrr_args_hipMemcpyAtoH a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.srcArray = reinterpret_cast<uint64_t>(srcArray);
    a.srcOffset = static_cast<decltype(a.srcOffset)>(srcOffset);
    a.count = static_cast<decltype(a.count)>(count);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPYATOH, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpyDtoD(hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeBytes) {
  hipError_t r = g_real_table.hipMemcpyDtoD_fn(dst, src, sizeBytes);
  if (r == hipSuccess) {
    hrr_args_hipMemcpyDtoD a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(dst));
    a.src = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(src));
    a.sizeBytes = static_cast<decltype(a.sizeBytes)>(sizeBytes);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPYDTOD, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpyDtoDAsync(hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeBytes, hipStream_t stream) {
  hipError_t r = g_real_table.hipMemcpyDtoDAsync_fn(dst, src, sizeBytes, stream);
  if (r == hipSuccess) {
    hrr_args_hipMemcpyDtoDAsync a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(dst));
    a.src = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(src));
    a.sizeBytes = static_cast<decltype(a.sizeBytes)>(sizeBytes);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPYDTODASYNC, &a.hdr, sizeof(a));
  }
  return r;
}



// Generated shim
static hipError_t capture_hipMemcpyFromArray(void* dst, hipArray_const_t srcArray, size_t wOffset, size_t hOffset, size_t count, hipMemcpyKind kind) {
  hipError_t r = g_real_table.hipMemcpyFromArray_fn(dst, srcArray, wOffset, hOffset, count, kind);
  if (r == hipSuccess) {
    hrr_args_hipMemcpyFromArray a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.srcArray = reinterpret_cast<uint64_t>(srcArray);
    a.wOffset = static_cast<decltype(a.wOffset)>(wOffset);
    a.hOffset = static_cast<decltype(a.hOffset)>(hOffset);
    a.count = static_cast<decltype(a.count)>(count);
    a.kind = static_cast<decltype(a.kind)>(kind);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPYFROMARRAY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpyFromSymbol(void* dst, const void* symbol, size_t sizeBytes, size_t offset, hipMemcpyKind kind) {
  hipError_t r = g_real_table.hipMemcpyFromSymbol_fn(dst, symbol, sizeBytes, offset, kind);
  if (r == hipSuccess) {
    hrr_args_hipMemcpyFromSymbol a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.symbol = reinterpret_cast<uint64_t>(symbol);
    a.sizeBytes = static_cast<decltype(a.sizeBytes)>(sizeBytes);
    a.offset = static_cast<decltype(a.offset)>(offset);
    a.kind = static_cast<decltype(a.kind)>(kind);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPYFROMSYMBOL, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpyFromSymbolAsync(void* dst, const void* symbol, size_t sizeBytes, size_t offset, hipMemcpyKind kind, hipStream_t stream) {
  hipError_t r = g_real_table.hipMemcpyFromSymbolAsync_fn(dst, symbol, sizeBytes, offset, kind, stream);
  if (r == hipSuccess) {
    hrr_args_hipMemcpyFromSymbolAsync a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.symbol = reinterpret_cast<uint64_t>(symbol);
    a.sizeBytes = static_cast<decltype(a.sizeBytes)>(sizeBytes);
    a.offset = static_cast<decltype(a.offset)>(offset);
    a.kind = static_cast<decltype(a.kind)>(kind);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPYFROMSYMBOLASYNC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpyHtoA(hipArray_t dstArray, size_t dstOffset, const void* srcHost, size_t count) {
  hipError_t r = g_real_table.hipMemcpyHtoA_fn(dstArray, dstOffset, srcHost, count);
  if (r == hipSuccess) {
    hrr_args_hipMemcpyHtoA a{};
    a.ret         = static_cast<int32_t>(r);
    a.dstArray = reinterpret_cast<uint64_t>(dstArray);
    a.dstOffset = static_cast<decltype(a.dstOffset)>(dstOffset);
    a.srcHost = reinterpret_cast<uint64_t>(srcHost);
    a.count = static_cast<decltype(a.count)>(count);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPYHTOA, &a.hdr, sizeof(a));
  }
  return r;
}



// Generated shim
static hipError_t capture_hipMemcpyParam2D(const hip_Memcpy2D* pCopy) {
  hipError_t r = g_real_table.hipMemcpyParam2D_fn(pCopy);
  if (r == hipSuccess) {
    hrr_args_hipMemcpyParam2D a{};
    a.ret         = static_cast<int32_t>(r);
    a.pCopy = reinterpret_cast<uint64_t>(pCopy);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPYPARAM2D, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpyParam2DAsync(const hip_Memcpy2D* pCopy, hipStream_t stream) {
  hipError_t r = g_real_table.hipMemcpyParam2DAsync_fn(pCopy, stream);
  if (r == hipSuccess) {
    hrr_args_hipMemcpyParam2DAsync a{};
    a.ret         = static_cast<int32_t>(r);
    a.pCopy = reinterpret_cast<uint64_t>(pCopy);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPYPARAM2DASYNC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpyPeer(void* dst, int dstDeviceId, const void* src, int srcDeviceId, size_t sizeBytes) {
  hipError_t r = g_real_table.hipMemcpyPeer_fn(dst, dstDeviceId, src, srcDeviceId, sizeBytes);
  if (r == hipSuccess) {
    hrr_args_hipMemcpyPeer a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.dstDeviceId = static_cast<decltype(a.dstDeviceId)>(dstDeviceId);
    a.src = reinterpret_cast<uint64_t>(src);
    a.srcDeviceId = static_cast<decltype(a.srcDeviceId)>(srcDeviceId);
    a.sizeBytes = static_cast<decltype(a.sizeBytes)>(sizeBytes);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPYPEER, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpyPeerAsync(void* dst, int dstDeviceId, const void* src, int srcDevice, size_t sizeBytes, hipStream_t stream) {
  hipError_t r = g_real_table.hipMemcpyPeerAsync_fn(dst, dstDeviceId, src, srcDevice, sizeBytes, stream);
  if (r == hipSuccess) {
    hrr_args_hipMemcpyPeerAsync a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.dstDeviceId = static_cast<decltype(a.dstDeviceId)>(dstDeviceId);
    a.src = reinterpret_cast<uint64_t>(src);
    a.srcDevice = static_cast<decltype(a.srcDevice)>(srcDevice);
    a.sizeBytes = static_cast<decltype(a.sizeBytes)>(sizeBytes);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPYPEERASYNC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpyToArray(hipArray_t dst, size_t wOffset, size_t hOffset, const void* src, size_t count, hipMemcpyKind kind) {
  hipError_t r = g_real_table.hipMemcpyToArray_fn(dst, wOffset, hOffset, src, count, kind);
  if (r == hipSuccess) {
    hrr_args_hipMemcpyToArray a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.wOffset = static_cast<decltype(a.wOffset)>(wOffset);
    a.hOffset = static_cast<decltype(a.hOffset)>(hOffset);
    a.src = reinterpret_cast<uint64_t>(src);
    a.count = static_cast<decltype(a.count)>(count);
    a.kind = static_cast<decltype(a.kind)>(kind);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPYTOARRAY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpyToSymbol(const void* symbol, const void* src, size_t sizeBytes, size_t offset, hipMemcpyKind kind) {
  hipError_t r = g_real_table.hipMemcpyToSymbol_fn(symbol, src, sizeBytes, offset, kind);
  if (r == hipSuccess) {
    hrr_args_hipMemcpyToSymbol a{};
    a.ret         = static_cast<int32_t>(r);
    a.symbol = reinterpret_cast<uint64_t>(symbol);
    a.src = reinterpret_cast<uint64_t>(src);
    a.sizeBytes = static_cast<decltype(a.sizeBytes)>(sizeBytes);
    a.offset = static_cast<decltype(a.offset)>(offset);
    a.kind = static_cast<decltype(a.kind)>(kind);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPYTOSYMBOL, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpyToSymbolAsync(const void* symbol, const void* src, size_t sizeBytes, size_t offset, hipMemcpyKind kind, hipStream_t stream) {
  hipError_t r = g_real_table.hipMemcpyToSymbolAsync_fn(symbol, src, sizeBytes, offset, kind, stream);
  if (r == hipSuccess) {
    hrr_args_hipMemcpyToSymbolAsync a{};
    a.ret         = static_cast<int32_t>(r);
    a.symbol = reinterpret_cast<uint64_t>(symbol);
    a.src = reinterpret_cast<uint64_t>(src);
    a.sizeBytes = static_cast<decltype(a.sizeBytes)>(sizeBytes);
    a.offset = static_cast<decltype(a.offset)>(offset);
    a.kind = static_cast<decltype(a.kind)>(kind);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPYTOSYMBOLASYNC, &a.hdr, sizeof(a));
  }
  return r;
}


// Generated shim
static hipError_t capture_hipMemset(void* dst, int value, size_t sizeBytes) {
  hipError_t r = g_real_table.hipMemset_fn(dst, value, sizeBytes);
  if (r == hipSuccess) {
    hrr_args_hipMemset a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.value = static_cast<decltype(a.value)>(value);
    a.sizeBytes = static_cast<decltype(a.sizeBytes)>(sizeBytes);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMSET, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemset2D(void* dst, size_t pitch, int value, size_t width, size_t height) {
  hipError_t r = g_real_table.hipMemset2D_fn(dst, pitch, value, width, height);
  if (r == hipSuccess) {
    hrr_args_hipMemset2D a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.pitch = static_cast<decltype(a.pitch)>(pitch);
    a.value = static_cast<decltype(a.value)>(value);
    a.width = static_cast<decltype(a.width)>(width);
    a.height = static_cast<decltype(a.height)>(height);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMSET2D, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemset2DAsync(void* dst, size_t pitch, int value, size_t width, size_t height, hipStream_t stream) {
  hipError_t r = g_real_table.hipMemset2DAsync_fn(dst, pitch, value, width, height, stream);
  if (r == hipSuccess) {
    hrr_args_hipMemset2DAsync a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.pitch = static_cast<decltype(a.pitch)>(pitch);
    a.value = static_cast<decltype(a.value)>(value);
    a.width = static_cast<decltype(a.width)>(width);
    a.height = static_cast<decltype(a.height)>(height);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMSET2DASYNC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemset3D(hipPitchedPtr pitchedDevPtr, int value, hipExtent extent) {
  hipError_t r = g_real_table.hipMemset3D_fn(pitchedDevPtr, value, extent);
  if (r == hipSuccess) {
    hrr_args_hipMemset3D a{};
    a.ret         = static_cast<int32_t>(r);
    a.pitchedDevPtr = 0;  // non-castable type skipped
    a.value = static_cast<decltype(a.value)>(value);
    a.extent = 0;  // non-castable type skipped
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMSET3D, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemset3DAsync(hipPitchedPtr pitchedDevPtr, int value, hipExtent extent, hipStream_t stream) {
  hipError_t r = g_real_table.hipMemset3DAsync_fn(pitchedDevPtr, value, extent, stream);
  if (r == hipSuccess) {
    hrr_args_hipMemset3DAsync a{};
    a.ret         = static_cast<int32_t>(r);
    a.pitchedDevPtr = 0;  // non-castable type skipped
    a.value = static_cast<decltype(a.value)>(value);
    a.extent = 0;  // non-castable type skipped
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMSET3DASYNC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemsetAsync(void* dst, int value, size_t sizeBytes, hipStream_t stream) {
  hipError_t r = g_real_table.hipMemsetAsync_fn(dst, value, sizeBytes, stream);
  if (r == hipSuccess) {
    hrr_args_hipMemsetAsync a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.value = static_cast<decltype(a.value)>(value);
    a.sizeBytes = static_cast<decltype(a.sizeBytes)>(sizeBytes);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMSETASYNC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemsetD16(hipDeviceptr_t dest, unsigned short value, size_t count) {
  hipError_t r = g_real_table.hipMemsetD16_fn(dest, value, count);
  if (r == hipSuccess) {
    hrr_args_hipMemsetD16 a{};
    a.ret         = static_cast<int32_t>(r);
    a.dest = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(dest));
    a.value = static_cast<decltype(a.value)>(value);
    a.count = static_cast<decltype(a.count)>(count);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMSETD16, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemsetD16Async(hipDeviceptr_t dest, unsigned short value, size_t count, hipStream_t stream) {
  hipError_t r = g_real_table.hipMemsetD16Async_fn(dest, value, count, stream);
  if (r == hipSuccess) {
    hrr_args_hipMemsetD16Async a{};
    a.ret         = static_cast<int32_t>(r);
    a.dest = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(dest));
    a.value = static_cast<decltype(a.value)>(value);
    a.count = static_cast<decltype(a.count)>(count);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMSETD16ASYNC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemsetD32(hipDeviceptr_t dest, int value, size_t count) {
  hipError_t r = g_real_table.hipMemsetD32_fn(dest, value, count);
  if (r == hipSuccess) {
    hrr_args_hipMemsetD32 a{};
    a.ret         = static_cast<int32_t>(r);
    a.dest = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(dest));
    a.value = static_cast<decltype(a.value)>(value);
    a.count = static_cast<decltype(a.count)>(count);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMSETD32, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemsetD32Async(hipDeviceptr_t dst, int value, size_t count, hipStream_t stream) {
  hipError_t r = g_real_table.hipMemsetD32Async_fn(dst, value, count, stream);
  if (r == hipSuccess) {
    hrr_args_hipMemsetD32Async a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(dst));
    a.value = static_cast<decltype(a.value)>(value);
    a.count = static_cast<decltype(a.count)>(count);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMSETD32ASYNC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemsetD8(hipDeviceptr_t dest, unsigned char value, size_t count) {
  hipError_t r = g_real_table.hipMemsetD8_fn(dest, value, count);
  if (r == hipSuccess) {
    hrr_args_hipMemsetD8 a{};
    a.ret         = static_cast<int32_t>(r);
    a.dest = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(dest));
    a.value = static_cast<decltype(a.value)>(value);
    a.count = static_cast<decltype(a.count)>(count);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMSETD8, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemsetD8Async(hipDeviceptr_t dest, unsigned char value, size_t count, hipStream_t stream) {
  hipError_t r = g_real_table.hipMemsetD8Async_fn(dest, value, count, stream);
  if (r == hipSuccess) {
    hrr_args_hipMemsetD8Async a{};
    a.ret         = static_cast<int32_t>(r);
    a.dest = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(dest));
    a.value = static_cast<decltype(a.value)>(value);
    a.count = static_cast<decltype(a.count)>(count);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMSETD8ASYNC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMipmappedArrayCreate(hipMipmappedArray_t* pHandle, HIP_ARRAY3D_DESCRIPTOR* pMipmappedArrayDesc, unsigned int numMipmapLevels) {
  hipError_t r = g_real_table.hipMipmappedArrayCreate_fn(pHandle, pMipmappedArrayDesc, numMipmapLevels);
  if (r == hipSuccess) {
    hrr_args_hipMipmappedArrayCreate a{};
    a.ret         = static_cast<int32_t>(r);
    a.pMipmappedArrayDesc = reinterpret_cast<uint64_t>(pMipmappedArrayDesc);
    a.numMipmapLevels = static_cast<decltype(a.numMipmapLevels)>(numMipmapLevels);
    if (pHandle) a.pHandle = reinterpret_cast<uint64_t>(*pHandle);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMIPMAPPEDARRAYCREATE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMipmappedArrayDestroy(hipMipmappedArray_t hMipmappedArray) {
  hipError_t r = g_real_table.hipMipmappedArrayDestroy_fn(hMipmappedArray);
  if (r == hipSuccess) {
    hrr_args_hipMipmappedArrayDestroy a{};
    a.ret         = static_cast<int32_t>(r);
    a.hMipmappedArray = reinterpret_cast<uint64_t>(hMipmappedArray);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMIPMAPPEDARRAYDESTROY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMipmappedArrayGetLevel(hipArray_t* pLevelArray, hipMipmappedArray_t hMipMappedArray, unsigned int level) {
  hipError_t r = g_real_table.hipMipmappedArrayGetLevel_fn(pLevelArray, hMipMappedArray, level);
  if (r == hipSuccess) {
    hrr_args_hipMipmappedArrayGetLevel a{};
    a.ret         = static_cast<int32_t>(r);
    a.hMipMappedArray = reinterpret_cast<uint64_t>(hMipMappedArray);
    a.level = static_cast<decltype(a.level)>(level);
    if (pLevelArray) a.pLevelArray = reinterpret_cast<uint64_t>(*pLevelArray);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMIPMAPPEDARRAYGETLEVEL, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipModuleGetFunction(hipFunction_t* function, hipModule_t module, const char* kname) {
  hipError_t r = g_real_table.hipModuleGetFunction_fn(function, module, kname);
  return r;
}

// Generated shim
static hipError_t capture_hipModuleGetFunctionCount(unsigned int* count, hipModule_t module) {
  hipError_t r = g_real_table.hipModuleGetFunctionCount_fn(count, module);
  if (r == hipSuccess) {
    hrr_args_hipModuleGetFunctionCount a{};
    a.ret         = static_cast<int32_t>(r);
    a.count = reinterpret_cast<uint64_t>(count);
    a.module = reinterpret_cast<uint64_t>(module);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMODULEGETFUNCTIONCOUNT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipModuleGetGlobal(hipDeviceptr_t* dptr, size_t* bytes, hipModule_t hmod, const char* name) {
  hipError_t r = g_real_table.hipModuleGetGlobal_fn(dptr, bytes, hmod, name);
  if (r == hipSuccess) {
    hrr_args_hipModuleGetGlobal a{};
    a.ret         = static_cast<int32_t>(r);
    a.dptr = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(dptr));
    a.bytes = reinterpret_cast<uint64_t>(bytes);
    a.hmod = reinterpret_cast<uint64_t>(hmod);
    a.name = reinterpret_cast<uint64_t>(name);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMODULEGETGLOBAL, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipModuleGetTexRef(textureReference** texRef, hipModule_t hmod, const char* name) {
  hipError_t r = g_real_table.hipModuleGetTexRef_fn(texRef, hmod, name);
  if (r == hipSuccess) {
    hrr_args_hipModuleGetTexRef a{};
    a.ret         = static_cast<int32_t>(r);
    a.hmod = reinterpret_cast<uint64_t>(hmod);
    a.name = reinterpret_cast<uint64_t>(name);
    if (texRef) a.texRef = reinterpret_cast<uint64_t>(*texRef);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMODULEGETTEXREF, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipModuleLaunchCooperativeKernel(hipFunction_t f, unsigned int gridDimX, unsigned int gridDimY, unsigned int gridDimZ, unsigned int blockDimX, unsigned int blockDimY, unsigned int blockDimZ, unsigned int sharedMemBytes, hipStream_t stream, void** kernelParams) {
  hipError_t r = g_real_table.hipModuleLaunchCooperativeKernel_fn(f, gridDimX, gridDimY, gridDimZ, blockDimX, blockDimY, blockDimZ, sharedMemBytes, stream, kernelParams);
  if (r == hipSuccess) {
    hrr_args_hipModuleLaunchCooperativeKernel a{};
    a.ret         = static_cast<int32_t>(r);
    a.f = reinterpret_cast<uint64_t>(f);
    a.gridDimX = static_cast<decltype(a.gridDimX)>(gridDimX);
    a.gridDimY = static_cast<decltype(a.gridDimY)>(gridDimY);
    a.gridDimZ = static_cast<decltype(a.gridDimZ)>(gridDimZ);
    a.blockDimX = static_cast<decltype(a.blockDimX)>(blockDimX);
    a.blockDimY = static_cast<decltype(a.blockDimY)>(blockDimY);
    a.blockDimZ = static_cast<decltype(a.blockDimZ)>(blockDimZ);
    a.sharedMemBytes = static_cast<decltype(a.sharedMemBytes)>(sharedMemBytes);
    a.stream = reinterpret_cast<uint64_t>(stream);
    if (kernelParams) a.kernelParams = reinterpret_cast<uint64_t>(*kernelParams);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMODULELAUNCHCOOPERATIVEKERNEL, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipModuleLaunchCooperativeKernelMultiDevice(hipFunctionLaunchParams* launchParamsList, unsigned int numDevices, unsigned int flags) {
  hipError_t r = g_real_table.hipModuleLaunchCooperativeKernelMultiDevice_fn(launchParamsList, numDevices, flags);
  if (r == hipSuccess) {
    hrr_args_hipModuleLaunchCooperativeKernelMultiDevice a{};
    a.ret         = static_cast<int32_t>(r);
    a.launchParamsList = reinterpret_cast<uint64_t>(launchParamsList);
    a.numDevices = static_cast<decltype(a.numDevices)>(numDevices);
    a.flags = static_cast<decltype(a.flags)>(flags);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMODULELAUNCHCOOPERATIVEKERNELMULTIDEVICE, &a.hdr, sizeof(a));
  }
  return r;
}





// Generated shim
static hipError_t capture_hipLinkAddData(hipLinkState_t state, hipJitInputType type, void* data, size_t size, const char* name, unsigned int numOptions, hipJitOption* options, void** optionValues) {
  hipError_t r = g_real_table.hipLinkAddData_fn(state, type, data, size, name, numOptions, options, optionValues);
  if (r == hipSuccess) {
    hrr_args_hipLinkAddData a{};
    a.ret         = static_cast<int32_t>(r);
    a.state = 0;  // non-castable type skipped
    a.type = static_cast<decltype(a.type)>(type);
    a.data = reinterpret_cast<uint64_t>(data);
    a.size = static_cast<decltype(a.size)>(size);
    a.name = reinterpret_cast<uint64_t>(name);
    a.numOptions = static_cast<decltype(a.numOptions)>(numOptions);
    a.options = reinterpret_cast<uint64_t>(options);
    if (optionValues) a.optionValues = reinterpret_cast<uint64_t>(*optionValues);
    hrr_cap::writer::write_event_raw(HRR_API_HIPLINKADDDATA, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipLinkAddFile(hipLinkState_t state, hipJitInputType type, const char* path, unsigned int numOptions, hipJitOption* options, void** optionValues) {
  hipError_t r = g_real_table.hipLinkAddFile_fn(state, type, path, numOptions, options, optionValues);
  if (r == hipSuccess) {
    hrr_args_hipLinkAddFile a{};
    a.ret         = static_cast<int32_t>(r);
    a.state = 0;  // non-castable type skipped
    a.type = static_cast<decltype(a.type)>(type);
    a.path = reinterpret_cast<uint64_t>(path);
    a.numOptions = static_cast<decltype(a.numOptions)>(numOptions);
    a.options = reinterpret_cast<uint64_t>(options);
    if (optionValues) a.optionValues = reinterpret_cast<uint64_t>(*optionValues);
    hrr_cap::writer::write_event_raw(HRR_API_HIPLINKADDFILE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipLinkComplete(hipLinkState_t state, void** hipBinOut, size_t* sizeOut) {
  hipError_t r = g_real_table.hipLinkComplete_fn(state, hipBinOut, sizeOut);
  if (r == hipSuccess) {
    hrr_args_hipLinkComplete a{};
    a.ret         = static_cast<int32_t>(r);
    a.state = 0;  // non-castable type skipped
    a.sizeOut = reinterpret_cast<uint64_t>(sizeOut);
    if (hipBinOut) a.hipBinOut = reinterpret_cast<uint64_t>(*hipBinOut);
    hrr_cap::writer::write_event_raw(HRR_API_HIPLINKCOMPLETE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipLinkCreate(unsigned int numOptions, hipJitOption* options, void** optionValues, hipLinkState_t* stateOut) {
  hipError_t r = g_real_table.hipLinkCreate_fn(numOptions, options, optionValues, stateOut);
  if (r == hipSuccess) {
    hrr_args_hipLinkCreate a{};
    a.ret         = static_cast<int32_t>(r);
    a.numOptions = static_cast<decltype(a.numOptions)>(numOptions);
    a.options = reinterpret_cast<uint64_t>(options);
    a.stateOut = 0;  // non-castable type skipped
    if (optionValues) a.optionValues = reinterpret_cast<uint64_t>(*optionValues);
    hrr_cap::writer::write_event_raw(HRR_API_HIPLINKCREATE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipLinkDestroy(hipLinkState_t state) {
  hipError_t r = g_real_table.hipLinkDestroy_fn(state);
  if (r == hipSuccess) {
    hrr_args_hipLinkDestroy a{};
    a.ret         = static_cast<int32_t>(r);
    a.state = 0;  // non-castable type skipped
    hrr_cap::writer::write_event_raw(HRR_API_HIPLINKDESTROY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipModuleOccupancyMaxActiveBlocksPerMultiprocessor(int* numBlocks, hipFunction_t f, int blockSize, size_t dynSharedMemPerBlk) {
  hipError_t r = g_real_table.hipModuleOccupancyMaxActiveBlocksPerMultiprocessor_fn(numBlocks, f, blockSize, dynSharedMemPerBlk);
  if (r == hipSuccess) {
    hrr_args_hipModuleOccupancyMaxActiveBlocksPerMultiprocessor a{};
    a.ret         = static_cast<int32_t>(r);
    a.numBlocks = reinterpret_cast<uint64_t>(numBlocks);
    a.f = reinterpret_cast<uint64_t>(f);
    a.blockSize = static_cast<decltype(a.blockSize)>(blockSize);
    a.dynSharedMemPerBlk = static_cast<decltype(a.dynSharedMemPerBlk)>(dynSharedMemPerBlk);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMODULEOCCUPANCYMAXACTIVEBLOCKSPERMULTIPROCESSOR, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipModuleOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(int* numBlocks, hipFunction_t f, int blockSize, size_t dynSharedMemPerBlk, unsigned int flags) {
  hipError_t r = g_real_table.hipModuleOccupancyMaxActiveBlocksPerMultiprocessorWithFlags_fn(numBlocks, f, blockSize, dynSharedMemPerBlk, flags);
  if (r == hipSuccess) {
    hrr_args_hipModuleOccupancyMaxActiveBlocksPerMultiprocessorWithFlags a{};
    a.ret         = static_cast<int32_t>(r);
    a.numBlocks = reinterpret_cast<uint64_t>(numBlocks);
    a.f = reinterpret_cast<uint64_t>(f);
    a.blockSize = static_cast<decltype(a.blockSize)>(blockSize);
    a.dynSharedMemPerBlk = static_cast<decltype(a.dynSharedMemPerBlk)>(dynSharedMemPerBlk);
    a.flags = static_cast<decltype(a.flags)>(flags);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMODULEOCCUPANCYMAXACTIVEBLOCKSPERMULTIPROCESSORWITHFLAGS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipModuleOccupancyMaxPotentialBlockSize(int* gridSize, int* blockSize, hipFunction_t f, size_t dynSharedMemPerBlk, int blockSizeLimit) {
  hipError_t r = g_real_table.hipModuleOccupancyMaxPotentialBlockSize_fn(gridSize, blockSize, f, dynSharedMemPerBlk, blockSizeLimit);
  if (r == hipSuccess) {
    hrr_args_hipModuleOccupancyMaxPotentialBlockSize a{};
    a.ret         = static_cast<int32_t>(r);
    a.gridSize = reinterpret_cast<uint64_t>(gridSize);
    a.blockSize = reinterpret_cast<uint64_t>(blockSize);
    a.f = reinterpret_cast<uint64_t>(f);
    a.dynSharedMemPerBlk = static_cast<decltype(a.dynSharedMemPerBlk)>(dynSharedMemPerBlk);
    a.blockSizeLimit = static_cast<decltype(a.blockSizeLimit)>(blockSizeLimit);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMODULEOCCUPANCYMAXPOTENTIALBLOCKSIZE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipModuleOccupancyMaxPotentialBlockSizeWithFlags(int* gridSize, int* blockSize, hipFunction_t f, size_t dynSharedMemPerBlk, int blockSizeLimit, unsigned int flags) {
  hipError_t r = g_real_table.hipModuleOccupancyMaxPotentialBlockSizeWithFlags_fn(gridSize, blockSize, f, dynSharedMemPerBlk, blockSizeLimit, flags);
  if (r == hipSuccess) {
    hrr_args_hipModuleOccupancyMaxPotentialBlockSizeWithFlags a{};
    a.ret         = static_cast<int32_t>(r);
    a.gridSize = reinterpret_cast<uint64_t>(gridSize);
    a.blockSize = reinterpret_cast<uint64_t>(blockSize);
    a.f = reinterpret_cast<uint64_t>(f);
    a.dynSharedMemPerBlk = static_cast<decltype(a.dynSharedMemPerBlk)>(dynSharedMemPerBlk);
    a.blockSizeLimit = static_cast<decltype(a.blockSizeLimit)>(blockSizeLimit);
    a.flags = static_cast<decltype(a.flags)>(flags);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMODULEOCCUPANCYMAXPOTENTIALBLOCKSIZEWITHFLAGS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipModuleUnload(hipModule_t module) {
  hipError_t r = g_real_table.hipModuleUnload_fn(module);
  if (r == hipSuccess) {
    hrr_args_hipModuleUnload a{};
    a.ret         = static_cast<int32_t>(r);
    a.module = reinterpret_cast<uint64_t>(module);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMODULEUNLOAD, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipOccupancyAvailableDynamicSMemPerBlock(size_t* dynamicSmemSize, const void* f, int numBlocks, int blockSize) {
  hipError_t r = g_real_table.hipOccupancyAvailableDynamicSMemPerBlock_fn(dynamicSmemSize, f, numBlocks, blockSize);
  if (r == hipSuccess) {
    hrr_args_hipOccupancyAvailableDynamicSMemPerBlock a{};
    a.ret         = static_cast<int32_t>(r);
    a.dynamicSmemSize = reinterpret_cast<uint64_t>(dynamicSmemSize);
    a.f = reinterpret_cast<uint64_t>(f);
    a.numBlocks = static_cast<decltype(a.numBlocks)>(numBlocks);
    a.blockSize = static_cast<decltype(a.blockSize)>(blockSize);
    hrr_cap::writer::write_event_raw(HRR_API_HIPOCCUPANCYAVAILABLEDYNAMICSMEMPERBLOCK, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipOccupancyMaxActiveBlocksPerMultiprocessor(int* numBlocks, const void* f, int blockSize, size_t dynSharedMemPerBlk) {
  hipError_t r = g_real_table.hipOccupancyMaxActiveBlocksPerMultiprocessor_fn(numBlocks, f, blockSize, dynSharedMemPerBlk);
  if (r == hipSuccess) {
    hrr_args_hipOccupancyMaxActiveBlocksPerMultiprocessor a{};
    a.ret         = static_cast<int32_t>(r);
    a.numBlocks = reinterpret_cast<uint64_t>(numBlocks);
    a.f = reinterpret_cast<uint64_t>(f);
    a.blockSize = static_cast<decltype(a.blockSize)>(blockSize);
    a.dynSharedMemPerBlk = static_cast<decltype(a.dynSharedMemPerBlk)>(dynSharedMemPerBlk);
    hrr_cap::writer::write_event_raw(HRR_API_HIPOCCUPANCYMAXACTIVEBLOCKSPERMULTIPROCESSOR, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(int* numBlocks, const void* f, int blockSize, size_t dynSharedMemPerBlk, unsigned int flags) {
  hipError_t r = g_real_table.hipOccupancyMaxActiveBlocksPerMultiprocessorWithFlags_fn(numBlocks, f, blockSize, dynSharedMemPerBlk, flags);
  if (r == hipSuccess) {
    hrr_args_hipOccupancyMaxActiveBlocksPerMultiprocessorWithFlags a{};
    a.ret         = static_cast<int32_t>(r);
    a.numBlocks = reinterpret_cast<uint64_t>(numBlocks);
    a.f = reinterpret_cast<uint64_t>(f);
    a.blockSize = static_cast<decltype(a.blockSize)>(blockSize);
    a.dynSharedMemPerBlk = static_cast<decltype(a.dynSharedMemPerBlk)>(dynSharedMemPerBlk);
    a.flags = static_cast<decltype(a.flags)>(flags);
    hrr_cap::writer::write_event_raw(HRR_API_HIPOCCUPANCYMAXACTIVEBLOCKSPERMULTIPROCESSORWITHFLAGS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipOccupancyMaxPotentialBlockSize(int* gridSize, int* blockSize, const void* f, size_t dynSharedMemPerBlk, int blockSizeLimit) {
  hipError_t r = g_real_table.hipOccupancyMaxPotentialBlockSize_fn(gridSize, blockSize, f, dynSharedMemPerBlk, blockSizeLimit);
  if (r == hipSuccess) {
    hrr_args_hipOccupancyMaxPotentialBlockSize a{};
    a.ret         = static_cast<int32_t>(r);
    a.gridSize = reinterpret_cast<uint64_t>(gridSize);
    a.blockSize = reinterpret_cast<uint64_t>(blockSize);
    a.f = reinterpret_cast<uint64_t>(f);
    a.dynSharedMemPerBlk = static_cast<decltype(a.dynSharedMemPerBlk)>(dynSharedMemPerBlk);
    a.blockSizeLimit = static_cast<decltype(a.blockSizeLimit)>(blockSizeLimit);
    hrr_cap::writer::write_event_raw(HRR_API_HIPOCCUPANCYMAXPOTENTIALBLOCKSIZE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipOccupancyMaxActiveClusters(int* numClusters, const void* f, const hipLaunchConfig_t* launchConfig) {
  hipError_t r = g_real_table.hipOccupancyMaxActiveClusters_fn(numClusters, f, launchConfig);
  if (r == hipSuccess) {
    hrr_args_hipOccupancyMaxActiveClusters a{};
    a.ret         = static_cast<int32_t>(r);
    a.numClusters = reinterpret_cast<uint64_t>(numClusters);
    a.f = reinterpret_cast<uint64_t>(f);
    a.launchConfig = reinterpret_cast<uint64_t>(launchConfig);
    hrr_cap::writer::write_event_raw(HRR_API_HIPOCCUPANCYMAXACTIVECLUSTERS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipOccupancyMaxPotentialClusterSize(int* clusterSize, const void* f, const hipLaunchConfig_t* config) {
  hipError_t r = g_real_table.hipOccupancyMaxPotentialClusterSize_fn(clusterSize, f, config);
  if (r == hipSuccess) {
    hrr_args_hipOccupancyMaxPotentialClusterSize a{};
    a.ret         = static_cast<int32_t>(r);
    a.clusterSize = reinterpret_cast<uint64_t>(clusterSize);
    a.f = reinterpret_cast<uint64_t>(f);
    a.config = reinterpret_cast<uint64_t>(config);
    hrr_cap::writer::write_event_raw(HRR_API_HIPOCCUPANCYMAXPOTENTIALCLUSTERSIZE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipPeekAtLastError(void) {
  hipError_t r = g_real_table.hipPeekAtLastError_fn();
  if (r == hipSuccess) {
    hrr_args_hipPeekAtLastError a{};
    a.ret         = static_cast<int32_t>(r);
    hrr_cap::writer::write_event_raw(HRR_API_HIPPEEKATLASTERROR, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipPointerGetAttribute(void* data, hipPointer_attribute attribute, hipDeviceptr_t ptr) {
  hipError_t r = g_real_table.hipPointerGetAttribute_fn(data, attribute, ptr);
  if (r == hipSuccess) {
    hrr_args_hipPointerGetAttribute a{};
    a.ret         = static_cast<int32_t>(r);
    a.data = reinterpret_cast<uint64_t>(data);
    a.attribute = static_cast<decltype(a.attribute)>(attribute);
    a.ptr = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(ptr));
    hrr_cap::writer::write_event_raw(HRR_API_HIPPOINTERGETATTRIBUTE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipPointerGetAttributes(hipPointerAttribute_t* attributes, const void* ptr) {
  hipError_t r = g_real_table.hipPointerGetAttributes_fn(attributes, ptr);
  if (r == hipSuccess) {
    hrr_args_hipPointerGetAttributes a{};
    a.ret         = static_cast<int32_t>(r);
    a.attributes = reinterpret_cast<uint64_t>(attributes);
    a.ptr = reinterpret_cast<uint64_t>(ptr);
    hrr_cap::writer::write_event_raw(HRR_API_HIPPOINTERGETATTRIBUTES, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipPointerSetAttribute(const void* value, hipPointer_attribute attribute, hipDeviceptr_t ptr) {
  hipError_t r = g_real_table.hipPointerSetAttribute_fn(value, attribute, ptr);
  if (r == hipSuccess) {
    hrr_args_hipPointerSetAttribute a{};
    a.ret         = static_cast<int32_t>(r);
    a.value = reinterpret_cast<uint64_t>(value);
    a.attribute = static_cast<decltype(a.attribute)>(attribute);
    a.ptr = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(ptr));
    hrr_cap::writer::write_event_raw(HRR_API_HIPPOINTERSETATTRIBUTE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipProfilerStart(void) {
  hipError_t r = g_real_table.hipProfilerStart_fn();
  if (r == hipSuccess) {
    hrr_args_hipProfilerStart a{};
    a.ret         = static_cast<int32_t>(r);
    hrr_cap::writer::write_event_raw(HRR_API_HIPPROFILERSTART, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipProfilerStop(void) {
  hipError_t r = g_real_table.hipProfilerStop_fn();
  if (r == hipSuccess) {
    hrr_args_hipProfilerStop a{};
    a.ret         = static_cast<int32_t>(r);
    hrr_cap::writer::write_event_raw(HRR_API_HIPPROFILERSTOP, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipRuntimeGetVersion(int* runtimeVersion) {
  hipError_t r = g_real_table.hipRuntimeGetVersion_fn(runtimeVersion);
  if (r == hipSuccess) {
    hrr_args_hipRuntimeGetVersion a{};
    a.ret         = static_cast<int32_t>(r);
    a.runtimeVersion = reinterpret_cast<uint64_t>(runtimeVersion);
    hrr_cap::writer::write_event_raw(HRR_API_HIPRUNTIMEGETVERSION, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipSetDevice(int deviceId) {
  hipError_t r = g_real_table.hipSetDevice_fn(deviceId);
  if (r == hipSuccess) {
    hrr_args_hipSetDevice a{};
    a.ret         = static_cast<int32_t>(r);
    a.deviceId = static_cast<decltype(a.deviceId)>(deviceId);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSETDEVICE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipSetDeviceFlags(unsigned flags) {
  hipError_t r = g_real_table.hipSetDeviceFlags_fn(flags);
  if (r == hipSuccess) {
    hrr_args_hipSetDeviceFlags a{};
    a.ret         = static_cast<int32_t>(r);
    a.flags = static_cast<decltype(a.flags)>(flags);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSETDEVICEFLAGS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipSetupArgument(const void* arg, size_t size, size_t offset) {
  hipError_t r = g_real_table.hipSetupArgument_fn(arg, size, offset);
  if (r == hipSuccess) {
    hrr_args_hipSetupArgument a{};
    a.ret         = static_cast<int32_t>(r);
    a.arg = reinterpret_cast<uint64_t>(arg);
    a.size = static_cast<decltype(a.size)>(size);
    a.offset = static_cast<decltype(a.offset)>(offset);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSETUPARGUMENT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipSignalExternalSemaphoresAsync(const hipExternalSemaphore_t* extSemArray, const hipExternalSemaphoreSignalParams* paramsArray, unsigned int numExtSems, hipStream_t stream) {
  hipError_t r = g_real_table.hipSignalExternalSemaphoresAsync_fn(extSemArray, paramsArray, numExtSems, stream);
  if (r == hipSuccess) {
    hrr_args_hipSignalExternalSemaphoresAsync a{};
    a.ret         = static_cast<int32_t>(r);
    a.extSemArray = reinterpret_cast<uint64_t>(extSemArray);
    a.paramsArray = reinterpret_cast<uint64_t>(paramsArray);
    a.numExtSems = static_cast<decltype(a.numExtSems)>(numExtSems);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSIGNALEXTERNALSEMAPHORESASYNC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamAddCallback(hipStream_t stream, hipStreamCallback_t callback, void* userData, unsigned int flags) {
  hipError_t r = g_real_table.hipStreamAddCallback_fn(stream, callback, userData, flags);
  if (r == hipSuccess) {
    hrr_args_hipStreamAddCallback a{};
    a.ret         = static_cast<int32_t>(r);
    a.stream = reinterpret_cast<uint64_t>(stream);
    a.callback = 0;  // non-castable type skipped
    a.userData = reinterpret_cast<uint64_t>(userData);
    a.flags = static_cast<decltype(a.flags)>(flags);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMADDCALLBACK, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamAttachMemAsync(hipStream_t stream, void* dev_ptr, size_t length, unsigned int flags) {
  hipError_t r = g_real_table.hipStreamAttachMemAsync_fn(stream, dev_ptr, length, flags);
  if (r == hipSuccess) {
    hrr_args_hipStreamAttachMemAsync a{};
    a.ret         = static_cast<int32_t>(r);
    a.stream = reinterpret_cast<uint64_t>(stream);
    a.dev_ptr = reinterpret_cast<uint64_t>(dev_ptr);
    a.length = static_cast<decltype(a.length)>(length);
    a.flags = static_cast<decltype(a.flags)>(flags);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMATTACHMEMASYNC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamBeginCapture(hipStream_t stream, hipStreamCaptureMode mode) {
  hipError_t r = g_real_table.hipStreamBeginCapture_fn(stream, mode);
  if (r == hipSuccess) {
    hrr_args_hipStreamBeginCapture a{};
    a.ret         = static_cast<int32_t>(r);
    a.stream = reinterpret_cast<uint64_t>(stream);
    a.mode = static_cast<decltype(a.mode)>(mode);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMBEGINCAPTURE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamCopyAttributes(hipStream_t dst, hipStream_t src) {
  hipError_t r = g_real_table.hipStreamCopyAttributes_fn(dst, src);
  if (r == hipSuccess) {
    hrr_args_hipStreamCopyAttributes a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.src = reinterpret_cast<uint64_t>(src);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMCOPYATTRIBUTES, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamCreate(hipStream_t* stream) {
  hipError_t r = g_real_table.hipStreamCreate_fn(stream);
  if (r == hipSuccess) {
    hrr_args_hipStreamCreate a{};
    a.ret         = static_cast<int32_t>(r);
    if (stream) a.stream = reinterpret_cast<uint64_t>(*stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMCREATE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamCreateWithFlags(hipStream_t* stream, unsigned int flags) {
  hipError_t r = g_real_table.hipStreamCreateWithFlags_fn(stream, flags);
  if (r == hipSuccess) {
    hrr_args_hipStreamCreateWithFlags a{};
    a.ret         = static_cast<int32_t>(r);
    a.flags = static_cast<decltype(a.flags)>(flags);
    if (stream) a.stream = reinterpret_cast<uint64_t>(*stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMCREATEWITHFLAGS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamCreateWithPriority(hipStream_t* stream, unsigned int flags, int priority) {
  hipError_t r = g_real_table.hipStreamCreateWithPriority_fn(stream, flags, priority);
  if (r == hipSuccess) {
    hrr_args_hipStreamCreateWithPriority a{};
    a.ret         = static_cast<int32_t>(r);
    a.flags = static_cast<decltype(a.flags)>(flags);
    a.priority = static_cast<decltype(a.priority)>(priority);
    if (stream) a.stream = reinterpret_cast<uint64_t>(*stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMCREATEWITHPRIORITY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamDestroy(hipStream_t stream) {
  hipError_t r = g_real_table.hipStreamDestroy_fn(stream);
  if (r == hipSuccess) {
    hrr_args_hipStreamDestroy a{};
    a.ret         = static_cast<int32_t>(r);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMDESTROY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamEndCapture(hipStream_t stream, hipGraph_t* pGraph) {
  hipError_t r = g_real_table.hipStreamEndCapture_fn(stream, pGraph);
  if (r == hipSuccess) {
    hrr_args_hipStreamEndCapture a{};
    a.ret         = static_cast<int32_t>(r);
    a.stream = reinterpret_cast<uint64_t>(stream);
    if (pGraph) a.pGraph = reinterpret_cast<uint64_t>(*pGraph);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMENDCAPTURE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamGetCaptureInfo(hipStream_t stream, hipStreamCaptureStatus* pCaptureStatus, unsigned long long* pId) {
  hipError_t r = g_real_table.hipStreamGetCaptureInfo_fn(stream, pCaptureStatus, pId);
  if (r == hipSuccess) {
    hrr_args_hipStreamGetCaptureInfo a{};
    a.ret         = static_cast<int32_t>(r);
    a.stream = reinterpret_cast<uint64_t>(stream);
    a.pCaptureStatus = reinterpret_cast<uint64_t>(pCaptureStatus);
    a.pId = reinterpret_cast<uint64_t>(pId);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMGETCAPTUREINFO, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamGetCaptureInfo_v2(hipStream_t stream, hipStreamCaptureStatus* captureStatus_out, unsigned long long* id_out, hipGraph_t* graph_out, const hipGraphNode_t** dependencies_out, size_t* numDependencies_out) {
  hipError_t r = g_real_table.hipStreamGetCaptureInfo_v2_fn(stream, captureStatus_out, id_out, graph_out, dependencies_out, numDependencies_out);
  if (r == hipSuccess) {
    hrr_args_hipStreamGetCaptureInfo_v2 a{};
    a.ret         = static_cast<int32_t>(r);
    a.stream = reinterpret_cast<uint64_t>(stream);
    a.captureStatus_out = reinterpret_cast<uint64_t>(captureStatus_out);
    a.id_out = reinterpret_cast<uint64_t>(id_out);
    a.numDependencies_out = reinterpret_cast<uint64_t>(numDependencies_out);
    if (graph_out) a.graph_out = reinterpret_cast<uint64_t>(*graph_out);
    if (dependencies_out) a.dependencies_out = reinterpret_cast<uint64_t>(*dependencies_out);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMGETCAPTUREINFO_V2, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamGetDevice(hipStream_t stream, hipDevice_t* device) {
  hipError_t r = g_real_table.hipStreamGetDevice_fn(stream, device);
  if (r == hipSuccess) {
    hrr_args_hipStreamGetDevice a{};
    a.ret         = static_cast<int32_t>(r);
    a.stream = reinterpret_cast<uint64_t>(stream);
    if (device) a.device = static_cast<uint64_t>(static_cast<int>(*device));
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMGETDEVICE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamGetFlags(hipStream_t stream, unsigned int* flags) {
  hipError_t r = g_real_table.hipStreamGetFlags_fn(stream, flags);
  if (r == hipSuccess) {
    hrr_args_hipStreamGetFlags a{};
    a.ret         = static_cast<int32_t>(r);
    a.stream = reinterpret_cast<uint64_t>(stream);
    a.flags = reinterpret_cast<uint64_t>(flags);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMGETFLAGS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamGetId(hipStream_t stream, unsigned long long* streamId) {
  hipError_t r = g_real_table.hipStreamGetId_fn(stream, streamId);
  if (r == hipSuccess) {
    hrr_args_hipStreamGetId a{};
    a.ret         = static_cast<int32_t>(r);
    a.stream = reinterpret_cast<uint64_t>(stream);
    a.streamId = reinterpret_cast<uint64_t>(streamId);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMGETID, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamGetPriority(hipStream_t stream, int* priority) {
  hipError_t r = g_real_table.hipStreamGetPriority_fn(stream, priority);
  if (r == hipSuccess) {
    hrr_args_hipStreamGetPriority a{};
    a.ret         = static_cast<int32_t>(r);
    a.stream = reinterpret_cast<uint64_t>(stream);
    a.priority = reinterpret_cast<uint64_t>(priority);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMGETPRIORITY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamIsCapturing(hipStream_t stream, hipStreamCaptureStatus* pCaptureStatus) {
  hipError_t r = g_real_table.hipStreamIsCapturing_fn(stream, pCaptureStatus);
  if (r == hipSuccess) {
    hrr_args_hipStreamIsCapturing a{};
    a.ret         = static_cast<int32_t>(r);
    a.stream = reinterpret_cast<uint64_t>(stream);
    a.pCaptureStatus = reinterpret_cast<uint64_t>(pCaptureStatus);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMISCAPTURING, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamQuery(hipStream_t stream) {
  hipError_t r = g_real_table.hipStreamQuery_fn(stream);
  if (r == hipSuccess) {
    hrr_args_hipStreamQuery a{};
    a.ret         = static_cast<int32_t>(r);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMQUERY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamSynchronize(hipStream_t stream) {
  hipError_t r = g_real_table.hipStreamSynchronize_fn(stream);
  if (r == hipSuccess) {
    hrr_args_hipStreamSynchronize a{};
    a.ret         = static_cast<int32_t>(r);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMSYNCHRONIZE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamUpdateCaptureDependencies(hipStream_t stream, hipGraphNode_t* dependencies, size_t numDependencies, unsigned int flags) {
  hipError_t r = g_real_table.hipStreamUpdateCaptureDependencies_fn(stream, dependencies, numDependencies, flags);
  if (r == hipSuccess) {
    hrr_args_hipStreamUpdateCaptureDependencies a{};
    a.ret         = static_cast<int32_t>(r);
    a.stream = reinterpret_cast<uint64_t>(stream);
    a.numDependencies = static_cast<decltype(a.numDependencies)>(numDependencies);
    a.flags = static_cast<decltype(a.flags)>(flags);
    if (dependencies) a.dependencies = reinterpret_cast<uint64_t>(*dependencies);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMUPDATECAPTUREDEPENDENCIES, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamWaitEvent(hipStream_t stream, hipEvent_t event, unsigned int flags) {
  hipError_t r = g_real_table.hipStreamWaitEvent_fn(stream, event, flags);
  if (r == hipSuccess) {
    hrr_args_hipStreamWaitEvent a{};
    a.ret         = static_cast<int32_t>(r);
    a.stream = reinterpret_cast<uint64_t>(stream);
    a.event = reinterpret_cast<uint64_t>(event);
    a.flags = static_cast<decltype(a.flags)>(flags);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMWAITEVENT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamWaitValue32(hipStream_t stream, void* ptr, uint32_t value, unsigned int flags, uint32_t mask) {
  hipError_t r = g_real_table.hipStreamWaitValue32_fn(stream, ptr, value, flags, mask);
  if (r == hipSuccess) {
    hrr_args_hipStreamWaitValue32 a{};
    a.ret         = static_cast<int32_t>(r);
    a.stream = reinterpret_cast<uint64_t>(stream);
    a.ptr = reinterpret_cast<uint64_t>(ptr);
    a.value = static_cast<decltype(a.value)>(value);
    a.flags = static_cast<decltype(a.flags)>(flags);
    a.mask = static_cast<decltype(a.mask)>(mask);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMWAITVALUE32, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamWaitValue64(hipStream_t stream, void* ptr, uint64_t value, unsigned int flags, uint64_t mask) {
  hipError_t r = g_real_table.hipStreamWaitValue64_fn(stream, ptr, value, flags, mask);
  if (r == hipSuccess) {
    hrr_args_hipStreamWaitValue64 a{};
    a.ret         = static_cast<int32_t>(r);
    a.stream = reinterpret_cast<uint64_t>(stream);
    a.ptr = reinterpret_cast<uint64_t>(ptr);
    a.value = static_cast<decltype(a.value)>(value);
    a.flags = static_cast<decltype(a.flags)>(flags);
    a.mask = static_cast<decltype(a.mask)>(mask);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMWAITVALUE64, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamWriteValue32(hipStream_t stream, void* ptr, uint32_t value, unsigned int flags) {
  hipError_t r = g_real_table.hipStreamWriteValue32_fn(stream, ptr, value, flags);
  if (r == hipSuccess) {
    hrr_args_hipStreamWriteValue32 a{};
    a.ret         = static_cast<int32_t>(r);
    a.stream = reinterpret_cast<uint64_t>(stream);
    a.ptr = reinterpret_cast<uint64_t>(ptr);
    a.value = static_cast<decltype(a.value)>(value);
    a.flags = static_cast<decltype(a.flags)>(flags);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMWRITEVALUE32, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamWriteValue64(hipStream_t stream, void* ptr, uint64_t value, unsigned int flags) {
  hipError_t r = g_real_table.hipStreamWriteValue64_fn(stream, ptr, value, flags);
  if (r == hipSuccess) {
    hrr_args_hipStreamWriteValue64 a{};
    a.ret         = static_cast<int32_t>(r);
    a.stream = reinterpret_cast<uint64_t>(stream);
    a.ptr = reinterpret_cast<uint64_t>(ptr);
    a.value = static_cast<decltype(a.value)>(value);
    a.flags = static_cast<decltype(a.flags)>(flags);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMWRITEVALUE64, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamBatchMemOp(hipStream_t stream, unsigned int count, hipStreamBatchMemOpParams* paramArray, unsigned int flags) {
  hipError_t r = g_real_table.hipStreamBatchMemOp_fn(stream, count, paramArray, flags);
  if (r == hipSuccess) {
    hrr_args_hipStreamBatchMemOp a{};
    a.ret         = static_cast<int32_t>(r);
    a.stream = reinterpret_cast<uint64_t>(stream);
    a.count = static_cast<decltype(a.count)>(count);
    a.paramArray = reinterpret_cast<uint64_t>(paramArray);
    a.flags = static_cast<decltype(a.flags)>(flags);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMBATCHMEMOP, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipTexObjectCreate(hipTextureObject_t* pTexObject, const HIP_RESOURCE_DESC* pResDesc, const HIP_TEXTURE_DESC* pTexDesc, const HIP_RESOURCE_VIEW_DESC* pResViewDesc) {
  hipError_t r = g_real_table.hipTexObjectCreate_fn(pTexObject, pResDesc, pTexDesc, pResViewDesc);
  if (r == hipSuccess) {
    hrr_args_hipTexObjectCreate a{};
    a.ret         = static_cast<int32_t>(r);
    a.pResDesc = reinterpret_cast<uint64_t>(pResDesc);
    a.pTexDesc = reinterpret_cast<uint64_t>(pTexDesc);
    a.pResViewDesc = reinterpret_cast<uint64_t>(pResViewDesc);
    if (pTexObject) a.pTexObject = reinterpret_cast<uint64_t>(*pTexObject);
    hrr_cap::writer::write_event_raw(HRR_API_HIPTEXOBJECTCREATE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipTexObjectDestroy(hipTextureObject_t texObject) {
  hipError_t r = g_real_table.hipTexObjectDestroy_fn(texObject);
  if (r == hipSuccess) {
    hrr_args_hipTexObjectDestroy a{};
    a.ret         = static_cast<int32_t>(r);
    a.texObject = reinterpret_cast<uint64_t>(texObject);
    hrr_cap::writer::write_event_raw(HRR_API_HIPTEXOBJECTDESTROY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipTexObjectGetResourceDesc(HIP_RESOURCE_DESC* pResDesc, hipTextureObject_t texObject) {
  hipError_t r = g_real_table.hipTexObjectGetResourceDesc_fn(pResDesc, texObject);
  if (r == hipSuccess) {
    hrr_args_hipTexObjectGetResourceDesc a{};
    a.ret         = static_cast<int32_t>(r);
    a.pResDesc = reinterpret_cast<uint64_t>(pResDesc);
    a.texObject = reinterpret_cast<uint64_t>(texObject);
    hrr_cap::writer::write_event_raw(HRR_API_HIPTEXOBJECTGETRESOURCEDESC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipTexObjectGetResourceViewDesc(HIP_RESOURCE_VIEW_DESC* pResViewDesc, hipTextureObject_t texObject) {
  hipError_t r = g_real_table.hipTexObjectGetResourceViewDesc_fn(pResViewDesc, texObject);
  if (r == hipSuccess) {
    hrr_args_hipTexObjectGetResourceViewDesc a{};
    a.ret         = static_cast<int32_t>(r);
    a.pResViewDesc = reinterpret_cast<uint64_t>(pResViewDesc);
    a.texObject = reinterpret_cast<uint64_t>(texObject);
    hrr_cap::writer::write_event_raw(HRR_API_HIPTEXOBJECTGETRESOURCEVIEWDESC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipTexObjectGetTextureDesc(HIP_TEXTURE_DESC* pTexDesc, hipTextureObject_t texObject) {
  hipError_t r = g_real_table.hipTexObjectGetTextureDesc_fn(pTexDesc, texObject);
  if (r == hipSuccess) {
    hrr_args_hipTexObjectGetTextureDesc a{};
    a.ret         = static_cast<int32_t>(r);
    a.pTexDesc = reinterpret_cast<uint64_t>(pTexDesc);
    a.texObject = reinterpret_cast<uint64_t>(texObject);
    hrr_cap::writer::write_event_raw(HRR_API_HIPTEXOBJECTGETTEXTUREDESC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipTexRefGetAddress(hipDeviceptr_t* dev_ptr, const textureReference* texRef) {
  hipError_t r = g_real_table.hipTexRefGetAddress_fn(dev_ptr, texRef);
  if (r == hipSuccess) {
    hrr_args_hipTexRefGetAddress a{};
    a.ret         = static_cast<int32_t>(r);
    a.dev_ptr = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(dev_ptr));
    a.texRef = reinterpret_cast<uint64_t>(texRef);
    hrr_cap::writer::write_event_raw(HRR_API_HIPTEXREFGETADDRESS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipTexRefGetAddressMode(enum hipTextureAddressMode* pam, const textureReference* texRef, int dim) {
  hipError_t r = g_real_table.hipTexRefGetAddressMode_fn(pam, texRef, dim);
  if (r == hipSuccess) {
    hrr_args_hipTexRefGetAddressMode a{};
    a.ret         = static_cast<int32_t>(r);
    a.pam = reinterpret_cast<uint64_t>(pam);
    a.texRef = reinterpret_cast<uint64_t>(texRef);
    a.dim = static_cast<decltype(a.dim)>(dim);
    hrr_cap::writer::write_event_raw(HRR_API_HIPTEXREFGETADDRESSMODE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipTexRefGetFilterMode(enum hipTextureFilterMode* pfm, const textureReference* texRef) {
  hipError_t r = g_real_table.hipTexRefGetFilterMode_fn(pfm, texRef);
  if (r == hipSuccess) {
    hrr_args_hipTexRefGetFilterMode a{};
    a.ret         = static_cast<int32_t>(r);
    a.pfm = reinterpret_cast<uint64_t>(pfm);
    a.texRef = reinterpret_cast<uint64_t>(texRef);
    hrr_cap::writer::write_event_raw(HRR_API_HIPTEXREFGETFILTERMODE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipTexRefGetFlags(unsigned int* pFlags, const textureReference* texRef) {
  hipError_t r = g_real_table.hipTexRefGetFlags_fn(pFlags, texRef);
  if (r == hipSuccess) {
    hrr_args_hipTexRefGetFlags a{};
    a.ret         = static_cast<int32_t>(r);
    a.pFlags = reinterpret_cast<uint64_t>(pFlags);
    a.texRef = reinterpret_cast<uint64_t>(texRef);
    hrr_cap::writer::write_event_raw(HRR_API_HIPTEXREFGETFLAGS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipTexRefGetFormat(hipArray_Format* pFormat, int* pNumChannels, const textureReference* texRef) {
  hipError_t r = g_real_table.hipTexRefGetFormat_fn(pFormat, pNumChannels, texRef);
  if (r == hipSuccess) {
    hrr_args_hipTexRefGetFormat a{};
    a.ret         = static_cast<int32_t>(r);
    a.pFormat = reinterpret_cast<uint64_t>(pFormat);
    a.pNumChannels = reinterpret_cast<uint64_t>(pNumChannels);
    a.texRef = reinterpret_cast<uint64_t>(texRef);
    hrr_cap::writer::write_event_raw(HRR_API_HIPTEXREFGETFORMAT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipTexRefGetMaxAnisotropy(int* pmaxAnsio, const textureReference* texRef) {
  hipError_t r = g_real_table.hipTexRefGetMaxAnisotropy_fn(pmaxAnsio, texRef);
  if (r == hipSuccess) {
    hrr_args_hipTexRefGetMaxAnisotropy a{};
    a.ret         = static_cast<int32_t>(r);
    a.pmaxAnsio = reinterpret_cast<uint64_t>(pmaxAnsio);
    a.texRef = reinterpret_cast<uint64_t>(texRef);
    hrr_cap::writer::write_event_raw(HRR_API_HIPTEXREFGETMAXANISOTROPY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipTexRefGetMipMappedArray(hipMipmappedArray_t* pArray, const textureReference* texRef) {
  hipError_t r = g_real_table.hipTexRefGetMipMappedArray_fn(pArray, texRef);
  if (r == hipSuccess) {
    hrr_args_hipTexRefGetMipMappedArray a{};
    a.ret         = static_cast<int32_t>(r);
    a.texRef = reinterpret_cast<uint64_t>(texRef);
    if (pArray) a.pArray = reinterpret_cast<uint64_t>(*pArray);
    hrr_cap::writer::write_event_raw(HRR_API_HIPTEXREFGETMIPMAPPEDARRAY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipTexRefGetMipmapFilterMode(enum hipTextureFilterMode* pfm, const textureReference* texRef) {
  hipError_t r = g_real_table.hipTexRefGetMipmapFilterMode_fn(pfm, texRef);
  if (r == hipSuccess) {
    hrr_args_hipTexRefGetMipmapFilterMode a{};
    a.ret         = static_cast<int32_t>(r);
    a.pfm = reinterpret_cast<uint64_t>(pfm);
    a.texRef = reinterpret_cast<uint64_t>(texRef);
    hrr_cap::writer::write_event_raw(HRR_API_HIPTEXREFGETMIPMAPFILTERMODE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipTexRefGetMipmapLevelBias(float* pbias, const textureReference* texRef) {
  hipError_t r = g_real_table.hipTexRefGetMipmapLevelBias_fn(pbias, texRef);
  if (r == hipSuccess) {
    hrr_args_hipTexRefGetMipmapLevelBias a{};
    a.ret         = static_cast<int32_t>(r);
    a.pbias = reinterpret_cast<uint64_t>(pbias);
    a.texRef = reinterpret_cast<uint64_t>(texRef);
    hrr_cap::writer::write_event_raw(HRR_API_HIPTEXREFGETMIPMAPLEVELBIAS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipTexRefGetMipmapLevelClamp(float* pminMipmapLevelClamp, float* pmaxMipmapLevelClamp, const textureReference* texRef) {
  hipError_t r = g_real_table.hipTexRefGetMipmapLevelClamp_fn(pminMipmapLevelClamp, pmaxMipmapLevelClamp, texRef);
  if (r == hipSuccess) {
    hrr_args_hipTexRefGetMipmapLevelClamp a{};
    a.ret         = static_cast<int32_t>(r);
    a.pminMipmapLevelClamp = reinterpret_cast<uint64_t>(pminMipmapLevelClamp);
    a.pmaxMipmapLevelClamp = reinterpret_cast<uint64_t>(pmaxMipmapLevelClamp);
    a.texRef = reinterpret_cast<uint64_t>(texRef);
    hrr_cap::writer::write_event_raw(HRR_API_HIPTEXREFGETMIPMAPLEVELCLAMP, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipTexRefSetAddress(size_t* ByteOffset, textureReference* texRef, hipDeviceptr_t dptr, size_t bytes) {
  hipError_t r = g_real_table.hipTexRefSetAddress_fn(ByteOffset, texRef, dptr, bytes);
  if (r == hipSuccess) {
    hrr_args_hipTexRefSetAddress a{};
    a.ret         = static_cast<int32_t>(r);
    a.ByteOffset = reinterpret_cast<uint64_t>(ByteOffset);
    a.texRef = reinterpret_cast<uint64_t>(texRef);
    a.dptr = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(dptr));
    a.bytes = static_cast<decltype(a.bytes)>(bytes);
    hrr_cap::writer::write_event_raw(HRR_API_HIPTEXREFSETADDRESS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipTexRefSetAddress2D(textureReference* texRef, const HIP_ARRAY_DESCRIPTOR* desc, hipDeviceptr_t dptr, size_t Pitch) {
  hipError_t r = g_real_table.hipTexRefSetAddress2D_fn(texRef, desc, dptr, Pitch);
  if (r == hipSuccess) {
    hrr_args_hipTexRefSetAddress2D a{};
    a.ret         = static_cast<int32_t>(r);
    a.texRef = reinterpret_cast<uint64_t>(texRef);
    a.desc = reinterpret_cast<uint64_t>(desc);
    a.dptr = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(dptr));
    a.Pitch = static_cast<decltype(a.Pitch)>(Pitch);
    hrr_cap::writer::write_event_raw(HRR_API_HIPTEXREFSETADDRESS2D, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipTexRefSetAddressMode(textureReference* texRef, int dim, enum hipTextureAddressMode am) {
  hipError_t r = g_real_table.hipTexRefSetAddressMode_fn(texRef, dim, am);
  if (r == hipSuccess) {
    hrr_args_hipTexRefSetAddressMode a{};
    a.ret         = static_cast<int32_t>(r);
    a.texRef = reinterpret_cast<uint64_t>(texRef);
    a.dim = static_cast<decltype(a.dim)>(dim);
    a.am = static_cast<decltype(a.am)>(am);
    hrr_cap::writer::write_event_raw(HRR_API_HIPTEXREFSETADDRESSMODE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipTexRefSetArray(textureReference* tex, hipArray_const_t array, unsigned int flags) {
  hipError_t r = g_real_table.hipTexRefSetArray_fn(tex, array, flags);
  if (r == hipSuccess) {
    hrr_args_hipTexRefSetArray a{};
    a.ret         = static_cast<int32_t>(r);
    a.tex = reinterpret_cast<uint64_t>(tex);
    a.array = reinterpret_cast<uint64_t>(array);
    a.flags = static_cast<decltype(a.flags)>(flags);
    hrr_cap::writer::write_event_raw(HRR_API_HIPTEXREFSETARRAY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipTexRefSetBorderColor(textureReference* texRef, float* pBorderColor) {
  hipError_t r = g_real_table.hipTexRefSetBorderColor_fn(texRef, pBorderColor);
  if (r == hipSuccess) {
    hrr_args_hipTexRefSetBorderColor a{};
    a.ret         = static_cast<int32_t>(r);
    a.texRef = reinterpret_cast<uint64_t>(texRef);
    a.pBorderColor = reinterpret_cast<uint64_t>(pBorderColor);
    hrr_cap::writer::write_event_raw(HRR_API_HIPTEXREFSETBORDERCOLOR, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipTexRefSetFilterMode(textureReference* texRef, enum hipTextureFilterMode fm) {
  hipError_t r = g_real_table.hipTexRefSetFilterMode_fn(texRef, fm);
  if (r == hipSuccess) {
    hrr_args_hipTexRefSetFilterMode a{};
    a.ret         = static_cast<int32_t>(r);
    a.texRef = reinterpret_cast<uint64_t>(texRef);
    a.fm = static_cast<decltype(a.fm)>(fm);
    hrr_cap::writer::write_event_raw(HRR_API_HIPTEXREFSETFILTERMODE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipTexRefSetFlags(textureReference* texRef, unsigned int Flags) {
  hipError_t r = g_real_table.hipTexRefSetFlags_fn(texRef, Flags);
  if (r == hipSuccess) {
    hrr_args_hipTexRefSetFlags a{};
    a.ret         = static_cast<int32_t>(r);
    a.texRef = reinterpret_cast<uint64_t>(texRef);
    a.Flags = static_cast<decltype(a.Flags)>(Flags);
    hrr_cap::writer::write_event_raw(HRR_API_HIPTEXREFSETFLAGS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipTexRefSetFormat(textureReference* texRef, hipArray_Format fmt, int NumPackedComponents) {
  hipError_t r = g_real_table.hipTexRefSetFormat_fn(texRef, fmt, NumPackedComponents);
  if (r == hipSuccess) {
    hrr_args_hipTexRefSetFormat a{};
    a.ret         = static_cast<int32_t>(r);
    a.texRef = reinterpret_cast<uint64_t>(texRef);
    a.fmt = static_cast<decltype(a.fmt)>(fmt);
    a.NumPackedComponents = static_cast<decltype(a.NumPackedComponents)>(NumPackedComponents);
    hrr_cap::writer::write_event_raw(HRR_API_HIPTEXREFSETFORMAT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipTexRefSetMaxAnisotropy(textureReference* texRef, unsigned int maxAniso) {
  hipError_t r = g_real_table.hipTexRefSetMaxAnisotropy_fn(texRef, maxAniso);
  if (r == hipSuccess) {
    hrr_args_hipTexRefSetMaxAnisotropy a{};
    a.ret         = static_cast<int32_t>(r);
    a.texRef = reinterpret_cast<uint64_t>(texRef);
    a.maxAniso = static_cast<decltype(a.maxAniso)>(maxAniso);
    hrr_cap::writer::write_event_raw(HRR_API_HIPTEXREFSETMAXANISOTROPY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipTexRefSetMipmapFilterMode(textureReference* texRef, enum hipTextureFilterMode fm) {
  hipError_t r = g_real_table.hipTexRefSetMipmapFilterMode_fn(texRef, fm);
  if (r == hipSuccess) {
    hrr_args_hipTexRefSetMipmapFilterMode a{};
    a.ret         = static_cast<int32_t>(r);
    a.texRef = reinterpret_cast<uint64_t>(texRef);
    a.fm = static_cast<decltype(a.fm)>(fm);
    hrr_cap::writer::write_event_raw(HRR_API_HIPTEXREFSETMIPMAPFILTERMODE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipTexRefSetMipmapLevelBias(textureReference* texRef, float bias) {
  hipError_t r = g_real_table.hipTexRefSetMipmapLevelBias_fn(texRef, bias);
  if (r == hipSuccess) {
    hrr_args_hipTexRefSetMipmapLevelBias a{};
    a.ret         = static_cast<int32_t>(r);
    a.texRef = reinterpret_cast<uint64_t>(texRef);
    a.bias = static_cast<decltype(a.bias)>(bias);
    hrr_cap::writer::write_event_raw(HRR_API_HIPTEXREFSETMIPMAPLEVELBIAS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipTexRefSetMipmapLevelClamp(textureReference* texRef, float minMipMapLevelClamp, float maxMipMapLevelClamp) {
  hipError_t r = g_real_table.hipTexRefSetMipmapLevelClamp_fn(texRef, minMipMapLevelClamp, maxMipMapLevelClamp);
  if (r == hipSuccess) {
    hrr_args_hipTexRefSetMipmapLevelClamp a{};
    a.ret         = static_cast<int32_t>(r);
    a.texRef = reinterpret_cast<uint64_t>(texRef);
    a.minMipMapLevelClamp = static_cast<decltype(a.minMipMapLevelClamp)>(minMipMapLevelClamp);
    a.maxMipMapLevelClamp = static_cast<decltype(a.maxMipMapLevelClamp)>(maxMipMapLevelClamp);
    hrr_cap::writer::write_event_raw(HRR_API_HIPTEXREFSETMIPMAPLEVELCLAMP, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipTexRefSetMipmappedArray(textureReference* texRef, struct hipMipmappedArray* mipmappedArray, unsigned int Flags) {
  hipError_t r = g_real_table.hipTexRefSetMipmappedArray_fn(texRef, mipmappedArray, Flags);
  if (r == hipSuccess) {
    hrr_args_hipTexRefSetMipmappedArray a{};
    a.ret         = static_cast<int32_t>(r);
    a.texRef = reinterpret_cast<uint64_t>(texRef);
    a.mipmappedArray = reinterpret_cast<uint64_t>(mipmappedArray);
    a.Flags = static_cast<decltype(a.Flags)>(Flags);
    hrr_cap::writer::write_event_raw(HRR_API_HIPTEXREFSETMIPMAPPEDARRAY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipThreadExchangeStreamCaptureMode(hipStreamCaptureMode* mode) {
  hipError_t r = g_real_table.hipThreadExchangeStreamCaptureMode_fn(mode);
  if (r == hipSuccess) {
    hrr_args_hipThreadExchangeStreamCaptureMode a{};
    a.ret         = static_cast<int32_t>(r);
    a.mode = reinterpret_cast<uint64_t>(mode);
    hrr_cap::writer::write_event_raw(HRR_API_HIPTHREADEXCHANGESTREAMCAPTUREMODE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipUnbindTexture(const textureReference* tex) {
  hipError_t r = g_real_table.hipUnbindTexture_fn(tex);
  if (r == hipSuccess) {
    hrr_args_hipUnbindTexture a{};
    a.ret         = static_cast<int32_t>(r);
    a.tex = reinterpret_cast<uint64_t>(tex);
    hrr_cap::writer::write_event_raw(HRR_API_HIPUNBINDTEXTURE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipUserObjectCreate(hipUserObject_t* object_out, void* ptr, hipHostFn_t destroy, unsigned int initialRefcount, unsigned int flags) {
  hipError_t r = g_real_table.hipUserObjectCreate_fn(object_out, ptr, destroy, initialRefcount, flags);
  if (r == hipSuccess) {
    hrr_args_hipUserObjectCreate a{};
    a.ret         = static_cast<int32_t>(r);
    a.ptr = reinterpret_cast<uint64_t>(ptr);
    a.destroy = 0;  // non-castable type skipped
    a.initialRefcount = static_cast<decltype(a.initialRefcount)>(initialRefcount);
    a.flags = static_cast<decltype(a.flags)>(flags);
    if (object_out) a.object_out = reinterpret_cast<uint64_t>(*object_out);
    hrr_cap::writer::write_event_raw(HRR_API_HIPUSEROBJECTCREATE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipUserObjectRelease(hipUserObject_t object, unsigned int count) {
  hipError_t r = g_real_table.hipUserObjectRelease_fn(object, count);
  if (r == hipSuccess) {
    hrr_args_hipUserObjectRelease a{};
    a.ret         = static_cast<int32_t>(r);
    a.object = reinterpret_cast<uint64_t>(object);
    a.count = static_cast<decltype(a.count)>(count);
    hrr_cap::writer::write_event_raw(HRR_API_HIPUSEROBJECTRELEASE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipUserObjectRetain(hipUserObject_t object, unsigned int count) {
  hipError_t r = g_real_table.hipUserObjectRetain_fn(object, count);
  if (r == hipSuccess) {
    hrr_args_hipUserObjectRetain a{};
    a.ret         = static_cast<int32_t>(r);
    a.object = reinterpret_cast<uint64_t>(object);
    a.count = static_cast<decltype(a.count)>(count);
    hrr_cap::writer::write_event_raw(HRR_API_HIPUSEROBJECTRETAIN, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipWaitExternalSemaphoresAsync(const hipExternalSemaphore_t* extSemArray, const hipExternalSemaphoreWaitParams* paramsArray, unsigned int numExtSems, hipStream_t stream) {
  hipError_t r = g_real_table.hipWaitExternalSemaphoresAsync_fn(extSemArray, paramsArray, numExtSems, stream);
  if (r == hipSuccess) {
    hrr_args_hipWaitExternalSemaphoresAsync a{};
    a.ret         = static_cast<int32_t>(r);
    a.extSemArray = reinterpret_cast<uint64_t>(extSemArray);
    a.paramsArray = reinterpret_cast<uint64_t>(paramsArray);
    a.numExtSems = static_cast<decltype(a.numExtSems)>(numExtSems);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPWAITEXTERNALSEMAPHORESASYNC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpy_spt(void* dst, const void* src, size_t sizeBytes, hipMemcpyKind kind) {
  hipError_t r = g_real_table.hipMemcpy_spt_fn(dst, src, sizeBytes, kind);
  if (r == hipSuccess) {
    hrr_args_hipMemcpy_spt a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.src = reinterpret_cast<uint64_t>(src);
    a.sizeBytes = static_cast<decltype(a.sizeBytes)>(sizeBytes);
    a.kind = static_cast<decltype(a.kind)>(kind);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPY_SPT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpyToSymbol_spt(const void* symbol, const void* src, size_t sizeBytes, size_t offset, hipMemcpyKind kind) {
  hipError_t r = g_real_table.hipMemcpyToSymbol_spt_fn(symbol, src, sizeBytes, offset, kind);
  if (r == hipSuccess) {
    hrr_args_hipMemcpyToSymbol_spt a{};
    a.ret         = static_cast<int32_t>(r);
    a.symbol = reinterpret_cast<uint64_t>(symbol);
    a.src = reinterpret_cast<uint64_t>(src);
    a.sizeBytes = static_cast<decltype(a.sizeBytes)>(sizeBytes);
    a.offset = static_cast<decltype(a.offset)>(offset);
    a.kind = static_cast<decltype(a.kind)>(kind);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPYTOSYMBOL_SPT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpyFromSymbol_spt(void* dst, const void* symbol, size_t sizeBytes, size_t offset, hipMemcpyKind kind) {
  hipError_t r = g_real_table.hipMemcpyFromSymbol_spt_fn(dst, symbol, sizeBytes, offset, kind);
  if (r == hipSuccess) {
    hrr_args_hipMemcpyFromSymbol_spt a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.symbol = reinterpret_cast<uint64_t>(symbol);
    a.sizeBytes = static_cast<decltype(a.sizeBytes)>(sizeBytes);
    a.offset = static_cast<decltype(a.offset)>(offset);
    a.kind = static_cast<decltype(a.kind)>(kind);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPYFROMSYMBOL_SPT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpy2D_spt(void* dst, size_t dpitch, const void* src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind) {
  hipError_t r = g_real_table.hipMemcpy2D_spt_fn(dst, dpitch, src, spitch, width, height, kind);
  if (r == hipSuccess) {
    hrr_args_hipMemcpy2D_spt a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.dpitch = static_cast<decltype(a.dpitch)>(dpitch);
    a.src = reinterpret_cast<uint64_t>(src);
    a.spitch = static_cast<decltype(a.spitch)>(spitch);
    a.width = static_cast<decltype(a.width)>(width);
    a.height = static_cast<decltype(a.height)>(height);
    a.kind = static_cast<decltype(a.kind)>(kind);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPY2D_SPT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpy2DFromArray_spt(void* dst, size_t dpitch, hipArray_const_t src, size_t wOffset, size_t hOffset, size_t width, size_t height, hipMemcpyKind kind) {
  hipError_t r = g_real_table.hipMemcpy2DFromArray_spt_fn(dst, dpitch, src, wOffset, hOffset, width, height, kind);
  if (r == hipSuccess) {
    hrr_args_hipMemcpy2DFromArray_spt a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.dpitch = static_cast<decltype(a.dpitch)>(dpitch);
    a.src = reinterpret_cast<uint64_t>(src);
    a.wOffset = static_cast<decltype(a.wOffset)>(wOffset);
    a.hOffset = static_cast<decltype(a.hOffset)>(hOffset);
    a.width = static_cast<decltype(a.width)>(width);
    a.height = static_cast<decltype(a.height)>(height);
    a.kind = static_cast<decltype(a.kind)>(kind);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPY2DFROMARRAY_SPT, &a.hdr, sizeof(a));
  }
  return r;
}


// Generated shim
static hipError_t capture_hipMemset_spt(void* dst, int value, size_t sizeBytes) {
  hipError_t r = g_real_table.hipMemset_spt_fn(dst, value, sizeBytes);
  if (r == hipSuccess) {
    hrr_args_hipMemset_spt a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.value = static_cast<decltype(a.value)>(value);
    a.sizeBytes = static_cast<decltype(a.sizeBytes)>(sizeBytes);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMSET_SPT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemsetAsync_spt(void* dst, int value, size_t sizeBytes, hipStream_t stream) {
  hipError_t r = g_real_table.hipMemsetAsync_spt_fn(dst, value, sizeBytes, stream);
  if (r == hipSuccess) {
    hrr_args_hipMemsetAsync_spt a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.value = static_cast<decltype(a.value)>(value);
    a.sizeBytes = static_cast<decltype(a.sizeBytes)>(sizeBytes);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMSETASYNC_SPT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemset2D_spt(void* dst, size_t pitch, int value, size_t width, size_t height) {
  hipError_t r = g_real_table.hipMemset2D_spt_fn(dst, pitch, value, width, height);
  if (r == hipSuccess) {
    hrr_args_hipMemset2D_spt a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.pitch = static_cast<decltype(a.pitch)>(pitch);
    a.value = static_cast<decltype(a.value)>(value);
    a.width = static_cast<decltype(a.width)>(width);
    a.height = static_cast<decltype(a.height)>(height);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMSET2D_SPT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemset2DAsync_spt(void* dst, size_t pitch, int value, size_t width, size_t height, hipStream_t stream) {
  hipError_t r = g_real_table.hipMemset2DAsync_spt_fn(dst, pitch, value, width, height, stream);
  if (r == hipSuccess) {
    hrr_args_hipMemset2DAsync_spt a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.pitch = static_cast<decltype(a.pitch)>(pitch);
    a.value = static_cast<decltype(a.value)>(value);
    a.width = static_cast<decltype(a.width)>(width);
    a.height = static_cast<decltype(a.height)>(height);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMSET2DASYNC_SPT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemset3DAsync_spt(hipPitchedPtr pitchedDevPtr, int value, hipExtent extent, hipStream_t stream) {
  hipError_t r = g_real_table.hipMemset3DAsync_spt_fn(pitchedDevPtr, value, extent, stream);
  if (r == hipSuccess) {
    hrr_args_hipMemset3DAsync_spt a{};
    a.ret         = static_cast<int32_t>(r);
    a.pitchedDevPtr = 0;  // non-castable type skipped
    a.value = static_cast<decltype(a.value)>(value);
    a.extent = 0;  // non-castable type skipped
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMSET3DASYNC_SPT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemset3D_spt(hipPitchedPtr pitchedDevPtr, int value, hipExtent extent) {
  hipError_t r = g_real_table.hipMemset3D_spt_fn(pitchedDevPtr, value, extent);
  if (r == hipSuccess) {
    hrr_args_hipMemset3D_spt a{};
    a.ret         = static_cast<int32_t>(r);
    a.pitchedDevPtr = 0;  // non-castable type skipped
    a.value = static_cast<decltype(a.value)>(value);
    a.extent = 0;  // non-castable type skipped
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMSET3D_SPT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpyAsync_spt(void* dst, const void* src, size_t sizeBytes, hipMemcpyKind kind, hipStream_t stream) {
  hipError_t r = g_real_table.hipMemcpyAsync_spt_fn(dst, src, sizeBytes, kind, stream);
  if (r == hipSuccess) {
    hrr_args_hipMemcpyAsync_spt a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.src = reinterpret_cast<uint64_t>(src);
    a.sizeBytes = static_cast<decltype(a.sizeBytes)>(sizeBytes);
    a.kind = static_cast<decltype(a.kind)>(kind);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPYASYNC_SPT, &a.hdr, sizeof(a));
  }
  return r;
}


// Generated shim
static hipError_t capture_hipMemcpy2DAsync_spt(void* dst, size_t dpitch, const void* src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind, hipStream_t stream) {
  hipError_t r = g_real_table.hipMemcpy2DAsync_spt_fn(dst, dpitch, src, spitch, width, height, kind, stream);
  if (r == hipSuccess) {
    hrr_args_hipMemcpy2DAsync_spt a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.dpitch = static_cast<decltype(a.dpitch)>(dpitch);
    a.src = reinterpret_cast<uint64_t>(src);
    a.spitch = static_cast<decltype(a.spitch)>(spitch);
    a.width = static_cast<decltype(a.width)>(width);
    a.height = static_cast<decltype(a.height)>(height);
    a.kind = static_cast<decltype(a.kind)>(kind);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPY2DASYNC_SPT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpyFromSymbolAsync_spt(void* dst, const void* symbol, size_t sizeBytes, size_t offset, hipMemcpyKind kind, hipStream_t stream) {
  hipError_t r = g_real_table.hipMemcpyFromSymbolAsync_spt_fn(dst, symbol, sizeBytes, offset, kind, stream);
  if (r == hipSuccess) {
    hrr_args_hipMemcpyFromSymbolAsync_spt a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.symbol = reinterpret_cast<uint64_t>(symbol);
    a.sizeBytes = static_cast<decltype(a.sizeBytes)>(sizeBytes);
    a.offset = static_cast<decltype(a.offset)>(offset);
    a.kind = static_cast<decltype(a.kind)>(kind);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPYFROMSYMBOLASYNC_SPT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpyToSymbolAsync_spt(const void* symbol, const void* src, size_t sizeBytes, size_t offset, hipMemcpyKind kind, hipStream_t stream) {
  hipError_t r = g_real_table.hipMemcpyToSymbolAsync_spt_fn(symbol, src, sizeBytes, offset, kind, stream);
  if (r == hipSuccess) {
    hrr_args_hipMemcpyToSymbolAsync_spt a{};
    a.ret         = static_cast<int32_t>(r);
    a.symbol = reinterpret_cast<uint64_t>(symbol);
    a.src = reinterpret_cast<uint64_t>(src);
    a.sizeBytes = static_cast<decltype(a.sizeBytes)>(sizeBytes);
    a.offset = static_cast<decltype(a.offset)>(offset);
    a.kind = static_cast<decltype(a.kind)>(kind);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPYTOSYMBOLASYNC_SPT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpyFromArray_spt(void* dst, hipArray_const_t src, size_t wOffsetSrc, size_t hOffset, size_t count, hipMemcpyKind kind) {
  hipError_t r = g_real_table.hipMemcpyFromArray_spt_fn(dst, src, wOffsetSrc, hOffset, count, kind);
  if (r == hipSuccess) {
    hrr_args_hipMemcpyFromArray_spt a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.src = reinterpret_cast<uint64_t>(src);
    a.wOffsetSrc = static_cast<decltype(a.wOffsetSrc)>(wOffsetSrc);
    a.hOffset = static_cast<decltype(a.hOffset)>(hOffset);
    a.count = static_cast<decltype(a.count)>(count);
    a.kind = static_cast<decltype(a.kind)>(kind);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPYFROMARRAY_SPT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpy2DToArray_spt(hipArray_t dst, size_t wOffset, size_t hOffset, const void* src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind) {
  hipError_t r = g_real_table.hipMemcpy2DToArray_spt_fn(dst, wOffset, hOffset, src, spitch, width, height, kind);
  if (r == hipSuccess) {
    hrr_args_hipMemcpy2DToArray_spt a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.wOffset = static_cast<decltype(a.wOffset)>(wOffset);
    a.hOffset = static_cast<decltype(a.hOffset)>(hOffset);
    a.src = reinterpret_cast<uint64_t>(src);
    a.spitch = static_cast<decltype(a.spitch)>(spitch);
    a.width = static_cast<decltype(a.width)>(width);
    a.height = static_cast<decltype(a.height)>(height);
    a.kind = static_cast<decltype(a.kind)>(kind);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPY2DTOARRAY_SPT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpy2DFromArrayAsync_spt(void* dst, size_t dpitch, hipArray_const_t src, size_t wOffsetSrc, size_t hOffsetSrc, size_t width, size_t height, hipMemcpyKind kind, hipStream_t stream) {
  hipError_t r = g_real_table.hipMemcpy2DFromArrayAsync_spt_fn(dst, dpitch, src, wOffsetSrc, hOffsetSrc, width, height, kind, stream);
  if (r == hipSuccess) {
    hrr_args_hipMemcpy2DFromArrayAsync_spt a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.dpitch = static_cast<decltype(a.dpitch)>(dpitch);
    a.src = reinterpret_cast<uint64_t>(src);
    a.wOffsetSrc = static_cast<decltype(a.wOffsetSrc)>(wOffsetSrc);
    a.hOffsetSrc = static_cast<decltype(a.hOffsetSrc)>(hOffsetSrc);
    a.width = static_cast<decltype(a.width)>(width);
    a.height = static_cast<decltype(a.height)>(height);
    a.kind = static_cast<decltype(a.kind)>(kind);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPY2DFROMARRAYASYNC_SPT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpy2DToArrayAsync_spt(hipArray_t dst, size_t wOffset, size_t hOffset, const void* src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind, hipStream_t stream) {
  hipError_t r = g_real_table.hipMemcpy2DToArrayAsync_spt_fn(dst, wOffset, hOffset, src, spitch, width, height, kind, stream);
  if (r == hipSuccess) {
    hrr_args_hipMemcpy2DToArrayAsync_spt a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.wOffset = static_cast<decltype(a.wOffset)>(wOffset);
    a.hOffset = static_cast<decltype(a.hOffset)>(hOffset);
    a.src = reinterpret_cast<uint64_t>(src);
    a.spitch = static_cast<decltype(a.spitch)>(spitch);
    a.width = static_cast<decltype(a.width)>(width);
    a.height = static_cast<decltype(a.height)>(height);
    a.kind = static_cast<decltype(a.kind)>(kind);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPY2DTOARRAYASYNC_SPT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamQuery_spt(hipStream_t stream) {
  hipError_t r = g_real_table.hipStreamQuery_spt_fn(stream);
  if (r == hipSuccess) {
    hrr_args_hipStreamQuery_spt a{};
    a.ret         = static_cast<int32_t>(r);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMQUERY_SPT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamSynchronize_spt(hipStream_t stream) {
  hipError_t r = g_real_table.hipStreamSynchronize_spt_fn(stream);
  if (r == hipSuccess) {
    hrr_args_hipStreamSynchronize_spt a{};
    a.ret         = static_cast<int32_t>(r);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMSYNCHRONIZE_SPT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamGetPriority_spt(hipStream_t stream, int* priority) {
  hipError_t r = g_real_table.hipStreamGetPriority_spt_fn(stream, priority);
  if (r == hipSuccess) {
    hrr_args_hipStreamGetPriority_spt a{};
    a.ret         = static_cast<int32_t>(r);
    a.stream = reinterpret_cast<uint64_t>(stream);
    a.priority = reinterpret_cast<uint64_t>(priority);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMGETPRIORITY_SPT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamWaitEvent_spt(hipStream_t stream, hipEvent_t event, unsigned int flags) {
  hipError_t r = g_real_table.hipStreamWaitEvent_spt_fn(stream, event, flags);
  if (r == hipSuccess) {
    hrr_args_hipStreamWaitEvent_spt a{};
    a.ret         = static_cast<int32_t>(r);
    a.stream = reinterpret_cast<uint64_t>(stream);
    a.event = reinterpret_cast<uint64_t>(event);
    a.flags = static_cast<decltype(a.flags)>(flags);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMWAITEVENT_SPT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamGetFlags_spt(hipStream_t stream, unsigned int* flags) {
  hipError_t r = g_real_table.hipStreamGetFlags_spt_fn(stream, flags);
  if (r == hipSuccess) {
    hrr_args_hipStreamGetFlags_spt a{};
    a.ret         = static_cast<int32_t>(r);
    a.stream = reinterpret_cast<uint64_t>(stream);
    a.flags = reinterpret_cast<uint64_t>(flags);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMGETFLAGS_SPT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamAddCallback_spt(hipStream_t stream, hipStreamCallback_t callback, void* userData, unsigned int flags) {
  hipError_t r = g_real_table.hipStreamAddCallback_spt_fn(stream, callback, userData, flags);
  if (r == hipSuccess) {
    hrr_args_hipStreamAddCallback_spt a{};
    a.ret         = static_cast<int32_t>(r);
    a.stream = reinterpret_cast<uint64_t>(stream);
    a.callback = 0;  // non-castable type skipped
    a.userData = reinterpret_cast<uint64_t>(userData);
    a.flags = static_cast<decltype(a.flags)>(flags);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMADDCALLBACK_SPT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipEventRecord_spt(hipEvent_t event, hipStream_t stream) {
  hipError_t r = g_real_table.hipEventRecord_spt_fn(event, stream);
  if (r == hipSuccess) {
    hrr_args_hipEventRecord_spt a{};
    a.ret         = static_cast<int32_t>(r);
    a.event = reinterpret_cast<uint64_t>(event);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPEVENTRECORD_SPT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipLaunchCooperativeKernel_spt(const void* f, dim3 gridDim, dim3 blockDim, void** kernelParams, uint32_t sharedMemBytes, hipStream_t hStream) {
  hipError_t r = g_real_table.hipLaunchCooperativeKernel_spt_fn(f, gridDim, blockDim, kernelParams, sharedMemBytes, hStream);
  if (r == hipSuccess) {
    hrr_args_hipLaunchCooperativeKernel_spt a{};
    a.ret         = static_cast<int32_t>(r);
    a.f = reinterpret_cast<uint64_t>(f);
    a.gridDim_x = gridDim.x;
    a.gridDim_y = gridDim.y;
    a.gridDim_z = gridDim.z;
    a.blockDim_x = blockDim.x;
    a.blockDim_y = blockDim.y;
    a.blockDim_z = blockDim.z;
    a.sharedMemBytes = static_cast<decltype(a.sharedMemBytes)>(sharedMemBytes);
    a.hStream = reinterpret_cast<uint64_t>(hStream);
    if (kernelParams) a.kernelParams = reinterpret_cast<uint64_t>(*kernelParams);
    hrr_cap::writer::write_event_raw(HRR_API_HIPLAUNCHCOOPERATIVEKERNEL_SPT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipLaunchKernel_spt(const void* function_address, dim3 numBlocks, dim3 dimBlocks, void** args, size_t sharedMemBytes, hipStream_t stream) {
  hipError_t r = g_real_table.hipLaunchKernel_spt_fn(function_address, numBlocks, dimBlocks, args, sharedMemBytes, stream);
  if (r == hipSuccess) {
    hrr_args_hipLaunchKernel_spt a{};
    a.ret         = static_cast<int32_t>(r);
    a.function_address = reinterpret_cast<uint64_t>(function_address);
    a.numBlocks_x = numBlocks.x;
    a.numBlocks_y = numBlocks.y;
    a.numBlocks_z = numBlocks.z;
    a.dimBlocks_x = dimBlocks.x;
    a.dimBlocks_y = dimBlocks.y;
    a.dimBlocks_z = dimBlocks.z;
    a.sharedMemBytes = static_cast<decltype(a.sharedMemBytes)>(sharedMemBytes);
    a.stream = reinterpret_cast<uint64_t>(stream);
    if (args) a.args = reinterpret_cast<uint64_t>(*args);
    hrr_cap::writer::write_event_raw(HRR_API_HIPLAUNCHKERNEL_SPT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphLaunch_spt(hipGraphExec_t graphExec, hipStream_t stream) {
  hipError_t r = g_real_table.hipGraphLaunch_spt_fn(graphExec, stream);
  if (r == hipSuccess) {
    hrr_args_hipGraphLaunch_spt a{};
    a.ret         = static_cast<int32_t>(r);
    a.graphExec = reinterpret_cast<uint64_t>(graphExec);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHLAUNCH_SPT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamBeginCapture_spt(hipStream_t stream, hipStreamCaptureMode mode) {
  hipError_t r = g_real_table.hipStreamBeginCapture_spt_fn(stream, mode);
  if (r == hipSuccess) {
    hrr_args_hipStreamBeginCapture_spt a{};
    a.ret         = static_cast<int32_t>(r);
    a.stream = reinterpret_cast<uint64_t>(stream);
    a.mode = static_cast<decltype(a.mode)>(mode);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMBEGINCAPTURE_SPT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamEndCapture_spt(hipStream_t stream, hipGraph_t* pGraph) {
  hipError_t r = g_real_table.hipStreamEndCapture_spt_fn(stream, pGraph);
  if (r == hipSuccess) {
    hrr_args_hipStreamEndCapture_spt a{};
    a.ret         = static_cast<int32_t>(r);
    a.stream = reinterpret_cast<uint64_t>(stream);
    if (pGraph) a.pGraph = reinterpret_cast<uint64_t>(*pGraph);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMENDCAPTURE_SPT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamIsCapturing_spt(hipStream_t stream, hipStreamCaptureStatus* pCaptureStatus) {
  hipError_t r = g_real_table.hipStreamIsCapturing_spt_fn(stream, pCaptureStatus);
  if (r == hipSuccess) {
    hrr_args_hipStreamIsCapturing_spt a{};
    a.ret         = static_cast<int32_t>(r);
    a.stream = reinterpret_cast<uint64_t>(stream);
    a.pCaptureStatus = reinterpret_cast<uint64_t>(pCaptureStatus);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMISCAPTURING_SPT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamGetCaptureInfo_spt(hipStream_t stream, hipStreamCaptureStatus* pCaptureStatus, unsigned long long* pId) {
  hipError_t r = g_real_table.hipStreamGetCaptureInfo_spt_fn(stream, pCaptureStatus, pId);
  if (r == hipSuccess) {
    hrr_args_hipStreamGetCaptureInfo_spt a{};
    a.ret         = static_cast<int32_t>(r);
    a.stream = reinterpret_cast<uint64_t>(stream);
    a.pCaptureStatus = reinterpret_cast<uint64_t>(pCaptureStatus);
    a.pId = reinterpret_cast<uint64_t>(pId);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMGETCAPTUREINFO_SPT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamGetCaptureInfo_v2_spt(hipStream_t stream, hipStreamCaptureStatus* captureStatus_out, unsigned long long* id_out, hipGraph_t* graph_out, const hipGraphNode_t** dependencies_out, size_t* numDependencies_out) {
  hipError_t r = g_real_table.hipStreamGetCaptureInfo_v2_spt_fn(stream, captureStatus_out, id_out, graph_out, dependencies_out, numDependencies_out);
  if (r == hipSuccess) {
    hrr_args_hipStreamGetCaptureInfo_v2_spt a{};
    a.ret         = static_cast<int32_t>(r);
    a.stream = reinterpret_cast<uint64_t>(stream);
    a.captureStatus_out = reinterpret_cast<uint64_t>(captureStatus_out);
    a.id_out = reinterpret_cast<uint64_t>(id_out);
    a.numDependencies_out = reinterpret_cast<uint64_t>(numDependencies_out);
    if (graph_out) a.graph_out = reinterpret_cast<uint64_t>(*graph_out);
    if (dependencies_out) a.dependencies_out = reinterpret_cast<uint64_t>(*dependencies_out);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMGETCAPTUREINFO_V2_SPT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipLaunchHostFunc_spt(hipStream_t stream, hipHostFn_t fn, void* userData) {
  hipError_t r = g_real_table.hipLaunchHostFunc_spt_fn(stream, fn, userData);
  if (r == hipSuccess) {
    hrr_args_hipLaunchHostFunc_spt a{};
    a.ret         = static_cast<int32_t>(r);
    a.stream = reinterpret_cast<uint64_t>(stream);
    a.fn = 0;  // non-castable type skipped
    a.userData = reinterpret_cast<uint64_t>(userData);
    hrr_cap::writer::write_event_raw(HRR_API_HIPLAUNCHHOSTFUNC_SPT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipChannelFormatDesc capture_hipCreateChannelDesc(int x, int y, int z, int w, hipChannelFormatKind f) {
  return g_real_table.hipCreateChannelDesc_fn(x, y, z, w, f);
}


// Generated shim
static hipError_t capture_hipHccModuleLaunchKernel(hipFunction_t f, uint32_t globalWorkSizeX, uint32_t globalWorkSizeY, uint32_t globalWorkSizeZ, uint32_t localWorkSizeX, uint32_t localWorkSizeY, uint32_t localWorkSizeZ, size_t sharedMemBytes, hipStream_t hStream, void** kernelParams, void** extra, hipEvent_t startEvent, hipEvent_t stopEvent) {
  hipError_t r = g_real_table.hipHccModuleLaunchKernel_fn(f, globalWorkSizeX, globalWorkSizeY, globalWorkSizeZ, localWorkSizeX, localWorkSizeY, localWorkSizeZ, sharedMemBytes, hStream, kernelParams, extra, startEvent, stopEvent);
  if (r == hipSuccess) {
    hrr_args_hipHccModuleLaunchKernel a{};
    a.ret         = static_cast<int32_t>(r);
    a.f = reinterpret_cast<uint64_t>(f);
    a.globalWorkSizeX = static_cast<decltype(a.globalWorkSizeX)>(globalWorkSizeX);
    a.globalWorkSizeY = static_cast<decltype(a.globalWorkSizeY)>(globalWorkSizeY);
    a.globalWorkSizeZ = static_cast<decltype(a.globalWorkSizeZ)>(globalWorkSizeZ);
    a.localWorkSizeX = static_cast<decltype(a.localWorkSizeX)>(localWorkSizeX);
    a.localWorkSizeY = static_cast<decltype(a.localWorkSizeY)>(localWorkSizeY);
    a.localWorkSizeZ = static_cast<decltype(a.localWorkSizeZ)>(localWorkSizeZ);
    a.sharedMemBytes = static_cast<decltype(a.sharedMemBytes)>(sharedMemBytes);
    a.hStream = reinterpret_cast<uint64_t>(hStream);
    a.startEvent = reinterpret_cast<uint64_t>(startEvent);
    a.stopEvent = reinterpret_cast<uint64_t>(stopEvent);
    if (kernelParams) a.kernelParams = reinterpret_cast<uint64_t>(*kernelParams);
    if (extra) a.extra = reinterpret_cast<uint64_t>(*extra);
    hrr_cap::writer::write_event_raw(HRR_API_HIPHCCMODULELAUNCHKERNEL, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static int capture_hipGetStreamDeviceId(hipStream_t stream) {
  return g_real_table.hipGetStreamDeviceId_fn(stream);
}

// Generated shim
static hipError_t capture_hipDrvGraphAddMemsetNode(hipGraphNode_t* phGraphNode, hipGraph_t hGraph, const hipGraphNode_t* dependencies, size_t numDependencies, const hipMemsetParams* memsetParams, hipCtx_t ctx) {
  hipError_t r = g_real_table.hipDrvGraphAddMemsetNode_fn(phGraphNode, hGraph, dependencies, numDependencies, memsetParams, ctx);
  if (r == hipSuccess) {
    hrr_args_hipDrvGraphAddMemsetNode a{};
    a.ret         = static_cast<int32_t>(r);
    a.hGraph = reinterpret_cast<uint64_t>(hGraph);
    a.numDependencies = static_cast<decltype(a.numDependencies)>(numDependencies);
    a.memsetParams = reinterpret_cast<uint64_t>(memsetParams);
    a.ctx = reinterpret_cast<uint64_t>(ctx);
    if (phGraphNode) a.phGraphNode = reinterpret_cast<uint64_t>(*phGraphNode);
    if (dependencies) a.dependencies = reinterpret_cast<uint64_t>(*dependencies);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDRVGRAPHADDMEMSETNODE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphAddExternalSemaphoresWaitNode(hipGraphNode_t* pGraphNode, hipGraph_t graph, const hipGraphNode_t* pDependencies, size_t numDependencies, const hipExternalSemaphoreWaitNodeParams* nodeParams) {
  hipError_t r = g_real_table.hipGraphAddExternalSemaphoresWaitNode_fn(pGraphNode, graph, pDependencies, numDependencies, nodeParams);
  if (r == hipSuccess) {
    hrr_args_hipGraphAddExternalSemaphoresWaitNode a{};
    a.ret         = static_cast<int32_t>(r);
    a.graph = reinterpret_cast<uint64_t>(graph);
    a.numDependencies = static_cast<decltype(a.numDependencies)>(numDependencies);
    a.nodeParams = reinterpret_cast<uint64_t>(nodeParams);
    if (pGraphNode) a.pGraphNode = reinterpret_cast<uint64_t>(*pGraphNode);
    if (pDependencies) a.pDependencies = reinterpret_cast<uint64_t>(*pDependencies);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHADDEXTERNALSEMAPHORESWAITNODE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphAddExternalSemaphoresSignalNode(hipGraphNode_t* pGraphNode, hipGraph_t graph, const hipGraphNode_t* pDependencies, size_t numDependencies, const hipExternalSemaphoreSignalNodeParams* nodeParams) {
  hipError_t r = g_real_table.hipGraphAddExternalSemaphoresSignalNode_fn(pGraphNode, graph, pDependencies, numDependencies, nodeParams);
  if (r == hipSuccess) {
    hrr_args_hipGraphAddExternalSemaphoresSignalNode a{};
    a.ret         = static_cast<int32_t>(r);
    a.graph = reinterpret_cast<uint64_t>(graph);
    a.numDependencies = static_cast<decltype(a.numDependencies)>(numDependencies);
    a.nodeParams = reinterpret_cast<uint64_t>(nodeParams);
    if (pGraphNode) a.pGraphNode = reinterpret_cast<uint64_t>(*pGraphNode);
    if (pDependencies) a.pDependencies = reinterpret_cast<uint64_t>(*pDependencies);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHADDEXTERNALSEMAPHORESSIGNALNODE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphExternalSemaphoresSignalNodeSetParams(hipGraphNode_t hNode, const hipExternalSemaphoreSignalNodeParams* nodeParams) {
  hipError_t r = g_real_table.hipGraphExternalSemaphoresSignalNodeSetParams_fn(hNode, nodeParams);
  if (r == hipSuccess) {
    hrr_args_hipGraphExternalSemaphoresSignalNodeSetParams a{};
    a.ret         = static_cast<int32_t>(r);
    a.hNode = reinterpret_cast<uint64_t>(hNode);
    a.nodeParams = reinterpret_cast<uint64_t>(nodeParams);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHEXTERNALSEMAPHORESSIGNALNODESETPARAMS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphExternalSemaphoresWaitNodeSetParams(hipGraphNode_t hNode, const hipExternalSemaphoreWaitNodeParams* nodeParams) {
  hipError_t r = g_real_table.hipGraphExternalSemaphoresWaitNodeSetParams_fn(hNode, nodeParams);
  if (r == hipSuccess) {
    hrr_args_hipGraphExternalSemaphoresWaitNodeSetParams a{};
    a.ret         = static_cast<int32_t>(r);
    a.hNode = reinterpret_cast<uint64_t>(hNode);
    a.nodeParams = reinterpret_cast<uint64_t>(nodeParams);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHEXTERNALSEMAPHORESWAITNODESETPARAMS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphExternalSemaphoresSignalNodeGetParams(hipGraphNode_t hNode, hipExternalSemaphoreSignalNodeParams* params_out) {
  hipError_t r = g_real_table.hipGraphExternalSemaphoresSignalNodeGetParams_fn(hNode, params_out);
  if (r == hipSuccess) {
    hrr_args_hipGraphExternalSemaphoresSignalNodeGetParams a{};
    a.ret         = static_cast<int32_t>(r);
    a.hNode = reinterpret_cast<uint64_t>(hNode);
    a.params_out = reinterpret_cast<uint64_t>(params_out);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHEXTERNALSEMAPHORESSIGNALNODEGETPARAMS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphExternalSemaphoresWaitNodeGetParams(hipGraphNode_t hNode, hipExternalSemaphoreWaitNodeParams* params_out) {
  hipError_t r = g_real_table.hipGraphExternalSemaphoresWaitNodeGetParams_fn(hNode, params_out);
  if (r == hipSuccess) {
    hrr_args_hipGraphExternalSemaphoresWaitNodeGetParams a{};
    a.ret         = static_cast<int32_t>(r);
    a.hNode = reinterpret_cast<uint64_t>(hNode);
    a.params_out = reinterpret_cast<uint64_t>(params_out);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHEXTERNALSEMAPHORESWAITNODEGETPARAMS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphExecExternalSemaphoresSignalNodeSetParams(hipGraphExec_t hGraphExec, hipGraphNode_t hNode, const hipExternalSemaphoreSignalNodeParams* nodeParams) {
  hipError_t r = g_real_table.hipGraphExecExternalSemaphoresSignalNodeSetParams_fn(hGraphExec, hNode, nodeParams);
  if (r == hipSuccess) {
    hrr_args_hipGraphExecExternalSemaphoresSignalNodeSetParams a{};
    a.ret         = static_cast<int32_t>(r);
    a.hGraphExec = reinterpret_cast<uint64_t>(hGraphExec);
    a.hNode = reinterpret_cast<uint64_t>(hNode);
    a.nodeParams = reinterpret_cast<uint64_t>(nodeParams);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHEXECEXTERNALSEMAPHORESSIGNALNODESETPARAMS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphExecExternalSemaphoresWaitNodeSetParams(hipGraphExec_t hGraphExec, hipGraphNode_t hNode, const hipExternalSemaphoreWaitNodeParams* nodeParams) {
  hipError_t r = g_real_table.hipGraphExecExternalSemaphoresWaitNodeSetParams_fn(hGraphExec, hNode, nodeParams);
  if (r == hipSuccess) {
    hrr_args_hipGraphExecExternalSemaphoresWaitNodeSetParams a{};
    a.ret         = static_cast<int32_t>(r);
    a.hGraphExec = reinterpret_cast<uint64_t>(hGraphExec);
    a.hNode = reinterpret_cast<uint64_t>(hNode);
    a.nodeParams = reinterpret_cast<uint64_t>(nodeParams);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHEXECEXTERNALSEMAPHORESWAITNODESETPARAMS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphAddNode(hipGraphNode_t* pGraphNode, hipGraph_t graph, const hipGraphNode_t* pDependencies, size_t numDependencies, hipGraphNodeParams* nodeParams) {
  hipError_t r = g_real_table.hipGraphAddNode_fn(pGraphNode, graph, pDependencies, numDependencies, nodeParams);
  if (r == hipSuccess) {
    hrr_args_hipGraphAddNode a{};
    a.ret         = static_cast<int32_t>(r);
    a.graph = reinterpret_cast<uint64_t>(graph);
    a.numDependencies = static_cast<decltype(a.numDependencies)>(numDependencies);
    a.nodeParams = reinterpret_cast<uint64_t>(nodeParams);
    if (pGraphNode) a.pGraphNode = reinterpret_cast<uint64_t>(*pGraphNode);
    if (pDependencies) a.pDependencies = reinterpret_cast<uint64_t>(*pDependencies);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHADDNODE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphInstantiateWithParams(hipGraphExec_t* pGraphExec, hipGraph_t graph, hipGraphInstantiateParams* instantiateParams) {
  hipError_t r = g_real_table.hipGraphInstantiateWithParams_fn(pGraphExec, graph, instantiateParams);
  if (r == hipSuccess) {
    hrr_args_hipGraphInstantiateWithParams a{};
    a.ret         = static_cast<int32_t>(r);
    a.graph = reinterpret_cast<uint64_t>(graph);
    a.instantiateParams = reinterpret_cast<uint64_t>(instantiateParams);
    if (pGraphExec) a.pGraphExec = reinterpret_cast<uint64_t>(*pGraphExec);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHINSTANTIATEWITHPARAMS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipExtGetLastError(void) {
  hipError_t r = g_real_table.hipExtGetLastError_fn();
  if (r == hipSuccess) {
    hrr_args_hipExtGetLastError a{};
    a.ret         = static_cast<int32_t>(r);
    hrr_cap::writer::write_event_raw(HRR_API_HIPEXTGETLASTERROR, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipTexRefGetBorderColor(float* pBorderColor, const textureReference* texRef) {
  hipError_t r = g_real_table.hipTexRefGetBorderColor_fn(pBorderColor, texRef);
  if (r == hipSuccess) {
    hrr_args_hipTexRefGetBorderColor a{};
    a.ret         = static_cast<int32_t>(r);
    a.pBorderColor = reinterpret_cast<uint64_t>(pBorderColor);
    a.texRef = reinterpret_cast<uint64_t>(texRef);
    hrr_cap::writer::write_event_raw(HRR_API_HIPTEXREFGETBORDERCOLOR, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipTexRefGetArray(hipArray_t* pArray, const textureReference* texRef) {
  hipError_t r = g_real_table.hipTexRefGetArray_fn(pArray, texRef);
  if (r == hipSuccess) {
    hrr_args_hipTexRefGetArray a{};
    a.ret         = static_cast<int32_t>(r);
    a.texRef = reinterpret_cast<uint64_t>(texRef);
    if (pArray) a.pArray = reinterpret_cast<uint64_t>(*pArray);
    hrr_cap::writer::write_event_raw(HRR_API_HIPTEXREFGETARRAY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGetProcAddress(const char* symbol, void** pfn, int hipVersion, uint64_t flags, hipDriverProcAddressQueryResult* symbolStatus) {
  hipError_t r = g_real_table.hipGetProcAddress_fn(symbol, pfn, hipVersion, flags, symbolStatus);
  if (r == hipSuccess) {
    hrr_args_hipGetProcAddress a{};
    a.ret         = static_cast<int32_t>(r);
    a.symbol = reinterpret_cast<uint64_t>(symbol);
    a.hipVersion = static_cast<decltype(a.hipVersion)>(hipVersion);
    a.flags = static_cast<decltype(a.flags)>(flags);
    a.symbolStatus = reinterpret_cast<uint64_t>(symbolStatus);
    if (pfn) a.pfn = reinterpret_cast<uint64_t>(*pfn);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGETPROCADDRESS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamBeginCaptureToGraph(hipStream_t stream, hipGraph_t graph, const hipGraphNode_t* dependencies, const hipGraphEdgeData* dependencyData, size_t numDependencies, hipStreamCaptureMode mode) {
  hipError_t r = g_real_table.hipStreamBeginCaptureToGraph_fn(stream, graph, dependencies, dependencyData, numDependencies, mode);
  if (r == hipSuccess) {
    hrr_args_hipStreamBeginCaptureToGraph a{};
    a.ret         = static_cast<int32_t>(r);
    a.stream = reinterpret_cast<uint64_t>(stream);
    a.graph = reinterpret_cast<uint64_t>(graph);
    a.dependencyData = reinterpret_cast<uint64_t>(dependencyData);
    a.numDependencies = static_cast<decltype(a.numDependencies)>(numDependencies);
    a.mode = static_cast<decltype(a.mode)>(mode);
    if (dependencies) a.dependencies = reinterpret_cast<uint64_t>(*dependencies);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMBEGINCAPTURETOGRAPH, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGetFuncBySymbol(hipFunction_t* functionPtr, const void* symbolPtr) {
  hipError_t r = g_real_table.hipGetFuncBySymbol_fn(functionPtr, symbolPtr);
  if (r == hipSuccess) {
    hrr_args_hipGetFuncBySymbol a{};
    a.ret         = static_cast<int32_t>(r);
    a.symbolPtr = reinterpret_cast<uint64_t>(symbolPtr);
    if (functionPtr) a.functionPtr = reinterpret_cast<uint64_t>(*functionPtr);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGETFUNCBYSYMBOL, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDrvGraphAddMemFreeNode(hipGraphNode_t* phGraphNode, hipGraph_t hGraph, const hipGraphNode_t* dependencies, size_t numDependencies, hipDeviceptr_t dptr) {
  hipError_t r = g_real_table.hipDrvGraphAddMemFreeNode_fn(phGraphNode, hGraph, dependencies, numDependencies, dptr);
  if (r == hipSuccess) {
    hrr_args_hipDrvGraphAddMemFreeNode a{};
    a.ret         = static_cast<int32_t>(r);
    a.hGraph = reinterpret_cast<uint64_t>(hGraph);
    a.numDependencies = static_cast<decltype(a.numDependencies)>(numDependencies);
    a.dptr = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(dptr));
    if (phGraphNode) a.phGraphNode = reinterpret_cast<uint64_t>(*phGraphNode);
    if (dependencies) a.dependencies = reinterpret_cast<uint64_t>(*dependencies);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDRVGRAPHADDMEMFREENODE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDrvGraphExecMemcpyNodeSetParams(hipGraphExec_t hGraphExec, hipGraphNode_t hNode, const HIP_MEMCPY3D* copyParams, hipCtx_t ctx) {
  hipError_t r = g_real_table.hipDrvGraphExecMemcpyNodeSetParams_fn(hGraphExec, hNode, copyParams, ctx);
  if (r == hipSuccess) {
    hrr_args_hipDrvGraphExecMemcpyNodeSetParams a{};
    a.ret         = static_cast<int32_t>(r);
    a.hGraphExec = reinterpret_cast<uint64_t>(hGraphExec);
    a.hNode = reinterpret_cast<uint64_t>(hNode);
    a.copyParams = reinterpret_cast<uint64_t>(copyParams);
    a.ctx = reinterpret_cast<uint64_t>(ctx);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDRVGRAPHEXECMEMCPYNODESETPARAMS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDrvGraphExecMemsetNodeSetParams(hipGraphExec_t hGraphExec, hipGraphNode_t hNode, const hipMemsetParams* memsetParams, hipCtx_t ctx) {
  hipError_t r = g_real_table.hipDrvGraphExecMemsetNodeSetParams_fn(hGraphExec, hNode, memsetParams, ctx);
  if (r == hipSuccess) {
    hrr_args_hipDrvGraphExecMemsetNodeSetParams a{};
    a.ret         = static_cast<int32_t>(r);
    a.hGraphExec = reinterpret_cast<uint64_t>(hGraphExec);
    a.hNode = reinterpret_cast<uint64_t>(hNode);
    a.memsetParams = reinterpret_cast<uint64_t>(memsetParams);
    a.ctx = reinterpret_cast<uint64_t>(ctx);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDRVGRAPHEXECMEMSETNODESETPARAMS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipSetValidDevices(int* device_arr, int len) {
  hipError_t r = g_real_table.hipSetValidDevices_fn(device_arr, len);
  if (r == hipSuccess) {
    hrr_args_hipSetValidDevices a{};
    a.ret         = static_cast<int32_t>(r);
    a.device_arr = reinterpret_cast<uint64_t>(device_arr);
    a.len = static_cast<decltype(a.len)>(len);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSETVALIDDEVICES, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpyAtoD(hipDeviceptr_t dstDevice, hipArray_t srcArray, size_t srcOffset, size_t ByteCount) {
  hipError_t r = g_real_table.hipMemcpyAtoD_fn(dstDevice, srcArray, srcOffset, ByteCount);
  if (r == hipSuccess) {
    hrr_args_hipMemcpyAtoD a{};
    a.ret         = static_cast<int32_t>(r);
    a.dstDevice = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(dstDevice));
    a.srcArray = reinterpret_cast<uint64_t>(srcArray);
    a.srcOffset = static_cast<decltype(a.srcOffset)>(srcOffset);
    a.ByteCount = static_cast<decltype(a.ByteCount)>(ByteCount);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPYATOD, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpyDtoA(hipArray_t dstArray, size_t dstOffset, hipDeviceptr_t srcDevice, size_t ByteCount) {
  hipError_t r = g_real_table.hipMemcpyDtoA_fn(dstArray, dstOffset, srcDevice, ByteCount);
  if (r == hipSuccess) {
    hrr_args_hipMemcpyDtoA a{};
    a.ret         = static_cast<int32_t>(r);
    a.dstArray = reinterpret_cast<uint64_t>(dstArray);
    a.dstOffset = static_cast<decltype(a.dstOffset)>(dstOffset);
    a.srcDevice = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(srcDevice));
    a.ByteCount = static_cast<decltype(a.ByteCount)>(ByteCount);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPYDTOA, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpyAtoA(hipArray_t dstArray, size_t dstOffset, hipArray_t srcArray, size_t srcOffset, size_t ByteCount) {
  hipError_t r = g_real_table.hipMemcpyAtoA_fn(dstArray, dstOffset, srcArray, srcOffset, ByteCount);
  if (r == hipSuccess) {
    hrr_args_hipMemcpyAtoA a{};
    a.ret         = static_cast<int32_t>(r);
    a.dstArray = reinterpret_cast<uint64_t>(dstArray);
    a.dstOffset = static_cast<decltype(a.dstOffset)>(dstOffset);
    a.srcArray = reinterpret_cast<uint64_t>(srcArray);
    a.srcOffset = static_cast<decltype(a.srcOffset)>(srcOffset);
    a.ByteCount = static_cast<decltype(a.ByteCount)>(ByteCount);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPYATOA, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpyAtoHAsync(void* dstHost, hipArray_t srcArray, size_t srcOffset, size_t ByteCount, hipStream_t stream) {
  hipError_t r = g_real_table.hipMemcpyAtoHAsync_fn(dstHost, srcArray, srcOffset, ByteCount, stream);
  if (r == hipSuccess) {
    hrr_args_hipMemcpyAtoHAsync a{};
    a.ret         = static_cast<int32_t>(r);
    a.dstHost = reinterpret_cast<uint64_t>(dstHost);
    a.srcArray = reinterpret_cast<uint64_t>(srcArray);
    a.srcOffset = static_cast<decltype(a.srcOffset)>(srcOffset);
    a.ByteCount = static_cast<decltype(a.ByteCount)>(ByteCount);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPYATOHASYNC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpyHtoAAsync(hipArray_t dstArray, size_t dstOffset, const void* srcHost, size_t ByteCount, hipStream_t stream) {
  hipError_t r = g_real_table.hipMemcpyHtoAAsync_fn(dstArray, dstOffset, srcHost, ByteCount, stream);
  if (r == hipSuccess) {
    hrr_args_hipMemcpyHtoAAsync a{};
    a.ret         = static_cast<int32_t>(r);
    a.dstArray = reinterpret_cast<uint64_t>(dstArray);
    a.dstOffset = static_cast<decltype(a.dstOffset)>(dstOffset);
    a.srcHost = reinterpret_cast<uint64_t>(srcHost);
    a.ByteCount = static_cast<decltype(a.ByteCount)>(ByteCount);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPYHTOAASYNC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpy2DArrayToArray(hipArray_t dst, size_t wOffsetDst, size_t hOffsetDst, hipArray_const_t src, size_t wOffsetSrc, size_t hOffsetSrc, size_t width, size_t height, hipMemcpyKind kind) {
  hipError_t r = g_real_table.hipMemcpy2DArrayToArray_fn(dst, wOffsetDst, hOffsetDst, src, wOffsetSrc, hOffsetSrc, width, height, kind);
  if (r == hipSuccess) {
    hrr_args_hipMemcpy2DArrayToArray a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = reinterpret_cast<uint64_t>(dst);
    a.wOffsetDst = static_cast<decltype(a.wOffsetDst)>(wOffsetDst);
    a.hOffsetDst = static_cast<decltype(a.hOffsetDst)>(hOffsetDst);
    a.src = reinterpret_cast<uint64_t>(src);
    a.wOffsetSrc = static_cast<decltype(a.wOffsetSrc)>(wOffsetSrc);
    a.hOffsetSrc = static_cast<decltype(a.hOffsetSrc)>(hOffsetSrc);
    a.width = static_cast<decltype(a.width)>(width);
    a.height = static_cast<decltype(a.height)>(height);
    a.kind = static_cast<decltype(a.kind)>(kind);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPY2DARRAYTOARRAY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphExecGetFlags(hipGraphExec_t graphExec, unsigned long long* flags) {
  hipError_t r = g_real_table.hipGraphExecGetFlags_fn(graphExec, flags);
  if (r == hipSuccess) {
    hrr_args_hipGraphExecGetFlags a{};
    a.ret         = static_cast<int32_t>(r);
    a.graphExec = reinterpret_cast<uint64_t>(graphExec);
    a.flags = reinterpret_cast<uint64_t>(flags);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHEXECGETFLAGS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphNodeSetParams(hipGraphNode_t node, hipGraphNodeParams* nodeParams) {
  hipError_t r = g_real_table.hipGraphNodeSetParams_fn(node, nodeParams);
  if (r == hipSuccess) {
    hrr_args_hipGraphNodeSetParams a{};
    a.ret         = static_cast<int32_t>(r);
    a.node = reinterpret_cast<uint64_t>(node);
    a.nodeParams = reinterpret_cast<uint64_t>(nodeParams);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHNODESETPARAMS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphExecNodeSetParams(hipGraphExec_t graphExec, hipGraphNode_t node, hipGraphNodeParams* nodeParams) {
  hipError_t r = g_real_table.hipGraphExecNodeSetParams_fn(graphExec, node, nodeParams);
  if (r == hipSuccess) {
    hrr_args_hipGraphExecNodeSetParams a{};
    a.ret         = static_cast<int32_t>(r);
    a.graphExec = reinterpret_cast<uint64_t>(graphExec);
    a.node = reinterpret_cast<uint64_t>(node);
    a.nodeParams = reinterpret_cast<uint64_t>(nodeParams);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHEXECNODESETPARAMS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipExternalMemoryGetMappedMipmappedArray(hipMipmappedArray_t* mipmap, hipExternalMemory_t extMem, const hipExternalMemoryMipmappedArrayDesc* mipmapDesc) {
  hipError_t r = g_real_table.hipExternalMemoryGetMappedMipmappedArray_fn(mipmap, extMem, mipmapDesc);
  if (r == hipSuccess) {
    hrr_args_hipExternalMemoryGetMappedMipmappedArray a{};
    a.ret         = static_cast<int32_t>(r);
    a.extMem = reinterpret_cast<uint64_t>(extMem);
    a.mipmapDesc = reinterpret_cast<uint64_t>(mipmapDesc);
    if (mipmap) a.mipmap = reinterpret_cast<uint64_t>(*mipmap);
    hrr_cap::writer::write_event_raw(HRR_API_HIPEXTERNALMEMORYGETMAPPEDMIPMAPPEDARRAY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDrvGraphMemcpyNodeGetParams(hipGraphNode_t hNode, HIP_MEMCPY3D* nodeParams) {
  hipError_t r = g_real_table.hipDrvGraphMemcpyNodeGetParams_fn(hNode, nodeParams);
  if (r == hipSuccess) {
    hrr_args_hipDrvGraphMemcpyNodeGetParams a{};
    a.ret         = static_cast<int32_t>(r);
    a.hNode = reinterpret_cast<uint64_t>(hNode);
    a.nodeParams = reinterpret_cast<uint64_t>(nodeParams);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDRVGRAPHMEMCPYNODEGETPARAMS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDrvGraphMemcpyNodeSetParams(hipGraphNode_t hNode, const HIP_MEMCPY3D* nodeParams) {
  hipError_t r = g_real_table.hipDrvGraphMemcpyNodeSetParams_fn(hNode, nodeParams);
  if (r == hipSuccess) {
    hrr_args_hipDrvGraphMemcpyNodeSetParams a{};
    a.ret         = static_cast<int32_t>(r);
    a.hNode = reinterpret_cast<uint64_t>(hNode);
    a.nodeParams = reinterpret_cast<uint64_t>(nodeParams);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDRVGRAPHMEMCPYNODESETPARAMS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipExtHostAlloc(void** ptr, size_t size, unsigned int flags) {
  hipError_t r = g_real_table.hipExtHostAlloc_fn(ptr, size, flags);
  if (r == hipSuccess) {
    hrr_args_hipExtHostAlloc a{};
    a.ret         = static_cast<int32_t>(r);
    a.size = static_cast<decltype(a.size)>(size);
    a.flags = static_cast<decltype(a.flags)>(flags);
    if (ptr) a.ptr = reinterpret_cast<uint64_t>(*ptr);
    hrr_cap::writer::write_event_raw(HRR_API_HIPEXTHOSTALLOC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDeviceGetTexture1DLinearMaxWidth(size_t* maxWidthInElements, const hipChannelFormatDesc* fmtDesc, int device) {
  hipError_t r = g_real_table.hipDeviceGetTexture1DLinearMaxWidth_fn(maxWidthInElements, fmtDesc, device);
  if (r == hipSuccess) {
    hrr_args_hipDeviceGetTexture1DLinearMaxWidth a{};
    a.ret         = static_cast<int32_t>(r);
    a.maxWidthInElements = reinterpret_cast<uint64_t>(maxWidthInElements);
    a.fmtDesc = 0;  // non-castable type skipped
    a.device = static_cast<decltype(a.device)>(device);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVICEGETTEXTURE1DLINEARMAXWIDTH, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphAddBatchMemOpNode(hipGraphNode_t* phGraphNode, hipGraph_t hGraph, const hipGraphNode_t* dependencies, size_t numDependencies, const hipBatchMemOpNodeParams* nodeParams) {
  hipError_t r = g_real_table.hipGraphAddBatchMemOpNode_fn(phGraphNode, hGraph, dependencies, numDependencies, nodeParams);
  if (r == hipSuccess) {
    hrr_args_hipGraphAddBatchMemOpNode a{};
    a.ret         = static_cast<int32_t>(r);
    a.hGraph = reinterpret_cast<uint64_t>(hGraph);
    a.numDependencies = static_cast<decltype(a.numDependencies)>(numDependencies);
    a.nodeParams = reinterpret_cast<uint64_t>(nodeParams);
    if (phGraphNode) a.phGraphNode = reinterpret_cast<uint64_t>(*phGraphNode);
    if (dependencies) a.dependencies = reinterpret_cast<uint64_t>(*dependencies);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHADDBATCHMEMOPNODE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphBatchMemOpNodeGetParams(hipGraphNode_t hNode, hipBatchMemOpNodeParams* nodeParams_out) {
  hipError_t r = g_real_table.hipGraphBatchMemOpNodeGetParams_fn(hNode, nodeParams_out);
  if (r == hipSuccess) {
    hrr_args_hipGraphBatchMemOpNodeGetParams a{};
    a.ret         = static_cast<int32_t>(r);
    a.hNode = reinterpret_cast<uint64_t>(hNode);
    a.nodeParams_out = reinterpret_cast<uint64_t>(nodeParams_out);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHBATCHMEMOPNODEGETPARAMS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphBatchMemOpNodeSetParams(hipGraphNode_t hNode, hipBatchMemOpNodeParams* nodeParams) {
  hipError_t r = g_real_table.hipGraphBatchMemOpNodeSetParams_fn(hNode, nodeParams);
  if (r == hipSuccess) {
    hrr_args_hipGraphBatchMemOpNodeSetParams a{};
    a.ret         = static_cast<int32_t>(r);
    a.hNode = reinterpret_cast<uint64_t>(hNode);
    a.nodeParams = reinterpret_cast<uint64_t>(nodeParams);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHBATCHMEMOPNODESETPARAMS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGraphExecBatchMemOpNodeSetParams(hipGraphExec_t hGraphExec, hipGraphNode_t hNode, const hipBatchMemOpNodeParams* nodeParams) {
  hipError_t r = g_real_table.hipGraphExecBatchMemOpNodeSetParams_fn(hGraphExec, hNode, nodeParams);
  if (r == hipSuccess) {
    hrr_args_hipGraphExecBatchMemOpNodeSetParams a{};
    a.ret         = static_cast<int32_t>(r);
    a.hGraphExec = reinterpret_cast<uint64_t>(hGraphExec);
    a.hNode = reinterpret_cast<uint64_t>(hNode);
    a.nodeParams = reinterpret_cast<uint64_t>(nodeParams);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGRAPHEXECBATCHMEMOPNODESETPARAMS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipEventRecordWithFlags(hipEvent_t event, hipStream_t stream, unsigned int flags) {
  hipError_t r = g_real_table.hipEventRecordWithFlags_fn(event, stream, flags);
  if (r == hipSuccess) {
    hrr_args_hipEventRecordWithFlags a{};
    a.ret         = static_cast<int32_t>(r);
    a.event = reinterpret_cast<uint64_t>(event);
    a.stream = reinterpret_cast<uint64_t>(stream);
    a.flags = static_cast<decltype(a.flags)>(flags);
    hrr_cap::writer::write_event_raw(HRR_API_HIPEVENTRECORDWITHFLAGS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipLaunchKernelExC(const hipLaunchConfig_t* config, const void* fPtr, void** args) {
  hipError_t r = g_real_table.hipLaunchKernelExC_fn(config, fPtr, args);
  if (r == hipSuccess) {
    hrr_args_hipLaunchKernelExC a{};
    a.ret         = static_cast<int32_t>(r);
    a.config = reinterpret_cast<uint64_t>(config);
    a.fPtr = reinterpret_cast<uint64_t>(fPtr);
    if (args) a.args = reinterpret_cast<uint64_t>(*args);
    hrr_cap::writer::write_event_raw(HRR_API_HIPLAUNCHKERNELEXC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDrvLaunchKernelEx(const HIP_LAUNCH_CONFIG* config, hipFunction_t f, void** params, void** extra) {
  hipError_t r = g_real_table.hipDrvLaunchKernelEx_fn(config, f, params, extra);
  if (r == hipSuccess) {
    hrr_args_hipDrvLaunchKernelEx a{};
    a.ret         = static_cast<int32_t>(r);
    a.config = reinterpret_cast<uint64_t>(config);
    a.f = reinterpret_cast<uint64_t>(f);
    if (params) a.params = reinterpret_cast<uint64_t>(*params);
    if (extra) a.extra = reinterpret_cast<uint64_t>(*extra);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDRVLAUNCHKERNELEX, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemGetHandleForAddressRange(void* handle, hipDeviceptr_t dptr, size_t size, hipMemRangeHandleType handleType, unsigned long long flags) {
  hipError_t r = g_real_table.hipMemGetHandleForAddressRange_fn(handle, dptr, size, handleType, flags);
  if (r == hipSuccess) {
    hrr_args_hipMemGetHandleForAddressRange a{};
    a.ret         = static_cast<int32_t>(r);
    a.handle = reinterpret_cast<uint64_t>(handle);
    a.dptr = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(dptr));
    a.size = static_cast<decltype(a.size)>(size);
    a.handleType = static_cast<decltype(a.handleType)>(handleType);
    a.flags = static_cast<decltype(a.flags)>(flags);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMGETHANDLEFORADDRESSRANGE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemsetD2D8(hipDeviceptr_t dst, size_t dstPitch, unsigned char value, size_t width, size_t height) {
  hipError_t r = g_real_table.hipMemsetD2D8_fn(dst, dstPitch, value, width, height);
  if (r == hipSuccess) {
    hrr_args_hipMemsetD2D8 a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(dst));
    a.dstPitch = static_cast<decltype(a.dstPitch)>(dstPitch);
    a.value = static_cast<decltype(a.value)>(value);
    a.width = static_cast<decltype(a.width)>(width);
    a.height = static_cast<decltype(a.height)>(height);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMSETD2D8, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemsetD2D8Async(hipDeviceptr_t dst, size_t dstPitch, unsigned char value, size_t width, size_t height, hipStream_t stream) {
  hipError_t r = g_real_table.hipMemsetD2D8Async_fn(dst, dstPitch, value, width, height, stream);
  if (r == hipSuccess) {
    hrr_args_hipMemsetD2D8Async a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(dst));
    a.dstPitch = static_cast<decltype(a.dstPitch)>(dstPitch);
    a.value = static_cast<decltype(a.value)>(value);
    a.width = static_cast<decltype(a.width)>(width);
    a.height = static_cast<decltype(a.height)>(height);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMSETD2D8ASYNC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemsetD2D16(hipDeviceptr_t dst, size_t dstPitch, unsigned short value, size_t width, size_t height) {
  hipError_t r = g_real_table.hipMemsetD2D16_fn(dst, dstPitch, value, width, height);
  if (r == hipSuccess) {
    hrr_args_hipMemsetD2D16 a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(dst));
    a.dstPitch = static_cast<decltype(a.dstPitch)>(dstPitch);
    a.value = static_cast<decltype(a.value)>(value);
    a.width = static_cast<decltype(a.width)>(width);
    a.height = static_cast<decltype(a.height)>(height);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMSETD2D16, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemsetD2D16Async(hipDeviceptr_t dst, size_t dstPitch, unsigned short value, size_t width, size_t height, hipStream_t stream) {
  hipError_t r = g_real_table.hipMemsetD2D16Async_fn(dst, dstPitch, value, width, height, stream);
  if (r == hipSuccess) {
    hrr_args_hipMemsetD2D16Async a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(dst));
    a.dstPitch = static_cast<decltype(a.dstPitch)>(dstPitch);
    a.value = static_cast<decltype(a.value)>(value);
    a.width = static_cast<decltype(a.width)>(width);
    a.height = static_cast<decltype(a.height)>(height);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMSETD2D16ASYNC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemsetD2D32(hipDeviceptr_t dst, size_t dstPitch, unsigned int value, size_t width, size_t height) {
  hipError_t r = g_real_table.hipMemsetD2D32_fn(dst, dstPitch, value, width, height);
  if (r == hipSuccess) {
    hrr_args_hipMemsetD2D32 a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(dst));
    a.dstPitch = static_cast<decltype(a.dstPitch)>(dstPitch);
    a.value = static_cast<decltype(a.value)>(value);
    a.width = static_cast<decltype(a.width)>(width);
    a.height = static_cast<decltype(a.height)>(height);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMSETD2D32, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemsetD2D32Async(hipDeviceptr_t dst, size_t dstPitch, unsigned int value, size_t width, size_t height, hipStream_t stream) {
  hipError_t r = g_real_table.hipMemsetD2D32Async_fn(dst, dstPitch, value, width, height, stream);
  if (r == hipSuccess) {
    hrr_args_hipMemsetD2D32Async a{};
    a.ret         = static_cast<int32_t>(r);
    a.dst = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(dst));
    a.dstPitch = static_cast<decltype(a.dstPitch)>(dstPitch);
    a.value = static_cast<decltype(a.value)>(value);
    a.width = static_cast<decltype(a.width)>(width);
    a.height = static_cast<decltype(a.height)>(height);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMSETD2D32ASYNC, &a.hdr, sizeof(a));
  }
  return r;
}


// Generated shim
static hipError_t capture_hipStreamGetAttribute(hipStream_t stream, hipStreamAttrID attr, hipStreamAttrValue* value_out) {
  hipError_t r = g_real_table.hipStreamGetAttribute_fn(stream, attr, value_out);
  if (r == hipSuccess) {
    hrr_args_hipStreamGetAttribute a{};
    a.ret         = static_cast<int32_t>(r);
    a.stream = reinterpret_cast<uint64_t>(stream);
    a.attr = static_cast<decltype(a.attr)>(attr);
    a.value_out = reinterpret_cast<uint64_t>(value_out);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMGETATTRIBUTE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipModuleLoadFatBinary(hipModule_t* module, const void* fatbin) {
  hipError_t r = g_real_table.hipModuleLoadFatBinary_fn(module, fatbin);
  if (r == hipSuccess) {
    hrr_args_hipModuleLoadFatBinary a{};
    a.ret         = static_cast<int32_t>(r);
    a.fatbin = reinterpret_cast<uint64_t>(fatbin);
    if (module) a.module = reinterpret_cast<uint64_t>(*module);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMODULELOADFATBINARY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpyBatchAsync(void** dsts, void** srcs, size_t* sizes, size_t count, hipMemcpyAttributes* attrs, size_t* attrsIdxs, size_t numAttrs, size_t* failIdx, hipStream_t stream) {
  hipError_t r = g_real_table.hipMemcpyBatchAsync_fn(dsts, srcs, sizes, count, attrs, attrsIdxs, numAttrs, failIdx, stream);
  if (r == hipSuccess) {
    hrr_args_hipMemcpyBatchAsync a{};
    a.ret         = static_cast<int32_t>(r);
    a.sizes = reinterpret_cast<uint64_t>(sizes);
    a.count = static_cast<decltype(a.count)>(count);
    a.attrs = reinterpret_cast<uint64_t>(attrs);
    a.attrsIdxs = reinterpret_cast<uint64_t>(attrsIdxs);
    a.numAttrs = static_cast<decltype(a.numAttrs)>(numAttrs);
    a.failIdx = reinterpret_cast<uint64_t>(failIdx);
    a.stream = reinterpret_cast<uint64_t>(stream);
    if (dsts) a.dsts = reinterpret_cast<uint64_t>(*dsts);
    if (srcs) a.srcs = reinterpret_cast<uint64_t>(*srcs);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPYBATCHASYNC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpy3DBatchAsync(size_t numOps, struct hipMemcpy3DBatchOp* opList, size_t* failIdx, unsigned long long flags, hipStream_t stream) {
  hipError_t r = g_real_table.hipMemcpy3DBatchAsync_fn(numOps, opList, failIdx, flags, stream);
  if (r == hipSuccess) {
    hrr_args_hipMemcpy3DBatchAsync a{};
    a.ret         = static_cast<int32_t>(r);
    a.numOps = static_cast<decltype(a.numOps)>(numOps);
    a.opList = reinterpret_cast<uint64_t>(opList);
    a.failIdx = reinterpret_cast<uint64_t>(failIdx);
    a.flags = static_cast<decltype(a.flags)>(flags);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPY3DBATCHASYNC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpy3DPeer(hipMemcpy3DPeerParms* p) {
  hipError_t r = g_real_table.hipMemcpy3DPeer_fn(p);
  if (r == hipSuccess) {
    hrr_args_hipMemcpy3DPeer a{};
    a.ret         = static_cast<int32_t>(r);
    a.p = reinterpret_cast<uint64_t>(p);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPY3DPEER, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemcpy3DPeerAsync(hipMemcpy3DPeerParms* p, hipStream_t stream) {
  hipError_t r = g_real_table.hipMemcpy3DPeerAsync_fn(p, stream);
  if (r == hipSuccess) {
    hrr_args_hipMemcpy3DPeerAsync a{};
    a.ret         = static_cast<int32_t>(r);
    a.p = reinterpret_cast<uint64_t>(p);
    a.stream = reinterpret_cast<uint64_t>(stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMCPY3DPEERASYNC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGetDriverEntryPoint(const char* symbol, void** funcPtr, unsigned long long flags, hipDriverEntryPointQueryResult* status) {
  hipError_t r = g_real_table.hipGetDriverEntryPoint_fn(symbol, funcPtr, flags, status);
  if (r == hipSuccess) {
    hrr_args_hipGetDriverEntryPoint a{};
    a.ret         = static_cast<int32_t>(r);
    a.symbol = reinterpret_cast<uint64_t>(symbol);
    a.flags = static_cast<decltype(a.flags)>(flags);
    a.status = reinterpret_cast<uint64_t>(status);
    if (funcPtr) a.funcPtr = reinterpret_cast<uint64_t>(*funcPtr);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGETDRIVERENTRYPOINT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGetDriverEntryPoint_spt(const char* symbol, void** funcPtr, unsigned long long flags, hipDriverEntryPointQueryResult* status) {
  hipError_t r = g_real_table.hipGetDriverEntryPoint_spt_fn(symbol, funcPtr, flags, status);
  if (r == hipSuccess) {
    hrr_args_hipGetDriverEntryPoint_spt a{};
    a.ret         = static_cast<int32_t>(r);
    a.symbol = reinterpret_cast<uint64_t>(symbol);
    a.flags = static_cast<decltype(a.flags)>(flags);
    a.status = reinterpret_cast<uint64_t>(status);
    if (funcPtr) a.funcPtr = reinterpret_cast<uint64_t>(*funcPtr);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGETDRIVERENTRYPOINT_SPT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipLibraryLoadData(hipLibrary_t* library, const void* code, hipJitOption* jitOptions, void** jitOptionsValues, unsigned int numJitOptions, hipLibraryOption* libraryOptions, void** libraryOptionValues, unsigned int numLibraryOptions) {
  hipError_t r = g_real_table.hipLibraryLoadData_fn(library, code, jitOptions, jitOptionsValues, numJitOptions, libraryOptions, libraryOptionValues, numLibraryOptions);
  if (r == hipSuccess) {
    hrr_args_hipLibraryLoadData a{};
    a.ret         = static_cast<int32_t>(r);
    a.library = reinterpret_cast<uint64_t>(library);
    a.code = reinterpret_cast<uint64_t>(code);
    a.jitOptions = reinterpret_cast<uint64_t>(jitOptions);
    a.numJitOptions = static_cast<decltype(a.numJitOptions)>(numJitOptions);
    a.libraryOptions = reinterpret_cast<uint64_t>(libraryOptions);
    a.numLibraryOptions = static_cast<decltype(a.numLibraryOptions)>(numLibraryOptions);
    if (jitOptionsValues) a.jitOptionsValues = reinterpret_cast<uint64_t>(*jitOptionsValues);
    if (libraryOptionValues) a.libraryOptionValues = reinterpret_cast<uint64_t>(*libraryOptionValues);
    hrr_cap::writer::write_event_raw(HRR_API_HIPLIBRARYLOADDATA, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipLibraryLoadFromFile(hipLibrary_t* library, const char* fileName, hipJitOption* jitOptions, void** jitOptionsValues, unsigned int numJitOptions, hipLibraryOption* libraryOptions, void** libraryOptionValues, unsigned int numLibraryOptions) {
  hipError_t r = g_real_table.hipLibraryLoadFromFile_fn(library, fileName, jitOptions, jitOptionsValues, numJitOptions, libraryOptions, libraryOptionValues, numLibraryOptions);
  if (r == hipSuccess) {
    hrr_args_hipLibraryLoadFromFile a{};
    a.ret         = static_cast<int32_t>(r);
    a.library = reinterpret_cast<uint64_t>(library);
    a.fileName = reinterpret_cast<uint64_t>(fileName);
    a.jitOptions = reinterpret_cast<uint64_t>(jitOptions);
    a.numJitOptions = static_cast<decltype(a.numJitOptions)>(numJitOptions);
    a.libraryOptions = reinterpret_cast<uint64_t>(libraryOptions);
    a.numLibraryOptions = static_cast<decltype(a.numLibraryOptions)>(numLibraryOptions);
    if (jitOptionsValues) a.jitOptionsValues = reinterpret_cast<uint64_t>(*jitOptionsValues);
    if (libraryOptionValues) a.libraryOptionValues = reinterpret_cast<uint64_t>(*libraryOptionValues);
    hrr_cap::writer::write_event_raw(HRR_API_HIPLIBRARYLOADFROMFILE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipLibraryUnload(hipLibrary_t library) {
  hipError_t r = g_real_table.hipLibraryUnload_fn(library);
  if (r == hipSuccess) {
    hrr_args_hipLibraryUnload a{};
    a.ret         = static_cast<int32_t>(r);
    a.library = reinterpret_cast<uint64_t>(library);
    hrr_cap::writer::write_event_raw(HRR_API_HIPLIBRARYUNLOAD, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipLibraryGetKernel(hipKernel_t* pKernel, hipLibrary_t library, const char* name) {
  hipError_t r = g_real_table.hipLibraryGetKernel_fn(pKernel, library, name);
  if (r == hipSuccess) {
    hrr_args_hipLibraryGetKernel a{};
    a.ret         = static_cast<int32_t>(r);
    a.pKernel = reinterpret_cast<uint64_t>(pKernel);
    a.library = reinterpret_cast<uint64_t>(library);
    a.name = reinterpret_cast<uint64_t>(name);
    hrr_cap::writer::write_event_raw(HRR_API_HIPLIBRARYGETKERNEL, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipLibraryGetKernelCount(unsigned int* count, hipLibrary_t library) {
  hipError_t r = g_real_table.hipLibraryGetKernelCount_fn(count, library);
  if (r == hipSuccess) {
    hrr_args_hipLibraryGetKernelCount a{};
    a.ret         = static_cast<int32_t>(r);
    a.count = reinterpret_cast<uint64_t>(count);
    a.library = reinterpret_cast<uint64_t>(library);
    hrr_cap::writer::write_event_raw(HRR_API_HIPLIBRARYGETKERNELCOUNT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipLibraryGetGlobal(void** dptr, size_t* bytes, hipLibrary_t library, const char* name) {
  hipError_t r = g_real_table.hipLibraryGetGlobal_fn(dptr, bytes, library, name);
  if (r == hipSuccess) {
    hrr_args_hipLibraryGetGlobal a{};
    a.ret         = static_cast<int32_t>(r);
    a.bytes = reinterpret_cast<uint64_t>(bytes);
    a.library = reinterpret_cast<uint64_t>(library);
    a.name = reinterpret_cast<uint64_t>(name);
    if (dptr) a.dptr = reinterpret_cast<uint64_t>(*dptr);
    hrr_cap::writer::write_event_raw(HRR_API_HIPLIBRARYGETGLOBAL, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipLibraryGetManaged(void** dptr, size_t* bytes, hipLibrary_t library, const char* name) {
  hipError_t r = g_real_table.hipLibraryGetManaged_fn(dptr, bytes, library, name);
  if (r == hipSuccess) {
    hrr_args_hipLibraryGetManaged a{};
    a.ret         = static_cast<int32_t>(r);
    a.bytes = reinterpret_cast<uint64_t>(bytes);
    a.library = reinterpret_cast<uint64_t>(library);
    a.name = reinterpret_cast<uint64_t>(name);
    if (dptr) a.dptr = reinterpret_cast<uint64_t>(*dptr);
    hrr_cap::writer::write_event_raw(HRR_API_HIPLIBRARYGETMANAGED, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipLibraryEnumerateKernels(hipKernel_t* kernels, unsigned int numKernels, hipLibrary_t library) {
  hipError_t r = g_real_table.hipLibraryEnumerateKernels_fn(kernels, numKernels, library);
  if (r == hipSuccess) {
    hrr_args_hipLibraryEnumerateKernels a{};
    a.ret         = static_cast<int32_t>(r);
    a.kernels = reinterpret_cast<uint64_t>(kernels);
    a.numKernels = static_cast<decltype(a.numKernels)>(numKernels);
    a.library = reinterpret_cast<uint64_t>(library);
    hrr_cap::writer::write_event_raw(HRR_API_HIPLIBRARYENUMERATEKERNELS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipKernelGetLibrary(hipLibrary_t* library, hipKernel_t kernel) {
  hipError_t r = g_real_table.hipKernelGetLibrary_fn(library, kernel);
  if (r == hipSuccess) {
    hrr_args_hipKernelGetLibrary a{};
    a.ret         = static_cast<int32_t>(r);
    a.library = reinterpret_cast<uint64_t>(library);
    a.kernel = reinterpret_cast<uint64_t>(kernel);
    hrr_cap::writer::write_event_raw(HRR_API_HIPKERNELGETLIBRARY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipKernelGetName(const char** name, hipKernel_t kernel) {
  hipError_t r = g_real_table.hipKernelGetName_fn(name, kernel);
  if (r == hipSuccess) {
    hrr_args_hipKernelGetName a{};
    a.ret         = static_cast<int32_t>(r);
    a.kernel = reinterpret_cast<uint64_t>(kernel);
    if (name) a.name = reinterpret_cast<uint64_t>(*name);
    hrr_cap::writer::write_event_raw(HRR_API_HIPKERNELGETNAME, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGetProcAddress_spt(const char* symbol, void** pfn, int hipVersion, uint64_t flags, hipDriverProcAddressQueryResult* symbolStatus) {
  hipError_t r = g_real_table.hipGetProcAddress_spt_fn(symbol, pfn, hipVersion, flags, symbolStatus);
  if (r == hipSuccess) {
    hrr_args_hipGetProcAddress_spt a{};
    a.ret         = static_cast<int32_t>(r);
    a.symbol = reinterpret_cast<uint64_t>(symbol);
    a.hipVersion = static_cast<decltype(a.hipVersion)>(hipVersion);
    a.flags = static_cast<decltype(a.flags)>(flags);
    a.symbolStatus = reinterpret_cast<uint64_t>(symbolStatus);
    if (pfn) a.pfn = reinterpret_cast<uint64_t>(*pfn);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGETPROCADDRESS_SPT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipExtDisableLogging(void) {
  hipError_t r = g_real_table.hipExtDisableLogging_fn();
  if (r == hipSuccess) {
    hrr_args_hipExtDisableLogging a{};
    a.ret         = static_cast<int32_t>(r);
    hrr_cap::writer::write_event_raw(HRR_API_HIPEXTDISABLELOGGING, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipExtEnableLogging(void) {
  hipError_t r = g_real_table.hipExtEnableLogging_fn();
  if (r == hipSuccess) {
    hrr_args_hipExtEnableLogging a{};
    a.ret         = static_cast<int32_t>(r);
    hrr_cap::writer::write_event_raw(HRR_API_HIPEXTENABLELOGGING, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipExtSetLoggingParams(size_t log_level, size_t log_size, size_t log_mask) {
  hipError_t r = g_real_table.hipExtSetLoggingParams_fn(log_level, log_size, log_mask);
  if (r == hipSuccess) {
    hrr_args_hipExtSetLoggingParams a{};
    a.ret         = static_cast<int32_t>(r);
    a.log_level = static_cast<decltype(a.log_level)>(log_level);
    a.log_size = static_cast<decltype(a.log_size)>(log_size);
    a.log_mask = static_cast<decltype(a.log_mask)>(log_mask);
    hrr_cap::writer::write_event_raw(HRR_API_HIPEXTSETLOGGINGPARAMS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipKernelGetAttribute(int* pi, hipFunction_attribute attrib, hipKernel_t kernel, hipDevice_t dev) {
  hipError_t r = g_real_table.hipKernelGetAttribute_fn(pi, attrib, kernel, dev);
  if (r == hipSuccess) {
    hrr_args_hipKernelGetAttribute a{};
    a.ret         = static_cast<int32_t>(r);
    a.pi = reinterpret_cast<uint64_t>(pi);
    a.attrib = static_cast<decltype(a.attrib)>(attrib);
    a.kernel = reinterpret_cast<uint64_t>(kernel);
    a.dev = static_cast<uint64_t>(static_cast<int>(dev));
    hrr_cap::writer::write_event_raw(HRR_API_HIPKERNELGETATTRIBUTE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipKernelSetAttribute(hipFunction_attribute attrib, int value, hipKernel_t kernel, hipDevice_t dev) {
  hipError_t r = g_real_table.hipKernelSetAttribute_fn(attrib, value, kernel, dev);
  if (r == hipSuccess) {
    hrr_args_hipKernelSetAttribute a{};
    a.ret         = static_cast<int32_t>(r);
    a.attrib = static_cast<decltype(a.attrib)>(attrib);
    a.value = static_cast<decltype(a.value)>(value);
    a.kernel = reinterpret_cast<uint64_t>(kernel);
    a.dev = static_cast<uint64_t>(static_cast<int>(dev));
    hrr_cap::writer::write_event_raw(HRR_API_HIPKERNELSETATTRIBUTE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipKernelGetFunction(hipFunction_t* pFunc, hipKernel_t kernel) {
  hipError_t r = g_real_table.hipKernelGetFunction_fn(pFunc, kernel);
  if (r == hipSuccess) {
    hrr_args_hipKernelGetFunction a{};
    a.ret         = static_cast<int32_t>(r);
    a.kernel = reinterpret_cast<uint64_t>(kernel);
    if (pFunc) a.pFunc = reinterpret_cast<uint64_t>(*pFunc);
    hrr_cap::writer::write_event_raw(HRR_API_HIPKERNELGETFUNCTION, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipKernelGetParamInfo(hipKernel_t kernel, size_t paramIndex, size_t* paramOffset, size_t* paramSize) {
  hipError_t r = g_real_table.hipKernelGetParamInfo_fn(kernel, paramIndex, paramOffset, paramSize);
  if (r == hipSuccess) {
    hrr_args_hipKernelGetParamInfo a{};
    a.ret         = static_cast<int32_t>(r);
    a.kernel = reinterpret_cast<uint64_t>(kernel);
    a.paramIndex = static_cast<decltype(a.paramIndex)>(paramIndex);
    a.paramOffset = reinterpret_cast<uint64_t>(paramOffset);
    a.paramSize = reinterpret_cast<uint64_t>(paramSize);
    hrr_cap::writer::write_event_raw(HRR_API_HIPKERNELGETPARAMINFO, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemSetMemPool(hipMemLocation* location, hipMemAllocationType type, hipMemPool_t pool) {
  hipError_t r = g_real_table.hipMemSetMemPool_fn(location, type, pool);
  if (r == hipSuccess) {
    hrr_args_hipMemSetMemPool a{};
    a.ret         = static_cast<int32_t>(r);
    a.location = 0;  // non-castable type skipped
    a.type = static_cast<decltype(a.type)>(type);
    a.pool = reinterpret_cast<uint64_t>(pool);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMSETMEMPOOL, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMemGetMemPool(hipMemPool_t* pool, hipMemLocation* location, hipMemAllocationType type) {
  hipError_t r = g_real_table.hipMemGetMemPool_fn(pool, location, type);
  if (r == hipSuccess) {
    hrr_args_hipMemGetMemPool a{};
    a.ret         = static_cast<int32_t>(r);
    a.location = 0;  // non-castable type skipped
    a.type = static_cast<decltype(a.type)>(type);
    if (pool) a.pool = reinterpret_cast<uint64_t>(*pool);
    hrr_cap::writer::write_event_raw(HRR_API_HIPMEMGETMEMPOOL, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipMipmappedArrayGetMemoryRequirements(hipArrayMemoryRequirements* memoryRequirements, hipMipmappedArray_t mipmap, hipDevice_t device) {
  hipError_t r = g_real_table.hipMipmappedArrayGetMemoryRequirements_fn(memoryRequirements, mipmap, device);
  if (r == hipSuccess) {
    hrr_args_hipMipmappedArrayGetMemoryRequirements a{};
    a.ret         = static_cast<int32_t>(r);
    a.memoryRequirements = reinterpret_cast<uint64_t>(memoryRequirements);
    a.mipmap = reinterpret_cast<uint64_t>(mipmap);
    a.device = static_cast<uint64_t>(static_cast<int>(device));
    hrr_cap::writer::write_event_raw(HRR_API_HIPMIPMAPPEDARRAYGETMEMORYREQUIREMENTS, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipGreenCtxCreate(hipExecutionCtx_t* ctx, hipDevResourceDesc_t desc, int device, unsigned int flags) {
  hipError_t r = g_real_table.hipGreenCtxCreate_fn(ctx, desc, device, flags);
  if (r == hipSuccess) {
    hrr_args_hipGreenCtxCreate a{};
    a.ret         = static_cast<int32_t>(r);
    a.ctx = reinterpret_cast<uint64_t>(ctx);
    a.desc = reinterpret_cast<uint64_t>(desc);
    a.device = static_cast<decltype(a.device)>(device);
    a.flags = static_cast<decltype(a.flags)>(flags);
    hrr_cap::writer::write_event_raw(HRR_API_HIPGREENCTXCREATE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipExecutionCtxDestroy(hipExecutionCtx_t ctx) {
  hipError_t r = g_real_table.hipExecutionCtxDestroy_fn(ctx);
  if (r == hipSuccess) {
    hrr_args_hipExecutionCtxDestroy a{};
    a.ret         = static_cast<int32_t>(r);
    a.ctx = reinterpret_cast<uint64_t>(ctx);
    hrr_cap::writer::write_event_raw(HRR_API_HIPEXECUTIONCTXDESTROY, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipExecutionCtxStreamCreate(hipStream_t* stream, hipExecutionCtx_t greenctx, unsigned int flags, int priority) {
  hipError_t r = g_real_table.hipExecutionCtxStreamCreate_fn(stream, greenctx, flags, priority);
  if (r == hipSuccess) {
    hrr_args_hipExecutionCtxStreamCreate a{};
    a.ret         = static_cast<int32_t>(r);
    a.greenctx = reinterpret_cast<uint64_t>(greenctx);
    a.flags = static_cast<decltype(a.flags)>(flags);
    a.priority = static_cast<decltype(a.priority)>(priority);
    if (stream) a.stream = reinterpret_cast<uint64_t>(*stream);
    hrr_cap::writer::write_event_raw(HRR_API_HIPEXECUTIONCTXSTREAMCREATE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDeviceGetDevResource(hipDevice_t device, hipDevResource* resource, hipDevResourceType type) {
  hipError_t r = g_real_table.hipDeviceGetDevResource_fn(device, resource, type);
  if (r == hipSuccess) {
    hrr_args_hipDeviceGetDevResource a{};
    a.ret         = static_cast<int32_t>(r);
    a.device = static_cast<uint64_t>(static_cast<int>(device));
    a.resource = reinterpret_cast<uint64_t>(resource);
    a.type = static_cast<decltype(a.type)>(type);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVICEGETDEVRESOURCE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDevSmResourceSplitByCount(hipDevResource* result, unsigned int* nbGroups, const hipDevResource* input, hipDevResource* remainder, unsigned int flags, unsigned int minCount) {
  hipError_t r = g_real_table.hipDevSmResourceSplitByCount_fn(result, nbGroups, input, remainder, flags, minCount);
  if (r == hipSuccess) {
    hrr_args_hipDevSmResourceSplitByCount a{};
    a.ret         = static_cast<int32_t>(r);
    a.result = reinterpret_cast<uint64_t>(result);
    a.nbGroups = reinterpret_cast<uint64_t>(nbGroups);
    a.input = reinterpret_cast<uint64_t>(input);
    a.remainder = reinterpret_cast<uint64_t>(remainder);
    a.flags = static_cast<decltype(a.flags)>(flags);
    a.minCount = static_cast<decltype(a.minCount)>(minCount);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVSMRESOURCESPLITBYCOUNT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDevSmResourceSplit(hipDevResource* result, unsigned int nbGroups, const hipDevResource* input, hipDevResource* remainder, unsigned int flags, hipDevSmResourceGroupParams* groupParams) {
  hipError_t r = g_real_table.hipDevSmResourceSplit_fn(result, nbGroups, input, remainder, flags, groupParams);
  if (r == hipSuccess) {
    hrr_args_hipDevSmResourceSplit a{};
    a.ret         = static_cast<int32_t>(r);
    a.result = reinterpret_cast<uint64_t>(result);
    a.nbGroups = static_cast<decltype(a.nbGroups)>(nbGroups);
    a.input = reinterpret_cast<uint64_t>(input);
    a.remainder = reinterpret_cast<uint64_t>(remainder);
    a.flags = static_cast<decltype(a.flags)>(flags);
    a.groupParams = reinterpret_cast<uint64_t>(groupParams);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVSMRESOURCESPLIT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDevResourceGenerateDesc(hipDevResourceDesc_t* phDesc, hipDevResource* resources, unsigned int nbResources) {
  hipError_t r = g_real_table.hipDevResourceGenerateDesc_fn(phDesc, resources, nbResources);
  if (r == hipSuccess) {
    hrr_args_hipDevResourceGenerateDesc a{};
    a.ret         = static_cast<int32_t>(r);
    a.phDesc = reinterpret_cast<uint64_t>(phDesc);
    a.resources = reinterpret_cast<uint64_t>(resources);
    a.nbResources = static_cast<decltype(a.nbResources)>(nbResources);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVRESOURCEGENERATEDESC, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipDeviceGetExecutionCtx(hipExecutionCtx_t* ctx, int device) {
  hipError_t r = g_real_table.hipDeviceGetExecutionCtx_fn(ctx, device);
  if (r == hipSuccess) {
    hrr_args_hipDeviceGetExecutionCtx a{};
    a.ret         = static_cast<int32_t>(r);
    a.ctx = reinterpret_cast<uint64_t>(ctx);
    a.device = static_cast<decltype(a.device)>(device);
    hrr_cap::writer::write_event_raw(HRR_API_HIPDEVICEGETEXECUTIONCTX, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipExecutionCtxGetDevResource(hipExecutionCtx_t ctx, hipDevResource* resource, hipDevResourceType type) {
  hipError_t r = g_real_table.hipExecutionCtxGetDevResource_fn(ctx, resource, type);
  if (r == hipSuccess) {
    hrr_args_hipExecutionCtxGetDevResource a{};
    a.ret         = static_cast<int32_t>(r);
    a.ctx = reinterpret_cast<uint64_t>(ctx);
    a.resource = reinterpret_cast<uint64_t>(resource);
    a.type = static_cast<decltype(a.type)>(type);
    hrr_cap::writer::write_event_raw(HRR_API_HIPEXECUTIONCTXGETDEVRESOURCE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipExecutionCtxGetDevice(int* device, hipExecutionCtx_t ctx) {
  hipError_t r = g_real_table.hipExecutionCtxGetDevice_fn(device, ctx);
  if (r == hipSuccess) {
    hrr_args_hipExecutionCtxGetDevice a{};
    a.ret         = static_cast<int32_t>(r);
    a.device = reinterpret_cast<uint64_t>(device);
    a.ctx = reinterpret_cast<uint64_t>(ctx);
    hrr_cap::writer::write_event_raw(HRR_API_HIPEXECUTIONCTXGETDEVICE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipExecutionCtxGetId(hipExecutionCtx_t ctx, unsigned long long* ctxId) {
  hipError_t r = g_real_table.hipExecutionCtxGetId_fn(ctx, ctxId);
  if (r == hipSuccess) {
    hrr_args_hipExecutionCtxGetId a{};
    a.ret         = static_cast<int32_t>(r);
    a.ctx = reinterpret_cast<uint64_t>(ctx);
    a.ctxId = reinterpret_cast<uint64_t>(ctxId);
    hrr_cap::writer::write_event_raw(HRR_API_HIPEXECUTIONCTXGETID, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipStreamGetDevResource(hipStream_t hStream, hipDevResource* resource, hipDevResourceType type) {
  hipError_t r = g_real_table.hipStreamGetDevResource_fn(hStream, resource, type);
  if (r == hipSuccess) {
    hrr_args_hipStreamGetDevResource a{};
    a.ret         = static_cast<int32_t>(r);
    a.hStream = reinterpret_cast<uint64_t>(hStream);
    a.resource = reinterpret_cast<uint64_t>(resource);
    a.type = static_cast<decltype(a.type)>(type);
    hrr_cap::writer::write_event_raw(HRR_API_HIPSTREAMGETDEVRESOURCE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipExecutionCtxRecordEvent(hipExecutionCtx_t ctx, hipEvent_t event) {
  hipError_t r = g_real_table.hipExecutionCtxRecordEvent_fn(ctx, event);
  if (r == hipSuccess) {
    hrr_args_hipExecutionCtxRecordEvent a{};
    a.ret         = static_cast<int32_t>(r);
    a.ctx = reinterpret_cast<uint64_t>(ctx);
    a.event = reinterpret_cast<uint64_t>(event);
    hrr_cap::writer::write_event_raw(HRR_API_HIPEXECUTIONCTXRECORDEVENT, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipExecutionCtxSynchronize(hipExecutionCtx_t ctx) {
  hipError_t r = g_real_table.hipExecutionCtxSynchronize_fn(ctx);
  if (r == hipSuccess) {
    hrr_args_hipExecutionCtxSynchronize a{};
    a.ret         = static_cast<int32_t>(r);
    a.ctx = reinterpret_cast<uint64_t>(ctx);
    hrr_cap::writer::write_event_raw(HRR_API_HIPEXECUTIONCTXSYNCHRONIZE, &a.hdr, sizeof(a));
  }
  return r;
}

// Generated shim
static hipError_t capture_hipExecutionCtxWaitEvent(hipExecutionCtx_t ctx, hipEvent_t event) {
  hipError_t r = g_real_table.hipExecutionCtxWaitEvent_fn(ctx, event);
  if (r == hipSuccess) {
    hrr_args_hipExecutionCtxWaitEvent a{};
    a.ret         = static_cast<int32_t>(r);
    a.ctx = reinterpret_cast<uint64_t>(ctx);
    a.event = reinterpret_cast<uint64_t>(event);
    hrr_cap::writer::write_event_raw(HRR_API_HIPEXECUTIONCTXWAITEVENT, &a.hdr, sizeof(a));
  }
  return r;
}

// ============================================================
// Table builders
// ============================================================

// Forward declarations for hand-written shims (non-static in hip_capture.cpp)
extern hipError_t capture_hipArray3DCreate(hipArray_t* array, const HIP_ARRAY3D_DESCRIPTOR* pAllocateArray);
extern hipError_t capture_hipArrayCreate(hipArray_t* pHandle, const HIP_ARRAY_DESCRIPTOR* pAllocateArray);
extern hipError_t capture_hipHostRegister(void* hostPtr, size_t sizeBytes, unsigned int flags);
extern hipError_t capture_hipHostUnregister(void* hostPtr);
extern hipError_t capture_hipLaunchByPtr(const void* func);
extern hipError_t capture_hipLaunchKernel(const void* function_address, dim3 numBlocks, dim3 dimBlocks, void** args, size_t sharedMemBytes, hipStream_t stream);
extern hipError_t capture_hipMemGetAllocationGranularity(size_t* granularity, const hipMemAllocationProp* prop, hipMemAllocationGranularity_flags option);
extern hipError_t capture_hipMemPoolCreate(hipMemPool_t* mem_pool, const hipMemPoolProps* pool_props);
extern hipError_t capture_hipMemPoolSetAccess(hipMemPool_t mem_pool, const hipMemAccessDesc* desc_list, size_t count);
extern hipError_t capture_hipMemPoolSetAttribute(hipMemPool_t mem_pool, hipMemPoolAttr attr, void* value);
extern hipError_t capture_hipMemSetAccess(void* ptr, size_t size, const hipMemAccessDesc* desc, size_t count);
extern hipError_t capture_hipMemcpy(void* dst, const void* src, size_t sizeBytes, hipMemcpyKind kind);
extern hipError_t capture_hipMemcpy3D(const struct hipMemcpy3DParms* p);
extern hipError_t capture_hipMemcpy3DAsync(const struct hipMemcpy3DParms* p, hipStream_t stream);
extern hipError_t capture_hipMemcpyAsync(void* dst, const void* src, size_t sizeBytes, hipMemcpyKind kind, hipStream_t stream);
extern hipError_t capture_hipMemcpyDtoH(void* dst, hipDeviceptr_t src, size_t sizeBytes);
extern hipError_t capture_hipMemcpyDtoHAsync(void* dst, hipDeviceptr_t src, size_t sizeBytes, hipStream_t stream);
extern hipError_t capture_hipMemcpyHtoD(hipDeviceptr_t dst, const void* src, size_t sizeBytes);
extern hipError_t capture_hipMemcpyHtoDAsync(hipDeviceptr_t dst, const void* src, size_t sizeBytes, hipStream_t stream);
extern hipError_t capture_hipMemcpyWithStream(void* dst, const void* src, size_t sizeBytes, hipMemcpyKind kind, hipStream_t stream);
extern hipError_t capture_hipModuleLaunchKernel(hipFunction_t f, unsigned int gridDimX, unsigned int gridDimY, unsigned int gridDimZ, unsigned int blockDimX, unsigned int blockDimY, unsigned int blockDimZ, unsigned int sharedMemBytes, hipStream_t stream, void** kernelParams, void** extra);
extern hipError_t capture_hipModuleLoad(hipModule_t* module, const char* fname);
extern hipError_t capture_hipModuleLoadData(hipModule_t* module, const void* image);
extern hipError_t capture_hipModuleLoadDataEx(hipModule_t* module, const void* image, unsigned int numOptions, hipJitOption* options, void** optionValues);
extern hipError_t capture_hipMemcpy3D_spt(const struct hipMemcpy3DParms* p);
extern hipError_t capture_hipMemcpy3DAsync_spt(const hipMemcpy3DParms* p, hipStream_t stream);
extern hipError_t capture_hipExtModuleLaunchKernel(hipFunction_t f, uint32_t globalWorkSizeX, uint32_t globalWorkSizeY, uint32_t globalWorkSizeZ, uint32_t localWorkSizeX, uint32_t localWorkSizeY, uint32_t localWorkSizeZ, size_t sharedMemBytes, hipStream_t hStream, void** kernelParams, void** extra, hipEvent_t startEvent, hipEvent_t stopEvent, uint32_t flags);
extern hipError_t capture_hipStreamSetAttribute(hipStream_t stream, hipStreamAttrID attr, const hipStreamAttrValue* value);
extern hipError_t capture___hipPushCallConfiguration(dim3 gridDim, dim3 blockDim, size_t sharedMem, hipStream_t stream);
extern void** capture___hipRegisterFatBinary(const void* data);
extern void capture___hipUnregisterFatBinary(void** modules);

void hip_capture_build_table() {
  // Guard: safe to call only once. A second call after shims are installed
  // would snapshot shim ptrs into g_real_table, causing infinite recursion.
  if (g_table_built.exchange(true)) return;
  // Snapshot the live real table; copy all slots as pass-through base
  g_real_table = *hip::GetHipDispatchTable();
  g_cap_table  = g_real_table;

  // Override every runtime slot with its capture shim
  g_cap_table.hipApiName_fn = capture_hipApiName;
  g_cap_table.hipArray3DCreate_fn = capture_hipArray3DCreate;
  g_cap_table.hipArray3DGetDescriptor_fn = capture_hipArray3DGetDescriptor;
  g_cap_table.hipArrayCreate_fn = capture_hipArrayCreate;
  g_cap_table.hipArrayDestroy_fn = capture_hipArrayDestroy;
  g_cap_table.hipArrayGetDescriptor_fn = capture_hipArrayGetDescriptor;
  g_cap_table.hipArrayGetInfo_fn = capture_hipArrayGetInfo;
  g_cap_table.hipBindTexture_fn = capture_hipBindTexture;
  g_cap_table.hipBindTexture2D_fn = capture_hipBindTexture2D;
  g_cap_table.hipBindTextureToArray_fn = capture_hipBindTextureToArray;
  g_cap_table.hipBindTextureToMipmappedArray_fn = capture_hipBindTextureToMipmappedArray;
  g_cap_table.hipChooseDevice_fn = capture_hipChooseDevice;
  g_cap_table.hipChooseDeviceR0000_fn = capture_hipChooseDeviceR0000;
  g_cap_table.hipConfigureCall_fn = capture_hipConfigureCall;
  g_cap_table.hipCreateSurfaceObject_fn = capture_hipCreateSurfaceObject;
  g_cap_table.hipCreateTextureObject_fn = capture_hipCreateTextureObject;
  g_cap_table.hipCtxCreate_fn = capture_hipCtxCreate;
  g_cap_table.hipCtxDestroy_fn = capture_hipCtxDestroy;
  g_cap_table.hipCtxDisablePeerAccess_fn = capture_hipCtxDisablePeerAccess;
  g_cap_table.hipCtxEnablePeerAccess_fn = capture_hipCtxEnablePeerAccess;
  g_cap_table.hipCtxGetApiVersion_fn = capture_hipCtxGetApiVersion;
  g_cap_table.hipCtxGetCacheConfig_fn = capture_hipCtxGetCacheConfig;
  g_cap_table.hipCtxGetCurrent_fn = capture_hipCtxGetCurrent;
  g_cap_table.hipCtxGetDevice_fn = capture_hipCtxGetDevice;
  g_cap_table.hipCtxGetFlags_fn = capture_hipCtxGetFlags;
  g_cap_table.hipCtxGetSharedMemConfig_fn = capture_hipCtxGetSharedMemConfig;
  g_cap_table.hipCtxPopCurrent_fn = capture_hipCtxPopCurrent;
  g_cap_table.hipCtxPushCurrent_fn = capture_hipCtxPushCurrent;
  g_cap_table.hipCtxSetCacheConfig_fn = capture_hipCtxSetCacheConfig;
  g_cap_table.hipCtxSetCurrent_fn = capture_hipCtxSetCurrent;
  g_cap_table.hipCtxSetSharedMemConfig_fn = capture_hipCtxSetSharedMemConfig;
  g_cap_table.hipCtxSynchronize_fn = capture_hipCtxSynchronize;
  g_cap_table.hipDestroyExternalMemory_fn = capture_hipDestroyExternalMemory;
  g_cap_table.hipDestroyExternalSemaphore_fn = capture_hipDestroyExternalSemaphore;
  g_cap_table.hipDestroySurfaceObject_fn = capture_hipDestroySurfaceObject;
  g_cap_table.hipDestroyTextureObject_fn = capture_hipDestroyTextureObject;
  g_cap_table.hipDeviceCanAccessPeer_fn = capture_hipDeviceCanAccessPeer;
  g_cap_table.hipDeviceComputeCapability_fn = capture_hipDeviceComputeCapability;
  g_cap_table.hipDeviceDisablePeerAccess_fn = capture_hipDeviceDisablePeerAccess;
  g_cap_table.hipDeviceEnablePeerAccess_fn = capture_hipDeviceEnablePeerAccess;
  g_cap_table.hipDeviceGet_fn = capture_hipDeviceGet;
  g_cap_table.hipDeviceGetAttribute_fn = capture_hipDeviceGetAttribute;
  g_cap_table.hipDeviceGetByPCIBusId_fn = capture_hipDeviceGetByPCIBusId;
  g_cap_table.hipDeviceGetCacheConfig_fn = capture_hipDeviceGetCacheConfig;
  g_cap_table.hipDeviceGetDefaultMemPool_fn = capture_hipDeviceGetDefaultMemPool;
  g_cap_table.hipDeviceGetGraphMemAttribute_fn = capture_hipDeviceGetGraphMemAttribute;
  g_cap_table.hipDeviceGetLimit_fn = capture_hipDeviceGetLimit;
  g_cap_table.hipDeviceGetMemPool_fn = capture_hipDeviceGetMemPool;
  g_cap_table.hipDeviceGetName_fn = capture_hipDeviceGetName;
  g_cap_table.hipDeviceGetP2PAttribute_fn = capture_hipDeviceGetP2PAttribute;
  g_cap_table.hipDeviceGetPCIBusId_fn = capture_hipDeviceGetPCIBusId;
  g_cap_table.hipDeviceGetSharedMemConfig_fn = capture_hipDeviceGetSharedMemConfig;
  g_cap_table.hipDeviceGetStreamPriorityRange_fn = capture_hipDeviceGetStreamPriorityRange;
  g_cap_table.hipDeviceGetUuid_fn = capture_hipDeviceGetUuid;
  g_cap_table.hipDeviceGraphMemTrim_fn = capture_hipDeviceGraphMemTrim;
  g_cap_table.hipDevicePrimaryCtxGetState_fn = capture_hipDevicePrimaryCtxGetState;
  g_cap_table.hipDevicePrimaryCtxRelease_fn = capture_hipDevicePrimaryCtxRelease;
  g_cap_table.hipDevicePrimaryCtxReset_fn = capture_hipDevicePrimaryCtxReset;
  g_cap_table.hipDevicePrimaryCtxRetain_fn = capture_hipDevicePrimaryCtxRetain;
  g_cap_table.hipDevicePrimaryCtxSetFlags_fn = capture_hipDevicePrimaryCtxSetFlags;
  g_cap_table.hipDeviceReset_fn = capture_hipDeviceReset;
  g_cap_table.hipDeviceSetCacheConfig_fn = capture_hipDeviceSetCacheConfig;
  g_cap_table.hipDeviceSetGraphMemAttribute_fn = capture_hipDeviceSetGraphMemAttribute;
  g_cap_table.hipDeviceSetLimit_fn = capture_hipDeviceSetLimit;
  g_cap_table.hipDeviceSetMemPool_fn = capture_hipDeviceSetMemPool;
  g_cap_table.hipDeviceSetSharedMemConfig_fn = capture_hipDeviceSetSharedMemConfig;
  g_cap_table.hipDeviceSynchronize_fn = capture_hipDeviceSynchronize;
  g_cap_table.hipDeviceTotalMem_fn = capture_hipDeviceTotalMem;
  g_cap_table.hipDriverGetVersion_fn = capture_hipDriverGetVersion;
  g_cap_table.hipDrvGetErrorName_fn = capture_hipDrvGetErrorName;
  g_cap_table.hipDrvGetErrorString_fn = capture_hipDrvGetErrorString;
  g_cap_table.hipDrvGraphAddMemcpyNode_fn = capture_hipDrvGraphAddMemcpyNode;
  g_cap_table.hipDrvMemcpy2DUnaligned_fn = capture_hipDrvMemcpy2DUnaligned;
  g_cap_table.hipDrvMemcpy3D_fn = capture_hipDrvMemcpy3D;
  g_cap_table.hipDrvMemcpy3DAsync_fn = capture_hipDrvMemcpy3DAsync;
  g_cap_table.hipDrvPointerGetAttributes_fn = capture_hipDrvPointerGetAttributes;
  g_cap_table.hipEventCreate_fn = capture_hipEventCreate;
  g_cap_table.hipEventCreateWithFlags_fn = capture_hipEventCreateWithFlags;
  g_cap_table.hipEventDestroy_fn = capture_hipEventDestroy;
  g_cap_table.hipEventElapsedTime_fn = capture_hipEventElapsedTime;
  g_cap_table.hipEventQuery_fn = capture_hipEventQuery;
  g_cap_table.hipEventRecord_fn = capture_hipEventRecord;
  g_cap_table.hipEventSynchronize_fn = capture_hipEventSynchronize;
  g_cap_table.hipExtGetLinkTypeAndHopCount_fn = capture_hipExtGetLinkTypeAndHopCount;
  g_cap_table.hipExtLaunchKernel_fn = capture_hipExtLaunchKernel;
  g_cap_table.hipExtLaunchMultiKernelMultiDevice_fn = capture_hipExtLaunchMultiKernelMultiDevice;
  g_cap_table.hipExtMallocWithFlags_fn = capture_hipExtMallocWithFlags;
  g_cap_table.hipExtStreamCreateWithCUMask_fn = capture_hipExtStreamCreateWithCUMask;
  g_cap_table.hipExtStreamGetCUMask_fn = capture_hipExtStreamGetCUMask;
  g_cap_table.hipExternalMemoryGetMappedBuffer_fn = capture_hipExternalMemoryGetMappedBuffer;
  g_cap_table.hipFree_fn = capture_hipFree;
  g_cap_table.hipFreeArray_fn = capture_hipFreeArray;
  g_cap_table.hipFreeAsync_fn = capture_hipFreeAsync;
  g_cap_table.hipFreeHost_fn = capture_hipFreeHost;
  g_cap_table.hipFreeMipmappedArray_fn = capture_hipFreeMipmappedArray;
  g_cap_table.hipFuncGetAttribute_fn = capture_hipFuncGetAttribute;
  g_cap_table.hipFuncGetAttributes_fn = capture_hipFuncGetAttributes;
  g_cap_table.hipFuncSetAttribute_fn = capture_hipFuncSetAttribute;
  g_cap_table.hipFuncSetCacheConfig_fn = capture_hipFuncSetCacheConfig;
  g_cap_table.hipFuncSetSharedMemConfig_fn = capture_hipFuncSetSharedMemConfig;
  g_cap_table.hipGLGetDevices_fn = capture_hipGLGetDevices;
  g_cap_table.hipGetChannelDesc_fn = capture_hipGetChannelDesc;
  g_cap_table.hipGetDevice_fn = capture_hipGetDevice;
  g_cap_table.hipGetDeviceCount_fn = capture_hipGetDeviceCount;
  g_cap_table.hipGetDeviceFlags_fn = capture_hipGetDeviceFlags;
  g_cap_table.hipGetDevicePropertiesR0600_fn = capture_hipGetDevicePropertiesR0600;
  g_cap_table.hipGetDevicePropertiesR0000_fn = capture_hipGetDevicePropertiesR0000;
  g_cap_table.hipGetErrorName_fn = capture_hipGetErrorName;
  g_cap_table.hipGetErrorString_fn = capture_hipGetErrorString;
  g_cap_table.hipGetLastError_fn = capture_hipGetLastError;
  g_cap_table.hipGetMipmappedArrayLevel_fn = capture_hipGetMipmappedArrayLevel;
  g_cap_table.hipGetSymbolAddress_fn = capture_hipGetSymbolAddress;
  g_cap_table.hipGetSymbolSize_fn = capture_hipGetSymbolSize;
  g_cap_table.hipGetTextureAlignmentOffset_fn = capture_hipGetTextureAlignmentOffset;
  g_cap_table.hipGetTextureObjectResourceDesc_fn = capture_hipGetTextureObjectResourceDesc;
  g_cap_table.hipGetTextureObjectResourceViewDesc_fn = capture_hipGetTextureObjectResourceViewDesc;
  g_cap_table.hipGetTextureObjectTextureDesc_fn = capture_hipGetTextureObjectTextureDesc;
  g_cap_table.hipGetTextureReference_fn = capture_hipGetTextureReference;
  g_cap_table.hipGraphAddChildGraphNode_fn = capture_hipGraphAddChildGraphNode;
  g_cap_table.hipGraphAddDependencies_fn = capture_hipGraphAddDependencies;
  g_cap_table.hipGraphAddEmptyNode_fn = capture_hipGraphAddEmptyNode;
  g_cap_table.hipGraphAddEventRecordNode_fn = capture_hipGraphAddEventRecordNode;
  g_cap_table.hipGraphAddEventWaitNode_fn = capture_hipGraphAddEventWaitNode;
  g_cap_table.hipGraphAddHostNode_fn = capture_hipGraphAddHostNode;
  g_cap_table.hipGraphAddKernelNode_fn = capture_hipGraphAddKernelNode;
  g_cap_table.hipGraphAddMemAllocNode_fn = capture_hipGraphAddMemAllocNode;
  g_cap_table.hipGraphAddMemFreeNode_fn = capture_hipGraphAddMemFreeNode;
  g_cap_table.hipGraphAddMemcpyNode_fn = capture_hipGraphAddMemcpyNode;
  g_cap_table.hipGraphAddMemcpyNode1D_fn = capture_hipGraphAddMemcpyNode1D;
  g_cap_table.hipGraphAddMemcpyNodeFromSymbol_fn = capture_hipGraphAddMemcpyNodeFromSymbol;
  g_cap_table.hipGraphAddMemcpyNodeToSymbol_fn = capture_hipGraphAddMemcpyNodeToSymbol;
  g_cap_table.hipGraphAddMemsetNode_fn = capture_hipGraphAddMemsetNode;
  g_cap_table.hipGraphChildGraphNodeGetGraph_fn = capture_hipGraphChildGraphNodeGetGraph;
  g_cap_table.hipGraphClone_fn = capture_hipGraphClone;
  g_cap_table.hipGraphCreate_fn = capture_hipGraphCreate;
  g_cap_table.hipGraphDebugDotPrint_fn = capture_hipGraphDebugDotPrint;
  g_cap_table.hipGraphDestroy_fn = capture_hipGraphDestroy;
  g_cap_table.hipGraphDestroyNode_fn = capture_hipGraphDestroyNode;
  g_cap_table.hipGraphEventRecordNodeGetEvent_fn = capture_hipGraphEventRecordNodeGetEvent;
  g_cap_table.hipGraphEventRecordNodeSetEvent_fn = capture_hipGraphEventRecordNodeSetEvent;
  g_cap_table.hipGraphEventWaitNodeGetEvent_fn = capture_hipGraphEventWaitNodeGetEvent;
  g_cap_table.hipGraphEventWaitNodeSetEvent_fn = capture_hipGraphEventWaitNodeSetEvent;
  g_cap_table.hipGraphExecChildGraphNodeSetParams_fn = capture_hipGraphExecChildGraphNodeSetParams;
  g_cap_table.hipGraphExecDestroy_fn = capture_hipGraphExecDestroy;
  g_cap_table.hipGraphExecEventRecordNodeSetEvent_fn = capture_hipGraphExecEventRecordNodeSetEvent;
  g_cap_table.hipGraphExecEventWaitNodeSetEvent_fn = capture_hipGraphExecEventWaitNodeSetEvent;
  g_cap_table.hipGraphExecHostNodeSetParams_fn = capture_hipGraphExecHostNodeSetParams;
  g_cap_table.hipGraphExecKernelNodeSetParams_fn = capture_hipGraphExecKernelNodeSetParams;
  g_cap_table.hipGraphExecMemcpyNodeSetParams_fn = capture_hipGraphExecMemcpyNodeSetParams;
  g_cap_table.hipGraphExecMemcpyNodeSetParams1D_fn = capture_hipGraphExecMemcpyNodeSetParams1D;
  g_cap_table.hipGraphExecMemcpyNodeSetParamsFromSymbol_fn = capture_hipGraphExecMemcpyNodeSetParamsFromSymbol;
  g_cap_table.hipGraphExecMemcpyNodeSetParamsToSymbol_fn = capture_hipGraphExecMemcpyNodeSetParamsToSymbol;
  g_cap_table.hipGraphExecMemsetNodeSetParams_fn = capture_hipGraphExecMemsetNodeSetParams;
  g_cap_table.hipGraphExecUpdate_fn = capture_hipGraphExecUpdate;
  g_cap_table.hipGraphGetEdges_fn = capture_hipGraphGetEdges;
  g_cap_table.hipGraphGetNodes_fn = capture_hipGraphGetNodes;
  g_cap_table.hipGraphGetRootNodes_fn = capture_hipGraphGetRootNodes;
  g_cap_table.hipGraphHostNodeGetParams_fn = capture_hipGraphHostNodeGetParams;
  g_cap_table.hipGraphHostNodeSetParams_fn = capture_hipGraphHostNodeSetParams;
  g_cap_table.hipGraphInstantiate_fn = capture_hipGraphInstantiate;
  g_cap_table.hipGraphInstantiateWithFlags_fn = capture_hipGraphInstantiateWithFlags;
  g_cap_table.hipGraphKernelNodeCopyAttributes_fn = capture_hipGraphKernelNodeCopyAttributes;
  g_cap_table.hipGraphKernelNodeGetAttribute_fn = capture_hipGraphKernelNodeGetAttribute;
  g_cap_table.hipGraphKernelNodeGetParams_fn = capture_hipGraphKernelNodeGetParams;
  g_cap_table.hipGraphKernelNodeSetAttribute_fn = capture_hipGraphKernelNodeSetAttribute;
  g_cap_table.hipGraphKernelNodeSetParams_fn = capture_hipGraphKernelNodeSetParams;
  g_cap_table.hipGraphLaunch_fn = capture_hipGraphLaunch;
  g_cap_table.hipGraphMemAllocNodeGetParams_fn = capture_hipGraphMemAllocNodeGetParams;
  g_cap_table.hipGraphMemFreeNodeGetParams_fn = capture_hipGraphMemFreeNodeGetParams;
  g_cap_table.hipGraphMemcpyNodeGetParams_fn = capture_hipGraphMemcpyNodeGetParams;
  g_cap_table.hipGraphMemcpyNodeSetParams_fn = capture_hipGraphMemcpyNodeSetParams;
  g_cap_table.hipGraphMemcpyNodeSetParams1D_fn = capture_hipGraphMemcpyNodeSetParams1D;
  g_cap_table.hipGraphMemcpyNodeSetParamsFromSymbol_fn = capture_hipGraphMemcpyNodeSetParamsFromSymbol;
  g_cap_table.hipGraphMemcpyNodeSetParamsToSymbol_fn = capture_hipGraphMemcpyNodeSetParamsToSymbol;
  g_cap_table.hipGraphMemsetNodeGetParams_fn = capture_hipGraphMemsetNodeGetParams;
  g_cap_table.hipGraphMemsetNodeSetParams_fn = capture_hipGraphMemsetNodeSetParams;
  g_cap_table.hipGraphNodeFindInClone_fn = capture_hipGraphNodeFindInClone;
  g_cap_table.hipGraphNodeGetDependencies_fn = capture_hipGraphNodeGetDependencies;
  g_cap_table.hipGraphNodeGetDependentNodes_fn = capture_hipGraphNodeGetDependentNodes;
  g_cap_table.hipGraphNodeGetEnabled_fn = capture_hipGraphNodeGetEnabled;
  g_cap_table.hipGraphNodeGetType_fn = capture_hipGraphNodeGetType;
  g_cap_table.hipGraphNodeSetEnabled_fn = capture_hipGraphNodeSetEnabled;
  g_cap_table.hipGraphReleaseUserObject_fn = capture_hipGraphReleaseUserObject;
  g_cap_table.hipGraphRemoveDependencies_fn = capture_hipGraphRemoveDependencies;
  g_cap_table.hipGraphRetainUserObject_fn = capture_hipGraphRetainUserObject;
  g_cap_table.hipGraphUpload_fn = capture_hipGraphUpload;
  g_cap_table.hipGraphicsGLRegisterBuffer_fn = capture_hipGraphicsGLRegisterBuffer;
  g_cap_table.hipGraphicsGLRegisterImage_fn = capture_hipGraphicsGLRegisterImage;
  g_cap_table.hipGraphicsMapResources_fn = capture_hipGraphicsMapResources;
  g_cap_table.hipGraphicsResourceGetMappedPointer_fn = capture_hipGraphicsResourceGetMappedPointer;
  g_cap_table.hipGraphicsSubResourceGetMappedArray_fn = capture_hipGraphicsSubResourceGetMappedArray;
  g_cap_table.hipGraphicsUnmapResources_fn = capture_hipGraphicsUnmapResources;
  g_cap_table.hipGraphicsUnregisterResource_fn = capture_hipGraphicsUnregisterResource;
  g_cap_table.hipHostAlloc_fn = capture_hipHostAlloc;
  g_cap_table.hipHostFree_fn = capture_hipHostFree;
  g_cap_table.hipHostGetDevicePointer_fn = capture_hipHostGetDevicePointer;
  g_cap_table.hipHostGetFlags_fn = capture_hipHostGetFlags;
  g_cap_table.hipHostMalloc_fn = capture_hipHostMalloc;
  g_cap_table.hipHostRegister_fn = capture_hipHostRegister;
  g_cap_table.hipHostUnregister_fn = capture_hipHostUnregister;
  g_cap_table.hipImportExternalMemory_fn = capture_hipImportExternalMemory;
  g_cap_table.hipImportExternalSemaphore_fn = capture_hipImportExternalSemaphore;
  g_cap_table.hipInit_fn = capture_hipInit;
  g_cap_table.hipIpcCloseMemHandle_fn = capture_hipIpcCloseMemHandle;
  g_cap_table.hipIpcGetEventHandle_fn = capture_hipIpcGetEventHandle;
  g_cap_table.hipIpcGetMemHandle_fn = capture_hipIpcGetMemHandle;
  g_cap_table.hipIpcOpenEventHandle_fn = capture_hipIpcOpenEventHandle;
  g_cap_table.hipIpcOpenMemHandle_fn = capture_hipIpcOpenMemHandle;
  g_cap_table.hipKernelNameRef_fn = capture_hipKernelNameRef;
  g_cap_table.hipKernelNameRefByPtr_fn = capture_hipKernelNameRefByPtr;
  g_cap_table.hipLaunchByPtr_fn = capture_hipLaunchByPtr;
  g_cap_table.hipLaunchCooperativeKernel_fn = capture_hipLaunchCooperativeKernel;
  g_cap_table.hipLaunchCooperativeKernelMultiDevice_fn = capture_hipLaunchCooperativeKernelMultiDevice;
  g_cap_table.hipLaunchHostFunc_fn = capture_hipLaunchHostFunc;
  g_cap_table.hipLaunchKernel_fn = capture_hipLaunchKernel;
  g_cap_table.hipMalloc_fn = capture_hipMalloc;
  g_cap_table.hipMalloc3D_fn = capture_hipMalloc3D;
  g_cap_table.hipMalloc3DArray_fn = capture_hipMalloc3DArray;
  g_cap_table.hipMallocArray_fn = capture_hipMallocArray;
  g_cap_table.hipMallocAsync_fn = capture_hipMallocAsync;
  g_cap_table.hipMallocFromPoolAsync_fn = capture_hipMallocFromPoolAsync;
  g_cap_table.hipMallocHost_fn = capture_hipMallocHost;
  g_cap_table.hipMallocManaged_fn = capture_hipMallocManaged;
  g_cap_table.hipMallocMipmappedArray_fn = capture_hipMallocMipmappedArray;
  g_cap_table.hipMallocPitch_fn = capture_hipMallocPitch;
  g_cap_table.hipMemAddressFree_fn = capture_hipMemAddressFree;
  g_cap_table.hipMemAddressReserve_fn = capture_hipMemAddressReserve;
  g_cap_table.hipMemAdvise_fn = capture_hipMemAdvise;
  g_cap_table.hipMemAdvise_v2_fn = capture_hipMemAdvise_v2;
  g_cap_table.hipMemAllocHost_fn = capture_hipMemAllocHost;
  g_cap_table.hipMemAllocPitch_fn = capture_hipMemAllocPitch;
  g_cap_table.hipMemCreate_fn = capture_hipMemCreate;
  g_cap_table.hipMemExportToShareableHandle_fn = capture_hipMemExportToShareableHandle;
  g_cap_table.hipMemGetAccess_fn = capture_hipMemGetAccess;
  g_cap_table.hipMemGetAddressRange_fn = capture_hipMemGetAddressRange;
  g_cap_table.hipMemGetAllocationGranularity_fn = capture_hipMemGetAllocationGranularity;
  g_cap_table.hipMemGetAllocationPropertiesFromHandle_fn = capture_hipMemGetAllocationPropertiesFromHandle;
  g_cap_table.hipMemGetInfo_fn = capture_hipMemGetInfo;
  g_cap_table.hipMemImportFromShareableHandle_fn = capture_hipMemImportFromShareableHandle;
  g_cap_table.hipMemMap_fn = capture_hipMemMap;
  g_cap_table.hipMemMapArrayAsync_fn = capture_hipMemMapArrayAsync;
  g_cap_table.hipMemPoolCreate_fn = capture_hipMemPoolCreate;
  g_cap_table.hipMemPoolDestroy_fn = capture_hipMemPoolDestroy;
  g_cap_table.hipMemPoolExportPointer_fn = capture_hipMemPoolExportPointer;
  g_cap_table.hipMemPoolExportToShareableHandle_fn = capture_hipMemPoolExportToShareableHandle;
  g_cap_table.hipMemPoolGetAccess_fn = capture_hipMemPoolGetAccess;
  g_cap_table.hipMemPoolGetAttribute_fn = capture_hipMemPoolGetAttribute;
  g_cap_table.hipMemPoolImportFromShareableHandle_fn = capture_hipMemPoolImportFromShareableHandle;
  g_cap_table.hipMemPoolImportPointer_fn = capture_hipMemPoolImportPointer;
  g_cap_table.hipMemPoolSetAccess_fn = capture_hipMemPoolSetAccess;
  g_cap_table.hipMemPoolSetAttribute_fn = capture_hipMemPoolSetAttribute;
  g_cap_table.hipMemPoolTrimTo_fn = capture_hipMemPoolTrimTo;
  g_cap_table.hipMemPrefetchAsync_fn = capture_hipMemPrefetchAsync;
  g_cap_table.hipMemPrefetchAsync_v2_fn = capture_hipMemPrefetchAsync_v2;
  g_cap_table.hipMemPrefetchBatchAsync_fn = capture_hipMemPrefetchBatchAsync;
  g_cap_table.hipMemDiscardBatchAsync_fn = capture_hipMemDiscardBatchAsync;
  g_cap_table.hipDrvMemDiscardBatchAsync_fn = capture_hipDrvMemDiscardBatchAsync;
  g_cap_table.hipMemDiscardAndPrefetchBatchAsync_fn = capture_hipMemDiscardAndPrefetchBatchAsync;
  g_cap_table.hipDrvMemDiscardAndPrefetchBatchAsync_fn = capture_hipDrvMemDiscardAndPrefetchBatchAsync;
  g_cap_table.hipMemPtrGetInfo_fn = capture_hipMemPtrGetInfo;
  g_cap_table.hipMemRangeGetAttribute_fn = capture_hipMemRangeGetAttribute;
  g_cap_table.hipMemRangeGetAttributes_fn = capture_hipMemRangeGetAttributes;
  g_cap_table.hipMemRelease_fn = capture_hipMemRelease;
  g_cap_table.hipMemRetainAllocationHandle_fn = capture_hipMemRetainAllocationHandle;
  g_cap_table.hipMemSetAccess_fn = capture_hipMemSetAccess;
  g_cap_table.hipMemUnmap_fn = capture_hipMemUnmap;
  g_cap_table.hipMemcpy_fn = capture_hipMemcpy;
  g_cap_table.hipMemcpy2D_fn = capture_hipMemcpy2D;
  g_cap_table.hipMemcpy2DAsync_fn = capture_hipMemcpy2DAsync;
  g_cap_table.hipMemcpy2DFromArray_fn = capture_hipMemcpy2DFromArray;
  g_cap_table.hipMemcpy2DFromArrayAsync_fn = capture_hipMemcpy2DFromArrayAsync;
  g_cap_table.hipMemcpy2DToArray_fn = capture_hipMemcpy2DToArray;
  g_cap_table.hipMemcpy2DToArrayAsync_fn = capture_hipMemcpy2DToArrayAsync;
  g_cap_table.hipMemcpy3D_fn = capture_hipMemcpy3D;
  g_cap_table.hipMemcpy3DAsync_fn = capture_hipMemcpy3DAsync;
  g_cap_table.hipMemcpyAsync_fn = capture_hipMemcpyAsync;
  g_cap_table.hipMemcpyAtoH_fn = capture_hipMemcpyAtoH;
  g_cap_table.hipMemcpyDtoD_fn = capture_hipMemcpyDtoD;
  g_cap_table.hipMemcpyDtoDAsync_fn = capture_hipMemcpyDtoDAsync;
  g_cap_table.hipMemcpyDtoH_fn = capture_hipMemcpyDtoH;
  g_cap_table.hipMemcpyDtoHAsync_fn = capture_hipMemcpyDtoHAsync;
  g_cap_table.hipMemcpyFromArray_fn = capture_hipMemcpyFromArray;
  g_cap_table.hipMemcpyFromSymbol_fn = capture_hipMemcpyFromSymbol;
  g_cap_table.hipMemcpyFromSymbolAsync_fn = capture_hipMemcpyFromSymbolAsync;
  g_cap_table.hipMemcpyHtoA_fn = capture_hipMemcpyHtoA;
  g_cap_table.hipMemcpyHtoD_fn = capture_hipMemcpyHtoD;
  g_cap_table.hipMemcpyHtoDAsync_fn = capture_hipMemcpyHtoDAsync;
  g_cap_table.hipMemcpyParam2D_fn = capture_hipMemcpyParam2D;
  g_cap_table.hipMemcpyParam2DAsync_fn = capture_hipMemcpyParam2DAsync;
  g_cap_table.hipMemcpyPeer_fn = capture_hipMemcpyPeer;
  g_cap_table.hipMemcpyPeerAsync_fn = capture_hipMemcpyPeerAsync;
  g_cap_table.hipMemcpyToArray_fn = capture_hipMemcpyToArray;
  g_cap_table.hipMemcpyToSymbol_fn = capture_hipMemcpyToSymbol;
  g_cap_table.hipMemcpyToSymbolAsync_fn = capture_hipMemcpyToSymbolAsync;
  g_cap_table.hipMemcpyWithStream_fn = capture_hipMemcpyWithStream;
  g_cap_table.hipMemset_fn = capture_hipMemset;
  g_cap_table.hipMemset2D_fn = capture_hipMemset2D;
  g_cap_table.hipMemset2DAsync_fn = capture_hipMemset2DAsync;
  g_cap_table.hipMemset3D_fn = capture_hipMemset3D;
  g_cap_table.hipMemset3DAsync_fn = capture_hipMemset3DAsync;
  g_cap_table.hipMemsetAsync_fn = capture_hipMemsetAsync;
  g_cap_table.hipMemsetD16_fn = capture_hipMemsetD16;
  g_cap_table.hipMemsetD16Async_fn = capture_hipMemsetD16Async;
  g_cap_table.hipMemsetD32_fn = capture_hipMemsetD32;
  g_cap_table.hipMemsetD32Async_fn = capture_hipMemsetD32Async;
  g_cap_table.hipMemsetD8_fn = capture_hipMemsetD8;
  g_cap_table.hipMemsetD8Async_fn = capture_hipMemsetD8Async;
  g_cap_table.hipMipmappedArrayCreate_fn = capture_hipMipmappedArrayCreate;
  g_cap_table.hipMipmappedArrayDestroy_fn = capture_hipMipmappedArrayDestroy;
  g_cap_table.hipMipmappedArrayGetLevel_fn = capture_hipMipmappedArrayGetLevel;
  g_cap_table.hipModuleGetFunction_fn = capture_hipModuleGetFunction;
  g_cap_table.hipModuleGetFunctionCount_fn = capture_hipModuleGetFunctionCount;
  g_cap_table.hipModuleGetGlobal_fn = capture_hipModuleGetGlobal;
  g_cap_table.hipModuleGetTexRef_fn = capture_hipModuleGetTexRef;
  g_cap_table.hipModuleLaunchCooperativeKernel_fn = capture_hipModuleLaunchCooperativeKernel;
  g_cap_table.hipModuleLaunchCooperativeKernelMultiDevice_fn = capture_hipModuleLaunchCooperativeKernelMultiDevice;
  g_cap_table.hipModuleLaunchKernel_fn = capture_hipModuleLaunchKernel;
  g_cap_table.hipModuleLoad_fn = capture_hipModuleLoad;
  g_cap_table.hipModuleLoadData_fn = capture_hipModuleLoadData;
  g_cap_table.hipModuleLoadDataEx_fn = capture_hipModuleLoadDataEx;
  g_cap_table.hipLinkAddData_fn = capture_hipLinkAddData;
  g_cap_table.hipLinkAddFile_fn = capture_hipLinkAddFile;
  g_cap_table.hipLinkComplete_fn = capture_hipLinkComplete;
  g_cap_table.hipLinkCreate_fn = capture_hipLinkCreate;
  g_cap_table.hipLinkDestroy_fn = capture_hipLinkDestroy;
  g_cap_table.hipModuleOccupancyMaxActiveBlocksPerMultiprocessor_fn = capture_hipModuleOccupancyMaxActiveBlocksPerMultiprocessor;
  g_cap_table.hipModuleOccupancyMaxActiveBlocksPerMultiprocessorWithFlags_fn = capture_hipModuleOccupancyMaxActiveBlocksPerMultiprocessorWithFlags;
  g_cap_table.hipModuleOccupancyMaxPotentialBlockSize_fn = capture_hipModuleOccupancyMaxPotentialBlockSize;
  g_cap_table.hipModuleOccupancyMaxPotentialBlockSizeWithFlags_fn = capture_hipModuleOccupancyMaxPotentialBlockSizeWithFlags;
  g_cap_table.hipModuleUnload_fn = capture_hipModuleUnload;
  g_cap_table.hipOccupancyAvailableDynamicSMemPerBlock_fn = capture_hipOccupancyAvailableDynamicSMemPerBlock;
  g_cap_table.hipOccupancyMaxActiveBlocksPerMultiprocessor_fn = capture_hipOccupancyMaxActiveBlocksPerMultiprocessor;
  g_cap_table.hipOccupancyMaxActiveBlocksPerMultiprocessorWithFlags_fn = capture_hipOccupancyMaxActiveBlocksPerMultiprocessorWithFlags;
  g_cap_table.hipOccupancyMaxPotentialBlockSize_fn = capture_hipOccupancyMaxPotentialBlockSize;
  g_cap_table.hipOccupancyMaxActiveClusters_fn = capture_hipOccupancyMaxActiveClusters;
  g_cap_table.hipOccupancyMaxPotentialClusterSize_fn = capture_hipOccupancyMaxPotentialClusterSize;
  g_cap_table.hipPeekAtLastError_fn = capture_hipPeekAtLastError;
  g_cap_table.hipPointerGetAttribute_fn = capture_hipPointerGetAttribute;
  g_cap_table.hipPointerGetAttributes_fn = capture_hipPointerGetAttributes;
  g_cap_table.hipPointerSetAttribute_fn = capture_hipPointerSetAttribute;
  g_cap_table.hipProfilerStart_fn = capture_hipProfilerStart;
  g_cap_table.hipProfilerStop_fn = capture_hipProfilerStop;
  g_cap_table.hipRuntimeGetVersion_fn = capture_hipRuntimeGetVersion;
  g_cap_table.hipSetDevice_fn = capture_hipSetDevice;
  g_cap_table.hipSetDeviceFlags_fn = capture_hipSetDeviceFlags;
  g_cap_table.hipSetupArgument_fn = capture_hipSetupArgument;
  g_cap_table.hipSignalExternalSemaphoresAsync_fn = capture_hipSignalExternalSemaphoresAsync;
  g_cap_table.hipStreamAddCallback_fn = capture_hipStreamAddCallback;
  g_cap_table.hipStreamAttachMemAsync_fn = capture_hipStreamAttachMemAsync;
  g_cap_table.hipStreamBeginCapture_fn = capture_hipStreamBeginCapture;
  g_cap_table.hipStreamCopyAttributes_fn = capture_hipStreamCopyAttributes;
  g_cap_table.hipStreamCreate_fn = capture_hipStreamCreate;
  g_cap_table.hipStreamCreateWithFlags_fn = capture_hipStreamCreateWithFlags;
  g_cap_table.hipStreamCreateWithPriority_fn = capture_hipStreamCreateWithPriority;
  g_cap_table.hipStreamDestroy_fn = capture_hipStreamDestroy;
  g_cap_table.hipStreamEndCapture_fn = capture_hipStreamEndCapture;
  g_cap_table.hipStreamGetCaptureInfo_fn = capture_hipStreamGetCaptureInfo;
  g_cap_table.hipStreamGetCaptureInfo_v2_fn = capture_hipStreamGetCaptureInfo_v2;
  g_cap_table.hipStreamGetDevice_fn = capture_hipStreamGetDevice;
  g_cap_table.hipStreamGetFlags_fn = capture_hipStreamGetFlags;
  g_cap_table.hipStreamGetId_fn = capture_hipStreamGetId;
  g_cap_table.hipStreamGetPriority_fn = capture_hipStreamGetPriority;
  g_cap_table.hipStreamIsCapturing_fn = capture_hipStreamIsCapturing;
  g_cap_table.hipStreamQuery_fn = capture_hipStreamQuery;
  g_cap_table.hipStreamSynchronize_fn = capture_hipStreamSynchronize;
  g_cap_table.hipStreamUpdateCaptureDependencies_fn = capture_hipStreamUpdateCaptureDependencies;
  g_cap_table.hipStreamWaitEvent_fn = capture_hipStreamWaitEvent;
  g_cap_table.hipStreamWaitValue32_fn = capture_hipStreamWaitValue32;
  g_cap_table.hipStreamWaitValue64_fn = capture_hipStreamWaitValue64;
  g_cap_table.hipStreamWriteValue32_fn = capture_hipStreamWriteValue32;
  g_cap_table.hipStreamWriteValue64_fn = capture_hipStreamWriteValue64;
  g_cap_table.hipStreamBatchMemOp_fn = capture_hipStreamBatchMemOp;
  g_cap_table.hipTexObjectCreate_fn = capture_hipTexObjectCreate;
  g_cap_table.hipTexObjectDestroy_fn = capture_hipTexObjectDestroy;
  g_cap_table.hipTexObjectGetResourceDesc_fn = capture_hipTexObjectGetResourceDesc;
  g_cap_table.hipTexObjectGetResourceViewDesc_fn = capture_hipTexObjectGetResourceViewDesc;
  g_cap_table.hipTexObjectGetTextureDesc_fn = capture_hipTexObjectGetTextureDesc;
  g_cap_table.hipTexRefGetAddress_fn = capture_hipTexRefGetAddress;
  g_cap_table.hipTexRefGetAddressMode_fn = capture_hipTexRefGetAddressMode;
  g_cap_table.hipTexRefGetFilterMode_fn = capture_hipTexRefGetFilterMode;
  g_cap_table.hipTexRefGetFlags_fn = capture_hipTexRefGetFlags;
  g_cap_table.hipTexRefGetFormat_fn = capture_hipTexRefGetFormat;
  g_cap_table.hipTexRefGetMaxAnisotropy_fn = capture_hipTexRefGetMaxAnisotropy;
  g_cap_table.hipTexRefGetMipMappedArray_fn = capture_hipTexRefGetMipMappedArray;
  g_cap_table.hipTexRefGetMipmapFilterMode_fn = capture_hipTexRefGetMipmapFilterMode;
  g_cap_table.hipTexRefGetMipmapLevelBias_fn = capture_hipTexRefGetMipmapLevelBias;
  g_cap_table.hipTexRefGetMipmapLevelClamp_fn = capture_hipTexRefGetMipmapLevelClamp;
  g_cap_table.hipTexRefSetAddress_fn = capture_hipTexRefSetAddress;
  g_cap_table.hipTexRefSetAddress2D_fn = capture_hipTexRefSetAddress2D;
  g_cap_table.hipTexRefSetAddressMode_fn = capture_hipTexRefSetAddressMode;
  g_cap_table.hipTexRefSetArray_fn = capture_hipTexRefSetArray;
  g_cap_table.hipTexRefSetBorderColor_fn = capture_hipTexRefSetBorderColor;
  g_cap_table.hipTexRefSetFilterMode_fn = capture_hipTexRefSetFilterMode;
  g_cap_table.hipTexRefSetFlags_fn = capture_hipTexRefSetFlags;
  g_cap_table.hipTexRefSetFormat_fn = capture_hipTexRefSetFormat;
  g_cap_table.hipTexRefSetMaxAnisotropy_fn = capture_hipTexRefSetMaxAnisotropy;
  g_cap_table.hipTexRefSetMipmapFilterMode_fn = capture_hipTexRefSetMipmapFilterMode;
  g_cap_table.hipTexRefSetMipmapLevelBias_fn = capture_hipTexRefSetMipmapLevelBias;
  g_cap_table.hipTexRefSetMipmapLevelClamp_fn = capture_hipTexRefSetMipmapLevelClamp;
  g_cap_table.hipTexRefSetMipmappedArray_fn = capture_hipTexRefSetMipmappedArray;
  g_cap_table.hipThreadExchangeStreamCaptureMode_fn = capture_hipThreadExchangeStreamCaptureMode;
  g_cap_table.hipUnbindTexture_fn = capture_hipUnbindTexture;
  g_cap_table.hipUserObjectCreate_fn = capture_hipUserObjectCreate;
  g_cap_table.hipUserObjectRelease_fn = capture_hipUserObjectRelease;
  g_cap_table.hipUserObjectRetain_fn = capture_hipUserObjectRetain;
  g_cap_table.hipWaitExternalSemaphoresAsync_fn = capture_hipWaitExternalSemaphoresAsync;
  g_cap_table.hipMemcpy_spt_fn = capture_hipMemcpy_spt;
  g_cap_table.hipMemcpyToSymbol_spt_fn = capture_hipMemcpyToSymbol_spt;
  g_cap_table.hipMemcpyFromSymbol_spt_fn = capture_hipMemcpyFromSymbol_spt;
  g_cap_table.hipMemcpy2D_spt_fn = capture_hipMemcpy2D_spt;
  g_cap_table.hipMemcpy2DFromArray_spt_fn = capture_hipMemcpy2DFromArray_spt;
  g_cap_table.hipMemcpy3D_spt_fn = capture_hipMemcpy3D_spt;
  g_cap_table.hipMemset_spt_fn = capture_hipMemset_spt;
  g_cap_table.hipMemsetAsync_spt_fn = capture_hipMemsetAsync_spt;
  g_cap_table.hipMemset2D_spt_fn = capture_hipMemset2D_spt;
  g_cap_table.hipMemset2DAsync_spt_fn = capture_hipMemset2DAsync_spt;
  g_cap_table.hipMemset3DAsync_spt_fn = capture_hipMemset3DAsync_spt;
  g_cap_table.hipMemset3D_spt_fn = capture_hipMemset3D_spt;
  g_cap_table.hipMemcpyAsync_spt_fn = capture_hipMemcpyAsync_spt;
  g_cap_table.hipMemcpy3DAsync_spt_fn = capture_hipMemcpy3DAsync_spt;
  g_cap_table.hipMemcpy2DAsync_spt_fn = capture_hipMemcpy2DAsync_spt;
  g_cap_table.hipMemcpyFromSymbolAsync_spt_fn = capture_hipMemcpyFromSymbolAsync_spt;
  g_cap_table.hipMemcpyToSymbolAsync_spt_fn = capture_hipMemcpyToSymbolAsync_spt;
  g_cap_table.hipMemcpyFromArray_spt_fn = capture_hipMemcpyFromArray_spt;
  g_cap_table.hipMemcpy2DToArray_spt_fn = capture_hipMemcpy2DToArray_spt;
  g_cap_table.hipMemcpy2DFromArrayAsync_spt_fn = capture_hipMemcpy2DFromArrayAsync_spt;
  g_cap_table.hipMemcpy2DToArrayAsync_spt_fn = capture_hipMemcpy2DToArrayAsync_spt;
  g_cap_table.hipStreamQuery_spt_fn = capture_hipStreamQuery_spt;
  g_cap_table.hipStreamSynchronize_spt_fn = capture_hipStreamSynchronize_spt;
  g_cap_table.hipStreamGetPriority_spt_fn = capture_hipStreamGetPriority_spt;
  g_cap_table.hipStreamWaitEvent_spt_fn = capture_hipStreamWaitEvent_spt;
  g_cap_table.hipStreamGetFlags_spt_fn = capture_hipStreamGetFlags_spt;
  g_cap_table.hipStreamAddCallback_spt_fn = capture_hipStreamAddCallback_spt;
  g_cap_table.hipEventRecord_spt_fn = capture_hipEventRecord_spt;
  g_cap_table.hipLaunchCooperativeKernel_spt_fn = capture_hipLaunchCooperativeKernel_spt;
  g_cap_table.hipLaunchKernel_spt_fn = capture_hipLaunchKernel_spt;
  g_cap_table.hipGraphLaunch_spt_fn = capture_hipGraphLaunch_spt;
  g_cap_table.hipStreamBeginCapture_spt_fn = capture_hipStreamBeginCapture_spt;
  g_cap_table.hipStreamEndCapture_spt_fn = capture_hipStreamEndCapture_spt;
  g_cap_table.hipStreamIsCapturing_spt_fn = capture_hipStreamIsCapturing_spt;
  g_cap_table.hipStreamGetCaptureInfo_spt_fn = capture_hipStreamGetCaptureInfo_spt;
  g_cap_table.hipStreamGetCaptureInfo_v2_spt_fn = capture_hipStreamGetCaptureInfo_v2_spt;
  g_cap_table.hipLaunchHostFunc_spt_fn = capture_hipLaunchHostFunc_spt;
  g_cap_table.hipCreateChannelDesc_fn = capture_hipCreateChannelDesc;
  g_cap_table.hipExtModuleLaunchKernel_fn = capture_hipExtModuleLaunchKernel;
  g_cap_table.hipHccModuleLaunchKernel_fn = capture_hipHccModuleLaunchKernel;
  g_cap_table.hipGetStreamDeviceId_fn = capture_hipGetStreamDeviceId;
  g_cap_table.hipDrvGraphAddMemsetNode_fn = capture_hipDrvGraphAddMemsetNode;
  g_cap_table.hipGraphAddExternalSemaphoresWaitNode_fn = capture_hipGraphAddExternalSemaphoresWaitNode;
  g_cap_table.hipGraphAddExternalSemaphoresSignalNode_fn = capture_hipGraphAddExternalSemaphoresSignalNode;
  g_cap_table.hipGraphExternalSemaphoresSignalNodeSetParams_fn = capture_hipGraphExternalSemaphoresSignalNodeSetParams;
  g_cap_table.hipGraphExternalSemaphoresWaitNodeSetParams_fn = capture_hipGraphExternalSemaphoresWaitNodeSetParams;
  g_cap_table.hipGraphExternalSemaphoresSignalNodeGetParams_fn = capture_hipGraphExternalSemaphoresSignalNodeGetParams;
  g_cap_table.hipGraphExternalSemaphoresWaitNodeGetParams_fn = capture_hipGraphExternalSemaphoresWaitNodeGetParams;
  g_cap_table.hipGraphExecExternalSemaphoresSignalNodeSetParams_fn = capture_hipGraphExecExternalSemaphoresSignalNodeSetParams;
  g_cap_table.hipGraphExecExternalSemaphoresWaitNodeSetParams_fn = capture_hipGraphExecExternalSemaphoresWaitNodeSetParams;
  g_cap_table.hipGraphAddNode_fn = capture_hipGraphAddNode;
  g_cap_table.hipGraphInstantiateWithParams_fn = capture_hipGraphInstantiateWithParams;
  g_cap_table.hipExtGetLastError_fn = capture_hipExtGetLastError;
  g_cap_table.hipTexRefGetBorderColor_fn = capture_hipTexRefGetBorderColor;
  g_cap_table.hipTexRefGetArray_fn = capture_hipTexRefGetArray;
  g_cap_table.hipGetProcAddress_fn = capture_hipGetProcAddress;
  g_cap_table.hipStreamBeginCaptureToGraph_fn = capture_hipStreamBeginCaptureToGraph;
  g_cap_table.hipGetFuncBySymbol_fn = capture_hipGetFuncBySymbol;
  g_cap_table.hipDrvGraphAddMemFreeNode_fn = capture_hipDrvGraphAddMemFreeNode;
  g_cap_table.hipDrvGraphExecMemcpyNodeSetParams_fn = capture_hipDrvGraphExecMemcpyNodeSetParams;
  g_cap_table.hipDrvGraphExecMemsetNodeSetParams_fn = capture_hipDrvGraphExecMemsetNodeSetParams;
  g_cap_table.hipSetValidDevices_fn = capture_hipSetValidDevices;
  g_cap_table.hipMemcpyAtoD_fn = capture_hipMemcpyAtoD;
  g_cap_table.hipMemcpyDtoA_fn = capture_hipMemcpyDtoA;
  g_cap_table.hipMemcpyAtoA_fn = capture_hipMemcpyAtoA;
  g_cap_table.hipMemcpyAtoHAsync_fn = capture_hipMemcpyAtoHAsync;
  g_cap_table.hipMemcpyHtoAAsync_fn = capture_hipMemcpyHtoAAsync;
  g_cap_table.hipMemcpy2DArrayToArray_fn = capture_hipMemcpy2DArrayToArray;
  g_cap_table.hipGraphExecGetFlags_fn = capture_hipGraphExecGetFlags;
  g_cap_table.hipGraphNodeSetParams_fn = capture_hipGraphNodeSetParams;
  g_cap_table.hipGraphExecNodeSetParams_fn = capture_hipGraphExecNodeSetParams;
  g_cap_table.hipExternalMemoryGetMappedMipmappedArray_fn = capture_hipExternalMemoryGetMappedMipmappedArray;
  g_cap_table.hipDrvGraphMemcpyNodeGetParams_fn = capture_hipDrvGraphMemcpyNodeGetParams;
  g_cap_table.hipDrvGraphMemcpyNodeSetParams_fn = capture_hipDrvGraphMemcpyNodeSetParams;
  g_cap_table.hipExtHostAlloc_fn = capture_hipExtHostAlloc;
  g_cap_table.hipDeviceGetTexture1DLinearMaxWidth_fn = capture_hipDeviceGetTexture1DLinearMaxWidth;
  g_cap_table.hipGraphAddBatchMemOpNode_fn = capture_hipGraphAddBatchMemOpNode;
  g_cap_table.hipGraphBatchMemOpNodeGetParams_fn = capture_hipGraphBatchMemOpNodeGetParams;
  g_cap_table.hipGraphBatchMemOpNodeSetParams_fn = capture_hipGraphBatchMemOpNodeSetParams;
  g_cap_table.hipGraphExecBatchMemOpNodeSetParams_fn = capture_hipGraphExecBatchMemOpNodeSetParams;
  g_cap_table.hipEventRecordWithFlags_fn = capture_hipEventRecordWithFlags;
  g_cap_table.hipLaunchKernelExC_fn = capture_hipLaunchKernelExC;
  g_cap_table.hipDrvLaunchKernelEx_fn = capture_hipDrvLaunchKernelEx;
  g_cap_table.hipMemGetHandleForAddressRange_fn = capture_hipMemGetHandleForAddressRange;
  g_cap_table.hipMemsetD2D8_fn = capture_hipMemsetD2D8;
  g_cap_table.hipMemsetD2D8Async_fn = capture_hipMemsetD2D8Async;
  g_cap_table.hipMemsetD2D16_fn = capture_hipMemsetD2D16;
  g_cap_table.hipMemsetD2D16Async_fn = capture_hipMemsetD2D16Async;
  g_cap_table.hipMemsetD2D32_fn = capture_hipMemsetD2D32;
  g_cap_table.hipMemsetD2D32Async_fn = capture_hipMemsetD2D32Async;
  g_cap_table.hipStreamSetAttribute_fn = capture_hipStreamSetAttribute;
  g_cap_table.hipStreamGetAttribute_fn = capture_hipStreamGetAttribute;
  g_cap_table.hipModuleLoadFatBinary_fn = capture_hipModuleLoadFatBinary;
  g_cap_table.hipMemcpyBatchAsync_fn = capture_hipMemcpyBatchAsync;
  g_cap_table.hipMemcpy3DBatchAsync_fn = capture_hipMemcpy3DBatchAsync;
  g_cap_table.hipMemcpy3DPeer_fn = capture_hipMemcpy3DPeer;
  g_cap_table.hipMemcpy3DPeerAsync_fn = capture_hipMemcpy3DPeerAsync;
  g_cap_table.hipGetDriverEntryPoint_fn = capture_hipGetDriverEntryPoint;
  g_cap_table.hipGetDriverEntryPoint_spt_fn = capture_hipGetDriverEntryPoint_spt;
  g_cap_table.hipLibraryLoadData_fn = capture_hipLibraryLoadData;
  g_cap_table.hipLibraryLoadFromFile_fn = capture_hipLibraryLoadFromFile;
  g_cap_table.hipLibraryUnload_fn = capture_hipLibraryUnload;
  g_cap_table.hipLibraryGetKernel_fn = capture_hipLibraryGetKernel;
  g_cap_table.hipLibraryGetKernelCount_fn = capture_hipLibraryGetKernelCount;
  g_cap_table.hipLibraryGetGlobal_fn = capture_hipLibraryGetGlobal;
  g_cap_table.hipLibraryGetManaged_fn = capture_hipLibraryGetManaged;
  g_cap_table.hipLibraryEnumerateKernels_fn = capture_hipLibraryEnumerateKernels;
  g_cap_table.hipKernelGetLibrary_fn = capture_hipKernelGetLibrary;
  g_cap_table.hipKernelGetName_fn = capture_hipKernelGetName;
  g_cap_table.hipGetProcAddress_spt_fn = capture_hipGetProcAddress_spt;
  g_cap_table.hipExtDisableLogging_fn = capture_hipExtDisableLogging;
  g_cap_table.hipExtEnableLogging_fn = capture_hipExtEnableLogging;
  g_cap_table.hipExtSetLoggingParams_fn = capture_hipExtSetLoggingParams;
  g_cap_table.hipKernelGetAttribute_fn = capture_hipKernelGetAttribute;
  g_cap_table.hipKernelSetAttribute_fn = capture_hipKernelSetAttribute;
  g_cap_table.hipKernelGetFunction_fn = capture_hipKernelGetFunction;
  g_cap_table.hipKernelGetParamInfo_fn = capture_hipKernelGetParamInfo;
  g_cap_table.hipMemSetMemPool_fn = capture_hipMemSetMemPool;
  g_cap_table.hipMemGetMemPool_fn = capture_hipMemGetMemPool;
  g_cap_table.hipMipmappedArrayGetMemoryRequirements_fn = capture_hipMipmappedArrayGetMemoryRequirements;
  g_cap_table.hipGreenCtxCreate_fn = capture_hipGreenCtxCreate;
  g_cap_table.hipExecutionCtxDestroy_fn = capture_hipExecutionCtxDestroy;
  g_cap_table.hipExecutionCtxStreamCreate_fn = capture_hipExecutionCtxStreamCreate;
  g_cap_table.hipDeviceGetDevResource_fn = capture_hipDeviceGetDevResource;
  g_cap_table.hipDevSmResourceSplitByCount_fn = capture_hipDevSmResourceSplitByCount;
  g_cap_table.hipDevSmResourceSplit_fn = capture_hipDevSmResourceSplit;
  g_cap_table.hipDevResourceGenerateDesc_fn = capture_hipDevResourceGenerateDesc;
  g_cap_table.hipDeviceGetExecutionCtx_fn = capture_hipDeviceGetExecutionCtx;
  g_cap_table.hipExecutionCtxGetDevResource_fn = capture_hipExecutionCtxGetDevResource;
  g_cap_table.hipExecutionCtxGetDevice_fn = capture_hipExecutionCtxGetDevice;
  g_cap_table.hipExecutionCtxGetId_fn = capture_hipExecutionCtxGetId;
  g_cap_table.hipStreamGetDevResource_fn = capture_hipStreamGetDevResource;
  g_cap_table.hipExecutionCtxRecordEvent_fn = capture_hipExecutionCtxRecordEvent;
  g_cap_table.hipExecutionCtxSynchronize_fn = capture_hipExecutionCtxSynchronize;
  g_cap_table.hipExecutionCtxWaitEvent_fn = capture_hipExecutionCtxWaitEvent;
}

void hip_capture_build_compiler_table() {
  // Guard: a second call after shims are installed would snapshot shim ptrs
  // into g_real_compiler_table — __hipRegister* calls from the compiler
  // would then recurse back through themselves.
  if (g_compiler_installed.exchange(true)) return;
  g_real_compiler_table = *hip::GetHipCompilerDispatchTable();
  HipCompilerDispatchTable cap = g_real_compiler_table;
  cap.__hipPopCallConfiguration_fn = capture___hipPopCallConfiguration;
  cap.__hipPushCallConfiguration_fn = capture___hipPushCallConfiguration;
  cap.__hipRegisterFatBinary_fn = capture___hipRegisterFatBinary;
  cap.__hipRegisterFunction_fn = capture___hipRegisterFunction;
  cap.__hipRegisterManagedVar_fn = capture___hipRegisterManagedVar;
  cap.__hipRegisterSurface_fn = capture___hipRegisterSurface;
  cap.__hipRegisterTexture_fn = capture___hipRegisterTexture;
  cap.__hipRegisterVar_fn = capture___hipRegisterVar;
  cap.__hipUnregisterFatBinary_fn = capture___hipUnregisterFatBinary;
  std::memcpy(const_cast<HipCompilerDispatchTable*>(hip::GetHipCompilerDispatchTable()),
              &cap, sizeof(HipCompilerDispatchTable));
}
