// particle_swarm_optimization.cu
#include <iostream>
#include <cuda_runtime.h>
#include <curand_kernel.h>

#define NUM_PARTICLES 128
#define DIMENSIONS 1
#define MAX_ITERATIONS 100

__global__ void initParticles(float *positions, float *velocities, float *pBestPositions, float *pBestValues, curandState *states) {
    int idx = blockIdx.x * blockDim.x + threadIdx.x;
    if (idx < NUM_PARTICLES) {
        // Initialize random states
        curand_init(idx, 0, 0, &states[idx]);
        
        // Initialize positions and velocities
        positions[idx] = curand_uniform(&states[idx]) * 10.0f - 5.0f; // Random position between -5 and 5
        velocities[idx] = curand_uniform(&states[idx]) * 2.0f - 1.0f; // Random velocity between -1 and 1
        
        // Initialize personal best positions and values
        pBestPositions[idx] = positions[idx];
        pBestValues[idx] = -1.0f; // Assume initial worst value
    }
}

__global__ void updateParticles(float *positions, float *velocities, float *pBestPositions, float *pBestValues, float gBestPosition, float gBestValue, float w, float c1, float c2, curandState *states) {
    int idx = blockIdx.x * blockDim.x + threadIdx.x;
    if (idx < NUM_PARTICLES) {
        // Update velocity
        float r1 = curand_uniform(&states[idx]);
        float r2 = curand_uniform(&states[idx]);
        velocities[idx] = w * velocities[idx] + c1 * r1 * (pBestPositions[idx] - positions[idx]) + c2 * r2 * (gBestPosition - positions[idx]);
        
        // Update position
        positions[idx] += velocities[idx];
        
        // Evaluate fitness (simple example: parabola)
        float fitness = positions[idx] * positions[idx];
        
        // Update personal best
        if (fitness < pBestValues[idx]) {
            pBestValues[idx] = fitness;
            pBestPositions[idx] = positions[idx];
        }
        
        // Update global best (not done here, but in the host code)
    }
}

int main() {
    float *h_positions, *h_velocities, *h_pBestPositions, *h_pBestValues;
    float *d_positions, *d_velocities, *d_pBestPositions, *d_pBestValues;
    curandState *d_states;
    
    // Allocate host memory
    h_positions = (float *)malloc(NUM_PARTICLES * sizeof(float));
    h_velocities = (float *)malloc(NUM_PARTICLES * sizeof(float));
    h_pBestPositions = (float *)malloc(NUM_PARTICLES * sizeof(float));
    h_pBestValues = (float *)malloc(NUM_PARTICLES * sizeof(float));
    
    // Allocate device memory
    cudaMalloc((void **)&d_positions, NUM_PARTICLES * sizeof(float));
    cudaMalloc((void **)&d_velocities, NUM_PARTICLES * sizeof(float));
    cudaMalloc((void **)&d_pBestPositions, NUM_PARTICLES * sizeof(float));
    cudaMalloc((void **)&d_pBestValues, NUM_PARTICLES * sizeof(float));
    cudaMalloc((void **)&d_states, NUM_PARTICLES * sizeof(curandState));
    
    // Initialize particles
    initParticles<<<(NUM_PARTICLES + 255) / 256, 256>>>(d_positions, d_velocities, d_pBestPositions, d_pBestValues, d_states);
    cudaDeviceSynchronize();
    
    // Check for errors in initialization
    cudaError_t err = cudaGetLastError();
    if (err != cudaSuccess) {
        std::cerr << "CUDA error: " << cudaGetErrorString(err) << std::endl;
        return -1;
    }
    
    // Copy initial positions to host for evaluation
    cudaMemcpy(h_positions, d_positions, NUM_PARTICLES * sizeof(float), cudaMemcpyDeviceToHost);
    cudaMemcpy(h_pBestValues, d_pBestValues, NUM_PARTICLES * sizeof(float), cudaMemcpyDeviceToHost);
    
    // Initialize global best
    float gBestValue = h_pBestValues[0];
    float gBestPosition = h_pBestPositions[0];
    for (int i = 1; i < NUM_PARTICLES; ++i) {
        if (h_pBestValues[i] < gBestValue) {
            gBestValue = h_pBestValues[i];
            gBestPosition = h_pBestPositions[i];
        }
    }
    
    // Constants for PSO
    float w = 0.729; // Inertia weight
    float c1 = 1.49445; // Cognitive coefficient
    float c2 = 1.49445; // Social coefficient
    
    // Main PSO loop
    for (int iter = 0; iter < MAX_ITERATIONS; ++iter) {
        // Update particles
        updateParticles<<<(NUM_PARTICLES + 255) / 256, 256>>>(d_positions, d_velocities, d_pBestPositions, d_pBestValues, gBestPosition, gBestValue, w, c1, c2, d_states);
        cudaDeviceSynchronize();
        
        // Check for errors in update
        err = cudaGetLastError();
        if (err != cudaSuccess) {
            std::cerr << "CUDA error: " << cudaGetErrorString(err) << std::endl;
            return -1;
        }
        
        // Update global best on host
        cudaMemcpy(h_pBestValues, d_pBestValues, NUM_PARTICLES * sizeof(float), cudaMemcpyDeviceToHost);
        cudaMemcpy(h_pBestPositions, d_pBestPositions, NUM_PARTICLES * sizeof(float), cudaMemcpyDeviceToHost);
        for (int i = 0; i < NUM_PARTICLES; ++i) {
            if (h_pBestValues[i] < gBestValue) {
                gBestValue = h_pBestValues[i];
                gBestPosition = h_pBestPositions[i];
            }
        }
    }
    
    // Output the best solution found
    std::cout << "Global best position: " << gBestPosition << std::endl;
    std::cout << "Global best value: " << gBestValue << std::endl;
    
    // Free device memory
    cudaFree(d_positions);
    cudaFree(d_velocities);
    cudaFree(d_pBestPositions);
    cudaFree(d_pBestValues);
    cudaFree(d_states);
    
    // Free host memory
    free(h_positions);
    free(h_velocities);
    free(h_pBestPositions);
    free(h_pBestValues);
    
    return 0;
}
	.file	"tmpxft_00188f6e_00000000-6_cuda_code_049875.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3852:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3852:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z59__device_stub__Z13initParticlesPfS_S_S_P17curandStateXORWOWPfS_S_S_P17curandStateXORWOW
	.type	_Z59__device_stub__Z13initParticlesPfS_S_S_P17curandStateXORWOWPfS_S_S_P17curandStateXORWOW, @function
_Z59__device_stub__Z13initParticlesPfS_S_S_P17curandStateXORWOWPfS_S_S_P17curandStateXORWOW:
.LFB3874:
	.cfi_startproc
	endbr64
	subq	$168, %rsp
	.cfi_def_cfa_offset 176
	movq	%rdi, 40(%rsp)
	leaq	64(%rsp), %rdi
	movq	%rsi, 32(%rsp)
	leaq	76(%rsp), %rsi
	movq	%rdx, 24(%rsp)
	leaq	48(%rsp), %rdx
	movq	%rcx, 16(%rsp)
	leaq	56(%rsp), %rcx
	movq	%r8, 8(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 152(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 72(%rsp)
	movq	%rax, 112(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 144(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 64(%rsp)
	movq	%rax, 76(%rsp)
	movl	$1, 84(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L2
	pushq	56(%rsp)
	.cfi_def_cfa_offset 184
	leaq	_Z13initParticlesPfS_S_S_P17curandStateXORWOW(%rip), %rdi
	pushq	56(%rsp)
	.cfi_def_cfa_offset 192
	movq	92(%rsp), %rcx
	movl	100(%rsp), %r8d
	movq	80(%rsp), %rsi
	movl	88(%rsp), %edx
	leaq	128(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 184
	popq	%rdx
	.cfi_def_cfa_offset 176
.L2:
	movq	152(%rsp), %rax
	subq	%fs:40, %rax
	je	.L4
	call	__stack_chk_fail@PLT
.L4:
	addq	$168, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3874:
	.size	_Z59__device_stub__Z13initParticlesPfS_S_S_P17curandStateXORWOWPfS_S_S_P17curandStateXORWOW, .-_Z59__device_stub__Z13initParticlesPfS_S_S_P17curandStateXORWOWPfS_S_S_P17curandStateXORWOW
	.globl	_Z13initParticlesPfS_S_S_P17curandStateXORWOW
	.type	_Z13initParticlesPfS_S_S_P17curandStateXORWOW, @function
_Z13initParticlesPfS_S_S_P17curandStateXORWOW:
.LFB3875:
	.cfi_startproc
	endbr64
	jmp	_Z59__device_stub__Z13initParticlesPfS_S_S_P17curandStateXORWOWPfS_S_S_P17curandStateXORWOW
	.cfi_endproc
.LFE3875:
	.size	_Z13initParticlesPfS_S_S_P17curandStateXORWOW, .-_Z13initParticlesPfS_S_S_P17curandStateXORWOW
	.globl	_Z66__device_stub__Z15updateParticlesPfS_S_S_fffffP17curandStateXORWOWPfS_S_S_fffffP17curandStateXORWOW
	.type	_Z66__device_stub__Z15updateParticlesPfS_S_S_fffffP17curandStateXORWOWPfS_S_S_fffffP17curandStateXORWOW, @function
_Z66__device_stub__Z15updateParticlesPfS_S_S_fffffP17curandStateXORWOWPfS_S_S_fffffP17curandStateXORWOW:
.LFB3876:
	.cfi_startproc
	endbr64
	subq	$232, %rsp
	.cfi_def_cfa_offset 240
	movq	%rdi, 56(%rsp)
	leaq	88(%rsp), %rdi
	movq	%rsi, 48(%rsp)
	leaq	100(%rsp), %rsi
	movq	%rdx, 40(%rsp)
	leaq	72(%rsp), %rdx
	movq	%rcx, 32(%rsp)
	leaq	80(%rsp), %rcx
	movq	%r8, (%rsp)
	movss	%xmm0, 28(%rsp)
	movss	%xmm1, 24(%rsp)
	movss	%xmm2, 20(%rsp)
	movss	%xmm3, 16(%rsp)
	movss	%xmm4, 12(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 216(%rsp)
	xorl	%eax, %eax
	leaq	56(%rsp), %rax
	movl	$1, 96(%rsp)
	movq	%rax, 136(%rsp)
	leaq	48(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	40(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 160(%rsp)
	leaq	28(%rsp), %rax
	movq	%rax, 168(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 176(%rsp)
	leaq	20(%rsp), %rax
	movq	%rax, 184(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 192(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 200(%rsp)
	movq	%rsp, %rax
	movq	%rax, 208(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 88(%rsp)
	movq	%rax, 100(%rsp)
	movl	$1, 108(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L8
	pushq	80(%rsp)
	.cfi_def_cfa_offset 248
	leaq	_Z15updateParticlesPfS_S_S_fffffP17curandStateXORWOW(%rip), %rdi
	pushq	80(%rsp)
	.cfi_def_cfa_offset 256
	movq	116(%rsp), %rcx
	movl	124(%rsp), %r8d
	movq	104(%rsp), %rsi
	movl	112(%rsp), %edx
	leaq	152(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 248
	popq	%rdx
	.cfi_def_cfa_offset 240
.L8:
	movq	216(%rsp), %rax
	subq	%fs:40, %rax
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	addq	$232, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3876:
	.size	_Z66__device_stub__Z15updateParticlesPfS_S_S_fffffP17curandStateXORWOWPfS_S_S_fffffP17curandStateXORWOW, .-_Z66__device_stub__Z15updateParticlesPfS_S_S_fffffP17curandStateXORWOWPfS_S_S_fffffP17curandStateXORWOW
	.globl	_Z15updateParticlesPfS_S_S_fffffP17curandStateXORWOW
	.type	_Z15updateParticlesPfS_S_S_fffffP17curandStateXORWOW, @function
_Z15updateParticlesPfS_S_S_fffffP17curandStateXORWOW:
.LFB3877:
	.cfi_startproc
	endbr64
	jmp	_Z66__device_stub__Z15updateParticlesPfS_S_S_fffffP17curandStateXORWOWPfS_S_S_fffffP17curandStateXORWOW
	.cfi_endproc
.LFE3877:
	.size	_Z15updateParticlesPfS_S_S_fffffP17curandStateXORWOW, .-_Z15updateParticlesPfS_S_S_fffffP17curandStateXORWOW
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"CUDA error: "
.LC3:
	.string	"Global best position: "
.LC4:
	.string	"Global best value: "
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3849:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$512, %edi
	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	$104, %rsp
	.cfi_def_cfa_offset 160
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	call	malloc@PLT
	movl	$512, %edi
	movq	%rax, %r12
	call	malloc@PLT
	movl	$512, %edi
	movq	%rax, %rbp
	call	malloc@PLT
	leaq	24(%rsp), %rdi
	movl	$512, %esi
	movq	%rax, %rbx
	call	cudaMalloc@PLT
	leaq	32(%rsp), %rdi
	movl	$512, %esi
	call	cudaMalloc@PLT
	leaq	40(%rsp), %rdi
	movl	$512, %esi
	call	cudaMalloc@PLT
	leaq	48(%rsp), %rdi
	movl	$512, %esi
	call	cudaMalloc@PLT
	leaq	56(%rsp), %rdi
	movl	$6144, %esi
	call	cudaMalloc@PLT
	movl	$16777217, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	salq	$8, %rdx
	movl	$1, %ecx
	movabsq	$4294967297, %rdi
	movl	$1, %esi
	movq	%rdx, 76(%rsp)
	movl	$1, 84(%rsp)
	movq	%rdi, 64(%rsp)
	movl	$1, 72(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L14
	movq	56(%rsp), %r8
	movq	48(%rsp), %rcx
	movq	40(%rsp), %rdx
	movq	32(%rsp), %rsi
	movq	24(%rsp), %rdi
	call	_Z59__device_stub__Z13initParticlesPfS_S_S_P17curandStateXORWOWPfS_S_S_P17curandStateXORWOW
.L14:
	call	cudaDeviceSynchronize@PLT
	call	cudaGetLastError@PLT
	movl	%eax, %r13d
	testl	%eax, %eax
	je	.L15
	leaq	_ZSt4cerr(%rip), %rdi
	leaq	.LC0(%rip), %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%r13d, %edi
	movq	%rax, %rbx
	jmp	.L34
.L15:
	movq	24(%rsp), %rsi
	movl	$2, %ecx
	movl	$512, %edx
	movq	%r12, %rdi
	call	cudaMemcpy@PLT
	movq	48(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbx, %rdi
	movl	$512, %edx
	call	cudaMemcpy@PLT
	movss	(%rbx), %xmm5
	movss	0(%rbp), %xmm6
	movl	$4, %eax
	movss	%xmm5, 8(%rsp)
	movss	%xmm6, 12(%rsp)
.L19:
	movss	(%rbx,%rax), %xmm0
	movss	8(%rsp), %xmm7
	comiss	%xmm0, %xmm7
	jbe	.L17
	movss	0(%rbp,%rax), %xmm1
	movss	%xmm0, 8(%rsp)
	movss	%xmm1, 12(%rsp)
.L17:
	addq	$4, %rax
	cmpq	$512, %rax
	jne	.L19
	movabsq	$4294967552, %r14
	movl	$100, %r13d
.L26:
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	%r14, %rdx
	movl	$1, %ecx
	movabsq	$4294967297, %rdi
	movl	$1, %esi
	movq	%r14, 76(%rsp)
	movl	$1, 84(%rsp)
	movq	%rdi, 64(%rsp)
	movl	$1, 72(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L20
	movss	.LC1(%rip), %xmm4
	movq	56(%rsp), %r8
	movss	.LC2(%rip), %xmm2
	movss	8(%rsp), %xmm1
	movss	12(%rsp), %xmm0
	movq	48(%rsp), %rcx
	movaps	%xmm4, %xmm3
	movq	40(%rsp), %rdx
	movq	32(%rsp), %rsi
	movq	24(%rsp), %rdi
	call	_Z66__device_stub__Z15updateParticlesPfS_S_S_fffffP17curandStateXORWOWPfS_S_S_fffffP17curandStateXORWOW
.L20:
	call	cudaDeviceSynchronize@PLT
	call	cudaGetLastError@PLT
	movl	%eax, %r15d
	testl	%eax, %eax
	je	.L21
	leaq	_ZSt4cerr(%rip), %rdi
	leaq	.LC0(%rip), %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%r15d, %edi
	movq	%rax, %rbx
.L34:
	call	cudaGetErrorString@PLT
	movq	%rbx, %rdi
	movq	%rax, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	orl	$-1, %eax
	jmp	.L13
.L21:
	movq	48(%rsp), %rsi
	movl	$2, %ecx
	movl	$512, %edx
	movq	%rbx, %rdi
	call	cudaMemcpy@PLT
	movq	40(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbp, %rdi
	movl	$512, %edx
	call	cudaMemcpy@PLT
	xorl	%eax, %eax
.L25:
	movss	(%rbx,%rax), %xmm0
	movss	8(%rsp), %xmm2
	comiss	%xmm0, %xmm2
	jbe	.L23
	movss	0(%rbp,%rax), %xmm3
	movss	%xmm0, 8(%rsp)
	movss	%xmm3, 12(%rsp)
.L23:
	addq	$4, %rax
	cmpq	$512, %rax
	jne	.L25
	decl	%r13d
	jne	.L26
	leaq	_ZSt4cout(%rip), %r13
	leaq	.LC3(%rip), %rsi
	movq	%r13, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	cvtss2sd	12(%rsp), %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	leaq	.LC4(%rip), %rsi
	movq	%r13, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	cvtss2sd	8(%rsp), %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	movq	48(%rsp), %rdi
	call	cudaFree@PLT
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	%rbp, %rdi
	call	free@PLT
	movq	%rbx, %rdi
	call	free@PLT
	xorl	%eax, %eax
.L13:
	movq	88(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L27
	call	__stack_chk_fail@PLT
.L27:
	addq	$104, %rsp
	.cfi_def_cfa_offset 56
	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
.LFE3849:
	.size	main, .-main
	.section	.rodata.str1.1
.LC5:
	.string	"_Z15updateParticlesPfS_S_S_fffffP17curandStateXORWOW"
.LC6:
	.string	"_Z13initParticlesPfS_S_S_P17curandStateXORWOW"
.LC7:
	.string	"precalc_xorwow_matrix"
.LC8:
	.string	"precalc_xorwow_offset_matrix"
.LC9:
	.string	"mrg32k3aM1"
.LC10:
	.string	"mrg32k3aM2"
.LC11:
	.string	"mrg32k3aM1SubSeq"
.LC12:
	.string	"mrg32k3aM2SubSeq"
.LC13:
	.string	"mrg32k3aM1Seq"
.LC14:
	.string	"mrg32k3aM2Seq"
.LC15:
	.string	"__cr_lgamma_table"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3879:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC5(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z15updateParticlesPfS_S_S_fffffP17curandStateXORWOW(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC6(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z13initParticlesPfS_S_S_P17curandStateXORWOW(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC7(%rip), %rdx
	movl	$102400, %r9d
	leaq	_ZL21precalc_xorwow_matrix(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	call	__cudaRegisterVar@PLT
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rdx
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC8(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$102400, %r9d
	leaq	_ZL28precalc_xorwow_offset_matrix(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rcx
	.cfi_def_cfa_offset 24
	popq	%rsi
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC9(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$2304, %r9d
	leaq	_ZL10mrg32k3aM1(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rdi
	.cfi_def_cfa_offset 24
	popq	%r8
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC10(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$2304, %r9d
	leaq	_ZL10mrg32k3aM2(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%r9
	.cfi_def_cfa_offset 24
	popq	%r10
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC11(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$2016, %r9d
	leaq	_ZL16mrg32k3aM1SubSeq(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%r11
	.cfi_def_cfa_offset 24
	popq	%rax
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC12(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$2016, %r9d
	leaq	_ZL16mrg32k3aM2SubSeq(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rdx
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC13(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$2304, %r9d
	leaq	_ZL13mrg32k3aM1Seq(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rcx
	.cfi_def_cfa_offset 24
	popq	%rsi
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC14(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$2304, %r9d
	leaq	_ZL13mrg32k3aM2Seq(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rdi
	.cfi_def_cfa_offset 24
	popq	%r8
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$1
	.cfi_def_cfa_offset 32
	leaq	.LC15(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movl	$72, %r9d
	movq	%rdx, %rcx
	leaq	_ZL17__cr_lgamma_table(%rip), %rsi
	call	__cudaRegisterVar@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	popq	%r9
	.cfi_def_cfa_offset 24
	popq	%r10
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE3879:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.local	_ZL17__cr_lgamma_table
	.comm	_ZL17__cr_lgamma_table,72,32
	.local	_ZL13mrg32k3aM2Seq
	.comm	_ZL13mrg32k3aM2Seq,2304,32
	.local	_ZL13mrg32k3aM1Seq
	.comm	_ZL13mrg32k3aM1Seq,2304,32
	.local	_ZL16mrg32k3aM2SubSeq
	.comm	_ZL16mrg32k3aM2SubSeq,2016,32
	.local	_ZL16mrg32k3aM1SubSeq
	.comm	_ZL16mrg32k3aM1SubSeq,2016,32
	.local	_ZL10mrg32k3aM2
	.comm	_ZL10mrg32k3aM2,2304,32
	.local	_ZL10mrg32k3aM1
	.comm	_ZL10mrg32k3aM1,2304,32
	.local	_ZL28precalc_xorwow_offset_matrix
	.comm	_ZL28precalc_xorwow_offset_matrix,102400,32
	.local	_ZL21precalc_xorwow_matrix
	.comm	_ZL21precalc_xorwow_matrix,102400,32
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC1:
	.long	1069500963
	.align 4
.LC2:
	.long	1060806590
	.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:

// particle_swarm_optimization.cu
#include <iostream>
#include <hip/hip_runtime.h>
#include <hiprand/hiprand_kernel.h>

#define NUM_PARTICLES 128
#define DIMENSIONS 1
#define MAX_ITERATIONS 100

__global__ void initParticles(float *positions, float *velocities, float *pBestPositions, float *pBestValues, hiprandState *states) {
    int idx = blockIdx.x * blockDim.x + threadIdx.x;
    if (idx < NUM_PARTICLES) {
        // Initialize random states
        hiprand_init(idx, 0, 0, &states[idx]);
        
        // Initialize positions and velocities
        positions[idx] = hiprand_uniform(&states[idx]) * 10.0f - 5.0f; // Random position between -5 and 5
        velocities[idx] = hiprand_uniform(&states[idx]) * 2.0f - 1.0f; // Random velocity between -1 and 1
        
        // Initialize personal best positions and values
        pBestPositions[idx] = positions[idx];
        pBestValues[idx] = -1.0f; // Assume initial worst value
    }
}

__global__ void updateParticles(float *positions, float *velocities, float *pBestPositions, float *pBestValues, float gBestPosition, float gBestValue, float w, float c1, float c2, hiprandState *states) {
    int idx = blockIdx.x * blockDim.x + threadIdx.x;
    if (idx < NUM_PARTICLES) {
        // Update velocity
        float r1 = hiprand_uniform(&states[idx]);
        float r2 = hiprand_uniform(&states[idx]);
        velocities[idx] = w * velocities[idx] + c1 * r1 * (pBestPositions[idx] - positions[idx]) + c2 * r2 * (gBestPosition - positions[idx]);
        
        // Update position
        positions[idx] += velocities[idx];
        
        // Evaluate fitness (simple example: parabola)
        float fitness = positions[idx] * positions[idx];
        
        // Update personal best
        if (fitness < pBestValues[idx]) {
            pBestValues[idx] = fitness;
            pBestPositions[idx] = positions[idx];
        }
        
        // Update global best (not done here, but in the host code)
    }
}

int main() {
    float *h_positions, *h_velocities, *h_pBestPositions, *h_pBestValues;
    float *d_positions, *d_velocities, *d_pBestPositions, *d_pBestValues;
    hiprandState *d_states;
    
    // Allocate host memory
    h_positions = (float *)malloc(NUM_PARTICLES * sizeof(float));
    h_velocities = (float *)malloc(NUM_PARTICLES * sizeof(float));
    h_pBestPositions = (float *)malloc(NUM_PARTICLES * sizeof(float));
    h_pBestValues = (float *)malloc(NUM_PARTICLES * sizeof(float));
    
    // Allocate device memory
    hipMalloc((void **)&d_positions, NUM_PARTICLES * sizeof(float));
    hipMalloc((void **)&d_velocities, NUM_PARTICLES * sizeof(float));
    hipMalloc((void **)&d_pBestPositions, NUM_PARTICLES * sizeof(float));
    hipMalloc((void **)&d_pBestValues, NUM_PARTICLES * sizeof(float));
    hipMalloc((void **)&d_states, NUM_PARTICLES * sizeof(hiprandState));
    
    // Initialize particles
    initParticles<<<(NUM_PARTICLES + 255) / 256, 256>>>(d_positions, d_velocities, d_pBestPositions, d_pBestValues, d_states);
    hipDeviceSynchronize();
    
    // Check for errors in initialization
    hipError_t err = hipGetLastError();
    if (err != hipSuccess) {
        std::cerr << "CUDA error: " << hipGetErrorString(err) << std::endl;
        return -1;
    }
    
    // Copy initial positions to host for evaluation
    hipMemcpy(h_positions, d_positions, NUM_PARTICLES * sizeof(float), hipMemcpyDeviceToHost);
    hipMemcpy(h_pBestValues, d_pBestValues, NUM_PARTICLES * sizeof(float), hipMemcpyDeviceToHost);
    
    // Initialize global best
    float gBestValue = h_pBestValues[0];
    float gBestPosition = h_pBestPositions[0];
    for (int i = 1; i < NUM_PARTICLES; ++i) {
        if (h_pBestValues[i] < gBestValue) {
            gBestValue = h_pBestValues[i];
            gBestPosition = h_pBestPositions[i];
        }
    }
    
    // Constants for PSO
    float w = 0.729; // Inertia weight
    float c1 = 1.49445; // Cognitive coefficient
    float c2 = 1.49445; // Social coefficient
    
    // Main PSO loop
    for (int iter = 0; iter < MAX_ITERATIONS; ++iter) {
        // Update particles
        updateParticles<<<(NUM_PARTICLES + 255) / 256, 256>>>(d_positions, d_velocities, d_pBestPositions, d_pBestValues, gBestPosition, gBestValue, w, c1, c2, d_states);
        hipDeviceSynchronize();
        
        // Check for errors in update
        err = hipGetLastError();
        if (err != hipSuccess) {
            std::cerr << "CUDA error: " << hipGetErrorString(err) << std::endl;
            return -1;
        }
        
        // Update global best on host
        hipMemcpy(h_pBestValues, d_pBestValues, NUM_PARTICLES * sizeof(float), hipMemcpyDeviceToHost);
        hipMemcpy(h_pBestPositions, d_pBestPositions, NUM_PARTICLES * sizeof(float), hipMemcpyDeviceToHost);
        for (int i = 0; i < NUM_PARTICLES; ++i) {
            if (h_pBestValues[i] < gBestValue) {
                gBestValue = h_pBestValues[i];
                gBestPosition = h_pBestPositions[i];
            }
        }
    }
    
    // Output the best solution found
    std::cout << "Global best position: " << gBestPosition << std::endl;
    std::cout << "Global best value: " << gBestValue << std::endl;
    
    // Free device memory
    hipFree(d_positions);
    hipFree(d_velocities);
    hipFree(d_pBestPositions);
    hipFree(d_pBestValues);
    hipFree(d_states);
    
    // Free host memory
    free(h_positions);
    free(h_velocities);
    free(h_pBestPositions);
    free(h_pBestValues);
    
    return 0;
}
	.text
	.file	"cuda_code_049875.hip"
                                        # Start of file scope inline assembly
	.globl	_ZSt21ios_base_library_initv

                                        # End of file scope inline assembly
	.globl	_Z28__device_stub__initParticlesPfS_S_S_P12hiprandState # -- Begin function _Z28__device_stub__initParticlesPfS_S_S_P12hiprandState
	.type	_Z28__device_stub__initParticlesPfS_S_S_P12hiprandState,@function
_Z28__device_stub__initParticlesPfS_S_S_P12hiprandState: # @_Z28__device_stub__initParticlesPfS_S_S_P12hiprandState
	.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	$144, %rsp
	.cfi_def_cfa_offset 192
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	56(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	48(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	40(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	32(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	24(%rsp), %rcx
	movq	%r8, (%rcx)
	leaq	96(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	leaq	80(%rsp), %r14
	leaq	64(%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	$_Z13initParticlesPfS_S_S_P12hiprandState, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$160, %rsp
	.cfi_adjust_cfa_offset -160
	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	_Z28__device_stub__initParticlesPfS_S_S_P12hiprandState, .Lfunc_end0-_Z28__device_stub__initParticlesPfS_S_S_P12hiprandState
	.cfi_endproc
                                        # -- End function
	.globl	_Z30__device_stub__updateParticlesPfS_S_S_fffffP12hiprandState # -- Begin function _Z30__device_stub__updateParticlesPfS_S_S_fffffP12hiprandState
	.type	_Z30__device_stub__updateParticlesPfS_S_S_fffffP12hiprandState,@function
_Z30__device_stub__updateParticlesPfS_S_S_fffffP12hiprandState: # @_Z30__device_stub__updateParticlesPfS_S_S_fffffP12hiprandState
	.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	$192, %rsp
	.cfi_def_cfa_offset 240
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	72(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	64(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	56(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	48(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	20(%rsp), %rcx
	movss	%xmm0, (%rcx)
	leaq	16(%rsp), %r9
	movss	%xmm1, (%r9)
	leaq	12(%rsp), %r10
	movss	%xmm2, (%r10)
	leaq	8(%rsp), %r11
	movss	%xmm3, (%r11)
	leaq	4(%rsp), %r14
	movss	%xmm4, (%r14)
	leaq	40(%rsp), %r15
	movq	%r8, (%r15)
	leaq	112(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	movq	%r9, 40(%rbx)
	movq	%r10, 48(%rbx)
	movq	%r11, 56(%rbx)
	movq	%r14, 64(%rbx)
	movq	%r15, 72(%rbx)
	leaq	96(%rsp), %r14
	leaq	80(%rsp), %r15
	leaq	32(%rsp), %r12
	leaq	24(%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	$_Z15updateParticlesPfS_S_S_fffffP12hiprandState, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$208, %rsp
	.cfi_adjust_cfa_offset -208
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z30__device_stub__updateParticlesPfS_S_S_fffffP12hiprandState, .Lfunc_end1-_Z30__device_stub__updateParticlesPfS_S_S_fffffP12hiprandState
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI2_0:
	.long	0x3f3a9fbe                      # float 0.728999972
.LCPI2_1:
	.long	0x3fbf4a23                      # float 1.49444997
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movabsq	$4294967297, %r12               # imm = 0x100000001
	movl	$512, %edi                      # imm = 0x200
	callq	malloc
	movq	%rax, %rbx
	movl	$512, %edi                      # imm = 0x200
	callq	malloc
	movq	%rax, %r14
	movl	$512, %edi                      # imm = 0x200
	callq	malloc
	movq	%rax, %r15
	leaq	24(%rsp), %rdi
	movl	$512, %esi                      # imm = 0x200
	callq	hipMalloc
	leaq	40(%rsp), %rdi
	movl	$512, %esi                      # imm = 0x200
	callq	hipMalloc
	leaq	16(%rsp), %rdi
	movl	$512, %esi                      # imm = 0x200
	callq	hipMalloc
	leaq	8(%rsp), %rdi
	movl	$512, %esi                      # imm = 0x200
	callq	hipMalloc
	leaq	32(%rsp), %rdi
	movl	$6144, %esi                     # imm = 0x1800
	callq	hipMalloc
	leaq	255(%r12), %r13
	movq	%r12, %rdi
	movl	$1, %esi
	movq	%r13, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB2_2
# %bb.1:
	movq	24(%rsp), %rdi
	movq	40(%rsp), %rsi
	movq	16(%rsp), %rdx
	movq	8(%rsp), %rcx
	movq	32(%rsp), %r8
	callq	_Z28__device_stub__initParticlesPfS_S_S_P12hiprandState
.LBB2_2:
	callq	hipDeviceSynchronize
	callq	hipGetLastError
	testl	%eax, %eax
	je	.LBB2_8
.LBB2_3:
	movl	%eax, %ebp
	movl	$_ZSt4cerr, %edi
	movl	$.L.str, %esi
	movl	$12, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	%ebp, %edi
	callq	hipGetErrorString
	testq	%rax, %rax
	je	.LBB2_4
# %bb.5:
	movq	%rax, %rbx
	movq	%rax, %rdi
	callq	strlen
	movl	$_ZSt4cerr, %edi
	movq	%rbx, %rsi
	movq	%rax, %rdx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	jmp	.LBB2_6
.LBB2_8:
	movq	24(%rsp), %rsi
	movl	$512, %edx                      # imm = 0x200
	movq	%rbx, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movq	8(%rsp), %rsi
	movl	$512, %edx                      # imm = 0x200
	movq	%r15, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movss	(%r15), %xmm1                   # xmm1 = mem[0],zero,zero,zero
	movl	$1, %eax
                                        # implicit-def: $xmm2
.LBB2_9:                                # =>This Inner Loop Header: Depth=1
	movss	(%r15,%rax,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	ucomiss	%xmm0, %xmm1
	jbe	.LBB2_11
# %bb.10:                               #   in Loop: Header=BB2_9 Depth=1
	movss	(%r14,%rax,4), %xmm2            # xmm2 = mem[0],zero,zero,zero
	movaps	%xmm0, %xmm1
.LBB2_11:                               #   in Loop: Header=BB2_9 Depth=1
	incq	%rax
	cmpq	$128, %rax
	jne	.LBB2_9
# %bb.12:                               # %.preheader.preheader
	movss	%xmm2, (%rsp)                   # 4-byte Spill
	movss	%xmm1, 4(%rsp)                  # 4-byte Spill
	movq	%rbx, 48(%rsp)                  # 8-byte Spill
	xorl	%ebx, %ebx
.LBB2_13:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_17 Depth 2
	movq	%r12, %rdi
	movl	$1, %esi
	movq	%r13, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB2_15
# %bb.14:                               #   in Loop: Header=BB2_13 Depth=1
	movq	24(%rsp), %rdi
	movq	40(%rsp), %rsi
	movq	16(%rsp), %rdx
	movq	8(%rsp), %rcx
	movq	32(%rsp), %r8
	movss	(%rsp), %xmm0                   # 4-byte Reload
                                        # xmm0 = mem[0],zero,zero,zero
	movss	4(%rsp), %xmm1                  # 4-byte Reload
                                        # xmm1 = mem[0],zero,zero,zero
	movss	.LCPI2_0(%rip), %xmm2           # xmm2 = mem[0],zero,zero,zero
	movss	.LCPI2_1(%rip), %xmm3           # xmm3 = mem[0],zero,zero,zero
	movaps	%xmm3, %xmm4
	callq	_Z30__device_stub__updateParticlesPfS_S_S_fffffP12hiprandState
.LBB2_15:                               #   in Loop: Header=BB2_13 Depth=1
	callq	hipDeviceSynchronize
	callq	hipGetLastError
	testl	%eax, %eax
	jne	.LBB2_3
# %bb.16:                               #   in Loop: Header=BB2_13 Depth=1
	movq	8(%rsp), %rsi
	movl	$512, %edx                      # imm = 0x200
	movq	%r15, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movq	16(%rsp), %rsi
	movl	$512, %edx                      # imm = 0x200
	movq	%r14, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	xorl	%eax, %eax
	movss	4(%rsp), %xmm1                  # 4-byte Reload
                                        # xmm1 = mem[0],zero,zero,zero
	movss	(%rsp), %xmm2                   # 4-byte Reload
                                        # xmm2 = mem[0],zero,zero,zero
.LBB2_17:                               #   Parent Loop BB2_13 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movss	(%r15,%rax,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	ucomiss	%xmm0, %xmm1
	jbe	.LBB2_19
# %bb.18:                               #   in Loop: Header=BB2_17 Depth=2
	movss	(%r14,%rax,4), %xmm2            # xmm2 = mem[0],zero,zero,zero
	movaps	%xmm0, %xmm1
.LBB2_19:                               #   in Loop: Header=BB2_17 Depth=2
	incq	%rax
	cmpq	$128, %rax
	jne	.LBB2_17
# %bb.20:                               #   in Loop: Header=BB2_13 Depth=1
	movss	%xmm2, (%rsp)                   # 4-byte Spill
	movss	%xmm1, 4(%rsp)                  # 4-byte Spill
	incl	%ebx
	cmpl	$100, %ebx
	jne	.LBB2_13
# %bb.21:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.1, %esi
	movl	$22, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rsp), %xmm0                   # 4-byte Folded Reload
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %r12
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r12, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%r12, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$_ZSt4cout, %edi
	movl	$.L.str.2, %esi
	movl	$19, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	xorps	%xmm0, %xmm0
	cvtss2sd	4(%rsp), %xmm0                  # 4-byte Folded Reload
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %r12
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r12, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%r12, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movq	24(%rsp), %rdi
	callq	hipFree
	movq	40(%rsp), %rdi
	callq	hipFree
	movq	16(%rsp), %rdi
	callq	hipFree
	movq	8(%rsp), %rdi
	callq	hipFree
	movq	32(%rsp), %rdi
	callq	hipFree
	movq	48(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	%r14, %rdi
	callq	free
	movq	%r15, %rdi
	callq	free
	xorl	%eax, %eax
	jmp	.LBB2_7
.LBB2_4:
	movq	_ZSt4cerr(%rip), %rax
	movq	-24(%rax), %rax
	leaq	_ZSt4cerr(%rax), %rdi
	movl	32(%rdi), %esi
	orl	$1, %esi
	callq	_ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate
.LBB2_6:                                # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit
	movq	_ZSt4cerr(%rip), %rax
	movl	$_ZSt4cerr, %ecx
	movq	-24(%rax), %rdi
	addq	%rcx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cerr, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$-1, %eax
.LBB2_7:
	addq	$56, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	main, .Lfunc_end2-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB3_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB3_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z13initParticlesPfS_S_S_P12hiprandState, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z15updateParticlesPfS_S_S_fffffP12hiprandState, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end3:
	.size	__hip_module_ctor, .Lfunc_end3-__hip_module_ctor
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_dtor
	.type	__hip_module_dtor,@function
__hip_module_dtor:                      # @__hip_module_dtor
	.cfi_startproc
# %bb.0:
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	je	.LBB4_2
# %bb.1:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	__hipUnregisterFatBinary
	movq	$0, __hip_gpubin_handle(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
.LBB4_2:
	retq
.Lfunc_end4:
	.size	__hip_module_dtor, .Lfunc_end4-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z13initParticlesPfS_S_S_P12hiprandState,@object # @_Z13initParticlesPfS_S_S_P12hiprandState
	.section	.rodata,"a",@progbits
	.globl	_Z13initParticlesPfS_S_S_P12hiprandState
	.p2align	3, 0x0
_Z13initParticlesPfS_S_S_P12hiprandState:
	.quad	_Z28__device_stub__initParticlesPfS_S_S_P12hiprandState
	.size	_Z13initParticlesPfS_S_S_P12hiprandState, 8

	.type	_Z15updateParticlesPfS_S_S_fffffP12hiprandState,@object # @_Z15updateParticlesPfS_S_S_fffffP12hiprandState
	.globl	_Z15updateParticlesPfS_S_S_fffffP12hiprandState
	.p2align	3, 0x0
_Z15updateParticlesPfS_S_S_fffffP12hiprandState:
	.quad	_Z30__device_stub__updateParticlesPfS_S_S_fffffP12hiprandState
	.size	_Z15updateParticlesPfS_S_S_fffffP12hiprandState, 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	"Global best position: "
	.size	.L.str.1, 23

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Global best value: "
	.size	.L.str.2, 20

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z13initParticlesPfS_S_S_P12hiprandState"
	.size	.L__unnamed_1, 41

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z15updateParticlesPfS_S_S_fffffP12hiprandState"
	.size	.L__unnamed_2, 48

	.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 _Z28__device_stub__initParticlesPfS_S_S_P12hiprandState
	.addrsig_sym _Z30__device_stub__updateParticlesPfS_S_S_fffffP12hiprandState
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z13initParticlesPfS_S_S_P12hiprandState
	.addrsig_sym _Z15updateParticlesPfS_S_S_fffffP12hiprandState
	.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	_Z13initParticlesPfS_S_S_P12hiprandState ; -- Begin function _Z13initParticlesPfS_S_S_P12hiprandState
	.globl	_Z13initParticlesPfS_S_S_P12hiprandState
	.p2align	8
	.type	_Z13initParticlesPfS_S_S_P12hiprandState,@function
_Z13initParticlesPfS_S_S_P12hiprandState: ; @_Z13initParticlesPfS_S_S_P12hiprandState
; %bb.0:
	s_load_b32 s2, s[0:1], 0x34
	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 0x80, v1
	s_cbranch_execz .LBB0_2
; %bb.1:
	v_xor_b32_e32 v0, 0x2c7f967f, v1
	v_cmp_lt_i32_e32 vcc_lo, -1, v1
	s_clause 0x1
	s_load_b64 s[8:9], s[0:1], 0x20
	s_load_b256 s[0:7], s[0:1], 0x0
	s_mov_b32 s10, 0x41200000
	v_mul_lo_u32 v0, 0x493c4aa1, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_add_nc_u32_e32 v2, 0x75bcd15, v0
	v_add_nc_u32_e32 v3, 0x583f19, v0
	v_lshrrev_b32_e32 v4, 2, v2
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_3)
	v_lshlrev_b32_e32 v5, 4, v3
	s_waitcnt lgkmcnt(0)
	v_mad_i64_i32 v[9:10], null, v1, 48, s[8:9]
	v_xor_b32_e32 v2, v4, v2
	v_xor_b32_e32 v4, 0x159a55e5, v0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_lshlrev_b32_e32 v6, 1, v2
	v_lshrrev_b32_e32 v7, 2, v4
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_xor_b32_e32 v5, v5, v6
	v_mov_b32_e32 v6, 0x8a5d614f
	v_xor_b32_e32 v7, v7, v4
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_xor3_b32 v4, v5, v3, v2
	v_dual_cndmask_b32 v13, 0xfa091aa4, v6 :: v_dual_lshlrev_b32 v2, 1, v7
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_lshlrev_b32_e32 v5, 4, v4
	v_add_nc_u32_e32 v0, v0, v13
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_xor_b32_e32 v2, v2, v5
	v_add_nc_u32_e32 v14, 0x700053, v0
	v_add3_u32 v0, v0, v4, 0x6a788e
	v_mov_b32_e32 v5, 0
	s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_xor3_b32 v15, v2, v7, v4
	v_ashrrev_i32_e32 v2, 31, v1
	v_dual_mov_b32 v6, v5 :: v_dual_add_nc_u32 v11, v15, v14
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_lshlrev_b64 v[7:8], 2, v[1:2]
	v_cvt_f32_u32_e32 v2, v0
	v_cvt_f32_u32_e32 v11, v11
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_fmaak_f32 v2, 0x2f800000, v2, 0x2f800000
	v_add_co_u32 v0, vcc_lo, s0, v7
	s_delay_alu instid0(VALU_DEP_3)
	v_fmaak_f32 v16, 0x2f800000, v11, 0x2f800000
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v8, vcc_lo
	v_add_co_u32 v11, vcc_lo, s2, v7
	v_fmaak_f32 v2, s10, v2, 0xc0a00000
	v_add_co_ci_u32_e32 v12, vcc_lo, s3, v8, vcc_lo
	v_fma_f32 v16, v16, 2.0, -1.0
	global_store_b64 v[9:10], v[5:6], off offset:4
	global_store_b32 v[0:1], v2, off
	global_store_b32 v[11:12], v16, off
	global_load_b32 v0, v[0:1], off
	v_add_co_u32 v5, vcc_lo, s4, v7
	v_add_nc_u32_e32 v1, 0x1f123bb5, v13
	v_xor_b32_e32 v2, 0x5491333, v13
	v_add_co_ci_u32_e32 v6, vcc_lo, s5, v8, vcc_lo
	v_add_co_u32 v7, vcc_lo, s6, v7
	v_mov_b32_e32 v11, -1.0
	v_add_co_ci_u32_e32 v8, vcc_lo, s7, v8, vcc_lo
	s_clause 0x2
	global_store_b32 v[9:10], v14, off
	global_store_b128 v[9:10], v[1:4], off offset:24
	global_store_b32 v[9:10], v15, off offset:40
	s_waitcnt vmcnt(0)
	global_store_b32 v[5:6], v0, off
	global_store_b32 v[7:8], v11, off
.LBB0_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z13initParticlesPfS_S_S_P12hiprandState
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 296
		.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 17
		.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	_Z13initParticlesPfS_S_S_P12hiprandState, .Lfunc_end0-_Z13initParticlesPfS_S_S_P12hiprandState
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 500
; NumSgprs: 18
; NumVgprs: 17
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 2
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 17
; 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
	.protected	_Z15updateParticlesPfS_S_S_fffffP12hiprandState ; -- Begin function _Z15updateParticlesPfS_S_S_fffffP12hiprandState
	.globl	_Z15updateParticlesPfS_S_S_fffffP12hiprandState
	.p2align	8
	.type	_Z15updateParticlesPfS_S_S_fffffP12hiprandState,@function
_Z15updateParticlesPfS_S_S_fffffP12hiprandState: ; @_Z15updateParticlesPfS_S_S_fffffP12hiprandState
; %bb.0:
	s_load_b32 s2, s[0:1], 0x4c
	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 0x80, v1
	s_cbranch_execz .LBB1_3
; %bb.1:
	s_clause 0x1
	s_load_b64 s[2:3], s[0:1], 0x38
	s_load_b256 s[4:11], s[0:1], 0x0
	v_ashrrev_i32_e32 v2, 31, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[13:14], 2, v[1:2]
	s_waitcnt lgkmcnt(0)
	v_mad_i64_i32 v[11:12], null, v1, 48, s[2:3]
	v_add_co_u32 v0, vcc_lo, s8, v13
	s_delay_alu instid0(VALU_DEP_3)
	v_add_co_ci_u32_e32 v1, vcc_lo, s9, v14, vcc_lo
	v_add_co_u32 v2, vcc_lo, s4, v13
	s_clause 0x2
	global_load_b128 v[5:8], v[11:12], off offset:24
	global_load_b32 v9, v[11:12], off offset:40
	global_load_b32 v4, v[11:12], off
	v_add_co_ci_u32_e32 v3, vcc_lo, s5, v14, vcc_lo
	global_load_b32 v17, v[0:1], off
	global_load_b32 v18, v[2:3], off
	v_add_co_u32 v15, vcc_lo, s6, v13
	v_add_co_ci_u32_e32 v16, vcc_lo, s7, v14, vcc_lo
	s_clause 0x1
	s_load_b128 s[4:7], s[0:1], 0x28
	s_load_b32 s0, s[0:1], 0x20
	global_load_b32 v19, v[15:16], off
	s_waitcnt vmcnt(5)
	v_lshrrev_b32_e32 v10, 2, v5
	v_lshrrev_b32_e32 v21, 2, v6
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_3)
	v_xor_b32_e32 v5, v10, v5
	s_waitcnt vmcnt(4)
	v_lshlrev_b32_e32 v10, 4, v9
	v_xor_b32_e32 v6, v21, v6
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b32_e32 v20, 1, v5
	v_xor_b32_e32 v10, v20, v10
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_xor3_b32 v10, v10, v5, v9
	v_lshlrev_b32_e32 v5, 1, v6
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_2)
	v_lshlrev_b32_e32 v20, 4, v10
	s_waitcnt vmcnt(3)
	v_add3_u32 v21, v4, v10, 0x587c5
	v_xor_b32_e32 v5, v5, v20
	v_add_nc_u32_e32 v20, 0xb0f8a, v4
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_cvt_f32_u32_e32 v4, v21
	v_xor3_b32 v21, v5, v6, v10
	s_waitcnt vmcnt(1)
	v_sub_f32_e32 v6, v17, v18
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_fmaak_f32 v4, 0x2f800000, v4, 0x2f800000
	s_waitcnt lgkmcnt(0)
	v_mul_f32_e32 v4, s5, v4
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_dual_mul_f32 v4, v4, v6 :: v_dual_add_nc_u32 v5, v21, v20
	v_cvt_f32_u32_e32 v5, v5
	v_sub_f32_e32 v6, s0, v18
	s_waitcnt vmcnt(0)
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_dual_fmac_f32 v4, s4, v19 :: v_dual_fmaak_f32 v5, 0x2f800000, v5, 0x2f800000
	v_mul_f32_e32 v5, s6, v5
	s_delay_alu instid0(VALU_DEP_1)
	v_fmac_f32_e32 v4, v5, v6
	global_store_b32 v[15:16], v4, off
	global_load_b32 v5, v[2:3], off
	s_waitcnt vmcnt(0)
	v_add_f32_e32 v6, v5, v4
	v_add_co_u32 v4, vcc_lo, s10, v13
	v_add_co_ci_u32_e32 v5, vcc_lo, s11, v14, vcc_lo
	global_store_b32 v[2:3], v6, off
	v_mul_f32_e32 v6, v6, v6
	global_load_b32 v13, v[4:5], off
	s_clause 0x2
	global_store_b32 v[11:12], v21, off offset:40
	global_store_b128 v[11:12], v[7:10], off offset:24
	global_store_b32 v[11:12], v20, off
	s_waitcnt vmcnt(0)
	v_cmp_lt_f32_e32 vcc_lo, v6, v13
	s_and_b32 exec_lo, exec_lo, vcc_lo
	s_cbranch_execz .LBB1_3
; %bb.2:
	global_store_b32 v[4:5], v6, off
	global_load_b32 v2, v[2:3], off
	s_waitcnt vmcnt(0)
	global_store_b32 v[0:1], v2, off
.LBB1_3:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z15updateParticlesPfS_S_S_fffffP12hiprandState
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 320
		.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 22
		.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_end1:
	.size	_Z15updateParticlesPfS_S_S_fffffP12hiprandState, .Lfunc_end1-_Z15updateParticlesPfS_S_S_fffffP12hiprandState
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 540
; NumSgprs: 18
; NumVgprs: 22
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 2
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 22
; 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
      - .address_space:  global
        .offset:         24
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         32
        .size:           8
        .value_kind:     global_buffer
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         44
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         48
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         52
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         54
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         56
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         58
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         60
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         62
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         96
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         104
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 296
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z13initParticlesPfS_S_S_P12hiprandState
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z13initParticlesPfS_S_S_P12hiprandState.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     17
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .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
      - .address_space:  global
        .offset:         24
        .size:           8
        .value_kind:     global_buffer
      - .offset:         32
        .size:           4
        .value_kind:     by_value
      - .offset:         36
        .size:           4
        .value_kind:     by_value
      - .offset:         40
        .size:           4
        .value_kind:     by_value
      - .offset:         44
        .size:           4
        .value_kind:     by_value
      - .offset:         48
        .size:           4
        .value_kind:     by_value
      - .address_space:  global
        .offset:         56
        .size:           8
        .value_kind:     global_buffer
      - .offset:         64
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         68
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         72
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         76
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         78
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         80
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         82
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         84
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         86
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         104
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         112
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         120
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         128
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 320
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z15updateParticlesPfS_S_S_fffffP12hiprandState
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z15updateParticlesPfS_S_S_fffffP12hiprandState.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     22
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
