#include <iostream>
#include <cuda_runtime.h>
#include <cufft.h>
#include <cuComplex.h>

#define BLOCK_SIZE 256
#define SIGNAL_SIZE 64

__constant__ float h_wavelet[SIGNAL_SIZE];

__global__ void waveletTransform(float *d_input, float *d_output, int numSignals) {
    extern __shared__ float sharedData[];
    int tid = threadIdx.x;
    int bid = blockIdx.x;
    int idx = bid * blockDim.x + tid;

    if (idx >= numSignals * SIGNAL_SIZE) return;

    int signalId = idx / SIGNAL_SIZE;
    int signalOffset = idx % SIGNAL_SIZE;

    // Load data into shared memory
    sharedData[tid] = d_input[idx];
    __syncthreads();

    float result = 0.0f;
    for (int j = 0; j < SIGNAL_SIZE; j++) {
        result += sharedData[j] * h_wavelet[(signalOffset + j) % SIGNAL_SIZE];
    }

    d_output[idx] = result;
}

void checkCudaError(cudaError_t err, const char *file, int line) {
    if (err != cudaSuccess) {
        std::cerr << "CUDA error at " << file << ":" << line << " - " << cudaGetErrorString(err) << std::endl;
        exit(EXIT_FAILURE);
    }
}

int main() {
    int numGPUs;
    cudaGetDeviceCount(&numGPUs);
    if (numGPUs < 2) {
        std::cerr << "This program requires at least 2 GPUs." << std::endl;
        return EXIT_FAILURE;
    }

    int numSignals = 1024; // Example number of signals
    size_t totalSize = numSignals * SIGNAL_SIZE * sizeof(float);

    float *h_input = new float[numSignals * SIGNAL_SIZE];
    float *h_output = new float[numSignals * SIGNAL_SIZE];
    float h_wavelet_host[SIGNAL_SIZE];

    // Initialize wavelet coefficients (example)
    for (int i = 0; i < SIGNAL_SIZE; i++) {
        h_wavelet_host[i] = 1.0f / SIGNAL_SIZE; // Simple averaging for demonstration
    }

    // Initialize input data (example)
    for (int i = 0; i < numSignals * SIGNAL_SIZE; i++) {
        h_input[i] = static_cast<float>(i % 10);
    }

    // Allocate device memory and copy data to device
    float *d_input[numGPUs], *d_output[numGPUs];
    for (int gpu = 0; gpu < numGPUs; gpu++) {
        cudaSetDevice(gpu);
        checkCudaError(cudaMalloc(&d_input[gpu], totalSize / numGPUs), __FILE__, __LINE__);
        checkCudaError(cudaMalloc(&d_output[gpu], totalSize / numGPUs), __FILE__, __LINE__);
        checkCudaError(cudaMemcpy(d_input[gpu], h_input + (gpu * numSignals * SIGNAL_SIZE / numGPUs), totalSize / numGPUs, cudaMemcpyHostToDevice), __FILE__, __LINE__);
        checkCudaError(cudaMemcpyToSymbol(h_wavelet, h_wavelet_host, sizeof(h_wavelet_host)), __FILE__, __LINE__);
    }

    // Launch kernel on each GPU
    for (int gpu = 0; gpu < numGPUs; gpu++) {
        cudaSetDevice(gpu);
        waveletTransform<<<(numSignals / numGPUs + BLOCK_SIZE - 1) / BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE * sizeof(float)>>>(d_input[gpu], d_output[gpu], numSignals / numGPUs);
        checkCudaError(cudaGetLastError(), __FILE__, __LINE__);
    }

    // Copy results back to host
    for (int gpu = 0; gpu < numGPUs; gpu++) {
        cudaSetDevice(gpu);
        checkCudaError(cudaMemcpy(h_output + (gpu * numSignals * SIGNAL_SIZE / numGPUs), d_output[gpu], totalSize / numGPUs, cudaMemcpyDeviceToHost), __FILE__, __LINE__);
    }

    // Free device memory
    for (int gpu = 0; gpu < numGPUs; gpu++) {
        cudaSetDevice(gpu);
        cudaFree(d_input[gpu]);
        cudaFree(d_output[gpu]);
    }

    // Output the first few results for verification
    for (int i = 0; i < 10; i++) {
        std::cout << "Output[" << i << "] = " << h_output[i] << std::endl;
    }

    delete[] h_input;
    delete[] h_output;

    return 0;
}
	.file	"tmpxft_001ca4d2_00000000-6_cuda_code_000543.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3662:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3662:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"CUDA error at "
.LC1:
	.string	":"
.LC2:
	.string	" - "
	.text
	.globl	_Z14checkCudaError9cudaErrorPKci
	.type	_Z14checkCudaError9cudaErrorPKci, @function
_Z14checkCudaError9cudaErrorPKci:
.LFB3658:
	.cfi_startproc
	endbr64
	testl	%edi, %edi
	je	.L2
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rsi, %r12
	leaq	.LC0(%rip), %rsi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movl	%edx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movl	%edi, %ebx
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%r12, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC1(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%ebp, %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	leaq	.LC2(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%ebx, %edi
	movq	%rax, %rbp
	call	cudaGetErrorString@PLT
	movq	%rbp, %rdi
	movq	%rax, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	movl	$1, %edi
	call	exit@PLT
.L2:
	.cfi_def_cfa_offset 8
	.cfi_restore 3
	.cfi_restore 6
	.cfi_restore 12
	ret
	.cfi_endproc
.LFE3658:
	.size	_Z14checkCudaError9cudaErrorPKci, .-_Z14checkCudaError9cudaErrorPKci
	.globl	_Z39__device_stub__Z16waveletTransformPfS_iPfS_i
	.type	_Z39__device_stub__Z16waveletTransformPfS_iPfS_i, @function
_Z39__device_stub__Z16waveletTransformPfS_iPfS_i:
.LFB3684:
	.cfi_startproc
	endbr64
	subq	$136, %rsp
	.cfi_def_cfa_offset 144
	movq	%rdi, 24(%rsp)
	leaq	40(%rsp), %rcx
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	32(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 112(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L8
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z16waveletTransformPfS_i(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 160
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 152
	popq	%rdx
	.cfi_def_cfa_offset 144
.L8:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3684:
	.size	_Z39__device_stub__Z16waveletTransformPfS_iPfS_i, .-_Z39__device_stub__Z16waveletTransformPfS_iPfS_i
	.globl	_Z16waveletTransformPfS_i
	.type	_Z16waveletTransformPfS_i, @function
_Z16waveletTransformPfS_i:
.LFB3685:
	.cfi_startproc
	endbr64
	jmp	_Z39__device_stub__Z16waveletTransformPfS_iPfS_i
	.cfi_endproc
.LFE3685:
	.size	_Z16waveletTransformPfS_i, .-_Z16waveletTransformPfS_i
	.section	.rodata.str1.1
.LC3:
	.string	"This program requires at least 2 GPUs."
.LC5:
	.string	"/home/ubuntu/Datasets/cuda-codes-80k-from-llm-dedup/cuda_code_000543.cu"
.LC6:
	.string	"Output["
.LC7:
	.string	"] = "
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3659:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	leaq	-340(%rbp), %rdi
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$344, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	cudaGetDeviceCount@PLT
	cmpl	$1, -340(%rbp)
	jg	.L14
	leaq	.LC3(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	movl	$1, %eax
	jmp	.L13
.L14:
	movl	$262144, %edi
	call	_Znam@PLT
	movl	$262144, %edi
	movq	%rax, %rbx
	call	_Znam@PLT
	leaq	-312(%rbp), %rcx
	movss	.LC4(%rip), %xmm0
	movq	%rcx, -376(%rbp)
	movq	%rax, -360(%rbp)
	xorl	%eax, %eax
.L16:
	movq	-376(%rbp), %rcx
	movss	%xmm0, (%rcx,%rax,4)
	incq	%rax
	cmpq	$64, %rax
	jne	.L16
	xorl	%ecx, %ecx
	movl	$10, %esi
.L17:
	movl	%ecx, %eax
	cltd
	idivl	%esi
	cvtsi2ssl	%edx, %xmm0
	movss	%xmm0, (%rbx,%rcx,4)
	incq	%rcx
	cmpq	$65536, %rcx
	jne	.L17
	movslq	-340(%rbp), %rax
	movq	%rsp, %rcx
	leaq	15(,%rax,8), %rax
	movq	%rax, %rsi
	movq	%rax, %rdx
	andq	$-4096, %rsi
	andq	$-16, %rdx
	subq	%rsi, %rcx
.L18:
	cmpq	%rcx, %rsp
	je	.L19
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L18
.L19:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	je	.L20
	orq	$0, -8(%rsp,%rdx)
.L20:
	movq	%rax, %rdx
	movq	%rsp, %rcx
	andq	$-4096, %rax
	movq	%rsp, %r15
	andq	$-16, %rdx
	subq	%rax, %rcx
.L21:
	cmpq	%rcx, %rsp
	je	.L22
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L21
.L22:
	movq	%rdx, %rax
	andl	$4095, %eax
	subq	%rax, %rsp
	testq	%rax, %rax
	je	.L23
	orq	$0, -8(%rsp,%rax)
.L23:
	movq	%rsp, %r13
	movq	%r15, %r14
	xorl	%r12d, %r12d
	movq	%r13, -368(%rbp)
.L24:
	cmpl	%r12d, -340(%rbp)
	jle	.L45
	movl	%r12d, %edi
	call	cudaSetDevice@PLT
	movl	$262144, %eax
	xorl	%edx, %edx
	movq	%r14, %rdi
	movslq	-340(%rbp), %rcx
	addq	$8, %r14
	divq	%rcx
	movq	%rax, %rsi
	call	cudaMalloc@PLT
	movl	$70, %edx
	leaq	.LC5(%rip), %rsi
	movl	%eax, %edi
	call	_Z14checkCudaError9cudaErrorPKci
	movslq	-340(%rbp), %rcx
	xorl	%edx, %edx
	movl	$262144, %eax
	movq	-368(%rbp), %rdi
	divq	%rcx
	movq	%rax, %rsi
	call	cudaMalloc@PLT
	movl	$71, %edx
	leaq	.LC5(%rip), %rsi
	movl	%eax, %edi
	call	_Z14checkCudaError9cudaErrorPKci
	movslq	-340(%rbp), %rsi
	movl	$262144, %eax
	xorl	%edx, %edx
	movl	$1, %ecx
	divq	%rsi
	movq	%rax, %rdi
	movl	%r12d, %eax
	incl	%r12d
	sall	$16, %eax
	cltd
	idivl	%esi
	movq	%rdi, %rdx
	movq	-8(%r14), %rdi
	cltq
	leaq	(%rbx,%rax,4), %rsi
	call	cudaMemcpy@PLT
	movl	$72, %edx
	leaq	.LC5(%rip), %rsi
	movl	%eax, %edi
	call	_Z14checkCudaError9cudaErrorPKci
	movq	-376(%rbp), %rsi
	movl	$1, %r8d
	xorl	%ecx, %ecx
	movl	$256, %edx
	leaq	_ZL9h_wavelet(%rip), %rdi
	call	cudaMemcpyToSymbol@PLT
	movl	$73, %edx
	leaq	.LC5(%rip), %rsi
	movl	%eax, %edi
	call	_Z14checkCudaError9cudaErrorPKci
	addq	$8, -368(%rbp)
	jmp	.L24
.L45:
	movabsq	$4294967552, %r12
	xorl	%r14d, %r14d
.L26:
	movl	%r14d, %edi
	cmpl	%r14d, -340(%rbp)
	jle	.L46
	call	cudaSetDevice@PLT
	movl	$1024, %eax
	movl	$256, %ecx
	xorl	%r9d, %r9d
	cltd
	movl	$1024, %r8d
	movq	%r12, -324(%rbp)
	idivl	-340(%rbp)
	movl	$1, -316(%rbp)
	addl	$255, %eax
	cltd
	idivl	%ecx
	movq	%r12, %rdx
	movl	$1, %ecx
	movl	%eax, -336(%rbp)
	movabsq	$4294967297, %rax
	movq	%rax, -332(%rbp)
	movq	-336(%rbp), %rdi
	movl	-328(%rbp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L27
	movl	$1024, %eax
	movq	0(%r13,%r14,8), %rsi
	movq	(%r15,%r14,8), %rdi
	cltd
	idivl	-340(%rbp)
	movl	%eax, %edx
	call	_Z39__device_stub__Z16waveletTransformPfS_iPfS_i
.L27:
	call	cudaGetLastError@PLT
	movl	$80, %edx
	leaq	.LC5(%rip), %rsi
	incq	%r14
	movl	%eax, %edi
	call	_Z14checkCudaError9cudaErrorPKci
	jmp	.L26
.L46:
	xorl	%r14d, %r14d
	leaq	.LC5(%rip), %r12
.L29:
	movl	%r14d, %edi
	cmpl	%r14d, -340(%rbp)
	jle	.L47
	call	cudaSetDevice@PLT
	movslq	-340(%rbp), %rsi
	movl	$262144, %eax
	xorl	%edx, %edx
	divq	%rsi
	movq	%rsi, %rcx
	movq	0(%r13,%r14,8), %rsi
	movq	%rax, %r8
	movl	%r14d, %eax
	incq	%r14
	sall	$16, %eax
	cltd
	idivl	%ecx
	movq	-360(%rbp), %rcx
	movq	%r8, %rdx
	cltq
	leaq	(%rcx,%rax,4), %rdi
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	movl	$86, %edx
	movq	%r12, %rsi
	movl	%eax, %edi
	call	_Z14checkCudaError9cudaErrorPKci
	jmp	.L29
.L47:
	xorl	%r12d, %r12d
.L31:
	movl	%r12d, %edi
	cmpl	%r12d, -340(%rbp)
	jle	.L48
	call	cudaSetDevice@PLT
	movq	(%r15,%r12,8), %rdi
	call	cudaFree@PLT
	movq	0(%r13,%r12,8), %rdi
	incq	%r12
	call	cudaFree@PLT
	jmp	.L31
.L48:
	xorl	%r12d, %r12d
	leaq	.LC6(%rip), %r13
.L33:
	movq	%r13, %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%r12d, %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	leaq	.LC7(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	movq	-360(%rbp), %rax
	cvtss2sd	(%rax,%r12,4), %xmm0
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	incq	%r12
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	cmpq	$10, %r12
	jne	.L33
	movq	%rbx, %rdi
	call	_ZdaPv@PLT
	movq	-360(%rbp), %rdi
	call	_ZdaPv@PLT
	xorl	%eax, %eax
.L13:
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L34
	call	__stack_chk_fail@PLT
.L34:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3659:
	.size	main, .-main
	.section	.rodata.str1.1
.LC8:
	.string	"_Z16waveletTransformPfS_i"
.LC9:
	.string	"h_wavelet"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3687:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC8(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z16waveletTransformPfS_i(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC9(%rip), %rdx
	movl	$256, %r9d
	leaq	_ZL9h_wavelet(%rip), %rsi
	pushq	$1
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	call	__cudaRegisterVar@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rdx
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE3687:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.local	_ZL9h_wavelet
	.comm	_ZL9h_wavelet,256,32
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC4:
	.long	1015021568
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include <iostream>
#include <hip/hip_runtime.h>
#include <hipfft/hipfft.h>
#include <hip/hip_complex.h>

#define BLOCK_SIZE 256
#define SIGNAL_SIZE 64

__constant__ float h_wavelet[SIGNAL_SIZE];

__global__ void waveletTransform(float *d_input, float *d_output, int numSignals) {
    extern __shared__ float sharedData[];
    int tid = threadIdx.x;
    int bid = blockIdx.x;
    int idx = bid * blockDim.x + tid;

    if (idx >= numSignals * SIGNAL_SIZE) return;

    int signalId = idx / SIGNAL_SIZE;
    int signalOffset = idx % SIGNAL_SIZE;

    // Load data into shared memory
    sharedData[tid] = d_input[idx];
    __syncthreads();

    float result = 0.0f;
    for (int j = 0; j < SIGNAL_SIZE; j++) {
        result += sharedData[j] * h_wavelet[(signalOffset + j) % SIGNAL_SIZE];
    }

    d_output[idx] = result;
}

void checkCudaError(hipError_t err, const char *file, int line) {
    if (err != hipSuccess) {
        std::cerr << "CUDA error at " << file << ":" << line << " - " << hipGetErrorString(err) << std::endl;
        exit(EXIT_FAILURE);
    }
}

int main() {
    int numGPUs;
    hipGetDeviceCount(&numGPUs);
    if (numGPUs < 2) {
        std::cerr << "This program requires at least 2 GPUs." << std::endl;
        return EXIT_FAILURE;
    }

    int numSignals = 1024; // Example number of signals
    size_t totalSize = numSignals * SIGNAL_SIZE * sizeof(float);

    float *h_input = new float[numSignals * SIGNAL_SIZE];
    float *h_output = new float[numSignals * SIGNAL_SIZE];
    float h_wavelet_host[SIGNAL_SIZE];

    // Initialize wavelet coefficients (example)
    for (int i = 0; i < SIGNAL_SIZE; i++) {
        h_wavelet_host[i] = 1.0f / SIGNAL_SIZE; // Simple averaging for demonstration
    }

    // Initialize input data (example)
    for (int i = 0; i < numSignals * SIGNAL_SIZE; i++) {
        h_input[i] = static_cast<float>(i % 10);
    }

    // Allocate device memory and copy data to device
    float *d_input[numGPUs], *d_output[numGPUs];
    for (int gpu = 0; gpu < numGPUs; gpu++) {
        hipSetDevice(gpu);
        checkCudaError(hipMalloc(&d_input[gpu], totalSize / numGPUs), __FILE__, __LINE__);
        checkCudaError(hipMalloc(&d_output[gpu], totalSize / numGPUs), __FILE__, __LINE__);
        checkCudaError(hipMemcpy(d_input[gpu], h_input + (gpu * numSignals * SIGNAL_SIZE / numGPUs), totalSize / numGPUs, hipMemcpyHostToDevice), __FILE__, __LINE__);
        checkCudaError(hipMemcpyToSymbol(HIP_SYMBOL(h_wavelet), h_wavelet_host, sizeof(h_wavelet_host)), __FILE__, __LINE__);
    }

    // Launch kernel on each GPU
    for (int gpu = 0; gpu < numGPUs; gpu++) {
        hipSetDevice(gpu);
        waveletTransform<<<(numSignals / numGPUs + BLOCK_SIZE - 1) / BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE * sizeof(float)>>>(d_input[gpu], d_output[gpu], numSignals / numGPUs);
        checkCudaError(hipGetLastError(), __FILE__, __LINE__);
    }

    // Copy results back to host
    for (int gpu = 0; gpu < numGPUs; gpu++) {
        hipSetDevice(gpu);
        checkCudaError(hipMemcpy(h_output + (gpu * numSignals * SIGNAL_SIZE / numGPUs), d_output[gpu], totalSize / numGPUs, hipMemcpyDeviceToHost), __FILE__, __LINE__);
    }

    // Free device memory
    for (int gpu = 0; gpu < numGPUs; gpu++) {
        hipSetDevice(gpu);
        hipFree(d_input[gpu]);
        hipFree(d_output[gpu]);
    }

    // Output the first few results for verification
    for (int i = 0; i < 10; i++) {
        std::cout << "Output[" << i << "] = " << h_output[i] << std::endl;
    }

    delete[] h_input;
    delete[] h_output;

    return 0;
}
	.text
	.file	"cuda_code_000543.hip"
                                        # Start of file scope inline assembly
	.globl	_ZSt21ios_base_library_initv

                                        # End of file scope inline assembly
	.globl	_Z31__device_stub__waveletTransformPfS_i # -- Begin function _Z31__device_stub__waveletTransformPfS_i
	.type	_Z31__device_stub__waveletTransformPfS_i,@function
_Z31__device_stub__waveletTransformPfS_i: # @_Z31__device_stub__waveletTransformPfS_i
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z16waveletTransformPfS_i, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z31__device_stub__waveletTransformPfS_i, .Lfunc_end0-_Z31__device_stub__waveletTransformPfS_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z14checkCudaError10hipError_tPKci # -- Begin function _Z14checkCudaError10hipError_tPKci
	.type	_Z14checkCudaError10hipError_tPKci,@function
_Z14checkCudaError10hipError_tPKci:     # @_Z14checkCudaError10hipError_tPKci
	.cfi_startproc
# %bb.0:
	testl	%edi, %edi
	jne	.LBB1_2
# %bb.1:
	retq
.LBB1_2:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %rbp, -16
	movl	%edx, %ebp
	movq	%rsi, %r14
	movl	%edi, %ebx
	movl	$_ZSt4cerr, %edi
	movl	$.L.str, %esi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movq	%r14, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.1, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movl	%ebp, %esi
	callq	_ZNSolsEi
	movl	$.L.str.2, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %r14
	movl	%ebx, %edi
	callq	hipGetErrorString
	movq	%r14, %rdi
	movq	%rax, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
	movl	$1, %edi
	callq	exit
.Lfunc_end1:
	.size	_Z14checkCudaError10hipError_tPKci, .Lfunc_end1-_Z14checkCudaError10hipError_tPKci
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$296, %rsp                      # imm = 0x128
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	leaq	-44(%rbp), %rbx
	movq	%rbx, %rdi
	callq	hipGetDeviceCount
	movl	(%rbx), %r14d
	cmpl	$1, %r14d
	jg	.LBB2_2
# %bb.1:
	movl	$_ZSt4cerr, %ebx
	movl	$_ZSt4cerr, %edi
	movl	$.L.str.3, %esi
	movl	$38, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cerr(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cerr, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$1, %eax
	jmp	.LBB2_23
.LBB2_2:
	movl	$262144, %edi                   # imm = 0x40000
	callq	_Znam
	movq	%rax, %rbx
	movl	$262144, %edi                   # imm = 0x40000
	callq	_Znam
	movq	%rax, %r13
	xorl	%eax, %eax
.LBB2_3:                                # =>This Inner Loop Header: Depth=1
	movl	$1015021568, -336(%rbp,%rax,4)  # imm = 0x3C800000
	incq	%rax
	cmpq	$64, %rax
	jne	.LBB2_3
# %bb.4:                                # %.preheader68.preheader
	xorl	%eax, %eax
	movl	$65535, %ecx                    # imm = 0xFFFF
.LBB2_5:                                # %.preheader68
                                        # =>This Inner Loop Header: Depth=1
	movl	%eax, %edx
	andl	%ecx, %edx
	imull	$52429, %edx, %edx              # imm = 0xCCCD
	shrl	$18, %edx
	andl	$-2, %edx
	leal	(%rdx,%rdx,4), %edx
	movl	%eax, %esi
	subl	%edx, %esi
	andl	%ecx, %esi
	xorps	%xmm0, %xmm0
	cvtsi2ss	%esi, %xmm0
	movss	%xmm0, (%rbx,%rax,4)
	incq	%rax
	cmpq	$65536, %rax                    # imm = 0x10000
	jne	.LBB2_5
# %bb.6:
	movq	%rsp, -80(%rbp)                 # 8-byte Spill
	movq	%rsp, %rdx
	leaq	15(,%r14,8), %rax
	andq	$-16, %rax
	subq	%rax, %rdx
	movq	%rdx, %rsp
	movl	-44(%rbp), %eax
	movq	%rsp, %r12
	leaq	15(,%rax,8), %rcx
	andq	$-16, %rcx
	subq	%rcx, %r12
	movq	%r12, %rsp
	testl	%eax, %eax
	jle	.LBB2_20
# %bb.7:                                # %.lr.ph.preheader
	movq	%r13, -72(%rbp)                 # 8-byte Spill
	xorl	%r15d, %r15d
	movq	%rdx, -56(%rbp)                 # 8-byte Spill
	movq	%rdx, %r13
	movq	%r12, -64(%rbp)                 # 8-byte Spill
	xorl	%r14d, %r14d
.LBB2_8:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	%r14d, %edi
	callq	hipSetDevice
	movslq	-44(%rbp), %rcx
	movl	$262144, %eax                   # imm = 0x40000
	xorl	%edx, %edx
	divq	%rcx
	movq	%r13, %rdi
	movq	%rax, %rsi
	callq	hipMalloc
	movl	$.L.str.4, %esi
	movl	%eax, %edi
	movl	$70, %edx
	callq	_Z14checkCudaError10hipError_tPKci
	movslq	-44(%rbp), %rcx
	movl	$262144, %eax                   # imm = 0x40000
	xorl	%edx, %edx
	divq	%rcx
	movq	%r12, %rdi
	movq	%rax, %rsi
	callq	hipMalloc
	movl	$.L.str.4, %esi
	movl	%eax, %edi
	movl	$71, %edx
	callq	_Z14checkCudaError10hipError_tPKci
	movq	(%r13), %rdi
	movslq	-44(%rbp), %rcx
	movl	%r15d, %eax
	cltd
	idivl	%ecx
	cltq
	leaq	(%rbx,%rax,4), %rsi
	movl	$262144, %eax                   # imm = 0x40000
	xorl	%edx, %edx
	divq	%rcx
	movq	%rax, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	$.L.str.4, %esi
	movl	%eax, %edi
	movl	$72, %edx
	callq	_Z14checkCudaError10hipError_tPKci
	movl	$h_wavelet, %edi
	movl	$256, %edx                      # imm = 0x100
	leaq	-336(%rbp), %rsi
	xorl	%ecx, %ecx
	movl	$1, %r8d
	callq	hipMemcpyToSymbol
	movl	$.L.str.4, %esi
	movl	%eax, %edi
	movl	$73, %edx
	callq	_Z14checkCudaError10hipError_tPKci
	incq	%r14
	movslq	-44(%rbp), %rax
	addl	$65536, %r15d                   # imm = 0x10000
	addq	$8, %r12
	addq	$8, %r13
	cmpq	%rax, %r14
	jl	.LBB2_8
# %bb.9:                                # %.preheader67
	testl	%eax, %eax
	movq	-72(%rbp), %r13                 # 8-byte Reload
	jle	.LBB2_20
# %bb.10:                               # %.lr.ph73.preheader
	movabsq	$4294967296, %r12               # imm = 0x100000000
	xorl	%r14d, %r14d
	leaq	256(%r12), %r15
.LBB2_11:                               # %.lr.ph73
                                        # =>This Inner Loop Header: Depth=1
	movl	%r14d, %edi
	callq	hipSetDevice
	movl	$1024, %eax                     # imm = 0x400
	xorl	%edx, %edx
	idivl	-44(%rbp)
                                        # kill: def $eax killed $eax def $rax
	leal	255(%rax), %ecx
	addl	$510, %eax                      # imm = 0x1FE
	testw	%cx, %cx
	cmovnsl	%ecx, %eax
	cwtl
	shrl	$8, %eax
	movswq	%ax, %rax
	movl	%eax, %edi
	orq	%r12, %rdi
	movl	$1024, %r8d                     # imm = 0x400
	movl	$1, %esi
	movq	%r15, %rdx
	movl	$1, %ecx
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB2_13
# %bb.12:                               #   in Loop: Header=BB2_11 Depth=1
	movq	-56(%rbp), %rax                 # 8-byte Reload
	movq	(%rax,%r14,8), %rdi
	movq	-64(%rbp), %rax                 # 8-byte Reload
	movq	(%rax,%r14,8), %rsi
	movl	$1024, %eax                     # imm = 0x400
	xorl	%edx, %edx
	idivl	-44(%rbp)
	movl	%eax, %edx
	callq	_Z31__device_stub__waveletTransformPfS_i
.LBB2_13:                               #   in Loop: Header=BB2_11 Depth=1
	callq	hipGetLastError
	movl	$.L.str.4, %esi
	movl	%eax, %edi
	movl	$80, %edx
	callq	_Z14checkCudaError10hipError_tPKci
	incq	%r14
	movslq	-44(%rbp), %rax
	cmpq	%rax, %r14
	jl	.LBB2_11
# %bb.14:                               # %.preheader66
	testl	%eax, %eax
	movq	-64(%rbp), %r12                 # 8-byte Reload
	jle	.LBB2_20
# %bb.15:                               # %.lr.ph75.preheader
	xorl	%r14d, %r14d
	xorl	%r15d, %r15d
.LBB2_16:                               # %.lr.ph75
                                        # =>This Inner Loop Header: Depth=1
	movl	%r15d, %edi
	callq	hipSetDevice
	movslq	-44(%rbp), %rcx
	movl	%r14d, %eax
	cltd
	idivl	%ecx
	cltq
	leaq	(,%rax,4), %rdi
	addq	%r13, %rdi
	movq	(%r12,%r15,8), %rsi
	movl	$262144, %eax                   # imm = 0x40000
	xorl	%edx, %edx
	divq	%rcx
	movq	%rax, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movl	$.L.str.4, %esi
	movl	%eax, %edi
	movl	$86, %edx
	callq	_Z14checkCudaError10hipError_tPKci
	incq	%r15
	movslq	-44(%rbp), %rax
	addl	$65536, %r14d                   # imm = 0x10000
	cmpq	%rax, %r15
	jl	.LBB2_16
# %bb.17:                               # %.preheader65
	testl	%eax, %eax
	movq	-56(%rbp), %r15                 # 8-byte Reload
	jle	.LBB2_20
# %bb.18:                               # %.lr.ph77.preheader
	xorl	%r14d, %r14d
.LBB2_19:                               # %.lr.ph77
                                        # =>This Inner Loop Header: Depth=1
	movl	%r14d, %edi
	callq	hipSetDevice
	movq	(%r15,%r14,8), %rdi
	callq	hipFree
	movq	(%r12,%r14,8), %rdi
	callq	hipFree
	incq	%r14
	movslq	-44(%rbp), %rax
	cmpq	%rax, %r14
	jl	.LBB2_19
.LBB2_20:                               # %.preheader.preheader
	xorl	%r14d, %r14d
.LBB2_21:                               # %.preheader
                                        # =>This Inner Loop Header: Depth=1
	movl	$_ZSt4cout, %edi
	movl	$.L.str.5, %esi
	movl	$7, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movl	%r14d, %esi
	callq	_ZNSolsEi
	movq	%rax, %r15
	movl	$.L.str.6, %esi
	movl	$4, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r13,%r14,4), %xmm0
	movq	%r15, %rdi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %r15
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r15, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%r15, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	incq	%r14
	cmpq	$10, %r14
	jne	.LBB2_21
# %bb.22:
	movq	%rbx, %rdi
	callq	_ZdaPv
	movq	%r13, %rdi
	callq	_ZdaPv
	movq	-80(%rbp), %rsp                 # 8-byte Reload
	xorl	%eax, %eax
.LBB2_23:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa %rsp, 8
	retq
.Lfunc_end2:
	.size	main, .Lfunc_end2-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB3_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB3_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z16waveletTransformPfS_i, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$0, 8(%rsp)
	movl	$1, (%rsp)
	movl	$h_wavelet, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movl	$256, %r9d                      # imm = 0x100
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	callq	__hipRegisterVar
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end3:
	.size	__hip_module_ctor, .Lfunc_end3-__hip_module_ctor
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_dtor
	.type	__hip_module_dtor,@function
__hip_module_dtor:                      # @__hip_module_dtor
	.cfi_startproc
# %bb.0:
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	je	.LBB4_2
# %bb.1:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	__hipUnregisterFatBinary
	movq	$0, __hip_gpubin_handle(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
.LBB4_2:
	retq
.Lfunc_end4:
	.size	__hip_module_dtor, .Lfunc_end4-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	h_wavelet,@object               # @h_wavelet
	.local	h_wavelet
	.comm	h_wavelet,256,16
	.type	_Z16waveletTransformPfS_i,@object # @_Z16waveletTransformPfS_i
	.section	.rodata,"a",@progbits
	.globl	_Z16waveletTransformPfS_i
	.p2align	3, 0x0
_Z16waveletTransformPfS_i:
	.quad	_Z31__device_stub__waveletTransformPfS_i
	.size	_Z16waveletTransformPfS_i, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"CUDA error at "
	.size	.L.str, 15

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	":"
	.size	.L.str.1, 2

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	" - "
	.size	.L.str.2, 4

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"This program requires at least 2 GPUs."
	.size	.L.str.3, 39

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"/home/ubuntu/Datasets/hip-codes-80k-from-llm-dedup-disassemble-sm89/cuda_code_000543.hip"
	.size	.L.str.4, 89

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"Output["
	.size	.L.str.5, 8

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"] = "
	.size	.L.str.6, 5

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z16waveletTransformPfS_i"
	.size	.L__unnamed_1, 26

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"h_wavelet"
	.size	.L__unnamed_2, 10

	.type	__hip_fatbin_wrapper,@object    # @__hip_fatbin_wrapper
	.section	.hipFatBinSegment,"a",@progbits
	.p2align	3, 0x0
__hip_fatbin_wrapper:
	.long	1212764230                      # 0x48495046
	.long	1                               # 0x1
	.quad	__hip_fatbin
	.quad	0
	.size	__hip_fatbin_wrapper, 24

	.type	__hip_gpubin_handle,@object     # @__hip_gpubin_handle
	.local	__hip_gpubin_handle
	.comm	__hip_gpubin_handle,8,8
	.section	.init_array,"aw",@init_array
	.p2align	3, 0x0
	.quad	__hip_module_ctor
	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym _Z31__device_stub__waveletTransformPfS_i
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym h_wavelet
	.addrsig_sym _Z16waveletTransformPfS_i
	.addrsig_sym _ZSt4cerr
	.addrsig_sym _ZSt4cout
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z16waveletTransformPfS_i ; -- Begin function _Z16waveletTransformPfS_i
	.globl	_Z16waveletTransformPfS_i
	.p2align	8
	.type	_Z16waveletTransformPfS_i,@function
_Z16waveletTransformPfS_i:              ; @_Z16waveletTransformPfS_i
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x24
	s_load_b32 s3, s[0:1], 0x10
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1)
	v_mad_u64_u32 v[3:4], null, s15, s2, v[0:1]
	s_lshl_b32 s2, s3, 6
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_cmp_gt_i32_e32 vcc_lo, s2, v3
	s_and_saveexec_b32 s2, vcc_lo
	s_cbranch_execz .LBB0_4
; %bb.1:
	s_load_b128 s[0:3], s[0:1], 0x0
	v_ashrrev_i32_e32 v4, 31, v3
	s_getpc_b64 s[4:5]
	s_add_u32 s4, s4, h_wavelet@rel32@lo+4
	s_addc_u32 s5, s5, h_wavelet@rel32@hi+12
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[1:2], 2, v[3:4]
	v_lshrrev_b32_e32 v4, 26, v4
	v_add_nc_u32_e32 v4, v3, v4
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_4)
	v_and_b32_e32 v4, 0xffffffc0, v4
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v5, vcc_lo, s0, v1
	v_add_co_ci_u32_e32 v6, vcc_lo, s1, v2, vcc_lo
	s_delay_alu instid0(VALU_DEP_3)
	v_sub_nc_u32_e32 v3, v3, v4
	s_mov_b32 s0, 0
	global_load_b32 v5, v[5:6], off
	v_lshl_add_u32 v6, v0, 2, 0
	v_mov_b32_e32 v0, 0
	s_waitcnt vmcnt(0)
	ds_store_b32 v6, v5
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
.LBB0_2:                                ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	v_ashrrev_i32_e32 v4, 31, v3
	s_add_i32 s1, s0, 0
	s_add_i32 s0, s0, 4
	s_cmpk_eq_i32 s0, 0x100
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshrrev_b32_e32 v4, 26, v4
	v_add_nc_u32_e32 v4, v3, v4
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_and_b32_e32 v4, 0xffffffc0, v4
	v_sub_nc_u32_e32 v4, v3, v4
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v5, 31, v4
	v_lshlrev_b64 v[4:5], 2, v[4:5]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v4, vcc_lo, v4, s4
	v_add_co_ci_u32_e32 v5, vcc_lo, s5, v5, vcc_lo
	global_load_b32 v4, v[4:5], off
	v_mov_b32_e32 v5, s1
	ds_load_b32 v5, v5
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_dual_fmac_f32 v0, v5, v4 :: v_dual_add_nc_u32 v3, 1, v3
	s_cbranch_scc0 .LBB0_2
; %bb.3:
	v_add_co_u32 v1, vcc_lo, s2, v1
	v_add_co_ci_u32_e32 v2, vcc_lo, s3, v2, vcc_lo
	global_store_b32 v[1:2], v0, off
.LBB0_4:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z16waveletTransformPfS_i
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 280
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 7
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z16waveletTransformPfS_i, .Lfunc_end0-_Z16waveletTransformPfS_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 352
; NumSgprs: 18
; NumVgprs: 7
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 7
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.protected	h_wavelet               ; @h_wavelet
	.type	h_wavelet,@object
	.section	.bss,"aw",@nobits
	.globl	h_wavelet
	.p2align	4, 0x0
h_wavelet:
	.zero	256
	.size	h_wavelet, 256

	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym h_wavelet
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .offset:         16
        .size:           4
        .value_kind:     by_value
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         28
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         36
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         38
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         40
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         42
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         44
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         46
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         88
        .size:           2
        .value_kind:     hidden_grid_dims
      - .offset:         144
        .size:           4
        .value_kind:     hidden_dynamic_lds_size
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z16waveletTransformPfS_i
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z16waveletTransformPfS_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     7
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
