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

// Define the grid size and block size
#define GRID_SIZE 32
#define BLOCK_SIZE 256
#define N 8192

// Kernel to perform fluid simulation using finite volume method
__global__ void fluidSimulationKernel(float* density, float* velocity, float* pressure, float dt, float dx) {
    // Calculate the global thread index
    int idx = blockIdx.x * blockDim.x + threadIdx.x;

    // Check if the index is within bounds
    if (idx >= N) return;

    // Atomic operations to update density, velocity, and pressure
    float newDensity = atomicAdd(&density[idx], dt * velocity[idx] * density[idx] / dx);
    float newVelocity = atomicAdd(&velocity[idx], dt * (pressure[idx + 1] - pressure[idx]) / dx);
    float newPressure = atomicAdd(&pressure[idx], dt * (velocity[idx + 1] - velocity[idx]) / dx);

    // Update the values
    density[idx] = newDensity;
    velocity[idx] = newVelocity;
    pressure[idx] = newPressure;
}

// Check for CUDA errors
void checkCudaError(cudaError_t err, const char* msg) {
    if (err != cudaSuccess) {
        std::cerr << "CUDA error: " << msg << " (" << cudaGetErrorString(err) << ")" << std::endl;
        exit(EXIT_FAILURE);
    }
}

int main() {
    // Allocate memory for density, velocity, and pressure on the host
    std::vector<float> h_density(N, 1.0f);
    std::vector<float> h_velocity(N, 0.1f);
    std::vector<float> h_pressure(N, 0.0f);

    // Allocate memory for density, velocity, and pressure on the device
    float* d_density;
    float* d_velocity;
    float* d_pressure;
    checkCudaError(cudaMalloc(&d_density, N * sizeof(float)), "cudaMalloc d_density");
    checkCudaError(cudaMalloc(&d_velocity, N * sizeof(float)), "cudaMalloc d_velocity");
    checkCudaError(cudaMalloc(&d_pressure, N * sizeof(float)), "cudaMalloc d_pressure");

    // Copy data from host to device
    checkCudaError(cudaMemcpy(d_density, h_density.data(), N * sizeof(float), cudaMemcpyHostToDevice), "cudaMemcpy d_density");
    checkCudaError(cudaMemcpy(d_velocity, h_velocity.data(), N * sizeof(float), cudaMemcpyHostToDevice), "cudaMemcpy d_velocity");
    checkCudaError(cudaMemcpy(d_pressure, h_pressure.data(), N * sizeof(float), cudaMemcpyHostToDevice), "cudaMemcpy d_pressure");

    // Define simulation parameters
    float dt = 0.01f; // Time step
    float dx = 1.0f;  // Spatial step

    // Launch the kernel
    fluidSimulationKernel<<<GRID_SIZE, BLOCK_SIZE>>>(d_density, d_velocity, d_pressure, dt, dx);
    checkCudaError(cudaGetLastError(), "fluidSimulationKernel launch");
    checkCudaError(cudaDeviceSynchronize(), "cudaDeviceSynchronize");

    // Copy results back to host
    checkCudaError(cudaMemcpy(h_density.data(), d_density, N * sizeof(float), cudaMemcpyDeviceToHost), "cudaMemcpy h_density");
    checkCudaError(cudaMemcpy(h_velocity.data(), d_velocity, N * sizeof(float), cudaMemcpyDeviceToHost), "cudaMemcpy h_velocity");
    checkCudaError(cudaMemcpy(h_pressure.data(), d_pressure, N * sizeof(float), cudaMemcpyDeviceToHost), "cudaMemcpy h_pressure");

    // Free device memory
    checkCudaError(cudaFree(d_density), "cudaFree d_density");
    checkCudaError(cudaFree(d_velocity), "cudaFree d_velocity");
    checkCudaError(cudaFree(d_pressure), "cudaFree d_pressure");

    // Print the first 10 values of density, velocity, and pressure as a simple check
    std::cout << "Density: ";
    for (int i = 0; i < 10; ++i) std::cout << h_density[i] << " ";
    std::cout << "\nVelocity: ";
    for (int i = 0; i < 10; ++i) std::cout << h_velocity[i] << " ";
    std::cout << "\nPressure: ";
    for (int i = 0; i < 10; ++i) std::cout << h_pressure[i] << " ";
    std::cout << std::endl;

    return 0;
}
	.file	"tmpxft_00008fc0_00000000-6_cuda_code_021313.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: "
.LC1:
	.string	" ("
.LC2:
	.string	")"
	.text
	.globl	_Z14checkCudaError9cudaErrorPKc
	.type	_Z14checkCudaError9cudaErrorPKc, @function
_Z14checkCudaError9cudaErrorPKc:
.LFB3998:
	.cfi_startproc
	endbr64
	testl	%edi, %edi
	je	.L2
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsi, %rbp
	leaq	.LC0(%rip), %rsi
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movl	%edi, %ebx
	leaq	_ZSt4cerr(%rip), %rdi
	pushq	%rax
	.cfi_def_cfa_offset 32
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rbp, %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	%ebx, %edi
	movq	%rax, %rbp
	call	cudaGetErrorString@PLT
	movq	%rbp, %rdi
	movq	%rax, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC2(%rip), %rsi
	movq	%rax, %rdi
	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
	ret
	.cfi_endproc
.LFE3998:
	.size	_Z14checkCudaError9cudaErrorPKc, .-_Z14checkCudaError9cudaErrorPKc
	.globl	_Z47__device_stub__Z21fluidSimulationKernelPfS_S_ffPfS_S_ff
	.type	_Z47__device_stub__Z21fluidSimulationKernelPfS_S_ffPfS_S_ff, @function
_Z47__device_stub__Z21fluidSimulationKernelPfS_S_ffPfS_S_ff:
.LFB4024:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	40(%rsp), %rcx
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	32(%rsp), %rdx
	movss	%xmm0, 4(%rsp)
	movss	%xmm1, (%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	8(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 120(%rsp)
	movq	%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	_Z21fluidSimulationKernelPfS_S_ff(%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	_Z47__device_stub__Z21fluidSimulationKernelPfS_S_ffPfS_S_ff, .-_Z47__device_stub__Z21fluidSimulationKernelPfS_S_ffPfS_S_ff
	.globl	_Z21fluidSimulationKernelPfS_S_ff
	.type	_Z21fluidSimulationKernelPfS_S_ff, @function
_Z21fluidSimulationKernelPfS_S_ff:
.LFB4025:
	.cfi_startproc
	endbr64
	jmp	_Z47__device_stub__Z21fluidSimulationKernelPfS_S_ffPfS_S_ff
	.cfi_endproc
.LFE4025:
	.size	_Z21fluidSimulationKernelPfS_S_ff, .-_Z21fluidSimulationKernelPfS_S_ff
	.section	.rodata.str1.1
.LC3:
	.string	"_Z21fluidSimulationKernelPfS_S_ff"
	.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	_Z21fluidSimulationKernelPfS_S_ff(%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._ZNSt6vectorIfSaIfEEC2EmRKfRKS0_.str1.1,"aMS",@progbits,1
.LC4:
	.string	"cannot create std::vector larger than max_size()"
	.section	.text._ZNSt6vectorIfSaIfEEC2EmRKfRKS0_,"axG",@progbits,_ZNSt6vectorIfSaIfEEC5EmRKfRKS0_,comdat
	.align 2
	.weak	_ZNSt6vectorIfSaIfEEC2EmRKfRKS0_
	.type	_ZNSt6vectorIfSaIfEEC2EmRKfRKS0_, @function
_ZNSt6vectorIfSaIfEEC2EmRKfRKS0_:
.LFB4337:
	.cfi_startproc
	endbr64
	movabsq	$2305843009213693951, %rax
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	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
	pushq	%rcx
	.cfi_def_cfa_offset 48
	cmpq	%rsi, %rax
	jnb	.L16
	leaq	.LC4(%rip), %rdi
	call	_ZSt20__throw_length_errorPKc@PLT
.L16:
	movq	%rdx, %r13
	xorl	%edx, %edx
	movq	%rdi, %rbx
	movq	%rsi, %rbp
	movq	%rdx, (%rdi)
	leaq	0(,%rsi,4), %r12
	xorl	%eax, %eax
	movq	%rdx, 8(%rdi)
	movq	%rdx, 16(%rdi)
	testq	%rsi, %rsi
	je	.L17
	movq	%r12, %rdi
	call	_Znwm@PLT
.L17:
	addq	%rax, %r12
	movq	%rax, (%rbx)
	movq	%r12, 16(%rbx)
	testq	%rbp, %rbp
	je	.L18
	movss	0(%r13), %xmm0
.L19:
	cmpq	%rax, %r12
	je	.L18
	movss	%xmm0, (%rax)
	addq	$4, %rax
	jmp	.L19
.L18:
	movq	%rax, 8(%rbx)
	popq	%rax
	.cfi_def_cfa_offset 40
	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
.LFE4337:
	.size	_ZNSt6vectorIfSaIfEEC2EmRKfRKS0_, .-_ZNSt6vectorIfSaIfEEC2EmRKfRKS0_
	.weak	_ZNSt6vectorIfSaIfEEC1EmRKfRKS0_
	.set	_ZNSt6vectorIfSaIfEEC1EmRKfRKS0_,_ZNSt6vectorIfSaIfEEC2EmRKfRKS0_
	.section	.text._ZNSt6vectorIfSaIfEED2Ev,"axG",@progbits,_ZNSt6vectorIfSaIfEED5Ev,comdat
	.align 2
	.weak	_ZNSt6vectorIfSaIfEED2Ev
	.type	_ZNSt6vectorIfSaIfEED2Ev, @function
_ZNSt6vectorIfSaIfEED2Ev:
.LFB4340:
	.cfi_startproc
	endbr64
	movq	(%rdi), %rax
	testq	%rax, %rax
	je	.L27
	movq	16(%rdi), %rsi
	movq	%rax, %rdi
	subq	%rax, %rsi
	jmp	_ZdlPvm@PLT
.L27:
	ret
	.cfi_endproc
.LFE4340:
	.size	_ZNSt6vectorIfSaIfEED2Ev, .-_ZNSt6vectorIfSaIfEED2Ev
	.weak	_ZNSt6vectorIfSaIfEED1Ev
	.set	_ZNSt6vectorIfSaIfEED1Ev,_ZNSt6vectorIfSaIfEED2Ev
	.section	.rodata.str1.1
.LC8:
	.string	"cudaMalloc d_density"
.LC9:
	.string	"cudaMalloc d_velocity"
.LC10:
	.string	"cudaMalloc d_pressure"
.LC11:
	.string	"cudaMemcpy d_density"
.LC12:
	.string	"cudaMemcpy d_velocity"
.LC13:
	.string	"cudaMemcpy d_pressure"
.LC15:
	.string	"fluidSimulationKernel launch"
.LC16:
	.string	"cudaDeviceSynchronize"
.LC17:
	.string	"cudaMemcpy h_density"
.LC18:
	.string	"cudaMemcpy h_velocity"
.LC19:
	.string	"cudaMemcpy h_pressure"
.LC20:
	.string	"cudaFree d_density"
.LC21:
	.string	"cudaFree d_velocity"
.LC22:
	.string	"cudaFree d_pressure"
.LC23:
	.string	"Density: "
.LC24:
	.string	" "
.LC25:
	.string	"\nVelocity: "
.LC26:
	.string	"\nPressure: "
	.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	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$8192, %esi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$168, %rsp
	.cfi_def_cfa_offset 224
	movq	%fs:40, %rax
	movq	%rax, 152(%rsp)
	xorl	%eax, %eax
	leaq	104(%rsp), %rax
	leaq	68(%rsp), %rbx
	movl	$0x3f800000, 128(%rsp)
	movq	%rax, 16(%rsp)
	leaq	128(%rsp), %rax
	movq	16(%rsp), %rcx
	movq	%rax, 8(%rsp)
	leaq	80(%rsp), %rax
	movq	8(%rsp), %rdx
	movq	%rax, %rdi
	movq	%rax, 24(%rsp)
.LEHB0:
	call	_ZNSt6vectorIfSaIfEEC1EmRKfRKS0_
.LEHE0:
	movq	8(%rsp), %rdx
	movq	16(%rsp), %rdi
	movq	%rbx, %rcx
	movl	$0x3dcccccd, 128(%rsp)
	movl	$8192, %esi
.LEHB1:
	call	_ZNSt6vectorIfSaIfEEC1EmRKfRKS0_
.LEHE1:
	movq	8(%rsp), %rdi
	leaq	56(%rsp), %rcx
	movq	%rbx, %rdx
	movl	$8192, %esi
	movl	$0x00000000, 68(%rsp)
.LEHB2:
	call	_ZNSt6vectorIfSaIfEEC1EmRKfRKS0_
.LEHE2:
	leaq	32(%rsp), %rdi
	movl	$32768, %esi
.LEHB3:
	call	cudaMalloc@PLT
	movl	%eax, %edi
	leaq	.LC8(%rip), %rsi
	call	_Z14checkCudaError9cudaErrorPKc
	leaq	40(%rsp), %rdi
	movl	$32768, %esi
	call	cudaMalloc@PLT
	movl	%eax, %edi
	leaq	.LC9(%rip), %rsi
	call	_Z14checkCudaError9cudaErrorPKc
	leaq	48(%rsp), %rdi
	movl	$32768, %esi
	call	cudaMalloc@PLT
	movl	%eax, %edi
	leaq	.LC10(%rip), %rsi
	call	_Z14checkCudaError9cudaErrorPKc
	movq	80(%rsp), %r15
	movq	32(%rsp), %rdi
	movl	$1, %ecx
	movl	$32768, %edx
	movq	%r15, %rsi
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	leaq	.LC11(%rip), %rsi
	call	_Z14checkCudaError9cudaErrorPKc
	movq	104(%rsp), %r14
	movq	40(%rsp), %rdi
	movl	$1, %ecx
	movl	$32768, %edx
	movq	%r14, %rsi
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	leaq	.LC12(%rip), %rsi
	call	_Z14checkCudaError9cudaErrorPKc
	movq	48(%rsp), %rdi
	movl	$1, %ecx
	movl	$32768, %edx
	movq	128(%rsp), %r12
	movq	%r12, %rsi
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	leaq	.LC13(%rip), %rsi
	call	_Z14checkCudaError9cudaErrorPKc
	movl	$16777217, %edx
	movl	$134217729, %edi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	salq	$8, %rdx
	salq	$5, %rdi
	movl	$1, %ecx
	movl	$1, %esi
	movq	%rdx, 68(%rsp)
	movl	$1, 76(%rsp)
	movq	%rdi, 56(%rsp)
	movl	$1, 64(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	je	.L30
.L32:
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	leaq	.LC15(%rip), %rsi
	call	_Z14checkCudaError9cudaErrorPKc
	jmp	.L50
.L30:
	movss	.LC5(%rip), %xmm1
	movss	.LC14(%rip), %xmm0
	movq	48(%rsp), %rdx
	movq	40(%rsp), %rsi
	movq	32(%rsp), %rdi
	call	_Z47__device_stub__Z21fluidSimulationKernelPfS_S_ffPfS_S_ff
	jmp	.L32
.L50:
	call	cudaDeviceSynchronize@PLT
	movl	%eax, %edi
	leaq	.LC16(%rip), %rsi
	call	_Z14checkCudaError9cudaErrorPKc
	movq	32(%rsp), %rsi
	movl	$2, %ecx
	movl	$32768, %edx
	movq	%r15, %rdi
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	leaq	.LC17(%rip), %rsi
	call	_Z14checkCudaError9cudaErrorPKc
	movq	40(%rsp), %rsi
	movl	$2, %ecx
	movl	$32768, %edx
	movq	%r14, %rdi
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	leaq	.LC18(%rip), %rsi
	call	_Z14checkCudaError9cudaErrorPKc
	movq	48(%rsp), %rsi
	movl	$2, %ecx
	movl	$32768, %edx
	movq	%r12, %rdi
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	leaq	.LC19(%rip), %rsi
	call	_Z14checkCudaError9cudaErrorPKc
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	leaq	.LC20(%rip), %rsi
	call	_Z14checkCudaError9cudaErrorPKc
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	leaq	.LC21(%rip), %rsi
	call	_Z14checkCudaError9cudaErrorPKc
	movq	48(%rsp), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	leaq	.LC22(%rip), %rsi
	call	_Z14checkCudaError9cudaErrorPKc
	leaq	_ZSt4cout(%rip), %rbx
	leaq	.LC23(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	xorl	%ebp, %ebp
	leaq	.LC24(%rip), %r13
.L33:
	movq	%rbx, %rdi
	cvtss2sd	(%r15,%rbp,4), %xmm0
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rax, %rdi
	movq	%r13, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	incq	%rbp
	cmpq	$10, %rbp
	jne	.L33
	leaq	.LC25(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	xorl	%ebp, %ebp
.L34:
	movq	%rbx, %rdi
	cvtss2sd	(%r14,%rbp,4), %xmm0
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rax, %rdi
	movq	%r13, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	incq	%rbp
	cmpq	$10, %rbp
	jne	.L34
	leaq	.LC26(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	xorl	%ebp, %ebp
.L35:
	movq	%rbx, %rdi
	cvtss2sd	(%r12,%rbp,4), %xmm0
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rax, %rdi
	movq	%r13, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	incq	%rbp
	cmpq	$10, %rbp
	jne	.L35
	movq	%rbx, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
.LEHE3:
	leaq	128(%rsp), %rdi
	call	_ZNSt6vectorIfSaIfEED1Ev
	leaq	104(%rsp), %rdi
	call	_ZNSt6vectorIfSaIfEED1Ev
	leaq	80(%rsp), %rdi
	call	_ZNSt6vectorIfSaIfEED1Ev
	movq	152(%rsp), %rax
	subq	%fs:40, %rax
	je	.L40
	jmp	.L48
.L43:
	endbr64
	movq	%rax, %rbx
.L36:
	movq	8(%rsp), %rdi
	call	_ZNSt6vectorIfSaIfEED1Ev
	jmp	.L37
.L42:
	endbr64
	movq	%rax, %rbx
.L37:
	movq	16(%rsp), %rdi
	call	_ZNSt6vectorIfSaIfEED1Ev
	jmp	.L38
.L41:
	endbr64
	movq	%rax, %rbx
.L38:
	movq	24(%rsp), %rdi
	call	_ZNSt6vectorIfSaIfEED1Ev
	movq	152(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L48
	movq	%rbx, %rdi
.LEHB4:
	call	_Unwind_Resume@PLT
.LEHE4:
.L48:
	call	__stack_chk_fail@PLT
.L40:
	addq	$168, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.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
	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 .L41-.LFB3999
	.uleb128 0
	.uleb128 .LEHB2-.LFB3999
	.uleb128 .LEHE2-.LEHB2
	.uleb128 .L42-.LFB3999
	.uleb128 0
	.uleb128 .LEHB3-.LFB3999
	.uleb128 .LEHE3-.LEHB3
	.uleb128 .L43-.LFB3999
	.uleb128 0
	.uleb128 .LEHB4-.LFB3999
	.uleb128 .LEHE4-.LEHB4
	.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
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC5:
	.long	1065353216
	.align 4
.LC14:
	.long	1008981770
	.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 the grid size and block size
#define GRID_SIZE 32
#define BLOCK_SIZE 256
#define N 8192

// Kernel to perform fluid simulation using finite volume method
__global__ void fluidSimulationKernel(float* density, float* velocity, float* pressure, float dt, float dx) {
    // Calculate the global thread index
    int idx = blockIdx.x * blockDim.x + threadIdx.x;

    // Check if the index is within bounds
    if (idx >= N) return;

    // Atomic operations to update density, velocity, and pressure
    float newDensity = atomicAdd(&density[idx], dt * velocity[idx] * density[idx] / dx);
    float newVelocity = atomicAdd(&velocity[idx], dt * (pressure[idx + 1] - pressure[idx]) / dx);
    float newPressure = atomicAdd(&pressure[idx], dt * (velocity[idx + 1] - velocity[idx]) / dx);

    // Update the values
    density[idx] = newDensity;
    velocity[idx] = newVelocity;
    pressure[idx] = newPressure;
}

// Check for CUDA errors
void checkCudaError(hipError_t err, const char* msg) {
    if (err != hipSuccess) {
        std::cerr << "CUDA error: " << msg << " (" << hipGetErrorString(err) << ")" << std::endl;
        exit(EXIT_FAILURE);
    }
}

int main() {
    // Allocate memory for density, velocity, and pressure on the host
    std::vector<float> h_density(N, 1.0f);
    std::vector<float> h_velocity(N, 0.1f);
    std::vector<float> h_pressure(N, 0.0f);

    // Allocate memory for density, velocity, and pressure on the device
    float* d_density;
    float* d_velocity;
    float* d_pressure;
    checkCudaError(hipMalloc(&d_density, N * sizeof(float)), "hipMalloc d_density");
    checkCudaError(hipMalloc(&d_velocity, N * sizeof(float)), "hipMalloc d_velocity");
    checkCudaError(hipMalloc(&d_pressure, N * sizeof(float)), "hipMalloc d_pressure");

    // Copy data from host to device
    checkCudaError(hipMemcpy(d_density, h_density.data(), N * sizeof(float), hipMemcpyHostToDevice), "hipMemcpy d_density");
    checkCudaError(hipMemcpy(d_velocity, h_velocity.data(), N * sizeof(float), hipMemcpyHostToDevice), "hipMemcpy d_velocity");
    checkCudaError(hipMemcpy(d_pressure, h_pressure.data(), N * sizeof(float), hipMemcpyHostToDevice), "hipMemcpy d_pressure");

    // Define simulation parameters
    float dt = 0.01f; // Time step
    float dx = 1.0f;  // Spatial step

    // Launch the kernel
    fluidSimulationKernel<<<GRID_SIZE, BLOCK_SIZE>>>(d_density, d_velocity, d_pressure, dt, dx);
    checkCudaError(hipGetLastError(), "fluidSimulationKernel launch");
    checkCudaError(hipDeviceSynchronize(), "hipDeviceSynchronize");

    // Copy results back to host
    checkCudaError(hipMemcpy(h_density.data(), d_density, N * sizeof(float), hipMemcpyDeviceToHost), "hipMemcpy h_density");
    checkCudaError(hipMemcpy(h_velocity.data(), d_velocity, N * sizeof(float), hipMemcpyDeviceToHost), "hipMemcpy h_velocity");
    checkCudaError(hipMemcpy(h_pressure.data(), d_pressure, N * sizeof(float), hipMemcpyDeviceToHost), "hipMemcpy h_pressure");

    // Free device memory
    checkCudaError(hipFree(d_density), "hipFree d_density");
    checkCudaError(hipFree(d_velocity), "hipFree d_velocity");
    checkCudaError(hipFree(d_pressure), "hipFree d_pressure");

    // Print the first 10 values of density, velocity, and pressure as a simple check
    std::cout << "Density: ";
    for (int i = 0; i < 10; ++i) std::cout << h_density[i] << " ";
    std::cout << "\nVelocity: ";
    for (int i = 0; i < 10; ++i) std::cout << h_velocity[i] << " ";
    std::cout << "\nPressure: ";
    for (int i = 0; i < 10; ++i) std::cout << h_pressure[i] << " ";
    std::cout << std::endl;

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

                                        # End of file scope inline assembly
	.globl	_Z36__device_stub__fluidSimulationKernelPfS_S_ff # -- Begin function _Z36__device_stub__fluidSimulationKernelPfS_S_ff
	.type	_Z36__device_stub__fluidSimulationKernelPfS_S_ff,@function
_Z36__device_stub__fluidSimulationKernelPfS_S_ff: # @_Z36__device_stub__fluidSimulationKernelPfS_S_ff
	.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), %rcx
	movq	%rsi, (%rcx)
	leaq	24(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	4(%rsp), %rdx
	movss	%xmm0, (%rdx)
	movq	%rsp, %rdi
	movss	%xmm1, (%rdi)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rdi, 32(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%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	$_Z21fluidSimulationKernelPfS_S_ff, %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	_Z36__device_stub__fluidSimulationKernelPfS_S_ff, .Lfunc_end0-_Z36__device_stub__fluidSimulationKernelPfS_S_ff
	.cfi_endproc
                                        # -- End function
	.globl	_Z14checkCudaError10hipError_tPKc # -- Begin function _Z14checkCudaError10hipError_tPKc
	.type	_Z14checkCudaError10hipError_tPKc,@function
_Z14checkCudaError10hipError_tPKc:      # @_Z14checkCudaError10hipError_tPKc
	.cfi_startproc
# %bb.0:
	testl	%edi, %edi
	jne	.LBB1_2
# %bb.1:
	retq
.LBB1_2:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	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, %r14
	movl	%ebx, %edi
	callq	hipGetErrorString
	movq	%r14, %rdi
	movq	%rax, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.2, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
	movl	$1, %edi
	callq	exit
.Lfunc_end1:
	.size	_Z14checkCudaError10hipError_tPKc, .Lfunc_end1-_Z14checkCudaError10hipError_tPKc
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI2_0:
	.long	0x3c23d70a                      # float 0.00999999977
.LCPI2_1:
	.long	0x3f800000                      # float 1
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
.Lfunc_begin0:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception0
# %bb.0:                                # %.noexc
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	subq	$24, %rsp
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	$32768, %edi                    # imm = 0x8000
	callq	_Znwm
	movq	%rax, %rbx
	xorl	%eax, %eax
.LBB2_1:                                # %.lr.ph.i.i.i.i.i.i.i.i.i
                                        # =>This Inner Loop Header: Depth=1
	movl	$1065353216, (%rbx,%rax)        # imm = 0x3F800000
	addq	$4, %rax
	cmpq	$32768, %rax                    # imm = 0x8000
	jne	.LBB2_1
# %bb.2:                                # %_ZNSt6vectorIfSaIfEEC2EmRKfRKS0_.exit
.Ltmp0:
	movl	$32768, %edi                    # imm = 0x8000
	callq	_Znwm
.Ltmp1:
# %bb.3:                                # %.lr.ph.i.i.i.i.i.i.i.i.i28.preheader
	movq	%rax, %r14
	xorl	%eax, %eax
.LBB2_4:                                # %.lr.ph.i.i.i.i.i.i.i.i.i28
                                        # =>This Inner Loop Header: Depth=1
	movl	$1036831949, (%r14,%rax)        # imm = 0x3DCCCCCD
	addq	$4, %rax
	cmpq	$32768, %rax                    # imm = 0x8000
	jne	.LBB2_4
# %bb.5:                                # %_ZNSt6vectorIfSaIfEEC2EmRKfRKS0_.exit32
.Ltmp3:
	movl	$32768, %edi                    # imm = 0x8000
	callq	_Znwm
.Ltmp4:
# %bb.6:                                # %.lr.ph.i.i.i.i.i.i.i.i.i33.preheader
	movq	%rax, %r15
	movl	$32768, %edx                    # imm = 0x8000
	movq	%rax, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
.Ltmp6:
	leaq	16(%rsp), %rdi
	movl	$32768, %esi                    # imm = 0x8000
	callq	hipMalloc
.Ltmp7:
# %bb.7:                                # %_ZL9hipMallocIfE10hipError_tPPT_m.exit
.Ltmp8:
	movl	$.L.str.3, %esi
	movl	%eax, %edi
	callq	_Z14checkCudaError10hipError_tPKc
.Ltmp9:
# %bb.8:
.Ltmp10:
	leaq	8(%rsp), %rdi
	movl	$32768, %esi                    # imm = 0x8000
	callq	hipMalloc
.Ltmp11:
# %bb.9:                                # %_ZL9hipMallocIfE10hipError_tPPT_m.exit40
.Ltmp12:
	movl	$.L.str.4, %esi
	movl	%eax, %edi
	callq	_Z14checkCudaError10hipError_tPKc
.Ltmp13:
# %bb.10:
.Ltmp14:
	movq	%rsp, %rdi
	movl	$32768, %esi                    # imm = 0x8000
	callq	hipMalloc
.Ltmp15:
# %bb.11:                               # %_ZL9hipMallocIfE10hipError_tPPT_m.exit42
.Ltmp16:
	movl	$.L.str.5, %esi
	movl	%eax, %edi
	callq	_Z14checkCudaError10hipError_tPKc
.Ltmp17:
# %bb.12:
	movq	16(%rsp), %rdi
.Ltmp18:
	movl	$32768, %edx                    # imm = 0x8000
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
.Ltmp19:
# %bb.13:
.Ltmp20:
	movl	$.L.str.6, %esi
	movl	%eax, %edi
	callq	_Z14checkCudaError10hipError_tPKc
.Ltmp21:
# %bb.14:
	movq	8(%rsp), %rdi
.Ltmp22:
	movl	$32768, %edx                    # imm = 0x8000
	movq	%r14, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
.Ltmp23:
# %bb.15:
.Ltmp24:
	movl	$.L.str.7, %esi
	movl	%eax, %edi
	callq	_Z14checkCudaError10hipError_tPKc
.Ltmp25:
# %bb.16:
	movq	(%rsp), %rdi
.Ltmp26:
	movl	$32768, %edx                    # imm = 0x8000
	movq	%r15, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
.Ltmp27:
# %bb.17:
.Ltmp28:
	movl	$.L.str.8, %esi
	movl	%eax, %edi
	callq	_Z14checkCudaError10hipError_tPKc
.Ltmp29:
# %bb.18:
.Ltmp31:
	movabsq	$4294967328, %rdi               # imm = 0x100000020
	movabsq	$4294967552, %rdx               # imm = 0x100000100
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
.Ltmp32:
# %bb.19:
	testl	%eax, %eax
	jne	.LBB2_21
# %bb.20:
	movq	16(%rsp), %rdi
	movq	8(%rsp), %rsi
	movq	(%rsp), %rdx
.Ltmp33:
	movss	.LCPI2_0(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
	movss	.LCPI2_1(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	callq	_Z36__device_stub__fluidSimulationKernelPfS_S_ff
.Ltmp34:
.LBB2_21:
.Ltmp35:
	callq	hipGetLastError
.Ltmp36:
# %bb.22:
.Ltmp37:
	movl	$.L.str.9, %esi
	movl	%eax, %edi
	callq	_Z14checkCudaError10hipError_tPKc
.Ltmp38:
# %bb.23:
.Ltmp39:
	callq	hipDeviceSynchronize
.Ltmp40:
# %bb.24:
.Ltmp41:
	movl	$.L.str.10, %esi
	movl	%eax, %edi
	callq	_Z14checkCudaError10hipError_tPKc
.Ltmp42:
# %bb.25:
	movq	16(%rsp), %rsi
.Ltmp43:
	movl	$32768, %edx                    # imm = 0x8000
	movq	%rbx, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
.Ltmp44:
# %bb.26:
.Ltmp45:
	movl	$.L.str.11, %esi
	movl	%eax, %edi
	callq	_Z14checkCudaError10hipError_tPKc
.Ltmp46:
# %bb.27:
	movq	8(%rsp), %rsi
.Ltmp47:
	movl	$32768, %edx                    # imm = 0x8000
	movq	%r14, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
.Ltmp48:
# %bb.28:
.Ltmp49:
	movl	$.L.str.12, %esi
	movl	%eax, %edi
	callq	_Z14checkCudaError10hipError_tPKc
.Ltmp50:
# %bb.29:
	movq	(%rsp), %rsi
.Ltmp51:
	movl	$32768, %edx                    # imm = 0x8000
	movq	%r15, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
.Ltmp52:
# %bb.30:
.Ltmp53:
	movl	$.L.str.13, %esi
	movl	%eax, %edi
	callq	_Z14checkCudaError10hipError_tPKc
.Ltmp54:
# %bb.31:
	movq	16(%rsp), %rdi
.Ltmp55:
	callq	hipFree
.Ltmp56:
# %bb.32:
.Ltmp57:
	movl	$.L.str.14, %esi
	movl	%eax, %edi
	callq	_Z14checkCudaError10hipError_tPKc
.Ltmp58:
# %bb.33:
	movq	8(%rsp), %rdi
.Ltmp59:
	callq	hipFree
.Ltmp60:
# %bb.34:
.Ltmp61:
	movl	$.L.str.15, %esi
	movl	%eax, %edi
	callq	_Z14checkCudaError10hipError_tPKc
.Ltmp62:
# %bb.35:
	movq	(%rsp), %rdi
.Ltmp63:
	callq	hipFree
.Ltmp64:
# %bb.36:
.Ltmp65:
	movl	$.L.str.16, %esi
	movl	%eax, %edi
	callq	_Z14checkCudaError10hipError_tPKc
.Ltmp66:
# %bb.37:
.Ltmp67:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.17, %esi
	movl	$9, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp68:
# %bb.38:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit.preheader.preheader
	xorl	%r12d, %r12d
.LBB2_39:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit.preheader
                                        # =>This Inner Loop Header: Depth=1
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rbx,%r12,4), %xmm0
.Ltmp69:
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
.Ltmp70:
# %bb.40:                               # %_ZNSolsEf.exit
                                        #   in Loop: Header=BB2_39 Depth=1
.Ltmp71:
	movl	$.L.str.18, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp72:
# %bb.41:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit48
                                        #   in Loop: Header=BB2_39 Depth=1
	incq	%r12
	cmpq	$10, %r12
	jne	.LBB2_39
# %bb.42:
.Ltmp74:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.19, %esi
	movl	$11, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp75:
# %bb.43:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit45.preheader.preheader
	xorl	%r12d, %r12d
.LBB2_44:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit45.preheader
                                        # =>This Inner Loop Header: Depth=1
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r14,%r12,4), %xmm0
.Ltmp76:
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
.Ltmp77:
# %bb.45:                               # %_ZNSolsEf.exit52
                                        #   in Loop: Header=BB2_44 Depth=1
.Ltmp78:
	movl	$.L.str.18, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp79:
# %bb.46:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit54
                                        #   in Loop: Header=BB2_44 Depth=1
	incq	%r12
	cmpq	$10, %r12
	jne	.LBB2_44
# %bb.47:
.Ltmp81:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.20, %esi
	movl	$11, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp82:
# %bb.48:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit50.preheader.preheader
	xorl	%r12d, %r12d
.LBB2_49:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit50.preheader
                                        # =>This Inner Loop Header: Depth=1
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r15,%r12,4), %xmm0
.Ltmp83:
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
.Ltmp84:
# %bb.50:                               # %_ZNSolsEf.exit57
                                        #   in Loop: Header=BB2_49 Depth=1
.Ltmp85:
	movl	$.L.str.18, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp86:
# %bb.51:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit59
                                        #   in Loop: Header=BB2_49 Depth=1
	incq	%r12
	cmpq	$10, %r12
	jne	.LBB2_49
# %bb.52:
	movq	_ZSt4cout(%rip), %rax
	movl	$_ZSt4cout, %edi
	addq	-24(%rax), %rdi
.Ltmp88:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp89:
# %bb.53:                               # %.noexc75
.Ltmp90:
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
.Ltmp91:
# %bb.54:                               # %.noexc76
.Ltmp92:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp93:
# %bb.55:                               # %_ZNSt6vectorIfSaIfEED2Ev.exit63
	movq	%r15, %rdi
	callq	_ZdlPv
	movq	%r14, %rdi
	callq	_ZdlPv
	movq	%rbx, %rdi
	callq	_ZdlPv
	xorl	%eax, %eax
	addq	$24, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.LBB2_57:
	.cfi_def_cfa_offset 64
.Ltmp5:
	movq	%rax, %r12
	jmp	.LBB2_63
.LBB2_56:
.Ltmp2:
	movq	%rax, %r12
	jmp	.LBB2_64
.LBB2_61:
.Ltmp30:
	jmp	.LBB2_62
.LBB2_58:
.Ltmp94:
	jmp	.LBB2_62
.LBB2_65:
.Ltmp87:
	jmp	.LBB2_62
.LBB2_60:
.Ltmp80:
	jmp	.LBB2_62
.LBB2_59:
.Ltmp73:
.LBB2_62:                               # %_ZNSt6vectorIfSaIfEED2Ev.exit65
	movq	%rax, %r12
	movq	%r15, %rdi
	callq	_ZdlPv
.LBB2_63:                               # %_ZNSt6vectorIfSaIfEED2Ev.exit67
	movq	%r14, %rdi
	callq	_ZdlPv
.LBB2_64:                               # %_ZNSt6vectorIfSaIfEED2Ev.exit69
	movq	%rbx, %rdi
	callq	_ZdlPv
	movq	%r12, %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 .Ltmp3-.Lfunc_begin0           # >> Call Site 3 <<
	.uleb128 .Ltmp4-.Ltmp3                  #   Call between .Ltmp3 and .Ltmp4
	.uleb128 .Ltmp5-.Lfunc_begin0           #     jumps to .Ltmp5
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp4-.Lfunc_begin0           # >> Call Site 4 <<
	.uleb128 .Ltmp6-.Ltmp4                  #   Call between .Ltmp4 and .Ltmp6
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp6-.Lfunc_begin0           # >> Call Site 5 <<
	.uleb128 .Ltmp29-.Ltmp6                 #   Call between .Ltmp6 and .Ltmp29
	.uleb128 .Ltmp30-.Lfunc_begin0          #     jumps to .Ltmp30
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp31-.Lfunc_begin0          # >> Call Site 6 <<
	.uleb128 .Ltmp68-.Ltmp31                #   Call between .Ltmp31 and .Ltmp68
	.uleb128 .Ltmp94-.Lfunc_begin0          #     jumps to .Ltmp94
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp69-.Lfunc_begin0          # >> Call Site 7 <<
	.uleb128 .Ltmp72-.Ltmp69                #   Call between .Ltmp69 and .Ltmp72
	.uleb128 .Ltmp73-.Lfunc_begin0          #     jumps to .Ltmp73
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp74-.Lfunc_begin0          # >> Call Site 8 <<
	.uleb128 .Ltmp75-.Ltmp74                #   Call between .Ltmp74 and .Ltmp75
	.uleb128 .Ltmp94-.Lfunc_begin0          #     jumps to .Ltmp94
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp76-.Lfunc_begin0          # >> Call Site 9 <<
	.uleb128 .Ltmp79-.Ltmp76                #   Call between .Ltmp76 and .Ltmp79
	.uleb128 .Ltmp80-.Lfunc_begin0          #     jumps to .Ltmp80
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp81-.Lfunc_begin0          # >> Call Site 10 <<
	.uleb128 .Ltmp82-.Ltmp81                #   Call between .Ltmp81 and .Ltmp82
	.uleb128 .Ltmp94-.Lfunc_begin0          #     jumps to .Ltmp94
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp83-.Lfunc_begin0          # >> Call Site 11 <<
	.uleb128 .Ltmp86-.Ltmp83                #   Call between .Ltmp83 and .Ltmp86
	.uleb128 .Ltmp87-.Lfunc_begin0          #     jumps to .Ltmp87
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp88-.Lfunc_begin0          # >> Call Site 12 <<
	.uleb128 .Ltmp93-.Ltmp88                #   Call between .Ltmp88 and .Ltmp93
	.uleb128 .Ltmp94-.Lfunc_begin0          #     jumps to .Ltmp94
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp93-.Lfunc_begin0          # >> Call Site 13 <<
	.uleb128 .Lfunc_end2-.Ltmp93            #   Call between .Ltmp93 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	$_Z21fluidSimulationKernelPfS_S_ff, %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	_Z21fluidSimulationKernelPfS_S_ff,@object # @_Z21fluidSimulationKernelPfS_S_ff
	.section	.rodata,"a",@progbits
	.globl	_Z21fluidSimulationKernelPfS_S_ff
	.p2align	3, 0x0
_Z21fluidSimulationKernelPfS_S_ff:
	.quad	_Z36__device_stub__fluidSimulationKernelPfS_S_ff
	.size	_Z21fluidSimulationKernelPfS_S_ff, 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	" ("
	.size	.L.str.1, 3

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

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"hipMalloc d_density"
	.size	.L.str.3, 20

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"hipMalloc d_velocity"
	.size	.L.str.4, 21

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"hipMalloc d_pressure"
	.size	.L.str.5, 21

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"hipMemcpy d_density"
	.size	.L.str.6, 20

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"hipMemcpy d_velocity"
	.size	.L.str.7, 21

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"hipMemcpy d_pressure"
	.size	.L.str.8, 21

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"fluidSimulationKernel launch"
	.size	.L.str.9, 29

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"hipDeviceSynchronize"
	.size	.L.str.10, 21

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"hipMemcpy h_density"
	.size	.L.str.11, 20

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"hipMemcpy h_velocity"
	.size	.L.str.12, 21

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"hipMemcpy h_pressure"
	.size	.L.str.13, 21

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	"hipFree d_density"
	.size	.L.str.14, 18

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"hipFree d_velocity"
	.size	.L.str.15, 19

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	"hipFree d_pressure"
	.size	.L.str.16, 19

	.type	.L.str.17,@object               # @.str.17
.L.str.17:
	.asciz	"Density: "
	.size	.L.str.17, 10

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

	.type	.L.str.19,@object               # @.str.19
.L.str.19:
	.asciz	"\nVelocity: "
	.size	.L.str.19, 12

	.type	.L.str.20,@object               # @.str.20
.L.str.20:
	.asciz	"\nPressure: "
	.size	.L.str.20, 12

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z21fluidSimulationKernelPfS_S_ff"
	.size	.L__unnamed_1, 34

	.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 _Z36__device_stub__fluidSimulationKernelPfS_S_ff
	.addrsig_sym __gxx_personality_v0
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Unwind_Resume
	.addrsig_sym _Z21fluidSimulationKernelPfS_S_ff
	.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	_Z21fluidSimulationKernelPfS_S_ff ; -- Begin function _Z21fluidSimulationKernelPfS_S_ff
	.globl	_Z21fluidSimulationKernelPfS_S_ff
	.p2align	8
	.type	_Z21fluidSimulationKernelPfS_S_ff,@function
_Z21fluidSimulationKernelPfS_S_ff:      ; @_Z21fluidSimulationKernelPfS_S_ff
; %bb.0:
	s_load_b32 s2, s[0:1], 0x2c
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_mov_b32 s2, exec_lo
	v_cmpx_gt_i32_e32 0x2000, v1
	s_cbranch_execz .LBB0_8
; %bb.1:
	s_load_b256 s[0:7], s[0:1], 0x0
	v_ashrrev_i32_e32 v2, 31, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[4:5], 2, v[1:2]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v0, vcc_lo, s2, v4
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v1, vcc_lo, s3, v5, vcc_lo
	v_add_co_u32 v2, vcc_lo, s0, v4
	v_add_co_ci_u32_e32 v3, vcc_lo, s1, v5, vcc_lo
	s_mov_b32 s0, 0
	global_load_b32 v7, v[0:1], off
	global_load_b32 v6, v[2:3], off
	s_waitcnt vmcnt(1)
	v_mul_f32_e32 v7, s6, v7
	s_waitcnt vmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f32_e32 v7, v7, v6
	v_div_scale_f32 v8, null, s7, s7, v7
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_rcp_f32_e32 v9, v8
	s_waitcnt_depctr 0xfff
	v_fma_f32 v10, -v8, v9, 1.0
	v_fmac_f32_e32 v9, v10, v9
	v_div_scale_f32 v10, vcc_lo, v7, s7, v7
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f32_e32 v11, v10, v9
	v_fma_f32 v12, -v8, v11, v10
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v11, v12, v9
	v_fma_f32 v8, -v8, v11, v10
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_div_fmas_f32 v8, v8, v9, v11
	v_div_fixup_f32 v7, v8, s7, v7
.LBB0_2:                                ; %atomicrmw.start
                                        ; =>This Inner Loop Header: Depth=1
	v_mov_b32_e32 v9, v6
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_4) | instid1(SALU_CYCLE_1)
	v_add_f32_e32 v8, v9, v7
	global_atomic_cmpswap_b32 v6, v[2:3], v[8:9], off glc
	s_waitcnt vmcnt(0)
	v_cmp_eq_u32_e32 vcc_lo, v6, v9
	s_or_b32 s0, vcc_lo, s0
	s_and_not1_b32 exec_lo, exec_lo, s0
	s_cbranch_execnz .LBB0_2
; %bb.3:                                ; %atomicrmw.end
	s_or_b32 exec_lo, exec_lo, s0
	v_add_co_u32 v4, vcc_lo, s4, v4
	v_add_co_ci_u32_e32 v5, vcc_lo, s5, v5, vcc_lo
	s_mov_b32 s0, 0
	global_load_b64 v[8:9], v[4:5], off
	global_load_b32 v7, v[0:1], off
	s_waitcnt vmcnt(1)
	v_sub_f32_e32 v8, v9, v8
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f32_e32 v8, s6, v8
	v_div_scale_f32 v9, null, s7, s7, v8
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_rcp_f32_e32 v10, v9
	s_waitcnt_depctr 0xfff
	v_fma_f32 v11, -v9, v10, 1.0
	v_fmac_f32_e32 v10, v11, v10
	v_div_scale_f32 v11, vcc_lo, v8, s7, v8
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f32_e32 v12, v11, v10
	v_fma_f32 v13, -v9, v12, v11
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v12, v13, v10
	v_fma_f32 v9, -v9, v12, v11
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_div_fmas_f32 v9, v9, v10, v12
	v_div_fixup_f32 v8, v9, s7, v8
.LBB0_4:                                ; %atomicrmw.start37
                                        ; =>This Inner Loop Header: Depth=1
	s_waitcnt vmcnt(0)
	v_mov_b32_e32 v10, v7
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_4) | instid1(SALU_CYCLE_1)
	v_add_f32_e32 v9, v10, v8
	global_atomic_cmpswap_b32 v7, v[0:1], v[9:10], off glc
	s_waitcnt vmcnt(0)
	v_cmp_eq_u32_e32 vcc_lo, v7, v10
	s_or_b32 s0, vcc_lo, s0
	s_and_not1_b32 exec_lo, exec_lo, s0
	s_cbranch_execnz .LBB0_4
; %bb.5:                                ; %atomicrmw.end36
	s_or_b32 exec_lo, exec_lo, s0
	global_load_b64 v[9:10], v[0:1], off
	global_load_b32 v8, v[4:5], off
	s_mov_b32 s0, 0
	s_waitcnt vmcnt(1)
	v_sub_f32_e32 v9, v10, v9
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f32_e32 v9, s6, v9
	v_div_scale_f32 v10, null, s7, s7, v9
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_rcp_f32_e32 v11, v10
	s_waitcnt_depctr 0xfff
	v_fma_f32 v12, -v10, v11, 1.0
	v_fmac_f32_e32 v11, v12, v11
	v_div_scale_f32 v12, vcc_lo, v9, s7, v9
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f32_e32 v13, v12, v11
	v_fma_f32 v14, -v10, v13, v12
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v13, v14, v11
	v_fma_f32 v10, -v10, v13, v12
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_div_fmas_f32 v10, v10, v11, v13
	v_div_fixup_f32 v9, v10, s7, v9
.LBB0_6:                                ; %atomicrmw.start43
                                        ; =>This Inner Loop Header: Depth=1
	s_waitcnt vmcnt(0)
	v_mov_b32_e32 v11, v8
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_4) | instid1(SALU_CYCLE_1)
	v_add_f32_e32 v10, v11, v9
	global_atomic_cmpswap_b32 v8, v[4:5], v[10:11], off glc
	s_waitcnt vmcnt(0)
	v_cmp_eq_u32_e32 vcc_lo, v8, v11
	s_or_b32 s0, vcc_lo, s0
	s_and_not1_b32 exec_lo, exec_lo, s0
	s_cbranch_execnz .LBB0_6
; %bb.7:                                ; %atomicrmw.end42
	s_or_b32 exec_lo, exec_lo, s0
	global_store_b32 v[2:3], v6, off
	global_store_b32 v[0:1], v7, off
	global_store_b32 v[4:5], v8, off
.LBB0_8:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z21fluidSimulationKernelPfS_S_ff
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 288
		.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 15
		.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	_Z21fluidSimulationKernelPfS_S_ff, .Lfunc_end0-_Z21fluidSimulationKernelPfS_S_ff
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 680
; NumSgprs: 18
; NumVgprs: 15
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 15
; 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:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .offset:         24
        .size:           4
        .value_kind:     by_value
      - .offset:         28
        .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:           _Z21fluidSimulationKernelPfS_S_ff
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z21fluidSimulationKernelPfS_S_ff.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     15
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
