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

// Define a simple sparse tensor structure
struct SparseTensor {
    int* indices;  // Indices of non-zero elements
    float* values; // Values of non-zero elements
    int nnz;       // Number of non-zero elements
};

// CUDA kernel to perform sparse tensor operations
__global__ void sparseTensorOperationKernel(const SparseTensor d_tensorA, const SparseTensor d_tensorB, SparseTensor d_result) {
    extern __shared__ float sharedMem[];
    int idx = threadIdx.x;

    // Load data into shared memory to reduce global memory access
    if (idx < d_tensorA.nnz) {
        sharedMem[idx] = d_tensorA.values[idx] + d_tensorB.values[idx];
    }
    __syncthreads();

    // Write results back to global memory
    if (idx < d_result.nnz) {
        d_result.values[idx] = sharedMem[idx];
    }
}

int main() {
    // Host data
    const int nnz = 512;
    int h_indices[nnz];
    float h_valuesA[nnz];
    float h_valuesB[nnz];
    float h_result[nnz];

    // Initialize host data
    for (int i = 0; i < nnz; ++i) {
        h_indices[i] = i; // Simplified index mapping
        h_valuesA[i] = static_cast<float>(i);
        h_valuesB[i] = static_cast<float>(i) * 2.0f;
    }

    // Device data
    SparseTensor d_tensorA, d_tensorB, d_result;
    cudaMalloc((void**)&d_tensorA.indices, nnz * sizeof(int));
    cudaMalloc((void**)&d_tensorA.values, nnz * sizeof(float));
    cudaMalloc((void**)&d_tensorB.indices, nnz * sizeof(int));
    cudaMalloc((void**)&d_tensorB.values, nnz * sizeof(float));
    cudaMalloc((void**)&d_result.indices, nnz * sizeof(int));
    cudaMalloc((void**)&d_result.values, nnz * sizeof(float));

    // Copy data from host to device
    cudaMemcpy(d_tensorA.indices, h_indices, nnz * sizeof(int), cudaMemcpyHostToDevice);
    cudaMemcpy(d_tensorA.values, h_valuesA, nnz * sizeof(float), cudaMemcpyHostToDevice);
    cudaMemcpy(d_tensorB.indices, h_indices, nnz * sizeof(int), cudaMemcpyHostToDevice);
    cudaMemcpy(d_tensorB.values, h_valuesB, nnz * sizeof(float), cudaMemcpyHostToDevice);
    cudaMemcpy(d_result.indices, h_indices, nnz * sizeof(int), cudaMemcpyHostToDevice);

    // Set the number of non-zero elements
    d_tensorA.nnz = nnz;
    d_tensorB.nnz = nnz;
    d_result.nnz = nnz;

    // Launch the kernel
    int blockSize = 512;
    int sharedMemSize = blockSize * sizeof(float);
    sparseTensorOperationKernel<<<1, blockSize, sharedMemSize>>>(d_tensorA, d_tensorB, d_result);

    // Check for kernel launch errors
    cudaError_t err = cudaGetLastError();
    if (err != cudaSuccess) {
        std::cerr << "CUDA error: " << cudaGetErrorString(err) << std::endl;
        return -1;
    }

    // Copy result back to host
    cudaMemcpy(h_result, d_result.values, nnz * sizeof(float), cudaMemcpyDeviceToHost);

    // Free device memory
    cudaFree(d_tensorA.indices);
    cudaFree(d_tensorA.values);
    cudaFree(d_tensorB.indices);
    cudaFree(d_tensorB.values);
    cudaFree(d_result.indices);
    cudaFree(d_result.values);

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

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

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3638:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3638:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z63__device_stub__Z27sparseTensorOperationKernel12SparseTensorS_S_RK12SparseTensorS1_RS_
	.type	_Z63__device_stub__Z27sparseTensorOperationKernel12SparseTensorS_S_RK12SparseTensorS1_RS_, @function
_Z63__device_stub__Z27sparseTensorOperationKernel12SparseTensorS_S_RK12SparseTensorS1_RS_:
.LFB3660:
	.cfi_startproc
	endbr64
	subq	$104, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rcx
	movq	%rdi, 64(%rsp)
	movabsq	$4294967297, %rax
	movq	%rsi, 72(%rsp)
	leaq	16(%rsp), %rdi
	leaq	28(%rsp), %rsi
	movq	%rdx, 80(%rsp)
	movq	%rsp, %rdx
	movq	%rax, 16(%rsp)
	movl	$1, 24(%rsp)
	movq	%rax, 28(%rsp)
	movl	$1, 36(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L2
	pushq	8(%rsp)
	.cfi_def_cfa_offset 120
	leaq	_Z27sparseTensorOperationKernel12SparseTensorS_S_(%rip), %rdi
	pushq	8(%rsp)
	.cfi_def_cfa_offset 128
	movq	44(%rsp), %rcx
	movl	52(%rsp), %r8d
	movq	32(%rsp), %rsi
	movl	40(%rsp), %edx
	leaq	80(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 120
	popq	%rdx
	.cfi_def_cfa_offset 112
.L2:
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L4
	call	__stack_chk_fail@PLT
.L4:
	addq	$104, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3660:
	.size	_Z63__device_stub__Z27sparseTensorOperationKernel12SparseTensorS_S_RK12SparseTensorS1_RS_, .-_Z63__device_stub__Z27sparseTensorOperationKernel12SparseTensorS_S_RK12SparseTensorS1_RS_
	.globl	_Z27sparseTensorOperationKernel12SparseTensorS_S_
	.type	_Z27sparseTensorOperationKernel12SparseTensorS_S_, @function
_Z27sparseTensorOperationKernel12SparseTensorS_S_:
.LFB3661:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	64(%rsp), %rdx
	leaq	40(%rsp), %rsi
	leaq	16(%rsp), %rdi
	call	_Z63__device_stub__Z27sparseTensorOperationKernel12SparseTensorS_S_RK12SparseTensorS1_RS_
	popq	%rdx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3661:
	.size	_Z27sparseTensorOperationKernel12SparseTensorS_S_, .-_Z27sparseTensorOperationKernel12SparseTensorS_S_
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"CUDA error: "
.LC1:
	.string	"Result["
.LC2:
	.string	"] = "
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3635:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$4096, %rsp
	.cfi_def_cfa_offset 4128
	orq	$0, (%rsp)
	subq	$4096, %rsp
	.cfi_def_cfa_offset 8224
	orq	$0, (%rsp)
	subq	$176, %rsp
	.cfi_def_cfa_offset 8400
	movq	%fs:40, %rax
	movq	%rax, 8360(%rsp)
	xorl	%eax, %eax
.L10:
	cvtsi2ssl	%eax, %xmm0
	leaq	2216(%rsp), %r12
	leaq	168(%rsp), %rbx
	leaq	4264(%rsp), %rbp
	movl	%eax, (%rbx,%rax,4)
	movss	%xmm0, (%r12,%rax,4)
	addss	%xmm0, %xmm0
	movss	%xmm0, 0(%rbp,%rax,4)
	incq	%rax
	cmpq	$512, %rax
	jne	.L10
	leaq	24(%rsp), %rdi
	movl	$2048, %esi
	call	cudaMalloc@PLT
	leaq	32(%rsp), %rdi
	movl	$2048, %esi
	call	cudaMalloc@PLT
	leaq	48(%rsp), %rdi
	movl	$2048, %esi
	call	cudaMalloc@PLT
	leaq	56(%rsp), %rdi
	movl	$2048, %esi
	call	cudaMalloc@PLT
	leaq	72(%rsp), %rdi
	movl	$2048, %esi
	call	cudaMalloc@PLT
	leaq	80(%rsp), %rdi
	movl	$2048, %esi
	call	cudaMalloc@PLT
	movq	24(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbx, %rsi
	movl	$2048, %edx
	call	cudaMemcpy@PLT
	movq	32(%rsp), %rdi
	movl	$1, %ecx
	movq	%r12, %rsi
	movl	$2048, %edx
	call	cudaMemcpy@PLT
	movq	48(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbx, %rsi
	movl	$2048, %edx
	call	cudaMemcpy@PLT
	movq	56(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	movl	$2048, %edx
	call	cudaMemcpy@PLT
	movq	72(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbx, %rsi
	movl	$2048, %edx
	call	cudaMemcpy@PLT
	movl	$8388609, %edx
	xorl	%r9d, %r9d
	movabsq	$4294967297, %rdi
	salq	$9, %rdx
	movl	$2048, %r8d
	movl	$1, %ecx
	movl	$1, %esi
	movl	$512, 40(%rsp)
	movl	$512, 64(%rsp)
	movl	$512, 88(%rsp)
	movq	%rdx, 12(%rsp)
	movl	$1, 20(%rsp)
	movq	%rdi, (%rsp)
	movl	$1, 8(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L11
	movq	40(%rsp), %rax
	movups	24(%rsp), %xmm1
	leaq	144(%rsp), %rdx
	leaq	120(%rsp), %rsi
	movups	48(%rsp), %xmm2
	movups	72(%rsp), %xmm3
	leaq	96(%rsp), %rdi
	movq	%rax, 112(%rsp)
	movq	64(%rsp), %rax
	movups	%xmm1, 96(%rsp)
	movq	%rax, 136(%rsp)
	movq	88(%rsp), %rax
	movups	%xmm2, 120(%rsp)
	movq	%rax, 160(%rsp)
	movups	%xmm3, 144(%rsp)
	call	_Z63__device_stub__Z27sparseTensorOperationKernel12SparseTensorS_S_RK12SparseTensorS1_RS_
.L11:
	call	cudaGetLastError@PLT
	movl	%eax, %ebx
	testl	%eax, %eax
	je	.L12
	leaq	.LC0(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %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
	orl	$-1, %eax
	jmp	.L9
.L12:
	movq	80(%rsp), %rsi
	leaq	6312(%rsp), %rbp
	movl	$2, %ecx
	xorl	%ebx, %ebx
	movl	$2048, %edx
	movq	%rbp, %rdi
	leaq	.LC1(%rip), %r12
	call	cudaMemcpy@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
	movq	48(%rsp), %rdi
	call	cudaFree@PLT
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	movq	72(%rsp), %rdi
	call	cudaFree@PLT
	movq	80(%rsp), %rdi
	call	cudaFree@PLT
.L14:
	movq	%r12, %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%ebx, %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	leaq	.LC2(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	cvtss2sd	0(%rbp,%rbx,4), %xmm0
	incq	%rbx
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	cmpq	$10, %rbx
	jne	.L14
	xorl	%eax, %eax
.L9:
	movq	8360(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	addq	$8368, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3635:
	.size	main, .-main
	.section	.rodata.str1.1
.LC3:
	.string	"_Z27sparseTensorOperationKernel12SparseTensorS_S_"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3663:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 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	.LC3(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z27sparseTensorOperationKernel12SparseTensorS_S_(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE3663:
	.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
	.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>

// Define a simple sparse tensor structure
struct SparseTensor {
    int* indices;  // Indices of non-zero elements
    float* values; // Values of non-zero elements
    int nnz;       // Number of non-zero elements
};

// CUDA kernel to perform sparse tensor operations
__global__ void sparseTensorOperationKernel(const SparseTensor d_tensorA, const SparseTensor d_tensorB, SparseTensor d_result) {
    extern __shared__ float sharedMem[];
    int idx = threadIdx.x;

    // Load data into shared memory to reduce global memory access
    if (idx < d_tensorA.nnz) {
        sharedMem[idx] = d_tensorA.values[idx] + d_tensorB.values[idx];
    }
    __syncthreads();

    // Write results back to global memory
    if (idx < d_result.nnz) {
        d_result.values[idx] = sharedMem[idx];
    }
}

int main() {
    // Host data
    const int nnz = 512;
    int h_indices[nnz];
    float h_valuesA[nnz];
    float h_valuesB[nnz];
    float h_result[nnz];

    // Initialize host data
    for (int i = 0; i < nnz; ++i) {
        h_indices[i] = i; // Simplified index mapping
        h_valuesA[i] = static_cast<float>(i);
        h_valuesB[i] = static_cast<float>(i) * 2.0f;
    }

    // Device data
    SparseTensor d_tensorA, d_tensorB, d_result;
    hipMalloc((void**)&d_tensorA.indices, nnz * sizeof(int));
    hipMalloc((void**)&d_tensorA.values, nnz * sizeof(float));
    hipMalloc((void**)&d_tensorB.indices, nnz * sizeof(int));
    hipMalloc((void**)&d_tensorB.values, nnz * sizeof(float));
    hipMalloc((void**)&d_result.indices, nnz * sizeof(int));
    hipMalloc((void**)&d_result.values, nnz * sizeof(float));

    // Copy data from host to device
    hipMemcpy(d_tensorA.indices, h_indices, nnz * sizeof(int), hipMemcpyHostToDevice);
    hipMemcpy(d_tensorA.values, h_valuesA, nnz * sizeof(float), hipMemcpyHostToDevice);
    hipMemcpy(d_tensorB.indices, h_indices, nnz * sizeof(int), hipMemcpyHostToDevice);
    hipMemcpy(d_tensorB.values, h_valuesB, nnz * sizeof(float), hipMemcpyHostToDevice);
    hipMemcpy(d_result.indices, h_indices, nnz * sizeof(int), hipMemcpyHostToDevice);

    // Set the number of non-zero elements
    d_tensorA.nnz = nnz;
    d_tensorB.nnz = nnz;
    d_result.nnz = nnz;

    // Launch the kernel
    int blockSize = 512;
    int sharedMemSize = blockSize * sizeof(float);
    sparseTensorOperationKernel<<<1, blockSize, sharedMemSize>>>(d_tensorA, d_tensorB, d_result);

    // Check for kernel launch errors
    hipError_t err = hipGetLastError();
    if (err != hipSuccess) {
        std::cerr << "CUDA error: " << hipGetErrorString(err) << std::endl;
        return -1;
    }

    // Copy result back to host
    hipMemcpy(h_result, d_result.values, nnz * sizeof(float), hipMemcpyDeviceToHost);

    // Free device memory
    hipFree(d_tensorA.indices);
    hipFree(d_tensorA.values);
    hipFree(d_tensorB.indices);
    hipFree(d_tensorB.values);
    hipFree(d_result.indices);
    hipFree(d_result.values);

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

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

                                        # End of file scope inline assembly
	.globl	_Z42__device_stub__sparseTensorOperationKernel12SparseTensorS_S_ # -- Begin function _Z42__device_stub__sparseTensorOperationKernel12SparseTensorS_S_
	.type	_Z42__device_stub__sparseTensorOperationKernel12SparseTensorS_S_,@function
_Z42__device_stub__sparseTensorOperationKernel12SparseTensorS_S_: # @_Z42__device_stub__sparseTensorOperationKernel12SparseTensorS_S_
	.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	$80, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	128(%rsp), %rax
	leaq	48(%rsp), %rbx
	movq	%rax, (%rbx)
	leaq	152(%rsp), %rax
	movq	%rax, 8(%rbx)
	leaq	176(%rsp), %rax
	movq	%rax, 16(%rbx)
	leaq	32(%rsp), %r14
	leaq	16(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%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	$_Z27sparseTensorOperationKernel12SparseTensorS_S_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
	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	_Z42__device_stub__sparseTensorOperationKernel12SparseTensorS_S_, .Lfunc_end0-_Z42__device_stub__sparseTensorOperationKernel12SparseTensorS_S_
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
	.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	$8416, %rsp                     # imm = 0x20E0
	.cfi_def_cfa_offset 8464
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	xorl	%eax, %eax
.LBB1_1:                                # =>This Inner Loop Header: Depth=1
	movl	%eax, 6368(%rsp,%rax,4)
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	movss	%xmm0, 4320(%rsp,%rax,4)
	addss	%xmm0, %xmm0
	movss	%xmm0, 2272(%rsp,%rax,4)
	incq	%rax
	cmpq	$512, %rax                      # imm = 0x200
	jne	.LBB1_1
# %bb.2:
	leaq	56(%rsp), %rdi
	movl	$2048, %esi                     # imm = 0x800
	callq	hipMalloc
	leaq	64(%rsp), %rbx
	movl	$2048, %esi                     # imm = 0x800
	movq	%rbx, %rdi
	callq	hipMalloc
	leaq	32(%rsp), %rdi
	movl	$2048, %esi                     # imm = 0x800
	callq	hipMalloc
	leaq	40(%rsp), %r14
	movl	$2048, %esi                     # imm = 0x800
	movq	%r14, %rdi
	callq	hipMalloc
	leaq	8(%rsp), %rdi
	movl	$2048, %esi                     # imm = 0x800
	callq	hipMalloc
	leaq	16(%rsp), %r15
	movl	$2048, %esi                     # imm = 0x800
	movq	%r15, %rdi
	callq	hipMalloc
	movq	-8(%rbx), %rdi
	leaq	6368(%rsp), %r12
	movl	$2048, %edx                     # imm = 0x800
	movq	%r12, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%rbx), %rdi
	leaq	4320(%rsp), %rsi
	movl	$2048, %edx                     # imm = 0x800
	movl	$1, %ecx
	callq	hipMemcpy
	movq	-8(%r14), %rdi
	movl	$2048, %edx                     # imm = 0x800
	movq	%r12, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%r14), %rdi
	leaq	2272(%rsp), %rsi
	movl	$2048, %edx                     # imm = 0x800
	movl	$1, %ecx
	callq	hipMemcpy
	movq	-8(%r15), %rdi
	movl	$2048, %edx                     # imm = 0x800
	movq	%r12, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movl	$512, %eax                      # imm = 0x200
	movl	%eax, 8(%rbx)
	movl	%eax, 8(%r14)
	movl	%eax, 8(%r15)
	movabsq	$4294967297, %rdi               # imm = 0x100000001
	leaq	511(%rdi), %rdx
	movl	$2048, %r8d                     # imm = 0x800
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB1_4
# %bb.3:
	movq	72(%rsp), %rax
	leaq	128(%rsp), %rcx
	movq	%rax, 16(%rcx)
	movups	56(%rsp), %xmm0
	movaps	%xmm0, (%rcx)
	movq	48(%rsp), %rax
	leaq	160(%rsp), %rdx
	movq	%rax, 16(%rdx)
	movups	32(%rsp), %xmm0
	movaps	%xmm0, (%rdx)
	movq	24(%rsp), %rax
	leaq	192(%rsp), %rsi
	movq	%rax, 16(%rsi)
	movups	8(%rsp), %xmm0
	movaps	%xmm0, (%rsi)
	leaq	224(%rsp), %rbx
	movq	%rcx, (%rbx)
	movq	%rdx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	leaq	112(%rsp), %r14
	leaq	96(%rsp), %r15
	leaq	88(%rsp), %r12
	leaq	80(%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	$_Z27sparseTensorOperationKernel12SparseTensorS_S_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$16, %rsp
	.cfi_adjust_cfa_offset -16
.LBB1_4:
	callq	hipGetLastError
	testl	%eax, %eax
	je	.LBB1_9
# %bb.5:
	movl	%eax, %ebx
	movl	$_ZSt4cerr, %edi
	movl	$.L.str, %esi
	movl	$12, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	%ebx, %edi
	callq	hipGetErrorString
	testq	%rax, %rax
	je	.LBB1_6
# %bb.7:
	movq	%rax, %rbx
	movq	%rax, %rdi
	callq	strlen
	movl	$_ZSt4cerr, %edi
	movq	%rbx, %rsi
	movq	%rax, %rdx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	jmp	.LBB1_8
.LBB1_9:
	movq	16(%rsp), %rsi
	leaq	224(%rsp), %rdi
	movl	$2048, %edx                     # imm = 0x800
	movl	$2, %ecx
	callq	hipMemcpy
	movq	56(%rsp), %rdi
	callq	hipFree
	movq	64(%rsp), %rdi
	callq	hipFree
	movq	32(%rsp), %rdi
	callq	hipFree
	movq	40(%rsp), %rdi
	callq	hipFree
	movq	8(%rsp), %rdi
	callq	hipFree
	movq	16(%rsp), %rdi
	callq	hipFree
	xorl	%ebx, %ebx
	xorl	%r14d, %r14d
.LBB1_10:                               # =>This Inner Loop Header: Depth=1
	movl	$_ZSt4cout, %edi
	movl	$.L.str.1, %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.2, %esi
	movl	$4, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	xorps	%xmm0, %xmm0
	cvtss2sd	224(%rsp,%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	.LBB1_10
	jmp	.LBB1_11
.LBB1_6:
	movq	_ZSt4cerr(%rip), %rax
	movq	-24(%rax), %rax
	leaq	_ZSt4cerr(%rax), %rdi
	movl	32(%rdi), %esi
	orl	$1, %esi
	callq	_ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate
.LBB1_8:                                # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit
	movq	_ZSt4cerr(%rip), %rax
	movl	$_ZSt4cerr, %ecx
	movq	-24(%rax), %rdi
	addq	%rcx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cerr, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$-1, %ebx
.LBB1_11:                               # %.loopexit
	movl	%ebx, %eax
	addq	$8416, %rsp                     # imm = 0x20E0
	.cfi_def_cfa_offset 48
	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_end1:
	.size	main, .Lfunc_end1-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:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB2_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB2_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z27sparseTensorOperationKernel12SparseTensorS_S_, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end2:
	.size	__hip_module_ctor, .Lfunc_end2-__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	.LBB3_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
.LBB3_2:
	retq
.Lfunc_end3:
	.size	__hip_module_dtor, .Lfunc_end3-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z27sparseTensorOperationKernel12SparseTensorS_S_,@object # @_Z27sparseTensorOperationKernel12SparseTensorS_S_
	.section	.rodata,"a",@progbits
	.globl	_Z27sparseTensorOperationKernel12SparseTensorS_S_
	.p2align	3, 0x0
_Z27sparseTensorOperationKernel12SparseTensorS_S_:
	.quad	_Z42__device_stub__sparseTensorOperationKernel12SparseTensorS_S_
	.size	_Z27sparseTensorOperationKernel12SparseTensorS_S_, 8

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

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"Result["
	.size	.L.str.1, 8

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

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z27sparseTensorOperationKernel12SparseTensorS_S_"
	.size	.L__unnamed_1, 50

	.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 _Z42__device_stub__sparseTensorOperationKernel12SparseTensorS_S_
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z27sparseTensorOperationKernel12SparseTensorS_S_
	.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	_Z27sparseTensorOperationKernel12SparseTensorS_S_ ; -- Begin function _Z27sparseTensorOperationKernel12SparseTensorS_S_
	.globl	_Z27sparseTensorOperationKernel12SparseTensorS_S_
	.p2align	8
	.type	_Z27sparseTensorOperationKernel12SparseTensorS_S_,@function
_Z27sparseTensorOperationKernel12SparseTensorS_S_: ; @_Z27sparseTensorOperationKernel12SparseTensorS_S_
; %bb.0:
	s_clause 0x1
	s_load_b32 s3, s[0:1], 0x10
	s_load_b32 s2, s[0:1], 0x40
	v_lshlrev_b32_e32 v1, 2, v0
	s_waitcnt lgkmcnt(0)
	v_cmp_gt_i32_e32 vcc_lo, s3, v0
	s_and_saveexec_b32 s3, vcc_lo
	s_cbranch_execz .LBB0_2
; %bb.1:
	s_clause 0x1
	s_load_b64 s[4:5], s[0:1], 0x8
	s_load_b64 s[6:7], s[0:1], 0x20
	v_add_nc_u32_e32 v4, 0, v1
	s_waitcnt lgkmcnt(0)
	s_clause 0x1
	global_load_b32 v2, v1, s[4:5]
	global_load_b32 v3, v1, s[6:7]
	s_waitcnt vmcnt(0)
	v_add_f32_e32 v2, v2, v3
	ds_store_b32 v4, v2
.LBB0_2:
	s_or_b32 exec_lo, exec_lo, s3
	v_cmp_gt_i32_e32 vcc_lo, s2, v0
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_and_saveexec_b32 s2, vcc_lo
	s_cbranch_execz .LBB0_4
; %bb.3:
	v_add_nc_u32_e32 v0, 0, v1
	s_load_b64 s[0:1], s[0:1], 0x38
	ds_load_b32 v0, v0
	s_waitcnt lgkmcnt(0)
	global_store_b32 v1, v0, s[0:1]
.LBB0_4:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z27sparseTensorOperationKernel12SparseTensorS_S_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 72
		.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 5
		.amdhsa_next_free_sgpr 8
		.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	_Z27sparseTensorOperationKernel12SparseTensorS_S_, .Lfunc_end0-_Z27sparseTensorOperationKernel12SparseTensorS_S_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 180
; NumSgprs: 10
; NumVgprs: 5
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 1
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 10
; NumVGPRsForWavesPerEU: 5
; 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
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.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 __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .offset:         0
        .size:           24
        .value_kind:     by_value
      - .offset:         24
        .size:           24
        .value_kind:     by_value
      - .offset:         48
        .size:           24
        .value_kind:     by_value
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 72
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z27sparseTensorOperationKernel12SparseTensorS_S_
    .private_segment_fixed_size: 0
    .sgpr_count:     10
    .sgpr_spill_count: 0
    .symbol:         _Z27sparseTensorOperationKernel12SparseTensorS_S_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     5
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
