#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <time.h>
#include <math.h>
#include <string.h>
#define EPSILON 1E-9
#define BLOCK_SIZE_F 512 //Work with blocks of 512 threads due to double precision - shared memory
#define BLOCK_SIZE_VP 1024 //Work with blocks of 512 threads due to double precision - shared memory
/*Declarando as structs de particula e forca*/
struct stCoord{
    double x,
          y,
          z;
};
typedef struct stCoord tpCoord;
struct stParticle
{
    tpCoord p,
            v,
            f;

};
typedef struct stParticle tpParticle;
//--------------------------------------------------------------------------------------------------------


__device__ double distance(  double* dx,
                            double* dy,
                            double* dz,
                            const tpParticle A,
                            const tpParticle B){
            double x = A.p.x - B.p.x;
            double y = A.p.y - B.p.y;
            double z = A.p.z - B.p.z;

            *dx = x; *dy = y; *dz = z;
            x *= x; y *= y; z *= z;
            return 1.0 / sqrt((double)x + y + z + EPSILON);

}


__global__ void particleParticleForces_k(tpParticle *particles, const double dt){
    extern __shared__ tpParticle subParticles[];
    int i  = blockDim.x * blockIdx.x + threadIdx.x;
//  __shared__ tpParticle subParticles[BLOCK_SIZE];
  
    for (int blk = 0; blk < gridDim.x; blk++){
        subParticles[threadIdx.x] = particles[ blockDim.x * blk + threadIdx.x];
        __syncthreads();

        for (int j = 0; j < blockDim.x; j++){
            double dx = 0.0f,  dy = 0.0f, dz = 0.0f;
            double d  = distance(&dx, &dy, &dz, particles[i], subParticles[j]);
            particles[i].f.x += dx * d;
            particles[i].f.y += dy * d;
            particles[i].f.z += dz * d;
        }//end-for (int j = 0; j < blockDim.x; j++){

    __syncthreads();
    }//end-for (int blk = 0; blk < gridDim.x; blk++){

    
}

__global__ void particleParticleVelocityPosition_k(tpParticle *particles, const double dt){
    int i  = blockDim.x * blockIdx.x + threadIdx.x;

    particles[i].v.x += dt * particles[i].f.x;
    particles[i].v.y += dt * particles[i].f.y;
    particles[i].v.z += dt * particles[i].f.z;

    particles[i].p.x += dt * particles[i].v.x;
    particles[i].p.y += dt * particles[i].v.y;
    particles[i].p.z += dt * particles[i].v.z;
}


void particleParticle (tpParticle *h_particles, int nParticles, int timesteps, double dt){
    int threadsF = BLOCK_SIZE_F,
        blocksF  = nParticles / BLOCK_SIZE_F,
        threadsVP = BLOCK_SIZE_VP,
        blocksVP  = nParticles / BLOCK_SIZE_VP;

    tpParticle *d_particles;


    if (nParticles < BLOCK_SIZE_F){
      blocksF = 1;
      threadsF = nParticles;
    }

    if (nParticles < BLOCK_SIZE_VP){
        blocksVP = 1;
        threadsVP = nParticles;
      }
  

    assert(cudaDeviceReset()== cudaSuccess);

    assert(cudaMalloc((void**) &d_particles, nParticles * sizeof(tpParticle)) == cudaSuccess);
    assert(cudaMemcpy(d_particles, h_particles, nParticles * sizeof(tpParticle),  cudaMemcpyHostToDevice) == cudaSuccess);


    assert( ((nParticles % threadsF) == 0) && ((nParticles % threadsVP) == 0) );
    //fprintf(stdout, "\n B(%d) T(%d) \n", blocks, threads);
    //fprintf(stdout, "Shared memory allocated %d\n", threads * sizeof(tpParticle));
    

    for (int t = 0; t < timesteps; t++){
      //setup_kernel<<<blocos, threads,0, mStreams[i] >>>(time (NULL) + offset, mStates+offset);

      particleParticleForces_k<<<blocksF, threadsF, threadsF * sizeof(tpParticle)>>>(d_particles, dt);
      //assert( cudaDeviceSynchronize() == cudaSuccess);

      particleParticleVelocityPosition_k<<<blocksVP, threadsVP>>>(d_particles, dt);
      //assert( cudaDeviceSynchronize() == cudaSuccess);
    }//end-for (int t = 0; t < timesteps; t++){
    
    assert(cudaMemcpy(h_particles, d_particles, nParticles * sizeof(tpParticle),  cudaMemcpyDeviceToHost) == cudaSuccess);
    cudaFree(d_particles);
}

//--------------------------------------------------------------------------------------------------------
void printLog(tpParticle *particles, int nParticles, int timestep);
void initialCondition(tpParticle *particles, int nParticles);

int main (int ac, char **av){
    int timesteps  = atoi(av[1]),
        nParticles = atoi(av[2]),
        flagSave = atoi(av[3]);


    double              dt =  0.00001f;
    tpParticle *particles = NULL;


    fprintf(stdout, "\nParcile system particle to particle \n");
    fprintf(stdout, "Memory used %lu bytes \n", nParticles * sizeof(tpParticle));

    particles = (tpParticle *) malloc ( nParticles * sizeof(tpParticle));
    assert(particles != NULL);

    initialCondition(particles, nParticles);

    particleParticle(particles, nParticles, timesteps, dt);

    if (flagSave == 1)
      printLog(particles, nParticles, timesteps);
    free(particles);



}

void printLog(tpParticle *particles, int nParticles, int timestep){
    char fileName[128];
    sprintf(fileName, "%s-%d-log.bin", __FILE__,  timestep);
    fprintf(stdout, "Saving file [%s] ", fileName); fflush(stdout);
    FILE *ptr = fopen(fileName, "wb+");
    //fwrite ((const void*)particles , sizeof(tpParticle), nParticles, ptr);
    for(int i = 0; i < nParticles; i++)
        fprintf(ptr, "%d \t %.10f %.10f %.10f \t %.10f %.10f %.10f \t %.10f %.10f %.10f \n", i,  particles[i].p.x, particles[i].p.y, particles[i].p.z,  particles[i].v.x, particles[i].v.y, particles[i].v.z, particles[i].f.x, particles[i].f.y, particles[i].f.z);


    fclose(ptr);
    fprintf(stdout, "[OK]\n"); fflush(stdout);
}

void initialCondition(tpParticle *particles, int nParticles){

    srand(42);

    memset(particles, 0x00, nParticles * sizeof(tpParticle));

    for (int i = 0; i < nParticles ; i++){
        particles[i].p.x =  2.0 * (rand() / (double)RAND_MAX) - 1.0;
        particles[i].p.y =  2.0 * (rand() / (double)RAND_MAX) - 1.0;
        particles[i].p.z =  2.0 * (rand() / (double)RAND_MAX) - 1.0;
      }




}

	.file	"tmpxft_0022c0c8_00000000-6_main-n-bodies.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2034:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2034:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z8distancePdS_S_10stParticleS0_
	.type	_Z8distancePdS_S_10stParticleS0_, @function
_Z8distancePdS_S_10stParticleS0_:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2027:
	.size	_Z8distancePdS_S_10stParticleS0_, .-_Z8distancePdS_S_10stParticleS0_
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"/home/ubuntu/Datasets/stackv2/train-structured/marzam/HPC-Aula/main/exemplos/problems-profile/nbody-cuda-profile/main-n-bodies.cu"
.LC1:
	.string	"%s-%d-log.bin"
.LC2:
	.string	"Saving file [%s] "
.LC3:
	.string	"wb+"
.LC4:
	.string	"%d \t %.10f %.10f %.10f \t %.10f %.10f %.10f \t %.10f %.10f %.10f \n"
.LC5:
	.string	"[OK]\n"
	.text
	.globl	_Z8printLogP10stParticleii
	.type	_Z8printLogP10stParticleii, @function
_Z8printLogP10stParticleii:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movl	%edx, %r9d
	leaq	.LC0(%rip), %r8
	leaq	.LC1(%rip), %rcx
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movl	$128, %edx
	movl	%esi, %r13d
	movl	$2, %esi
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	leaq	.LC4(%rip), %r14
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movq	%rdi, %rbx
	subq	$144, %rsp
	.cfi_def_cfa_offset 192
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rbp
	movq	%rbp, %rdi
	call	__sprintf_chk@PLT
	movq	%rbp, %rcx
	movl	$2, %esi
	xorl	%eax, %eax
	movq	stdout(%rip), %rdi
	leaq	.LC2(%rip), %rdx
	call	__fprintf_chk@PLT
	movq	stdout(%rip), %rdi
	call	fflush@PLT
	movq	%rbp, %rdi
	leaq	.LC3(%rip), %rsi
	xorl	%ebp, %ebp
	call	fopen@PLT
	movq	%rax, %r12
.L5:
	cmpl	%r13d, %ebp
	jge	.L10
	movsd	56(%rbx), %xmm7
	movsd	48(%rbx), %xmm6
	movl	%ebp, %ecx
	movq	%r14, %rdx
	movsd	40(%rbx), %xmm5
	movsd	32(%rbx), %xmm4
	movq	%r12, %rdi
	incl	%ebp
	movsd	24(%rbx), %xmm3
	movsd	16(%rbx), %xmm2
	movl	$2, %esi
	addq	$72, %rbx
	movsd	-64(%rbx), %xmm1
	pushq	%rax
	.cfi_def_cfa_offset 200
	movb	$8, %al
	pushq	-8(%rbx)
	.cfi_def_cfa_offset 208
	movsd	-72(%rbx), %xmm0
	call	__fprintf_chk@PLT
	popq	%rdx
	.cfi_def_cfa_offset 200
	popq	%rcx
	.cfi_def_cfa_offset 192
	jmp	.L5
.L10:
	movq	%r12, %rdi
	call	fclose@PLT
	movq	stdout(%rip), %rdi
	xorl	%eax, %eax
	leaq	.LC5(%rip), %rdx
	movl	$2, %esi
	call	__fprintf_chk@PLT
	movq	stdout(%rip), %rdi
	call	fflush@PLT
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L7
	call	__stack_chk_fail@PLT
.L7:
	addq	$144, %rsp
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2030:
	.size	_Z8printLogP10stParticleii, .-_Z8printLogP10stParticleii
	.globl	_Z16initialConditionP10stParticlei
	.type	_Z16initialConditionP10stParticlei, @function
_Z16initialConditionP10stParticlei:
.LFB2031:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movl	%esi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	%rdi, %rbx
	movl	$42, %edi
	call	srand@PLT
	movslq	%ebp, %rcx
	xorl	%eax, %eax
	movq	%rbx, %rdi
	imulq	$72, %rcx, %rcx
	rep stosb
.L12:
	cmpl	%ebp, %r12d
	jge	.L15
	call	rand@PLT
	incl	%r12d
	addq	$72, %rbx
	cvtsi2sdl	%eax, %xmm0
	divsd	.LC6(%rip), %xmm0
	addsd	%xmm0, %xmm0
	subsd	.LC7(%rip), %xmm0
	movsd	%xmm0, -72(%rbx)
	call	rand@PLT
	cvtsi2sdl	%eax, %xmm0
	divsd	.LC6(%rip), %xmm0
	addsd	%xmm0, %xmm0
	subsd	.LC7(%rip), %xmm0
	movsd	%xmm0, -64(%rbx)
	call	rand@PLT
	cvtsi2sdl	%eax, %xmm0
	divsd	.LC6(%rip), %xmm0
	addsd	%xmm0, %xmm0
	subsd	.LC7(%rip), %xmm0
	movsd	%xmm0, -56(%rbx)
	jmp	.L12
.L15:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2031:
	.size	_Z16initialConditionP10stParticlei, .-_Z16initialConditionP10stParticlei
	.globl	_Z56__device_stub__Z24particleParticleForces_kP10stParticledP10stParticled
	.type	_Z56__device_stub__Z24particleParticleForces_kP10stParticledP10stParticled, @function
_Z56__device_stub__Z24particleParticleForces_kP10stParticledP10stParticled:
.LFB2056:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	32(%rsp), %rcx
	leaq	24(%rsp), %rdx
	movsd	%xmm0, (%rsp)
	leaq	52(%rsp), %rsi
	leaq	40(%rsp), %rdi
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 48(%rsp)
	movq	%rax, 88(%rsp)
	movq	%rsp, %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 40(%rsp)
	movq	%rax, 52(%rsp)
	movl	$1, 60(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L16
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z24particleParticleForces_kP10stParticled(%rip), %rdi
	pushq	32(%rsp)
	.cfi_def_cfa_offset 144
	movq	68(%rsp), %rcx
	movl	76(%rsp), %r8d
	movq	56(%rsp), %rsi
	movl	64(%rsp), %edx
	leaq	104(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L16:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L18
	call	__stack_chk_fail@PLT
.L18:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2056:
	.size	_Z56__device_stub__Z24particleParticleForces_kP10stParticledP10stParticled, .-_Z56__device_stub__Z24particleParticleForces_kP10stParticledP10stParticled
	.globl	_Z24particleParticleForces_kP10stParticled
	.type	_Z24particleParticleForces_kP10stParticled, @function
_Z24particleParticleForces_kP10stParticled:
.LFB2057:
	.cfi_startproc
	endbr64
	jmp	_Z56__device_stub__Z24particleParticleForces_kP10stParticledP10stParticled
	.cfi_endproc
.LFE2057:
	.size	_Z24particleParticleForces_kP10stParticled, .-_Z24particleParticleForces_kP10stParticled
	.globl	_Z66__device_stub__Z34particleParticleVelocityPosition_kP10stParticledP10stParticled
	.type	_Z66__device_stub__Z34particleParticleVelocityPosition_kP10stParticledP10stParticled, @function
_Z66__device_stub__Z34particleParticleVelocityPosition_kP10stParticledP10stParticled:
.LFB2058:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	32(%rsp), %rcx
	leaq	24(%rsp), %rdx
	movsd	%xmm0, (%rsp)
	leaq	52(%rsp), %rsi
	leaq	40(%rsp), %rdi
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 48(%rsp)
	movq	%rax, 88(%rsp)
	movq	%rsp, %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 40(%rsp)
	movq	%rax, 52(%rsp)
	movl	$1, 60(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L21
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z34particleParticleVelocityPosition_kP10stParticled(%rip), %rdi
	pushq	32(%rsp)
	.cfi_def_cfa_offset 144
	movq	68(%rsp), %rcx
	movl	76(%rsp), %r8d
	movq	56(%rsp), %rsi
	movl	64(%rsp), %edx
	leaq	104(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L21:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L23
	call	__stack_chk_fail@PLT
.L23:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2058:
	.size	_Z66__device_stub__Z34particleParticleVelocityPosition_kP10stParticledP10stParticled, .-_Z66__device_stub__Z34particleParticleVelocityPosition_kP10stParticledP10stParticled
	.globl	_Z34particleParticleVelocityPosition_kP10stParticled
	.type	_Z34particleParticleVelocityPosition_kP10stParticled, @function
_Z34particleParticleVelocityPosition_kP10stParticled:
.LFB2059:
	.cfi_startproc
	endbr64
	jmp	_Z66__device_stub__Z34particleParticleVelocityPosition_kP10stParticledP10stParticled
	.cfi_endproc
.LFE2059:
	.size	_Z34particleParticleVelocityPosition_kP10stParticled, .-_Z34particleParticleVelocityPosition_kP10stParticled
	.globl	_Z16particleParticleP10stParticleiid
	.type	_Z16particleParticleP10stParticleiid, @function
_Z16particleParticleP10stParticleiid:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	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
	movl	%esi, %ebx
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movl	%edx, 28(%rsp)
	movsd	%xmm0, 8(%rsp)
	cmpl	$511, %esi
	jle	.L32
	cmpl	$1023, %esi
	jle	.L33
	movl	%esi, %eax
	movl	$512, %ecx
	sarl	$10, %ebx
	movl	$512, %ebp
	cltd
	movl	%ebx, %r14d
	movl	$1024, %ebx
	idivl	%ecx
	movl	%eax, %r15d
	jmp	.L27
.L32:
	movl	%esi, %ebp
	movl	$1, %r15d
	jmp	.L35
.L33:
	movl	$1, %r15d
	movl	$512, %ebp
.L35:
	movl	$1, %r14d
.L27:
	movabsq	$4294967297, %r12
	movslq	%ebp, %rax
	xorl	%r13d, %r13d
	imulq	$72, %rax, %rax
	movq	%rax, 16(%rsp)
.L28:
	movl	28(%rsp), %eax
	cmpl	%eax, %r13d
	jge	.L36
	movq	%r12, 56(%rsp)
	movq	16(%rsp), %r8
	xorl	%r9d, %r9d
	movq	%r12, 44(%rsp)
	movl	60(%rsp), %ecx
	movl	%ebp, 52(%rsp)
	movl	48(%rsp), %esi
	movl	%r15d, 40(%rsp)
	movq	52(%rsp), %rdx
	movq	40(%rsp), %rdi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L29
	movsd	8(%rsp), %xmm0
	xorl	%edi, %edi
	call	_Z56__device_stub__Z24particleParticleForces_kP10stParticledP10stParticled
.L29:
	movq	%r12, 56(%rsp)
	movl	60(%rsp), %ecx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	%r12, 44(%rsp)
	movl	48(%rsp), %esi
	movl	%ebx, 52(%rsp)
	movq	52(%rsp), %rdx
	movl	%r14d, 40(%rsp)
	movq	40(%rsp), %rdi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L30
	movsd	8(%rsp), %xmm0
	xorl	%edi, %edi
	call	_Z66__device_stub__Z34particleParticleVelocityPosition_kP10stParticledP10stParticled
.L30:
	incl	%r13d
	jmp	.L28
.L36:
	addq	$72, %rsp
	.cfi_def_cfa_offset 56
	xorl	%edi, %edi
	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
	jmp	cudaFree@PLT
	.cfi_endproc
.LFE2028:
	.size	_Z16particleParticleP10stParticleiid, .-_Z16particleParticleP10stParticleiid
	.section	.rodata.str1.1
.LC8:
	.string	"\nParcile system particle to particle \n"
.LC9:
	.string	"Memory used %lu bytes \n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2029:
	.cfi_startproc
	endbr64
	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
	movq	%rsi, %rbx
	pushq	%rcx
	.cfi_def_cfa_offset 48
	movq	8(%rsi), %rdi
	call	atoi@PLT
	movq	16(%rbx), %rdi
	movl	%eax, %r12d
	call	atoi@PLT
	movq	24(%rbx), %rdi
	movl	%eax, %ebp
	call	atoi@PLT
	movslq	%ebp, %rbx
	movl	$2, %esi
	movq	stdout(%rip), %rdi
	imulq	$72, %rbx, %rbx
	movl	%eax, %r13d
	leaq	.LC8(%rip), %rdx
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movq	stdout(%rip), %rdi
	leaq	.LC9(%rip), %rdx
	xorl	%eax, %eax
	movl	$2, %esi
	movq	%rbx, %rcx
	call	__fprintf_chk@PLT
	movq	%rbx, %rdi
	call	malloc@PLT
	movl	%ebp, %esi
	movq	%rax, %rdi
	movq	%rax, %rbx
	call	_Z16initialConditionP10stParticlei
	movl	%r12d, %edx
	movl	%ebp, %esi
	movq	%rbx, %rdi
	movsd	.LC10(%rip), %xmm0
	call	_Z16particleParticleP10stParticleiid
	decl	%r13d
	jne	.L38
	movl	%r12d, %edx
	movl	%ebp, %esi
	movq	%rbx, %rdi
	call	_Z8printLogP10stParticleii
.L38:
	movq	%rbx, %rdi
	call	free@PLT
	popq	%rdx
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2029:
	.size	main, .-main
	.section	.rodata.str1.1
.LC11:
	.string	"_Z34particleParticleVelocityPosition_kP10stParticled"
.LC12:
	.string	"_Z24particleParticleForces_kP10stParticled"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2061:
	.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	.LC11(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z34particleParticleVelocityPosition_kP10stParticled(%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	.LC12(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z24particleParticleForces_kP10stParticled(%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
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.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
.LFE2061:
	.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
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC6:
	.long	-4194304
	.long	1105199103
	.align 8
.LC7:
	.long	0
	.long	1072693248
	.align 8
.LC10:
	.long	-2147483648
	.long	1055193269
	.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 <hip/hip_runtime.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <time.h>
#include <math.h>
#include <string.h>
#define EPSILON 1E-9
#define BLOCK_SIZE_F 512 //Work with blocks of 512 threads due to double precision - shared memory
#define BLOCK_SIZE_VP 1024 //Work with blocks of 512 threads due to double precision - shared memory
/*Declarando as structs de particula e forca*/
struct stCoord{
    double x,
          y,
          z;
};
typedef struct stCoord tpCoord;
struct stParticle
{
    tpCoord p,
            v,
            f;

};
typedef struct stParticle tpParticle;
//--------------------------------------------------------------------------------------------------------


__device__ double distance(  double* dx,
                            double* dy,
                            double* dz,
                            const tpParticle A,
                            const tpParticle B){
            double x = A.p.x - B.p.x;
            double y = A.p.y - B.p.y;
            double z = A.p.z - B.p.z;

            *dx = x; *dy = y; *dz = z;
            x *= x; y *= y; z *= z;
            return 1.0 / sqrt((double)x + y + z + EPSILON);

}


__global__ void particleParticleForces_k(tpParticle *particles, const double dt){
    extern __shared__ tpParticle subParticles[];
    int i  = blockDim.x * blockIdx.x + threadIdx.x;
//  __shared__ tpParticle subParticles[BLOCK_SIZE];
  
    for (int blk = 0; blk < gridDim.x; blk++){
        subParticles[threadIdx.x] = particles[ blockDim.x * blk + threadIdx.x];
        __syncthreads();

        for (int j = 0; j < blockDim.x; j++){
            double dx = 0.0f,  dy = 0.0f, dz = 0.0f;
            double d  = distance(&dx, &dy, &dz, particles[i], subParticles[j]);
            particles[i].f.x += dx * d;
            particles[i].f.y += dy * d;
            particles[i].f.z += dz * d;
        }//end-for (int j = 0; j < blockDim.x; j++){

    __syncthreads();
    }//end-for (int blk = 0; blk < gridDim.x; blk++){

    
}

__global__ void particleParticleVelocityPosition_k(tpParticle *particles, const double dt){
    int i  = blockDim.x * blockIdx.x + threadIdx.x;

    particles[i].v.x += dt * particles[i].f.x;
    particles[i].v.y += dt * particles[i].f.y;
    particles[i].v.z += dt * particles[i].f.z;

    particles[i].p.x += dt * particles[i].v.x;
    particles[i].p.y += dt * particles[i].v.y;
    particles[i].p.z += dt * particles[i].v.z;
}


void particleParticle (tpParticle *h_particles, int nParticles, int timesteps, double dt){
    int threadsF = BLOCK_SIZE_F,
        blocksF  = nParticles / BLOCK_SIZE_F,
        threadsVP = BLOCK_SIZE_VP,
        blocksVP  = nParticles / BLOCK_SIZE_VP;

    tpParticle *d_particles;


    if (nParticles < BLOCK_SIZE_F){
      blocksF = 1;
      threadsF = nParticles;
    }

    if (nParticles < BLOCK_SIZE_VP){
        blocksVP = 1;
        threadsVP = nParticles;
      }
  

    assert(hipDeviceReset()== hipSuccess);

    assert(hipMalloc((void**) &d_particles, nParticles * sizeof(tpParticle)) == hipSuccess);
    assert(hipMemcpy(d_particles, h_particles, nParticles * sizeof(tpParticle),  hipMemcpyHostToDevice) == hipSuccess);


    assert( ((nParticles % threadsF) == 0) && ((nParticles % threadsVP) == 0) );
    //fprintf(stdout, "\n B(%d) T(%d) \n", blocks, threads);
    //fprintf(stdout, "Shared memory allocated %d\n", threads * sizeof(tpParticle));
    

    for (int t = 0; t < timesteps; t++){
      //setup_kernel<<<blocos, threads,0, mStreams[i] >>>(time (NULL) + offset, mStates+offset);

      particleParticleForces_k<<<blocksF, threadsF, threadsF * sizeof(tpParticle)>>>(d_particles, dt);
      //assert( cudaDeviceSynchronize() == cudaSuccess);

      particleParticleVelocityPosition_k<<<blocksVP, threadsVP>>>(d_particles, dt);
      //assert( cudaDeviceSynchronize() == cudaSuccess);
    }//end-for (int t = 0; t < timesteps; t++){
    
    assert(hipMemcpy(h_particles, d_particles, nParticles * sizeof(tpParticle),  hipMemcpyDeviceToHost) == hipSuccess);
    hipFree(d_particles);
}

//--------------------------------------------------------------------------------------------------------
void printLog(tpParticle *particles, int nParticles, int timestep);
void initialCondition(tpParticle *particles, int nParticles);

int main (int ac, char **av){
    int timesteps  = atoi(av[1]),
        nParticles = atoi(av[2]),
        flagSave = atoi(av[3]);


    double              dt =  0.00001f;
    tpParticle *particles = NULL;


    fprintf(stdout, "\nParcile system particle to particle \n");
    fprintf(stdout, "Memory used %lu bytes \n", nParticles * sizeof(tpParticle));

    particles = (tpParticle *) malloc ( nParticles * sizeof(tpParticle));
    assert(particles != NULL);

    initialCondition(particles, nParticles);

    particleParticle(particles, nParticles, timesteps, dt);

    if (flagSave == 1)
      printLog(particles, nParticles, timesteps);
    free(particles);



}

void printLog(tpParticle *particles, int nParticles, int timestep){
    char fileName[128];
    sprintf(fileName, "%s-%d-log.bin", __FILE__,  timestep);
    fprintf(stdout, "Saving file [%s] ", fileName); fflush(stdout);
    FILE *ptr = fopen(fileName, "wb+");
    //fwrite ((const void*)particles , sizeof(tpParticle), nParticles, ptr);
    for(int i = 0; i < nParticles; i++)
        fprintf(ptr, "%d \t %.10f %.10f %.10f \t %.10f %.10f %.10f \t %.10f %.10f %.10f \n", i,  particles[i].p.x, particles[i].p.y, particles[i].p.z,  particles[i].v.x, particles[i].v.y, particles[i].v.z, particles[i].f.x, particles[i].f.y, particles[i].f.z);


    fclose(ptr);
    fprintf(stdout, "[OK]\n"); fflush(stdout);
}

void initialCondition(tpParticle *particles, int nParticles){

    srand(42);

    memset(particles, 0x00, nParticles * sizeof(tpParticle));

    for (int i = 0; i < nParticles ; i++){
        particles[i].p.x =  2.0 * (rand() / (double)RAND_MAX) - 1.0;
        particles[i].p.y =  2.0 * (rand() / (double)RAND_MAX) - 1.0;
        particles[i].p.z =  2.0 * (rand() / (double)RAND_MAX) - 1.0;
      }




}

	.text
	.file	"main-n-bodies.hip"
	.globl	_Z39__device_stub__particleParticleForces_kP10stParticled # -- Begin function _Z39__device_stub__particleParticleForces_kP10stParticled
	.type	_Z39__device_stub__particleParticleForces_kP10stParticled,@function
_Z39__device_stub__particleParticleForces_kP10stParticled: # @_Z39__device_stub__particleParticleForces_kP10stParticled
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$80, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	16(%rsp), %rcx
	movsd	%xmm0, (%rcx)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%rsp, %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z24particleParticleForces_kP10stParticled, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z39__device_stub__particleParticleForces_kP10stParticled, .Lfunc_end0-_Z39__device_stub__particleParticleForces_kP10stParticled
	.cfi_endproc
                                        # -- End function
	.globl	_Z49__device_stub__particleParticleVelocityPosition_kP10stParticled # -- Begin function _Z49__device_stub__particleParticleVelocityPosition_kP10stParticled
	.type	_Z49__device_stub__particleParticleVelocityPosition_kP10stParticled,@function
_Z49__device_stub__particleParticleVelocityPosition_kP10stParticled: # @_Z49__device_stub__particleParticleVelocityPosition_kP10stParticled
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$80, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	16(%rsp), %rcx
	movsd	%xmm0, (%rcx)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%rsp, %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z34particleParticleVelocityPosition_kP10stParticled, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z49__device_stub__particleParticleVelocityPosition_kP10stParticled, .Lfunc_end1-_Z49__device_stub__particleParticleVelocityPosition_kP10stParticled
	.cfi_endproc
                                        # -- End function
	.globl	_Z16particleParticleP10stParticleiid # -- Begin function _Z16particleParticleP10stParticleiid
	.type	_Z16particleParticleP10stParticleiid,@function
_Z16particleParticleP10stParticleiid:   # @_Z16particleParticleP10stParticleiid
	.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
	pushq	%rax
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movsd	%xmm0, (%rsp)                   # 8-byte Spill
	testl	%edx, %edx
	jle	.LBB2_7
# %bb.1:                                # %.lr.ph
	movl	%edx, %ebx
	movl	%esi, %r14d
	shrl	$10, %r14d
	movl	$1024, %r15d                    # imm = 0x400
	cmpl	%r15d, %esi
	cmovll	%esi, %r15d
	movl	$1, %eax
	cmovll	%eax, %r14d
	movl	%esi, %r12d
	shrl	$9, %r12d
	movl	$512, %r13d                     # imm = 0x200
	cmpl	%r13d, %esi
	cmovll	%esi, %r13d
	cmovll	%eax, %r12d
	movslq	%r13d, %rax
	shlq	$3, %rax
	leaq	(%rax,%rax,8), %rbp
	btsq	$32, %r12
	btsq	$32, %r13
	btsq	$32, %r14
	btsq	$32, %r15
.LBB2_2:                                # =>This Inner Loop Header: Depth=1
	movq	%r12, %rdi
	movl	$1, %esi
	movq	%r13, %rdx
	movl	$1, %ecx
	movq	%rbp, %r8
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB2_4
# %bb.3:                                #   in Loop: Header=BB2_2 Depth=1
	movsd	(%rsp), %xmm0                   # 8-byte Reload
                                        # xmm0 = mem[0],zero
	callq	_Z39__device_stub__particleParticleForces_kP10stParticled
.LBB2_4:                                #   in Loop: Header=BB2_2 Depth=1
	movq	%r14, %rdi
	movl	$1, %esi
	movq	%r15, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB2_6
# %bb.5:                                #   in Loop: Header=BB2_2 Depth=1
	movsd	(%rsp), %xmm0                   # 8-byte Reload
                                        # xmm0 = mem[0],zero
	callq	_Z49__device_stub__particleParticleVelocityPosition_kP10stParticled
.LBB2_6:                                #   in Loop: Header=BB2_2 Depth=1
	decl	%ebx
	jne	.LBB2_2
.LBB2_7:                                # %._crit_edge
	addq	$8, %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
	jmp	hipFree                         # TAILCALL
.Lfunc_end2:
	.size	_Z16particleParticleP10stParticleiid, .Lfunc_end2-_Z16particleParticleP10stParticleiid
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI3_0:
	.quad	0x3ee4f8b580000000              # double 9.9999997473787516E-6
	.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	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, %r14
	movq	8(%rsi), %rdi
	callq	atoi
	movl	%eax, %ebx
	movq	16(%r14), %rdi
	callq	atoi
	movl	%eax, %ebp
	movq	24(%r14), %rdi
	callq	atoi
	movl	%eax, %r14d
	movq	stdout(%rip), %rcx
	movl	$.L.str, %edi
	movl	$38, %esi
	movl	$1, %edx
	callq	fwrite@PLT
	movq	stdout(%rip), %rdi
	movslq	%ebp, %rax
	shlq	$3, %rax
	leaq	(%rax,%rax,8), %r15
	movl	$.L.str.1, %esi
	movq	%r15, %rdx
	xorl	%eax, %eax
	callq	fprintf
	movq	%r15, %rdi
	callq	malloc
	movq	%rax, %r15
	movq	%rax, %rdi
	movl	%ebp, %esi
	callq	_Z16initialConditionP10stParticlei
	movsd	.LCPI3_0(%rip), %xmm0           # xmm0 = mem[0],zero
	movl	%ebp, %esi
	movl	%ebx, %edx
	callq	_Z16particleParticleP10stParticleiid
	cmpl	$1, %r14d
	jne	.LBB3_2
# %bb.1:
	movq	%r15, %rdi
	movl	%ebp, %esi
	movl	%ebx, %edx
	callq	_Z8printLogP10stParticleii
.LBB3_2:
	movq	%r15, %rdi
	callq	free
	xorl	%eax, %eax
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.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_end3:
	.size	main, .Lfunc_end3-main
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z16initialConditionP10stParticlei
.LCPI4_0:
	.quad	0x41dfffffffc00000              # double 2147483647
.LCPI4_1:
	.quad	0xbff0000000000000              # double -1
	.text
	.globl	_Z16initialConditionP10stParticlei
	.type	_Z16initialConditionP10stParticlei,@function
_Z16initialConditionP10stParticlei:     # @_Z16initialConditionP10stParticlei
	.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	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%esi, %ebp
	movq	%rdi, %rbx
	movl	$42, %edi
	callq	srand
	movslq	%ebp, %r14
	leaq	(,%r14,8), %rax
	leaq	(%rax,%rax,8), %rdx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
	testl	%r14d, %r14d
	jle	.LBB4_3
# %bb.1:                                # %.lr.ph.preheader
	movl	%ebp, %eax
	shlq	$3, %rax
	leaq	(%rax,%rax,8), %r14
	xorl	%r15d, %r15d
.LBB4_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	movsd	.LCPI4_0(%rip), %xmm1           # xmm1 = mem[0],zero
	divsd	%xmm1, %xmm0
	addsd	%xmm0, %xmm0
	movsd	.LCPI4_1(%rip), %xmm1           # xmm1 = mem[0],zero
	addsd	%xmm1, %xmm0
	movsd	%xmm0, (%rbx,%r15)
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	divsd	.LCPI4_0(%rip), %xmm0
	addsd	%xmm0, %xmm0
	addsd	.LCPI4_1(%rip), %xmm0
	movsd	%xmm0, 8(%rbx,%r15)
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	divsd	.LCPI4_0(%rip), %xmm0
	addsd	%xmm0, %xmm0
	addsd	.LCPI4_1(%rip), %xmm0
	movsd	%xmm0, 16(%rbx,%r15)
	addq	$72, %r15
	cmpq	%r15, %r14
	jne	.LBB4_2
.LBB4_3:                                # %._crit_edge
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.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_end4:
	.size	_Z16initialConditionP10stParticlei, .Lfunc_end4-_Z16initialConditionP10stParticlei
	.cfi_endproc
                                        # -- End function
	.globl	_Z8printLogP10stParticleii      # -- Begin function _Z8printLogP10stParticleii
	.type	_Z8printLogP10stParticleii,@function
_Z8printLogP10stParticleii:             # @_Z8printLogP10stParticleii
	.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	%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 %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%edx, %ecx
	movl	%esi, %ebp
	movq	%rdi, %rbx
	leaq	16(%rsp), %r14
	movl	$.L.str.2, %esi
	movl	$.L.str.3, %edx
	movq	%r14, %rdi
	xorl	%eax, %eax
	callq	sprintf
	movq	stdout(%rip), %rdi
	movl	$.L.str.4, %esi
	movq	%r14, %rdx
	xorl	%eax, %eax
	callq	fprintf
	movq	stdout(%rip), %rdi
	callq	fflush
	movl	$.L.str.5, %esi
	movq	%r14, %rdi
	callq	fopen
	movq	%rax, %r14
	testl	%ebp, %ebp
	jle	.LBB5_3
# %bb.1:                                # %.lr.ph.preheader
	movl	%ebp, %r12d
	addq	$64, %rbx
	xorl	%r15d, %r15d
.LBB5_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movsd	-64(%rbx), %xmm0                # xmm0 = mem[0],zero
	movsd	-56(%rbx), %xmm1                # xmm1 = mem[0],zero
	movsd	-48(%rbx), %xmm2                # xmm2 = mem[0],zero
	movsd	-40(%rbx), %xmm3                # xmm3 = mem[0],zero
	movsd	-32(%rbx), %xmm4                # xmm4 = mem[0],zero
	movsd	-24(%rbx), %xmm5                # xmm5 = mem[0],zero
	movsd	-16(%rbx), %xmm6                # xmm6 = mem[0],zero
	movsd	-8(%rbx), %xmm7                 # xmm7 = mem[0],zero
	movsd	(%rbx), %xmm8                   # xmm8 = mem[0],zero
	movsd	%xmm8, (%rsp)
	movl	$.L.str.6, %esi
	movq	%r14, %rdi
	movl	%r15d, %edx
	movb	$8, %al
	callq	fprintf
	incq	%r15
	addq	$72, %rbx
	cmpq	%r15, %r12
	jne	.LBB5_2
.LBB5_3:                                # %._crit_edge
	movq	%r14, %rdi
	callq	fclose
	movq	stdout(%rip), %rcx
	movl	$.L.str.7, %edi
	movl	$5, %esi
	movl	$1, %edx
	callq	fwrite@PLT
	movq	stdout(%rip), %rdi
	callq	fflush
	addq	$144, %rsp
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.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_end5:
	.size	_Z8printLogP10stParticleii, .Lfunc_end5-_Z8printLogP10stParticleii
	.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	.LBB6_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB6_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z24particleParticleForces_kP10stParticled, %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	$_Z34particleParticleVelocityPosition_kP10stParticled, %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_end6:
	.size	__hip_module_ctor, .Lfunc_end6-__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	.LBB7_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
.LBB7_2:
	retq
.Lfunc_end7:
	.size	__hip_module_dtor, .Lfunc_end7-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z24particleParticleForces_kP10stParticled,@object # @_Z24particleParticleForces_kP10stParticled
	.section	.rodata,"a",@progbits
	.globl	_Z24particleParticleForces_kP10stParticled
	.p2align	3, 0x0
_Z24particleParticleForces_kP10stParticled:
	.quad	_Z39__device_stub__particleParticleForces_kP10stParticled
	.size	_Z24particleParticleForces_kP10stParticled, 8

	.type	_Z34particleParticleVelocityPosition_kP10stParticled,@object # @_Z34particleParticleVelocityPosition_kP10stParticled
	.globl	_Z34particleParticleVelocityPosition_kP10stParticled
	.p2align	3, 0x0
_Z34particleParticleVelocityPosition_kP10stParticled:
	.quad	_Z49__device_stub__particleParticleVelocityPosition_kP10stParticled
	.size	_Z34particleParticleVelocityPosition_kP10stParticled, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"\nParcile system particle to particle \n"
	.size	.L.str, 39

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"Memory used %lu bytes \n"
	.size	.L.str.1, 24

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"%s-%d-log.bin"
	.size	.L.str.2, 14

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"/home/ubuntu/Datasets/stackv2/train-structured-repos-hip-sm89/marzam/HPC-Aula/main/exemplos/problems-profile/nbody-cuda-profile/main-n-bodies.hip"
	.size	.L.str.3, 146

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"Saving file [%s] "
	.size	.L.str.4, 18

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"wb+"
	.size	.L.str.5, 4

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"%d \t %.10f %.10f %.10f \t %.10f %.10f %.10f \t %.10f %.10f %.10f \n"
	.size	.L.str.6, 65

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"[OK]\n"
	.size	.L.str.7, 6

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z24particleParticleForces_kP10stParticled"
	.size	.L__unnamed_1, 43

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z34particleParticleVelocityPosition_kP10stParticled"
	.size	.L__unnamed_2, 53

	.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 _Z39__device_stub__particleParticleForces_kP10stParticled
	.addrsig_sym _Z49__device_stub__particleParticleVelocityPosition_kP10stParticled
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z24particleParticleForces_kP10stParticled
	.addrsig_sym _Z34particleParticleVelocityPosition_kP10stParticled
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z24particleParticleForces_kP10stParticled ; -- Begin function _Z24particleParticleForces_kP10stParticled
	.globl	_Z24particleParticleForces_kP10stParticled
	.p2align	8
	.type	_Z24particleParticleForces_kP10stParticled,@function
_Z24particleParticleForces_kP10stParticled: ; @_Z24particleParticleForces_kP10stParticled
; %bb.0:
	s_load_b32 s6, s[0:1], 0x10
	s_add_u32 s2, s0, 16
	s_addc_u32 s3, s1, 0
	s_mov_b32 s7, 0
	s_waitcnt lgkmcnt(0)
	s_cmp_eq_u32 s6, 0
	s_cbranch_scc1 .LBB0_7
; %bb.1:                                ; %.lr.ph32
	s_load_b32 s4, s[2:3], 0xc
	s_load_b64 s[2:3], s[0:1], 0x0
	v_mad_u32_u24 v19, 0x48, v0, 0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s1, s4, 0xffff
	s_mov_b32 s4, 0xe826d695
	v_mad_u64_u32 v[1:2], null, s15, s1, v[0:1]
	s_cmp_lg_u32 s1, 0
	s_mov_b32 s5, 0x3e112e0b
	s_cselect_b32 s0, -1, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_i64_i32 v[9:10], null, 0x48, v1, s[2:3]
	v_cndmask_b32_e64 v1, 0, 1, s0
	v_cmp_ne_u32_e64 s0, 1, v1
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_add_co_u32 v11, vcc_lo, v9, 48
	v_add_co_ci_u32_e32 v12, vcc_lo, 0, v10, vcc_lo
	v_add_co_u32 v13, vcc_lo, v9, 64
	v_add_co_ci_u32_e32 v14, vcc_lo, 0, v10, vcc_lo
.LBB0_2:                                ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_4 Depth 2
	v_mad_u64_u32 v[1:2], null, s7, s1, v[0:1]
	s_and_b32 vcc_lo, exec_lo, s0
	s_delay_alu instid0(VALU_DEP_1)
	v_mad_u64_u32 v[24:25], null, 0x48, v1, s[2:3]
	s_clause 0x4
	global_load_b128 v[1:4], v[24:25], off offset:56
	global_load_b128 v[5:8], v[24:25], off offset:48
	global_load_b128 v[15:18], v[24:25], off offset:32
	global_load_b128 v[20:23], v[24:25], off offset:16
	global_load_b128 v[24:27], v[24:25], off
	s_waitcnt vmcnt(4)
	ds_store_2addr_b64 v19, v[1:2], v[3:4] offset0:7 offset1:8
	s_waitcnt vmcnt(3)
	ds_store_2addr_b64 v19, v[5:6], v[7:8] offset0:6 offset1:7
	s_waitcnt vmcnt(2)
	ds_store_2addr_b64 v19, v[15:16], v[17:18] offset0:4 offset1:5
	s_waitcnt vmcnt(1)
	ds_store_2addr_b64 v19, v[20:21], v[22:23] offset0:2 offset1:3
	s_waitcnt vmcnt(0)
	ds_store_2addr_b64 v19, v[24:25], v[26:27] offset1:1
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_cbranch_vccnz .LBB0_6
; %bb.3:                                ; %.lr.ph
                                        ;   in Loop: Header=BB0_2 Depth=1
	s_clause 0x3
	global_load_b64 v[15:16], v[11:12], off offset:16
	global_load_b128 v[1:4], v[11:12], off
	global_load_b64 v[17:18], v[9:10], off offset:16
	global_load_b128 v[5:8], v[9:10], off
	s_mov_b32 s8, 0
	s_mov_b32 s9, s1
.LBB0_4:                                ;   Parent Loop BB0_2 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	v_mov_b32_e32 v24, s8
	s_add_i32 s9, s9, -1
	s_addk_i32 s8, 0x48
	s_cmp_eq_u32 s9, 0
	ds_load_2addr_b64 v[20:23], v24 offset1:1
	ds_load_b64 v[24:25], v24 offset:16
	s_waitcnt vmcnt(0) lgkmcnt(1)
	v_add_f64 v[22:23], v[7:8], -v[22:23]
	v_add_f64 v[20:21], v[5:6], -v[20:21]
	s_waitcnt lgkmcnt(0)
	v_add_f64 v[24:25], v[17:18], -v[24:25]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f64 v[26:27], v[22:23], v[22:23]
	v_fma_f64 v[26:27], v[20:21], v[20:21], v[26:27]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[26:27], v[24:25], v[24:25], v[26:27]
	v_add_f64 v[26:27], v[26:27], s[4:5]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_cmp_gt_f64_e32 vcc_lo, 0x10000000, v[26:27]
	v_cndmask_b32_e64 v28, 0, 1, vcc_lo
	v_lshlrev_b32_e32 v28, 8, v28
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ldexp_f64 v[26:27], v[26:27], v28
	v_rsq_f64_e32 v[28:29], v[26:27]
	s_waitcnt_depctr 0xfff
	v_mul_f64 v[30:31], v[26:27], v[28:29]
	v_mul_f64 v[28:29], v[28:29], 0.5
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[32:33], -v[28:29], v[30:31], 0.5
	v_fma_f64 v[30:31], v[30:31], v[32:33], v[30:31]
	v_fma_f64 v[28:29], v[28:29], v[32:33], v[28:29]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[32:33], -v[30:31], v[30:31], v[26:27]
	v_fma_f64 v[30:31], v[32:33], v[28:29], v[30:31]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[32:33], -v[30:31], v[30:31], v[26:27]
	v_fma_f64 v[28:29], v[32:33], v[28:29], v[30:31]
	v_cndmask_b32_e64 v30, 0, 0xffffff80, vcc_lo
	v_cmp_class_f64_e64 vcc_lo, v[26:27], 0x260
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ldexp_f64 v[28:29], v[28:29], v30
	v_dual_cndmask_b32 v27, v29, v27 :: v_dual_cndmask_b32 v26, v28, v26
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_div_scale_f64 v[28:29], null, v[26:27], v[26:27], 1.0
	v_div_scale_f64 v[34:35], vcc_lo, 1.0, v[26:27], 1.0
	v_rcp_f64_e32 v[30:31], v[28:29]
	s_waitcnt_depctr 0xfff
	v_fma_f64 v[32:33], -v[28:29], v[30:31], 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[30:31], v[30:31], v[32:33], v[30:31]
	v_fma_f64 v[32:33], -v[28:29], v[30:31], 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[30:31], v[30:31], v[32:33], v[30:31]
	v_mul_f64 v[32:33], v[34:35], v[30:31]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[28:29], -v[28:29], v[32:33], v[34:35]
	v_div_fmas_f64 v[28:29], v[28:29], v[30:31], v[32:33]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_div_fixup_f64 v[26:27], v[28:29], v[26:27], 1.0
	v_fma_f64 v[1:2], v[20:21], v[26:27], v[1:2]
	v_fma_f64 v[3:4], v[22:23], v[26:27], v[3:4]
	v_fma_f64 v[15:16], v[24:25], v[26:27], v[15:16]
	s_cbranch_scc0 .LBB0_4
; %bb.5:                                ; %._crit_edge
                                        ;   in Loop: Header=BB0_2 Depth=1
	s_clause 0x1
	global_store_b128 v[11:12], v[1:4], off
	global_store_b64 v[13:14], v[15:16], off
.LBB0_6:                                ;   in Loop: Header=BB0_2 Depth=1
	s_add_i32 s7, s7, 1
	s_waitcnt_vscnt null, 0x0
	s_cmp_eq_u32 s7, s6
	s_barrier
	buffer_gl0_inv
	s_cbranch_scc0 .LBB0_2
.LBB0_7:                                ; %._crit_edge33
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z24particleParticleForces_kP10stParticled
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 272
		.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 36
		.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	_Z24particleParticleForces_kP10stParticled, .Lfunc_end0-_Z24particleParticleForces_kP10stParticled
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 824
; NumSgprs: 18
; NumVgprs: 36
; ScratchSize: 0
; MemoryBound: 1
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 4
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 36
; 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	_Z34particleParticleVelocityPosition_kP10stParticled ; -- Begin function _Z34particleParticleVelocityPosition_kP10stParticled
	.globl	_Z34particleParticleVelocityPosition_kP10stParticled
	.p2align	8
	.type	_Z34particleParticleVelocityPosition_kP10stParticled,@function
_Z34particleParticleVelocityPosition_kP10stParticled: ; @_Z34particleParticleVelocityPosition_kP10stParticled
; %bb.0:
	s_clause 0x1
	s_load_b32 s4, s[0:1], 0x1c
	s_load_b128 s[0:3], s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s4, s4, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s4, v[0:1]
	v_mad_i64_i32 v[16:17], null, 0x48, v1, s[0:1]
	s_clause 0x4
	global_load_b128 v[0:3], v[16:17], off offset:16
	global_load_b128 v[4:7], v[16:17], off offset:48
	global_load_b128 v[8:11], v[16:17], off offset:32
	global_load_b64 v[18:19], v[16:17], off offset:64
	global_load_b128 v[12:15], v[16:17], off
	s_waitcnt vmcnt(3)
	v_fma_f64 v[2:3], v[4:5], s[2:3], v[2:3]
	s_waitcnt vmcnt(2)
	v_fma_f64 v[4:5], v[6:7], s[2:3], v[8:9]
	s_waitcnt vmcnt(1)
	v_fma_f64 v[6:7], v[18:19], s[2:3], v[10:11]
	s_waitcnt vmcnt(0)
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_fma_f64 v[8:9], v[2:3], s[2:3], v[12:13]
	v_fma_f64 v[10:11], v[4:5], s[2:3], v[14:15]
	s_delay_alu instid0(VALU_DEP_3)
	v_fma_f64 v[0:1], v[6:7], s[2:3], v[0:1]
	s_clause 0x2
	global_store_b128 v[16:17], v[4:7], off offset:32
	global_store_b128 v[16:17], v[8:11], off
	global_store_b128 v[16:17], v[0:3], off offset:16
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z34particleParticleVelocityPosition_kP10stParticled
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 272
		.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 20
		.amdhsa_next_free_sgpr 16
		.amdhsa_reserve_vcc 0
		.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	_Z34particleParticleVelocityPosition_kP10stParticled, .Lfunc_end1-_Z34particleParticleVelocityPosition_kP10stParticled
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 212
; NumSgprs: 16
; NumVgprs: 20
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 1
; VGPRBlocks: 2
; NumSGPRsForWavesPerEU: 16
; NumVGPRsForWavesPerEU: 20
; 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
      - .offset:         8
        .size:           8
        .value_kind:     by_value
      - .offset:         16
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         20
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         28
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         30
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         32
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         34
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         36
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         38
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         56
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         80
        .size:           2
        .value_kind:     hidden_grid_dims
      - .offset:         136
        .size:           4
        .value_kind:     hidden_dynamic_lds_size
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 272
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z24particleParticleForces_kP10stParticled
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z24particleParticleForces_kP10stParticled.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     36
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .offset:         8
        .size:           8
        .value_kind:     by_value
      - .offset:         16
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         20
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         28
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         30
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         32
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         34
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         36
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         38
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         56
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         80
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 272
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z34particleParticleVelocityPosition_kP10stParticled
    .private_segment_fixed_size: 0
    .sgpr_count:     16
    .sgpr_spill_count: 0
    .symbol:         _Z34particleParticleVelocityPosition_kP10stParticled.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     20
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
