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

// Define constants
#define WIDTH 3840
#define HEIGHT 2160
#define CHANNELS 4
#define BLOCK_WIDTH 16
#define BLOCK_HEIGHT 16

// Kernel function using persistent threads design pattern
__global__ void processFrame(unsigned char* d_input, unsigned char* d_output, int width, int height, int channels) {
    // Calculate the x and y indices for the current thread
    int x = blockIdx.x * blockDim.x + threadIdx.x;
    int y = blockIdx.y * blockDim.y + threadIdx.y;

    // Calculate the index for the current pixel
    int idx = (y * width + x) * channels;

    // Check if the current thread is within the bounds of the image
    if (x < width && y < height) {
        // Example processing: convert to grayscale
        unsigned char r = d_input[idx];
        unsigned char g = d_input[idx + 1];
        unsigned char b = d_input[idx + 2];
        unsigned char gray = static_cast<unsigned char>(0.299f * r + 0.587f * g + 0.114f * b);

        // Write the grayscale value to the output image
        d_output[idx] = gray;
        d_output[idx + 1] = gray;
        d_output[idx + 2] = gray;
        d_output[idx + 3] = d_input[idx + 3]; // Preserve alpha channel
    }
}

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

int main() {
    // Initialize input and output data
    std::vector<unsigned char> h_input(WIDTH * HEIGHT * CHANNELS, 0);
    std::vector<unsigned char> h_output(WIDTH * HEIGHT * CHANNELS, 0);

    // Fill input with dummy data (e.g., a solid color)
    for (int i = 0; i < WIDTH * HEIGHT * CHANNELS; i += CHANNELS) {
        h_input[i] = 255; // R
        h_input[i + 1] = 0; // G
        h_input[i + 2] = 0; // B
        h_input[i + 3] = 255; // A
    }

    // Allocate device memory
    unsigned char* d_input;
    unsigned char* d_output;
    checkCudaError(cudaMalloc(&d_input, WIDTH * HEIGHT * CHANNELS * sizeof(unsigned char)), __FILE__, __LINE__);
    checkCudaError(cudaMalloc(&d_output, WIDTH * HEIGHT * CHANNELS * sizeof(unsigned char)), __FILE__, __LINE__);

    // Copy input data to device
    checkCudaError(cudaMemcpy(d_input, h_input.data(), WIDTH * HEIGHT * CHANNELS * sizeof(unsigned char), cudaMemcpyHostToDevice), __FILE__, __LINE__);

    // Set up the grid and block dimensions
    dim3 blockSize(BLOCK_WIDTH, BLOCK_HEIGHT);
    dim3 gridSize((WIDTH + BLOCK_WIDTH - 1) / BLOCK_WIDTH, (HEIGHT + BLOCK_HEIGHT - 1) / BLOCK_HEIGHT);

    // Launch the kernel
    processFrame<<<gridSize, blockSize>>>(d_input, d_output, WIDTH, HEIGHT, CHANNELS);
    checkCudaError(cudaGetLastError(), __FILE__, __LINE__);
    checkCudaError(cudaDeviceSynchronize(), __FILE__, __LINE__);

    // Copy output data back to host
    checkCudaError(cudaMemcpy(h_output.data(), d_output, WIDTH * HEIGHT * CHANNELS * sizeof(unsigned char), cudaMemcpyDeviceToHost), __FILE__, __LINE__);

    // Free device memory
    checkCudaError(cudaFree(d_input), __FILE__, __LINE__);
    checkCudaError(cudaFree(d_output), __FILE__, __LINE__);

    // Output a small part of the result to verify
    std::cout << "Processed pixel (0,0): "
              << static_cast<int>(h_output[0]) << ", "
              << static_cast<int>(h_output[1]) << ", "
              << static_cast<int>(h_output[2]) << ", "
              << static_cast<int>(h_output[3]) << std::endl;

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

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB4002:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE4002:
	.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:
.LFB3998:
	.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
.LFE3998:
	.size	_Z14checkCudaError9cudaErrorPKci, .-_Z14checkCudaError9cudaErrorPKci
	.globl	_Z37__device_stub__Z12processFramePhS_iiiPhS_iii
	.type	_Z37__device_stub__Z12processFramePhS_iiiPhS_iii, @function
_Z37__device_stub__Z12processFramePhS_iiiPhS_iii:
.LFB4024:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	32(%rsp), %rdx
	movl	%ecx, 8(%rsp)
	leaq	40(%rsp), %rcx
	movl	%r8d, 4(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 136(%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)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 128(%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 168
	leaq	_Z12processFramePhS_iii(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 176
	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 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L8:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4024:
	.size	_Z37__device_stub__Z12processFramePhS_iiiPhS_iii, .-_Z37__device_stub__Z12processFramePhS_iiiPhS_iii
	.globl	_Z12processFramePhS_iii
	.type	_Z12processFramePhS_iii, @function
_Z12processFramePhS_iii:
.LFB4025:
	.cfi_startproc
	endbr64
	jmp	_Z37__device_stub__Z12processFramePhS_iiiPhS_iii
	.cfi_endproc
.LFE4025:
	.size	_Z12processFramePhS_iii, .-_Z12processFramePhS_iii
	.section	.rodata.str1.1
.LC3:
	.string	"_Z12processFramePhS_iii"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB4027:
	.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	_Z12processFramePhS_iii(%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
.LFE4027:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.rodata._ZNSt6vectorIhSaIhEEC2EmRKhRKS0_.str1.1,"aMS",@progbits,1
.LC4:
	.string	"cannot create std::vector larger than max_size()"
	.section	.text._ZNSt6vectorIhSaIhEEC2EmRKhRKS0_,"axG",@progbits,_ZNSt6vectorIhSaIhEEC5EmRKhRKS0_,comdat
	.align 2
	.weak	_ZNSt6vectorIhSaIhEEC2EmRKhRKS0_
	.type	_ZNSt6vectorIhSaIhEEC2EmRKhRKS0_, @function
_ZNSt6vectorIhSaIhEEC2EmRKhRKS0_:
.LFB4337:
	.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
	testq	%rsi, %rsi
	jns	.L16
	leaq	.LC4(%rip), %rdi
	call	_ZSt20__throw_length_errorPKc@PLT
.L16:
	movq	$0, (%rdi)
	movq	%rdi, %rbp
	movq	%rsi, %rbx
	movq	%rdx, %r12
	movq	$0, 8(%rdi)
	movl	$0, %r8d
	movq	$0, 16(%rdi)
	je	.L17
	movq	%rsi, %rdi
	call	_Znwm@PLT
	movq	%rax, %r8
.L17:
	leaq	(%r8,%rbx), %rdx
	movq	%r8, 0(%rbp)
	movq	%rdx, 16(%rbp)
	testq	%rbx, %rbx
	je	.L18
	movb	(%r12), %al
	movq	%r8, %rdi
	movq	%rbx, %rcx
	movq	%rdx, %r8
	rep stosb
.L18:
	movq	%r8, 8(%rbp)
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4337:
	.size	_ZNSt6vectorIhSaIhEEC2EmRKhRKS0_, .-_ZNSt6vectorIhSaIhEEC2EmRKhRKS0_
	.weak	_ZNSt6vectorIhSaIhEEC1EmRKhRKS0_
	.set	_ZNSt6vectorIhSaIhEEC1EmRKhRKS0_,_ZNSt6vectorIhSaIhEEC2EmRKhRKS0_
	.section	.text._ZNSt6vectorIhSaIhEED2Ev,"axG",@progbits,_ZNSt6vectorIhSaIhEED5Ev,comdat
	.align 2
	.weak	_ZNSt6vectorIhSaIhEED2Ev
	.type	_ZNSt6vectorIhSaIhEED2Ev, @function
_ZNSt6vectorIhSaIhEED2Ev:
.LFB4340:
	.cfi_startproc
	endbr64
	movq	(%rdi), %rax
	testq	%rax, %rax
	je	.L25
	movq	16(%rdi), %rsi
	movq	%rax, %rdi
	subq	%rax, %rsi
	jmp	_ZdlPvm@PLT
.L25:
	ret
	.cfi_endproc
.LFE4340:
	.size	_ZNSt6vectorIhSaIhEED2Ev, .-_ZNSt6vectorIhSaIhEED2Ev
	.weak	_ZNSt6vectorIhSaIhEED1Ev
	.set	_ZNSt6vectorIhSaIhEED1Ev,_ZNSt6vectorIhSaIhEED2Ev
	.section	.rodata.str1.1
.LC5:
	.string	"/home/ubuntu/Datasets/cuda-codes-80k-from-llm-dedup/cuda_code_018394.cu"
.LC6:
	.string	"Processed pixel (0,0): "
.LC7:
	.string	", "
	.section	.text.startup
	.globl	main
	.type	main, @function
main:
.LFB3999:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA3999
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	$33177600, %esi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$104, %rsp
	.cfi_def_cfa_offset 144
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	leaq	64(%rsp), %r12
	leaq	28(%rsp), %rbx
	movb	$0, 28(%rsp)
	leaq	40(%rsp), %rbp
	movq	%r12, %rcx
	movq	%rbx, %rdx
	movq	%rbp, %rdi
.LEHB0:
	call	_ZNSt6vectorIhSaIhEEC1EmRKhRKS0_
.LEHE0:
	leaq	16(%rsp), %rdx
	movq	%rbx, %rcx
	movq	%r12, %rdi
	movl	$33177600, %esi
	movb	$0, 16(%rsp)
.LEHB1:
	call	_ZNSt6vectorIhSaIhEEC1EmRKhRKS0_
.LEHE1:
	movq	40(%rsp), %r13
	movq	%r13, %rax
	leaq	33177600(%r13), %rdx
.L28:
	movb	$-1, (%rax)
	addq	$4, %rax
	movb	$0, -3(%rax)
	movb	$0, -2(%rax)
	movb	$-1, -1(%rax)
	cmpq	%rdx, %rax
	jne	.L28
	movq	%rsp, %rdi
	movl	$33177600, %esi
.LEHB2:
	call	cudaMalloc@PLT
	leaq	.LC5(%rip), %rbx
	movl	%eax, %edi
	movl	$61, %edx
	movq	%rbx, %rsi
	call	_Z14checkCudaError9cudaErrorPKci
	leaq	8(%rsp), %rdi
	movl	$33177600, %esi
	call	cudaMalloc@PLT
	movl	%eax, %edi
	movl	$62, %edx
	movq	%rbx, %rsi
	call	_Z14checkCudaError9cudaErrorPKci
	movq	(%rsp), %rdi
	movl	$1, %ecx
	movl	$33177600, %edx
	movq	%r13, %rsi
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	movl	$65, %edx
	movq	%rbx, %rsi
	call	_Z14checkCudaError9cudaErrorPKci
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$1, %ecx
	movl	$1, %esi
	movabsq	$68719476752, %rdx
	movl	$1, 24(%rsp)
	movabsq	$579820585200, %rdi
	movq	%rdx, 16(%rsp)
	movq	%rdi, 28(%rsp)
	movl	$1, 36(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	je	.L29
.L31:
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	movl	$73, %edx
	movq	%rbx, %rsi
	call	_Z14checkCudaError9cudaErrorPKci
	jmp	.L42
.L29:
	movq	8(%rsp), %rsi
	movq	(%rsp), %rdi
	movl	$4, %r8d
	movl	$2160, %ecx
	movl	$3840, %edx
	call	_Z37__device_stub__Z12processFramePhS_iiiPhS_iii
	jmp	.L31
.L42:
	call	cudaDeviceSynchronize@PLT
	movl	%eax, %edi
	movl	$74, %edx
	movq	%rbx, %rsi
	call	_Z14checkCudaError9cudaErrorPKci
	movq	64(%rsp), %r13
	movq	8(%rsp), %rsi
	movl	$2, %ecx
	movl	$33177600, %edx
	movq	%r13, %rdi
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	movl	$77, %edx
	movq	%rbx, %rsi
	call	_Z14checkCudaError9cudaErrorPKci
	movq	(%rsp), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	movl	$80, %edx
	movq	%rbx, %rsi
	call	_Z14checkCudaError9cudaErrorPKci
	movq	8(%rsp), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	movl	$81, %edx
	movq	%rbx, %rsi
	call	_Z14checkCudaError9cudaErrorPKci
	leaq	.LC6(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movzbl	0(%r13), %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	leaq	.LC7(%rip), %rbx
	movq	%rax, %rdi
	movq	%rbx, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movzbl	1(%r13), %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	movq	%rax, %rdi
	movq	%rbx, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movzbl	2(%r13), %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	movq	%rax, %rdi
	movq	%rbx, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movzbl	3(%r13), %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
.LEHE2:
	movq	%r12, %rdi
	call	_ZNSt6vectorIhSaIhEED1Ev
	movq	%rbp, %rdi
	call	_ZNSt6vectorIhSaIhEED1Ev
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L35
	jmp	.L40
.L37:
	endbr64
	movq	%rax, %rbx
.L32:
	movq	%r12, %rdi
	call	_ZNSt6vectorIhSaIhEED1Ev
	jmp	.L33
.L36:
	endbr64
	movq	%rax, %rbx
.L33:
	movq	%rbp, %rdi
	call	_ZNSt6vectorIhSaIhEED1Ev
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L40
	movq	%rbx, %rdi
.LEHB3:
	call	_Unwind_Resume@PLT
.LEHE3:
.L40:
	call	__stack_chk_fail@PLT
.L35:
	addq	$104, %rsp
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3999:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table,"a",@progbits
.LLSDA3999:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE3999-.LLSDACSB3999
.LLSDACSB3999:
	.uleb128 .LEHB0-.LFB3999
	.uleb128 .LEHE0-.LEHB0
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB1-.LFB3999
	.uleb128 .LEHE1-.LEHB1
	.uleb128 .L36-.LFB3999
	.uleb128 0
	.uleb128 .LEHB2-.LFB3999
	.uleb128 .LEHE2-.LEHB2
	.uleb128 .L37-.LFB3999
	.uleb128 0
	.uleb128 .LEHB3-.LFB3999
	.uleb128 .LEHE3-.LEHB3
	.uleb128 0
	.uleb128 0
.LLSDACSE3999:
	.section	.text.startup
	.size	main, .-main
	.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
	.hidden	DW.ref.__gxx_personality_v0
	.weak	DW.ref.__gxx_personality_v0
	.section	.data.rel.local.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat
	.align 8
	.type	DW.ref.__gxx_personality_v0, @object
	.size	DW.ref.__gxx_personality_v0, 8
DW.ref.__gxx_personality_v0:
	.quad	__gxx_personality_v0
	.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 <vector>

// Define constants
#define WIDTH 3840
#define HEIGHT 2160
#define CHANNELS 4
#define BLOCK_WIDTH 16
#define BLOCK_HEIGHT 16

// Kernel function using persistent threads design pattern
__global__ void processFrame(unsigned char* d_input, unsigned char* d_output, int width, int height, int channels) {
    // Calculate the x and y indices for the current thread
    int x = blockIdx.x * blockDim.x + threadIdx.x;
    int y = blockIdx.y * blockDim.y + threadIdx.y;

    // Calculate the index for the current pixel
    int idx = (y * width + x) * channels;

    // Check if the current thread is within the bounds of the image
    if (x < width && y < height) {
        // Example processing: convert to grayscale
        unsigned char r = d_input[idx];
        unsigned char g = d_input[idx + 1];
        unsigned char b = d_input[idx + 2];
        unsigned char gray = static_cast<unsigned char>(0.299f * r + 0.587f * g + 0.114f * b);

        // Write the grayscale value to the output image
        d_output[idx] = gray;
        d_output[idx + 1] = gray;
        d_output[idx + 2] = gray;
        d_output[idx + 3] = d_input[idx + 3]; // Preserve alpha channel
    }
}

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

int main() {
    // Initialize input and output data
    std::vector<unsigned char> h_input(WIDTH * HEIGHT * CHANNELS, 0);
    std::vector<unsigned char> h_output(WIDTH * HEIGHT * CHANNELS, 0);

    // Fill input with dummy data (e.g., a solid color)
    for (int i = 0; i < WIDTH * HEIGHT * CHANNELS; i += CHANNELS) {
        h_input[i] = 255; // R
        h_input[i + 1] = 0; // G
        h_input[i + 2] = 0; // B
        h_input[i + 3] = 255; // A
    }

    // Allocate device memory
    unsigned char* d_input;
    unsigned char* d_output;
    checkCudaError(hipMalloc(&d_input, WIDTH * HEIGHT * CHANNELS * sizeof(unsigned char)), __FILE__, __LINE__);
    checkCudaError(hipMalloc(&d_output, WIDTH * HEIGHT * CHANNELS * sizeof(unsigned char)), __FILE__, __LINE__);

    // Copy input data to device
    checkCudaError(hipMemcpy(d_input, h_input.data(), WIDTH * HEIGHT * CHANNELS * sizeof(unsigned char), hipMemcpyHostToDevice), __FILE__, __LINE__);

    // Set up the grid and block dimensions
    dim3 blockSize(BLOCK_WIDTH, BLOCK_HEIGHT);
    dim3 gridSize((WIDTH + BLOCK_WIDTH - 1) / BLOCK_WIDTH, (HEIGHT + BLOCK_HEIGHT - 1) / BLOCK_HEIGHT);

    // Launch the kernel
    processFrame<<<gridSize, blockSize>>>(d_input, d_output, WIDTH, HEIGHT, CHANNELS);
    checkCudaError(hipGetLastError(), __FILE__, __LINE__);
    checkCudaError(hipDeviceSynchronize(), __FILE__, __LINE__);

    // Copy output data back to host
    checkCudaError(hipMemcpy(h_output.data(), d_output, WIDTH * HEIGHT * CHANNELS * sizeof(unsigned char), hipMemcpyDeviceToHost), __FILE__, __LINE__);

    // Free device memory
    checkCudaError(hipFree(d_input), __FILE__, __LINE__);
    checkCudaError(hipFree(d_output), __FILE__, __LINE__);

    // Output a small part of the result to verify
    std::cout << "Processed pixel (0,0): "
              << static_cast<int>(h_output[0]) << ", "
              << static_cast<int>(h_output[1]) << ", "
              << static_cast<int>(h_output[2]) << ", "
              << static_cast<int>(h_output[3]) << std::endl;

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

                                        # End of file scope inline assembly
	.globl	_Z27__device_stub__processFramePhS_iii # -- Begin function _Z27__device_stub__processFramePhS_iii
	.type	_Z27__device_stub__processFramePhS_iii,@function
_Z27__device_stub__processFramePhS_iii: # @_Z27__device_stub__processFramePhS_iii
	.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	$128, %rsp
	.cfi_def_cfa_offset 176
	.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), %rdi
	movq	%rsi, (%rdi)
	leaq	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	8(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	4(%rsp), %rcx
	movl	%r8d, (%rcx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%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	$_Z12processFramePhS_iii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$144, %rsp
	.cfi_adjust_cfa_offset -144
	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	_Z27__device_stub__processFramePhS_iii, .Lfunc_end0-_Z27__device_stub__processFramePhS_iii
	.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
.Lfunc_begin0:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception0
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	$33177600, %edi                 # imm = 0x1FA4000
	callq	_Znwm
	movq	%rax, %rbx
	movl	$33177600, %edx                 # imm = 0x1FA4000
	movq	%rax, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
.Ltmp0:
	movl	$33177600, %edi                 # imm = 0x1FA4000
	callq	_Znwm
.Ltmp1:
# %bb.1:
	movq	%rax, %r14
	movl	$33177600, %edx                 # imm = 0x1FA4000
	movq	%rax, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
	movq	$-4, %rax
.LBB2_2:                                # =>This Inner Loop Header: Depth=1
	movl	$-16776961, 4(%rbx,%rax)        # imm = 0xFF0000FF
	addq	$4, %rax
	cmpq	$33177596, %rax                 # imm = 0x1FA3FFC
	jb	.LBB2_2
# %bb.3:
.Ltmp3:
	leaq	8(%rsp), %rdi
	movl	$33177600, %esi                 # imm = 0x1FA4000
	callq	hipMalloc
.Ltmp4:
# %bb.4:                                # %_ZL9hipMallocIhE10hipError_tPPT_m.exit
.Ltmp5:
	movl	$.L.str.3, %esi
	movl	%eax, %edi
	movl	$61, %edx
	callq	_Z14checkCudaError10hipError_tPKci
.Ltmp6:
# %bb.5:
.Ltmp7:
	movq	%rsp, %rdi
	movl	$33177600, %esi                 # imm = 0x1FA4000
	callq	hipMalloc
.Ltmp8:
# %bb.6:                                # %_ZL9hipMallocIhE10hipError_tPPT_m.exit22
.Ltmp9:
	movl	$.L.str.3, %esi
	movl	%eax, %edi
	movl	$62, %edx
	callq	_Z14checkCudaError10hipError_tPKci
.Ltmp10:
# %bb.7:
	movq	8(%rsp), %rdi
.Ltmp11:
	movl	$33177600, %edx                 # imm = 0x1FA4000
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
.Ltmp12:
# %bb.8:
.Ltmp13:
	movl	$.L.str.3, %esi
	movl	%eax, %edi
	movl	$65, %edx
	callq	_Z14checkCudaError10hipError_tPKci
.Ltmp14:
# %bb.9:
.Ltmp16:
	movabsq	$579820585200, %rdi             # imm = 0x87000000F0
	movabsq	$68719476752, %rdx              # imm = 0x1000000010
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
.Ltmp17:
# %bb.10:
	testl	%eax, %eax
	jne	.LBB2_12
# %bb.11:
	movq	8(%rsp), %rdi
	movq	(%rsp), %rsi
.Ltmp18:
	movl	$3840, %edx                     # imm = 0xF00
	movl	$2160, %ecx                     # imm = 0x870
	movl	$4, %r8d
	callq	_Z27__device_stub__processFramePhS_iii
.Ltmp19:
.LBB2_12:
.Ltmp20:
	callq	hipGetLastError
.Ltmp21:
# %bb.13:
.Ltmp22:
	movl	$.L.str.3, %esi
	movl	%eax, %edi
	movl	$73, %edx
	callq	_Z14checkCudaError10hipError_tPKci
.Ltmp23:
# %bb.14:
.Ltmp24:
	callq	hipDeviceSynchronize
.Ltmp25:
# %bb.15:
.Ltmp26:
	movl	$.L.str.3, %esi
	movl	%eax, %edi
	movl	$74, %edx
	callq	_Z14checkCudaError10hipError_tPKci
.Ltmp27:
# %bb.16:
	movq	(%rsp), %rsi
.Ltmp28:
	movl	$33177600, %edx                 # imm = 0x1FA4000
	movq	%r14, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
.Ltmp29:
# %bb.17:
.Ltmp30:
	movl	$.L.str.3, %esi
	movl	%eax, %edi
	movl	$77, %edx
	callq	_Z14checkCudaError10hipError_tPKci
.Ltmp31:
# %bb.18:
	movq	8(%rsp), %rdi
.Ltmp32:
	callq	hipFree
.Ltmp33:
# %bb.19:
.Ltmp34:
	movl	$.L.str.3, %esi
	movl	%eax, %edi
	movl	$80, %edx
	callq	_Z14checkCudaError10hipError_tPKci
.Ltmp35:
# %bb.20:
	movq	(%rsp), %rdi
.Ltmp36:
	callq	hipFree
.Ltmp37:
# %bb.21:
.Ltmp38:
	movl	$.L.str.3, %esi
	movl	%eax, %edi
	movl	$81, %edx
	callq	_Z14checkCudaError10hipError_tPKci
.Ltmp39:
# %bb.22:
.Ltmp40:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.4, %esi
	movl	$23, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp41:
# %bb.23:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit
	movzbl	(%r14), %esi
.Ltmp42:
	movl	$_ZSt4cout, %edi
	callq	_ZNSolsEi
.Ltmp43:
# %bb.24:
.Ltmp44:
	movq	%rax, %r15
	movl	$.L.str.5, %esi
	movl	$2, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp45:
# %bb.25:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit23
	movzbl	1(%r14), %esi
.Ltmp46:
	movq	%r15, %rdi
	callq	_ZNSolsEi
.Ltmp47:
# %bb.26:
.Ltmp48:
	movq	%rax, %r15
	movl	$.L.str.5, %esi
	movl	$2, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp49:
# %bb.27:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit24
	movzbl	2(%r14), %esi
.Ltmp50:
	movq	%r15, %rdi
	callq	_ZNSolsEi
.Ltmp51:
# %bb.28:
.Ltmp52:
	movq	%rax, %r15
	movl	$.L.str.5, %esi
	movl	$2, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp53:
# %bb.29:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit25
	movzbl	3(%r14), %esi
.Ltmp54:
	movq	%r15, %rdi
	callq	_ZNSolsEi
.Ltmp55:
# %bb.30:
	movq	%rax, %r15
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r15, %rdi
.Ltmp56:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp57:
# %bb.31:                               # %.noexc
.Ltmp58:
	movsbl	%al, %esi
	movq	%r15, %rdi
	callq	_ZNSo3putEc
.Ltmp59:
# %bb.32:                               # %.noexc33
.Ltmp60:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp61:
# %bb.33:                               # %_ZNSt6vectorIhSaIhEED2Ev.exit27
	movq	%r14, %rdi
	callq	_ZdlPv
	movq	%rbx, %rdi
	callq	_ZdlPv
	xorl	%eax, %eax
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.LBB2_37:
	.cfi_def_cfa_offset 48
.Ltmp2:
	movq	%rax, %r15
	jmp	.LBB2_36
.LBB2_34:
.Ltmp15:
	jmp	.LBB2_35
.LBB2_38:
.Ltmp62:
.LBB2_35:                               # %_ZNSt6vectorIhSaIhEED2Ev.exit29
	movq	%rax, %r15
	movq	%r14, %rdi
	callq	_ZdlPv
.LBB2_36:                               # %_ZNSt6vectorIhSaIhEED2Ev.exit31
	movq	%rbx, %rdi
	callq	_ZdlPv
	movq	%r15, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end2:
	.size	main, .Lfunc_end2-main
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table2:
.Lexception0:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end0-.Lcst_begin0
.Lcst_begin0:
	.uleb128 .Lfunc_begin0-.Lfunc_begin0    # >> Call Site 1 <<
	.uleb128 .Ltmp0-.Lfunc_begin0           #   Call between .Lfunc_begin0 and .Ltmp0
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp0-.Lfunc_begin0           # >> Call Site 2 <<
	.uleb128 .Ltmp1-.Ltmp0                  #   Call between .Ltmp0 and .Ltmp1
	.uleb128 .Ltmp2-.Lfunc_begin0           #     jumps to .Ltmp2
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp1-.Lfunc_begin0           # >> Call Site 3 <<
	.uleb128 .Ltmp3-.Ltmp1                  #   Call between .Ltmp1 and .Ltmp3
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp3-.Lfunc_begin0           # >> Call Site 4 <<
	.uleb128 .Ltmp14-.Ltmp3                 #   Call between .Ltmp3 and .Ltmp14
	.uleb128 .Ltmp15-.Lfunc_begin0          #     jumps to .Ltmp15
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp16-.Lfunc_begin0          # >> Call Site 5 <<
	.uleb128 .Ltmp61-.Ltmp16                #   Call between .Ltmp16 and .Ltmp61
	.uleb128 .Ltmp62-.Lfunc_begin0          #     jumps to .Ltmp62
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp61-.Lfunc_begin0          # >> Call Site 6 <<
	.uleb128 .Lfunc_end2-.Ltmp61            #   Call between .Ltmp61 and .Lfunc_end2
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end0:
	.p2align	2, 0x0
                                        # -- End function
	.text
	.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	.LBB3_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB3_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z12processFramePhS_iii, %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_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	_Z12processFramePhS_iii,@object # @_Z12processFramePhS_iii
	.section	.rodata,"a",@progbits
	.globl	_Z12processFramePhS_iii
	.p2align	3, 0x0
_Z12processFramePhS_iii:
	.quad	_Z27__device_stub__processFramePhS_iii
	.size	_Z12processFramePhS_iii, 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	"/home/ubuntu/Datasets/hip-codes-80k-from-llm-dedup-disassemble-sm89/cuda_code_018394.hip"
	.size	.L.str.3, 89

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"Processed pixel (0,0): "
	.size	.L.str.4, 24

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	", "
	.size	.L.str.5, 3

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z12processFramePhS_iii"
	.size	.L__unnamed_1, 24

	.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 _Z27__device_stub__processFramePhS_iii
	.addrsig_sym __gxx_personality_v0
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Unwind_Resume
	.addrsig_sym _Z12processFramePhS_iii
	.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	_Z12processFramePhS_iii ; -- Begin function _Z12processFramePhS_iii
	.globl	_Z12processFramePhS_iii
	.p2align	8
	.type	_Z12processFramePhS_iii,@function
_Z12processFramePhS_iii:                ; @_Z12processFramePhS_iii
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x2c
	s_load_b128 s[4:7], s[0:1], 0x10
	v_and_b32_e32 v2, 0x3ff, v0
	v_bfe_u32 v3, v0, 10, 10
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s3, s2, 16
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_mad_u64_u32 v[0:1], null, s14, s2, v[2:3]
	v_mad_u64_u32 v[1:2], null, s15, s3, v[3:4]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cmp_gt_i32_e32 vcc_lo, s4, v0
	v_cmp_gt_i32_e64 s2, s5, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s2, vcc_lo, s2
	s_and_saveexec_b32 s3, s2
	s_cbranch_execz .LBB0_2
; %bb.1:
	s_load_b128 s[0:3], s[0:1], 0x0
	v_mad_u64_u32 v[2:3], null, v1, s4, v[0:1]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_lo_u32 v2, v2, s6
	v_ashrrev_i32_e32 v3, 31, v2
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v0, vcc_lo, s0, v2
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v3, vcc_lo
	v_add_co_u32 v2, vcc_lo, s2, v2
	v_add_co_ci_u32_e32 v3, vcc_lo, s3, v3, vcc_lo
	s_clause 0x1
	global_load_u16 v4, v[0:1], off
	global_load_u8 v5, v[0:1], off offset:2
	s_waitcnt vmcnt(1)
	v_cvt_f32_ubyte1_e32 v6, v4
	v_cvt_f32_ubyte0_e32 v4, v4
	s_waitcnt vmcnt(0)
	v_cvt_f32_ubyte0_e32 v5, v5
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f32_e32 v6, 0x3f1645a2, v6
	v_fmamk_f32 v4, v4, 0x3e991687, v6
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmamk_f32 v4, v5, 0x3de978d5, v4
	v_cvt_i32_f32_e32 v4, v4
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b16 v5, 8, v4
	v_or_b32_e32 v5, v4, v5
	s_clause 0x1
	global_store_b8 v[2:3], v4, off offset:2
	global_store_b16 v[2:3], v5, off
	global_load_u8 v0, v[0:1], off offset:3
	s_waitcnt vmcnt(0)
	global_store_b8 v[2:3], v0, off offset:3
.LBB0_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z12processFramePhS_iii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 288
		.amdhsa_user_sgpr_count 14
		.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 1
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.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	_Z12processFramePhS_iii, .Lfunc_end0-_Z12processFramePhS_iii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 312
; 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: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.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:
      - .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:         20
        .size:           4
        .value_kind:     by_value
      - .offset:         24
        .size:           4
        .value_kind:     by_value
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         36
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         44
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         46
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         48
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         50
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         52
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         54
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         96
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 288
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z12processFramePhS_iii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z12processFramePhS_iii.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
