#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <sys/time.h>
#include <pthread.h>
#include <cuda_runtime.h>


// global constants
#define NUM_CPU_THREADS 32
#define MAX_MASS 100.0f
#define MAX_POS_X 100.0f
#define MAX_POS_Y 100.0f
#define MAX_VEL_X 0.0f
#define MAX_VEL_Y 0.0f
#define G 8
#define DT 0.0019531255f
#define DT2 0.000003814697265625f/2
#define DAMPING 1.0f
#define SOFTENING 0.0009765625f

typedef struct {
	float *m;
	float *r1, *r2;
	float *v1, *v2;
	float *a1, *a2;
	unsigned long nElem, nIter;
} UNIVERSE;

UNIVERSE US;

#define checkCudaErrors(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true)
{
	if (code != cudaSuccess)
	{
		fprintf(stderr,"GPUassert: %s %s %d\n", cudaGetErrorString(code), file, line);
		if (abort) exit(code);
	}
}

// time stamp function in seconds
double getTimeStamp()
{
	struct timeval tv;
	gettimeofday (&tv, NULL);
	return (double) tv.tv_usec/1000000 + tv.tv_sec;
}

void print_BodyStats (const float *m, const float *r, const float *v, const float *a)
{
    unsigned long nElem = US.nElem;

    printf("\n");
    // print body number
    for (unsigned long idx=0; idx<nElem; idx++) {
        if (idx == nElem-1)
            printf("Mass %ld\n", idx);
        else
            printf("Mass %ld\t", idx);
    }

    // print Mass
    for (unsigned long idx=0; idx<nElem; idx++) {
        if (idx == nElem-1)
            printf("%.2f\n", m[idx]);
        else
            printf("%.2f\t", m[idx]);
    }

    // print x-position
    for (unsigned long idx=0; idx<nElem; idx++) {
        if (idx == nElem-1)
            printf("%.2f\n", r[2*idx]);
        else
            printf("%.2f\t", r[2*idx]);
    }

    // print y-position
    for (unsigned long idx=0; idx<nElem; idx++) {
        if (idx == nElem-1)
            printf("%.2f\n", r[2*idx+1]);
        else
            printf("%.2f\t", r[2*idx+1]);
    }

    // print x-velocity
    for (unsigned long idx=0; idx<nElem; idx++) {
        if (idx == nElem-1)
            printf("%.2f\n", v[2*idx]);
        else
            printf("%.2f\t", v[2*idx]);
    }

    // print y-velocity
    for (unsigned long idx=0; idx<nElem; idx++) {
        if (idx == nElem-1)
            printf("%.2f\n", v[2*idx+1]);
        else
            printf("%.2f\t", v[2*idx+1]);
    }

    // print x-acceleration
    for (unsigned long idx=0; idx<nElem; idx++) {
        if (idx == nElem-1)
            printf("%.2f\n", a[2*idx]);
        else
            printf("%.2f\t", a[2*idx]);
    }

    // print y-acceleration
    for (unsigned long idx=0; idx<nElem; idx++) {
        if (idx == nElem-1)
            printf("%.2f\n\n", a[2*idx+1]);
        else
            printf("%.2f\t", a[2*idx+1]);
    }

}

void init_MassPositionVelocity ()
{
	// generate different seed for pseudo-random number generator
	// time_t t;
	// srand ((unsigned int) time(&t));
	srand ((unsigned int) 1000);

	// define local variables for convenience
	unsigned long nElem = US.nElem;

	// populating mass, position, & velocity arrays
	unsigned long idx;
	for (idx=0; idx<nElem; idx++)
	{
		US.m[idx]     = 100.0;//(float) ((double) rand() / (double) (RAND_MAX/MAX_MASS));
		US.r1[2*idx]   = (float) ((double) rand() / (double) (RAND_MAX/(MAX_POS_X*2)) - MAX_POS_X);
		US.r1[2*idx+1] = (float) ((double) rand() / (double) (RAND_MAX/(MAX_POS_Y*2)) - MAX_POS_Y);
		US.v1[2*idx]   = (float) ((double) rand() / (double) (RAND_MAX/(MAX_VEL_X*2)) - MAX_VEL_X);
		US.v1[2*idx+1] = (float) ((double) rand() / (double) (RAND_MAX/(MAX_VEL_Y*2)) - MAX_VEL_Y);
	}
}

void *init_Acceleration_SMT (void *arg)
{
    // define local variables for convenience
    unsigned long start, end, len, offset, nElem;

    nElem = US.nElem;
    offset = (unsigned long) arg;
    len = (unsigned long) US.nElem / NUM_CPU_THREADS;
    start = offset * len;
    end = start + len;

    unsigned long i, j;
    float ax_ip1, ay_ip1;
    float dx_ip1, dy_ip1, rDistSquared, invDistCubed;
    float **i_r = &US.r1;
    float **o_a = &US.a1;

    // calculating NEXT acceleration of each body from the position of every other bodies
    // ... and NEXT velocity of each body utilizing the next acceleration
    for (i=start; i<end; i++)
    {
        ax_ip1 = 0.0;
        ay_ip1 = 0.0;
        for (j=0; j<nElem; j++)
        {
            if (j != i)
            {
                dx_ip1 = *(*i_r + 2*j)   - *(*i_r + 2*i);
                dy_ip1 = *(*i_r + 2*j+1) - *(*i_r + 2*i+1);
                rDistSquared = dx_ip1*dx_ip1 + dy_ip1*dy_ip1 + SOFTENING;
                invDistCubed = G*US.m[j]/sqrtf(rDistSquared*rDistSquared*rDistSquared);
                ax_ip1 += dx_ip1 * invDistCubed;
                ay_ip1 += dy_ip1 * invDistCubed;
            }
        }

        *(*o_a + 2*i)   = ax_ip1;
        *(*o_a + 2*i+1) = ay_ip1;
    }

    pthread_exit (NULL);
}


__global__ void compute_Device (
	float *o_r, float *o_v, float *o_a,
	const float *i_r, const float *i_v, const float *i_a,
	const float *m, const unsigned long nElem)
{
	unsigned long tid = blockIdx.x * blockDim.x + threadIdx.x;
	// if (tid == 0)
	// 	printf("x: %.6f\ty:%.6f\n", i_r[0], i_r[1]);

	float ax_ip1 = 0.0, ay_ip1 = 0.0;
	float dx_ip1, dy_ip1, rDistSquared, invDistCubed;

	if (tid < nElem) {
		// calculating subsequent position of body (one body per thread)
		o_r[2*tid]   = i_r[2*tid]   + i_v[2*tid]*DT   + i_a[2*tid]*DT2;		// x-position
		o_r[2*tid+1] = i_r[2*tid+1] + i_v[2*tid+1]*DT + i_a[2*tid+1]*DT2;	// y-position

		// calculating the NEXT iteration's acceleration and velocity
		for (unsigned long j=0; j<nElem; j++) {
			if (j != tid) {
				dx_ip1 = o_r[2*j]   - o_r[2*tid];
				dy_ip1 = o_r[2*j+1] - o_r[2*tid+1];
				rDistSquared = dx_ip1*dx_ip1 + dy_ip1*dy_ip1 + SOFTENING;
				invDistCubed = G*m[j]*rsqrtf(rDistSquared*rDistSquared*rDistSquared);
				ax_ip1 += dx_ip1 * invDistCubed;
				ay_ip1 += dy_ip1 * invDistCubed;
			}
		}

		o_a[2*tid]   = ax_ip1;	// x-acceleration
		o_a[2*tid+1] = ay_ip1;	// y-acceleration

		o_v[2*tid]   = i_v[2*tid]   + (i_a[2*tid]   + ax_ip1)*DT/2;	// x-velocity
		o_v[2*tid+1] = i_v[2*tid+1] + (i_a[2*tid+1] + ay_ip1)*DT/2;	// y-velocity
	}
}


int main (int argc, char *argv[])
{
	if (argc > 3) {
		printf("Error: Wrong number of arguments.\n");
		exit(EXIT_FAILURE);
	}

	unsigned long nElem = 16000;
	unsigned long nIter = 10;
	char *ptr1, *ptr2;

	if (argc > 1)
		nElem = strtoul(argv[1], &ptr1, 10);
	if (argc > 2)
		nIter = strtoul(argv[2], &ptr2, 10);


	////////////////////////////////////////////////////////////////
	/// SETTING UP DEVICE
	////////////////////////////////////////////////////////////////

	int dev = 0, driverVersion = 0, runtimeVersion = 0;
	cudaDeviceProp deviceProp;
	checkCudaErrors (cudaGetDeviceProperties (&deviceProp, dev));
	checkCudaErrors (cudaSetDevice (dev));
	checkCudaErrors (cudaDriverGetVersion (&driverVersion));
	checkCudaErrors (cudaRuntimeGetVersion (&runtimeVersion));

	printf("\n===== Device Properties ======\n\n");
	printf("  Device %d: %s\n", dev, deviceProp.name);
	printf("  CUDA Driver Version / Runtime Version: %d.%d / %d.%d\n",
		driverVersion/1000, (driverVersion%100)/10,
		runtimeVersion/1000, (runtimeVersion%100)/10);
	printf("  CUDA Capability Major/Minor version number: %d.%d\n",
		deviceProp.major, deviceProp.minor);
	printf("  Number of SMs: %d\n", deviceProp.multiProcessorCount);
	printf("  Total amount of global memory: %.2f GB (%llu B)\n",
		(float) deviceProp.totalGlobalMem/pow(1024.0,3),
		(unsigned long long) deviceProp.totalGlobalMem);
	printf("  Total amount of constant memory: %4.2f kB\n",
		deviceProp.totalConstMem/1024.0);
	printf("  Total amount of shared memory per block: %4.2f kB\n",
		deviceProp.sharedMemPerBlock/1024.0);
	printf("  Total number of registers available per block: %d\n",
		deviceProp.regsPerBlock);
	printf("  Warp size: %d\n", deviceProp.warpSize);
	printf("  Maximum number of threads per block: %d\n",
		deviceProp.maxThreadsPerBlock);
	printf("  Maximum number of threads per SM: %d\n",
		deviceProp.maxThreadsPerMultiProcessor);
	printf("  Maximum number of warps per SM: %d\n",
		deviceProp.maxThreadsPerMultiProcessor/32);
	printf("  Maximum size of each block dimension: %d x %d x %d\n",
		deviceProp.maxThreadsDim[0], deviceProp.maxThreadsDim[1],
		deviceProp.maxThreadsDim[2]);
	printf("  Maximum size of each grid dimension: %d x %d x %d\n",
		deviceProp.maxGridSize[0], deviceProp.maxGridSize[1],
		deviceProp.maxGridSize[2]);
	printf("  Maximum memory pitch: %lu B\n", deviceProp.memPitch);
	printf("  Memory Clock Rate (MHz): %.1f\n",
		deviceProp.memoryClockRate/1e3);
	printf("  Memory Bus Width (b): %d\n", deviceProp.memoryBusWidth);
	printf("  Peak Memory Bandwidth (GB/s): %.2f\n\n",
		2.0*deviceProp.memoryClockRate*(deviceProp.memoryBusWidth/8)/1e6);


	printf("\n===== Simulation Parameters =====\n\n");
	printf("  Number of Bodies = %ld\n", nElem);
	printf("  Number of Time Steps = %ld\n", nIter);
	printf("  Number of CPU Threads = %d\n\n", NUM_CPU_THREADS);
	printf("=================================\n\n\n");

	////////////////////////////////////////////////////////////////
	/// INITIALIZING SIMULATION
	////////////////////////////////////////////////////////////////

	float *h_m, *h_r1, *h_r2, *h_v1, *h_v2, *h_a1, *h_a2;	// host data
	float *d_m, *d_r1, *d_r2, *d_v1, *d_v2, *d_a1, *d_a2;	// device data
	float *gref_m, *gref_r, *gref_v, *gref_a;

	size_t nBytes = nElem * sizeof(float);
	h_m  = (float *) malloc(nBytes);
	h_r1 = (float *) malloc(nBytes*2);
	h_r2 = (float *) malloc(nBytes*2);
	h_v1 = (float *) malloc(nBytes*2);
	h_v2 = (float *) malloc(nBytes*2);
	h_a1 = (float *) malloc(nBytes*2);
	h_a2 = (float *) malloc(nBytes*2);

	gref_m  = (float *) malloc(nBytes);
	gref_r = (float *) malloc(nBytes*2);
	gref_v = (float *) malloc(nBytes*2);
	gref_a = (float *) malloc(nBytes*2);

	memset (h_m,  0, nBytes);
	memset (h_r1, 0, nBytes*2);
	memset (h_r2, 0, nBytes*2);
	memset (h_v1, 0, nBytes*2);
	memset (h_v2, 0, nBytes*2);
	memset (h_a1, 0, nBytes*2);
	memset (h_a2, 0, nBytes*2);

	memset (gref_m,  0, nBytes);
	memset (gref_r, 0, nBytes*2);
	memset (gref_v, 0, nBytes*2);
	memset (gref_a, 0, nBytes*2);

	// initialize data on host size and then transfer to device
	US.m = h_m;
	US.r1 = h_r1;
	US.r2 = h_r2;
	US.v1 = h_v1;
	US.v2 = h_v2;
	US.a1 = h_a1;
	US.a2 = h_a2;
	US.nElem = nElem;
	US.nIter = nIter;

	printf("Initializing bodies on HOST. Time taken: ");
	double time0 = getTimeStamp();
	init_MassPositionVelocity();

	// for portability, explicity create threads in a joinable state
	pthread_t threads [NUM_CPU_THREADS];
	pthread_attr_t attr;
	pthread_attr_init (&attr);
	pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_JOINABLE);

	// creating the threads to calculate initial body accelerations on HOST
	unsigned long i;
	int rc;
	void *status;
	for (i=0; i<NUM_CPU_THREADS; i++) {
		rc = pthread_create (&threads[i], &attr, init_Acceleration_SMT, (void *) i);
		if (rc) {
			printf("Error; return code from pthread_create() is %d.\n", rc);
			exit(EXIT_FAILURE);
		}
	}

	// wait on the other threads after initial body accelerations on HOST
	for (i=0; i<NUM_CPU_THREADS; i++) {
		rc = pthread_join (threads[i], &status);
		if (rc) {
			printf("ERROR; return code from pthread_join() is %d.\n", rc);
			exit(EXIT_FAILURE);
		}
	}
	printf ("%lfs\n", getTimeStamp()-time0);
	//print_BodyStats(h_m, h_r1, h_v1, h_a1);

	// allocating space in device global memory for data
	checkCudaErrors (cudaMalloc ((void**) &d_m,  nBytes));
	checkCudaErrors (cudaMalloc ((void**) &d_r1, nBytes*2));
	checkCudaErrors (cudaMalloc ((void**) &d_r2, nBytes*2));
	checkCudaErrors (cudaMalloc ((void**) &d_v1, nBytes*2));
	checkCudaErrors (cudaMalloc ((void**) &d_v2, nBytes*2));
	checkCudaErrors (cudaMalloc ((void**) &d_a1, nBytes*2));
	checkCudaErrors (cudaMalloc ((void**) &d_a2, nBytes*2));

	// copying initialized data from host to device
	checkCudaErrors (cudaMemcpy (d_m,  h_m,  nBytes,   cudaMemcpyHostToDevice));
	checkCudaErrors (cudaMemcpy (d_r1, h_r1, nBytes*2, cudaMemcpyHostToDevice));
	checkCudaErrors (cudaMemcpy (d_r2, h_r2, nBytes*2, cudaMemcpyHostToDevice));
	checkCudaErrors (cudaMemcpy (d_v1, h_v1, nBytes*2, cudaMemcpyHostToDevice));
	checkCudaErrors (cudaMemcpy (d_v2, h_v2, nBytes*2, cudaMemcpyHostToDevice));
	checkCudaErrors (cudaMemcpy (d_a1, h_a1, nBytes*2, cudaMemcpyHostToDevice));
	checkCudaErrors (cudaMemcpy (d_a2, h_a2, nBytes*2, cudaMemcpyHostToDevice));

	////////////////////////////////////////////////////////////////
	/// PERFORMING SIMULATION ON DEVICE
	////////////////////////////////////////////////////////////////

	dim3 block (1024);
	dim3 grid  ((nElem+block.x-1)/(block.x));

	double timestamp_GPU_start = getTimeStamp();
	for (unsigned long iter=0; iter<nIter; iter++) {
		if (iter % 2 == 0) {
			compute_Device <<<grid, block, 0, 0>>> (d_r2, d_v2, d_a2, d_r1, d_v1, d_a1, d_m, nElem);
			cudaDeviceSynchronize ();
			// cudaMemcpy(gref_m, d_m, nBytes, cudaMemcpyDeviceToHost);
			// cudaMemcpy(gref_r, d_r2, nBytes*2, cudaMemcpyDeviceToHost);
			// cudaMemcpy(gref_v, d_v2, nBytes*2, cudaMemcpyDeviceToHost);
			// cudaMemcpy(gref_a, d_a2, nBytes*2, cudaMemcpyDeviceToHost);

		} else {
			compute_Device <<<grid, block, 0, 0>>> (d_r1, d_v1, d_a1, d_r2, d_v2, d_a2, d_m, nElem);
			cudaDeviceSynchronize ();
			// cudaMemcpy(gref_m, d_m, nBytes, cudaMemcpyDeviceToHost);
			// cudaMemcpy(gref_r, d_r1, nBytes*2, cudaMemcpyDeviceToHost);
			// cudaMemcpy(gref_v, d_v1, nBytes*2, cudaMemcpyDeviceToHost);
			// cudaMemcpy(gref_a, d_a1, nBytes*2, cudaMemcpyDeviceToHost);
		}
		// if (iter%1000 == 0)
		// 	print_BodyStats (gref_m, gref_r, gref_v, gref_a);
	}
	double timestamp_GPU_end = getTimeStamp();
	double elapsedTime = timestamp_GPU_end - timestamp_GPU_start;

	////////////////////////////////////////////////////////////////
	/// SIMULATION COMPLETE
	////////////////////////////////////////////////////////////////

	cudaFree (d_m);
	cudaFree (d_r1); cudaFree (d_r2);
	cudaFree (d_v1); cudaFree (d_v2);
	cudaFree (d_a1); cudaFree (d_a2);

	checkCudaErrors (cudaDeviceReset());
	printf("Device successfully reset.\n");
	printf("\nElapsed Time: %lfs\n", elapsedTime);
	printf("Average timestep simulation duration: %lfs\n", elapsedTime/nIter);


	free (h_m);
	free (h_r1); free (h_r2);
	free (h_v1); free (h_v2);
	free (h_a1); free (h_a2);

	free (gref_m);
	free (gref_r);
	free (gref_v);
	free (gref_a);

	pthread_attr_destroy (&attr);
	//pthread_exit(NULL);

	return 0;
}

	.file	"tmpxft_00393e2d_00000000-6_test_gpu.cudafe1.cpp"
	.text
#APP

#NO_APP
	.globl	_Z21init_Acceleration_SMTPv
	.type	_Z21init_Acceleration_SMTPv, @function
_Z21init_Acceleration_SMTPv:
.LFB2040:
	.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
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	56+US(%rip), %r14
	movq	%r14, %r13
	shrq	$5, %r13
	imulq	%r13, %rdi
	movq	%rdi, %rbx
	addq	%rdi, %r13
.L2:
	cmpq	%r13, %rbx
	jnb	.L5
	leaq	0(,%rbx,8), %r12
	xorps	%xmm6, %xmm6
	xorl	%ebp, %ebp
	leaq	4(%r12), %r15
	movaps	%xmm6, %xmm5
.L6:
	cmpq	%r14, %rbp
	je	.L9
	cmpq	%rbp, %rbx
	je	.L3
	movq	8+US(%rip), %rax
	movss	%xmm6, 28(%rsp)
	movss	%xmm5, 24(%rsp)
	movss	(%rax,%rbp,8), %xmm2
	movss	4(%rax,%rbp,8), %xmm1
	subss	(%rax,%r12), %xmm2
	subss	(%rax,%r15), %xmm1
	movq	US(%rip), %rax
	movaps	%xmm2, %xmm3
	movaps	%xmm1, %xmm0
	movss	(%rax,%rbp,4), %xmm4
	movss	%xmm2, 20(%rsp)
	mulss	%xmm1, %xmm0
	movss	%xmm1, 16(%rsp)
	mulss	%xmm2, %xmm3
	addss	%xmm0, %xmm3
	addss	.LC1(%rip), %xmm3
	movss	.LC2(%rip), %xmm0
	mulss	%xmm0, %xmm4
	movaps	%xmm3, %xmm0
	mulss	%xmm3, %xmm0
	movss	%xmm4, 12(%rsp)
	mulss	%xmm3, %xmm0
	call	sqrtf@PLT
	movss	12(%rsp), %xmm4
	movss	20(%rsp), %xmm2
	movss	16(%rsp), %xmm1
	movss	24(%rsp), %xmm5
	divss	%xmm0, %xmm4
	movss	28(%rsp), %xmm6
	mulss	%xmm4, %xmm2
	mulss	%xmm4, %xmm1
	addss	%xmm2, %xmm5
	addss	%xmm1, %xmm6
.L3:
	incq	%rbp
	jmp	.L6
.L9:
	movq	40+US(%rip), %rax
	incq	%rbx
	movss	%xmm5, (%rax,%r12)
	movss	%xmm6, 4(%rax,%r12)
	jmp	.L2
.L5:
	xorl	%edi, %edi
	call	pthread_exit@PLT
	.cfi_endproc
.LFE2040:
	.size	_Z21init_Acceleration_SMTPv, .-_Z21init_Acceleration_SMTPv
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2045:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2045:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata._Z9gpuAssert9cudaErrorPKcib.str1.1,"aMS",@progbits,1
.LC3:
	.string	"GPUassert: %s %s %d\n"
	.section	.text._Z9gpuAssert9cudaErrorPKcib,"axG",@progbits,_Z9gpuAssert9cudaErrorPKcib,comdat
	.weak	_Z9gpuAssert9cudaErrorPKcib
	.type	_Z9gpuAssert9cudaErrorPKcib, @function
_Z9gpuAssert9cudaErrorPKcib:
.LFB2036:
	.cfi_startproc
	endbr64
	testl	%edi, %edi
	je	.L17
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movl	%ecx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movl	%edi, %ebx
	subq	$24, %rsp
	.cfi_def_cfa_offset 48
	movl	%edx, 12(%rsp)
	movq	%rsi, (%rsp)
	call	cudaGetErrorString@PLT
	movl	12(%rsp), %r9d
	movq	(%rsp), %r8
	leaq	.LC3(%rip), %rdx
	movq	stderr(%rip), %rdi
	movq	%rax, %rcx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	testb	%bpl, %bpl
	je	.L11
	movl	%ebx, %edi
	call	exit@PLT
.L11:
	addq	$24, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
.L17:
	.cfi_restore 3
	.cfi_restore 6
	ret
	.cfi_endproc
.LFE2036:
	.size	_Z9gpuAssert9cudaErrorPKcib, .-_Z9gpuAssert9cudaErrorPKcib
	.text
	.globl	_Z12getTimeStampv
	.type	_Z12getTimeStampv, @function
_Z12getTimeStampv:
.LFB2037:
	.cfi_startproc
	endbr64
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	xorl	%esi, %esi
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rdi
	call	gettimeofday@PLT
	cvtsi2sdq	8(%rsp), %xmm1
	cvtsi2sdq	16(%rsp), %xmm0
	divsd	.LC4(%rip), %xmm0
	addsd	%xmm1, %xmm0
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2037:
	.size	_Z12getTimeStampv, .-_Z12getTimeStampv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC5:
	.string	"\n"
.LC6:
	.string	"Mass %ld\n"
.LC7:
	.string	"Mass %ld\t"
.LC8:
	.string	"%.2f\n"
.LC9:
	.string	"%.2f\t"
.LC10:
	.string	"%.2f\n\n"
	.text
	.globl	_Z15print_BodyStatsPKfS0_S0_S0_
	.type	_Z15print_BodyStatsPKfS0_S0_S0_, @function
_Z15print_BodyStatsPKfS0_S0_S0_:
.LFB2038:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rdi, %r15
	xorl	%eax, %eax
	movl	$2, %edi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rsi, %r14
	leaq	.LC5(%rip), %rsi
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rdx, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rcx, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	pushq	%r8
	.cfi_def_cfa_offset 64
	movq	56+US(%rip), %rbx
	call	__printf_chk@PLT
.L24:
	cmpq	%rbx, %rbp
	je	.L65
	leaq	-1(%rbx), %rax
	movq	%rbp, %rdx
	leaq	.LC6(%rip), %rsi
	cmpq	%rbp, %rax
	je	.L57
	leaq	.LC7(%rip), %rsi
.L57:
	movl	$2, %edi
	xorl	%eax, %eax
	incq	%rbp
	call	__printf_chk@PLT
	jmp	.L24
.L65:
	xorl	%ebp, %ebp
.L28:
	cmpq	%rbx, %rbp
	je	.L66
	leaq	-1(%rbx), %rax
	leaq	.LC8(%rip), %rsi
	cvtss2sd	(%r15,%rbp,4), %xmm0
	cmpq	%rbp, %rax
	je	.L58
	leaq	.LC9(%rip), %rsi
.L58:
	movl	$2, %edi
	movb	$1, %al
	incq	%rbp
	call	__printf_chk@PLT
	jmp	.L28
.L66:
	xorl	%ebp, %ebp
	leaq	.LC9(%rip), %r15
.L32:
	cmpq	%rbx, %rbp
	je	.L67
	leaq	-1(%rbx), %rax
	leaq	.LC8(%rip), %rsi
	cvtss2sd	(%r14,%rbp,8), %xmm0
	cmpq	%rbp, %rax
	je	.L59
	movq	%r15, %rsi
.L59:
	movl	$2, %edi
	movb	$1, %al
	incq	%rbp
	call	__printf_chk@PLT
	jmp	.L32
.L67:
	xorl	%ebp, %ebp
	leaq	.LC9(%rip), %r15
.L36:
	cmpq	%rbx, %rbp
	je	.L68
	leaq	-1(%rbx), %rax
	leaq	.LC8(%rip), %rsi
	cvtss2sd	4(%r14,%rbp,8), %xmm0
	cmpq	%rbp, %rax
	je	.L60
	movq	%r15, %rsi
.L60:
	movl	$2, %edi
	movb	$1, %al
	incq	%rbp
	call	__printf_chk@PLT
	jmp	.L36
.L68:
	xorl	%ebp, %ebp
	leaq	.LC9(%rip), %r14
.L40:
	cmpq	%rbx, %rbp
	je	.L69
	leaq	-1(%rbx), %rax
	leaq	.LC8(%rip), %rsi
	cvtss2sd	0(%r13,%rbp,8), %xmm0
	cmpq	%rbp, %rax
	je	.L61
	movq	%r14, %rsi
.L61:
	movl	$2, %edi
	movb	$1, %al
	incq	%rbp
	call	__printf_chk@PLT
	jmp	.L40
.L69:
	xorl	%ebp, %ebp
	leaq	.LC9(%rip), %r14
.L44:
	cmpq	%rbx, %rbp
	je	.L70
	leaq	-1(%rbx), %rax
	leaq	.LC8(%rip), %rsi
	cvtss2sd	4(%r13,%rbp,8), %xmm0
	cmpq	%rbp, %rax
	je	.L62
	movq	%r14, %rsi
.L62:
	movl	$2, %edi
	movb	$1, %al
	incq	%rbp
	call	__printf_chk@PLT
	jmp	.L44
.L70:
	xorl	%ebp, %ebp
	leaq	.LC9(%rip), %r13
.L48:
	cmpq	%rbx, %rbp
	je	.L71
	leaq	-1(%rbx), %rax
	leaq	.LC8(%rip), %rsi
	cvtss2sd	(%r12,%rbp,8), %xmm0
	cmpq	%rbp, %rax
	je	.L63
	movq	%r13, %rsi
.L63:
	movl	$2, %edi
	movb	$1, %al
	incq	%rbp
	call	__printf_chk@PLT
	jmp	.L48
.L71:
	xorl	%ebp, %ebp
	leaq	.LC9(%rip), %r13
.L52:
	cmpq	%rbx, %rbp
	je	.L72
	leaq	-1(%rbx), %rax
	leaq	.LC10(%rip), %rsi
	cvtss2sd	4(%r12,%rbp,8), %xmm0
	cmpq	%rbp, %rax
	je	.L64
	movq	%r13, %rsi
.L64:
	movl	$2, %edi
	movb	$1, %al
	incq	%rbp
	call	__printf_chk@PLT
	jmp	.L52
.L72:
	popq	%rax
	.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
.LFE2038:
	.size	_Z15print_BodyStatsPKfS0_S0_S0_, .-_Z15print_BodyStatsPKfS0_S0_S0_
	.globl	_Z25init_MassPositionVelocityv
	.type	_Z25init_MassPositionVelocityv, @function
_Z25init_MassPositionVelocityv:
.LFB2039:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movl	$1000, %edi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	xorl	%ebx, %ebx
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	call	srand@PLT
	movq	56+US(%rip), %r12
.L74:
	cmpq	%r12, %rbx
	je	.L77
	movq	US(%rip), %rax
	leaq	0(,%rbx,8), %rbp
	movl	$0x42c80000, (%rax,%rbx,4)
	call	rand@PLT
	cvtsi2sdl	%eax, %xmm0
	divsd	.LC12(%rip), %xmm0
	subsd	.LC13(%rip), %xmm0
	movq	8+US(%rip), %rax
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, (%rax,%rbx,8)
	call	rand@PLT
	cvtsi2sdl	%eax, %xmm0
	divsd	.LC12(%rip), %xmm0
	subsd	.LC13(%rip), %xmm0
	movq	8+US(%rip), %rax
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, 4(%rax,%rbp)
	call	rand@PLT
	movss	.LC14(%rip), %xmm0
	xorps	%xmm1, %xmm1
	divss	%xmm1, %xmm0
	cvtsi2sdl	%eax, %xmm1
	movq	24+US(%rip), %rax
	cvtss2sd	%xmm0, %xmm0
	divsd	%xmm0, %xmm1
	movsd	%xmm0, 8(%rsp)
	cvtsd2ss	%xmm1, %xmm1
	movss	%xmm1, (%rax,%rbx,8)
	incq	%rbx
	call	rand@PLT
	movsd	8(%rsp), %xmm0
	cvtsi2sdl	%eax, %xmm1
	movq	24+US(%rip), %rax
	divsd	%xmm0, %xmm1
	cvtsd2ss	%xmm1, %xmm1
	movss	%xmm1, 4(%rax,%rbp)
	jmp	.L74
.L77:
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2039:
	.size	_Z25init_MassPositionVelocityv, .-_Z25init_MassPositionVelocityv
	.globl	_Z51__device_stub__Z14compute_DevicePfS_S_PKfS1_S1_S1_mPfS_S_PKfS1_S1_S1_m
	.type	_Z51__device_stub__Z14compute_DevicePfS_S_PKfS1_S1_S1_mPfS_S_PKfS1_S1_S1_m, @function
_Z51__device_stub__Z14compute_DevicePfS_S_PKfS1_S1_S1_mPfS_S_PKfS1_S1_S1_m:
.LFB2067:
	.cfi_startproc
	endbr64
	subq	$216, %rsp
	.cfi_def_cfa_offset 224
	movq	224(%rsp), %rax
	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, 24(%rsp)
	movq	%r9, 16(%rsp)
	movq	%rax, 8(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 200(%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	24(%rsp), %rax
	movq	%rax, 168(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 176(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 184(%rsp)
	leaq	232(%rsp), %rax
	movq	%rax, 192(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 88(%rsp)
	movq	%rax, 100(%rsp)
	movl	$1, 108(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L78
	pushq	80(%rsp)
	.cfi_def_cfa_offset 232
	leaq	_Z14compute_DevicePfS_S_PKfS1_S1_S1_m(%rip), %rdi
	pushq	80(%rsp)
	.cfi_def_cfa_offset 240
	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 232
	popq	%rdx
	.cfi_def_cfa_offset 224
.L78:
	movq	200(%rsp), %rax
	subq	%fs:40, %rax
	je	.L80
	call	__stack_chk_fail@PLT
.L80:
	addq	$216, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2067:
	.size	_Z51__device_stub__Z14compute_DevicePfS_S_PKfS1_S1_S1_mPfS_S_PKfS1_S1_S1_m, .-_Z51__device_stub__Z14compute_DevicePfS_S_PKfS1_S1_S1_mPfS_S_PKfS1_S1_S1_m
	.globl	_Z14compute_DevicePfS_S_PKfS1_S1_S1_m
	.type	_Z14compute_DevicePfS_S_PKfS1_S1_S1_m, @function
_Z14compute_DevicePfS_S_PKfS1_S1_S1_m:
.LFB2068:
	.cfi_startproc
	endbr64
	jmp	_Z51__device_stub__Z14compute_DevicePfS_S_PKfS1_S1_S1_mPfS_S_PKfS1_S1_S1_m
	.cfi_endproc
.LFE2068:
	.size	_Z14compute_DevicePfS_S_PKfS1_S1_S1_m, .-_Z14compute_DevicePfS_S_PKfS1_S1_S1_m
	.section	.rodata.str1.1
.LC15:
	.string	"Error: Wrong number of arguments.\n"
.LC16:
	.string	"/home/ubuntu/Datasets/stackv2/train-structured/haldarritam/N-Body-Simulation-CUDA/master/Backup/Gianluca/test_gpu.cu"
.LC17:
	.string	"\n===== Device Properties ======\n\n"
.LC18:
	.string	"  Device %d: %s\n"
.LC19:
	.string	"  CUDA Driver Version / Runtime Version: %d.%d / %d.%d\n"
.LC20:
	.string	"  CUDA Capability Major/Minor version number: %d.%d\n"
.LC21:
	.string	"  Number of SMs: %d\n"
.LC23:
	.string	"  Total amount of global memory: %.2f GB (%llu B)\n"
.LC25:
	.string	"  Total amount of constant memory: %4.2f kB\n"
.LC26:
	.string	"  Total amount of shared memory per block: %4.2f kB\n"
.LC27:
	.string	"  Total number of registers available per block: %d\n"
.LC28:
	.string	"  Warp size: %d\n"
.LC29:
	.string	"  Maximum number of threads per block: %d\n"
.LC30:
	.string	"  Maximum number of threads per SM: %d\n"
.LC31:
	.string	"  Maximum number of warps per SM: %d\n"
.LC32:
	.string	"  Maximum size of each block dimension: %d x %d x %d\n"
.LC33:
	.string	"  Maximum size of each grid dimension: %d x %d x %d\n"
.LC34:
	.string	"  Maximum memory pitch: %lu B\n"
.LC36:
	.string	"  Memory Clock Rate (MHz): %.1f\n"
.LC37:
	.string	"  Memory Bus Width (b): %d\n"
.LC38:
	.string	"  Peak Memory Bandwidth (GB/s): %.2f\n\n"
.LC39:
	.string	"\n===== Simulation Parameters =====\n\n"
.LC40:
	.string	"  Number of Bodies = %ld\n"
.LC41:
	.string	"  Number of Time Steps = %ld\n"
.LC42:
	.string	"  Number of CPU Threads = %d\n\n"
.LC43:
	.string	"=================================\n\n\n"
.LC44:
	.string	"Initializing bodies on HOST. Time taken: "
.LC45:
	.string	"Error; return code from pthread_create() is %d.\n"
.LC46:
	.string	"ERROR; return code from pthread_join() is %d.\n"
.LC47:
	.string	"%lfs\n"
.LC48:
	.string	"Device successfully reset.\n"
.LC49:
	.string	"\nElapsed Time: %lfs\n"
.LC50:
	.string	"Average timestep simulation duration: %lfs\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2041:
	.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
	subq	$1576, %rsp
	.cfi_def_cfa_offset 1632
	movq	%fs:40, %rax
	movq	%rax, 1560(%rsp)
	xorl	%eax, %eax
	cmpl	$3, %edi
	jle	.L84
	leaq	.LC15(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	jmp	.L111
.L84:
	movl	%edi, %r12d
	cmpl	$1, %edi
	jle	.L105
	movq	%rsi, %r13
	movl	$10, %edx
	leaq	112(%rsp), %rsi
	movl	$10, %ebx
	movq	8(%r13), %rdi
	call	__isoc23_strtoul@PLT
	movq	%rax, %rbp
	cmpl	$3, %r12d
	jne	.L85
	movq	16(%r13), %rdi
	leaq	120(%rsp), %rsi
	movl	$10, %edx
	call	__isoc23_strtoul@PLT
	movq	%rax, %rbx
	jmp	.L85
.L105:
	movl	$16000, %ebp
	movl	$10, %ebx
.L85:
	leaq	528(%rsp), %r13
	xorl	%ecx, %ecx
	xorl	%esi, %esi
	movq	%r13, %rdi
	leaq	.LC16(%rip), %r12
	movl	%ecx, 104(%rsp)
	movl	%ecx, 108(%rsp)
	call	cudaGetDeviceProperties_v2@PLT
	movl	$1, %ecx
	movl	$249, %edx
	movq	%r12, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	xorl	%edi, %edi
	call	cudaSetDevice@PLT
	movl	$1, %ecx
	movl	$250, %edx
	movq	%r12, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	leaq	104(%rsp), %rdi
	call	cudaDriverGetVersion@PLT
	movl	$1, %ecx
	movl	$251, %edx
	movq	%r12, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	leaq	108(%rsp), %rdi
	call	cudaRuntimeGetVersion@PLT
	movl	$1, %ecx
	movl	$252, %edx
	movq	%r12, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	leaq	.LC17(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%edx, %edx
	movq	%r13, %rcx
	movl	$2, %edi
	leaq	.LC18(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	108(%rsp), %eax
	movl	$100, %r10d
	movl	$10, %edi
	movl	$1000, %esi
	cltd
	idivl	%r10d
	movl	%edx, %eax
	cltd
	idivl	%edi
	movl	%eax, %r9d
	movl	108(%rsp), %eax
	cltd
	idivl	%esi
	movl	%eax, %r8d
	movl	104(%rsp), %eax
	cltd
	idivl	%r10d
	movl	%edx, %eax
	cltd
	idivl	%edi
	movl	$2, %edi
	movl	%eax, %ecx
	movl	104(%rsp), %eax
	cltd
	idivl	%esi
	leaq	.LC19(%rip), %rsi
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	892(%rsp), %ecx
	movl	$2, %edi
	xorl	%eax, %eax
	movl	888(%rsp), %edx
	leaq	.LC20(%rip), %rsi
	call	__printf_chk@PLT
	movl	916(%rsp), %edx
	leaq	.LC21(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	816(%rsp), %rdx
	testq	%rdx, %rdx
	js	.L86
	cvtsi2ssq	%rdx, %xmm0
	jmp	.L87
.L86:
	movq	%rdx, %rax
	movq	%rdx, %rcx
	shrq	%rax
	andl	$1, %ecx
	orq	%rcx, %rax
	cvtsi2ssq	%rax, %xmm0
	addss	%xmm0, %xmm0
.L87:
	cvtss2sd	%xmm0, %xmm0
	leaq	.LC23(%rip), %rsi
	mulsd	.LC22(%rip), %xmm0
	movl	$2, %edi
	movb	$1, %al
	call	__printf_chk@PLT
	movq	880(%rsp), %rax
	testq	%rax, %rax
	js	.L88
	cvtsi2sdq	%rax, %xmm0
	jmp	.L89
.L88:
	movq	%rax, %rdx
	andl	$1, %eax
	shrq	%rdx
	orq	%rax, %rdx
	cvtsi2sdq	%rdx, %xmm0
	addsd	%xmm0, %xmm0
.L89:
	mulsd	.LC24(%rip), %xmm0
	leaq	.LC25(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	call	__printf_chk@PLT
	movq	824(%rsp), %rax
	testq	%rax, %rax
	js	.L90
	cvtsi2sdq	%rax, %xmm0
	jmp	.L91
.L90:
	movq	%rax, %rdx
	andl	$1, %eax
	shrq	%rdx
	orq	%rax, %rdx
	cvtsi2sdq	%rdx, %xmm0
	addsd	%xmm0, %xmm0
.L91:
	mulsd	.LC24(%rip), %xmm0
	leaq	.LC26(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	leaq	216(%rsp), %r15
	call	__printf_chk@PLT
	movl	832(%rsp), %edx
	leaq	.LC27(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	836(%rsp), %edx
	leaq	.LC28(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	848(%rsp), %edx
	leaq	.LC29(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	1152(%rsp), %edx
	leaq	.LC30(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	$32, %ecx
	movl	$2, %edi
	movl	1152(%rsp), %eax
	leaq	.LC31(%rip), %rsi
	cltd
	idivl	%ecx
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	860(%rsp), %r8d
	xorl	%eax, %eax
	movl	856(%rsp), %ecx
	movl	852(%rsp), %edx
	leaq	.LC32(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	872(%rsp), %r8d
	xorl	%eax, %eax
	movl	868(%rsp), %ecx
	movl	864(%rsp), %edx
	leaq	.LC33(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	840(%rsp), %rdx
	leaq	.LC34(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	leaq	.LC36(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtsi2sdl	1136(%rsp), %xmm0
	divsd	.LC35(%rip), %xmm0
	call	__printf_chk@PLT
	movl	1140(%rsp), %edx
	leaq	.LC37(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	$8, %ecx
	movl	$2, %edi
	movl	1140(%rsp), %eax
	cvtsi2sdl	1136(%rsp), %xmm0
	leaq	.LC38(%rip), %rsi
	cltd
	idivl	%ecx
	addsd	%xmm0, %xmm0
	cvtsi2sdl	%eax, %xmm1
	movb	$1, %al
	mulsd	%xmm1, %xmm0
	divsd	.LC4(%rip), %xmm0
	call	__printf_chk@PLT
	xorl	%eax, %eax
	leaq	.LC39(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	%rbp, %rdx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC40(%rip), %rsi
	call	__printf_chk@PLT
	movq	%rbx, %rdx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC41(%rip), %rsi
	call	__printf_chk@PLT
	movl	$32, %edx
	leaq	.LC42(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	leaq	.LC43(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	0(,%rbp,4), %rax
	movq	%rax, %rdi
	movq	%rax, 8(%rsp)
	call	malloc@PLT
	movq	%rax, %r14
	leaq	0(,%rbp,8), %rax
	movq	%rax, %rdi
	movq	%rax, (%rsp)
	call	malloc@PLT
	leaq	0(,%rbp,8), %rdi
	movq	%rax, %r13
	call	malloc@PLT
	leaq	0(,%rbp,8), %rdi
	movq	%rax, %r12
	call	malloc@PLT
	leaq	0(,%rbp,8), %rdi
	movq	%rax, 16(%rsp)
	call	malloc@PLT
	leaq	0(,%rbp,8), %rdi
	movq	%rax, 24(%rsp)
	call	malloc@PLT
	leaq	0(,%rbp,8), %rdi
	movq	%rax, 32(%rsp)
	call	malloc@PLT
	movq	8(%rsp), %rdi
	movq	%rax, 40(%rsp)
	call	malloc@PLT
	leaq	0(,%rbp,8), %rdi
	movq	%rax, 48(%rsp)
	call	malloc@PLT
	leaq	0(,%rbp,8), %rdi
	movq	%rax, 56(%rsp)
	call	malloc@PLT
	leaq	0(,%rbp,8), %rdi
	movq	%rax, 64(%rsp)
	call	malloc@PLT
	movq	8(%rsp), %rcx
	xorl	%esi, %esi
	movq	%r14, %rdi
	movq	%rax, 72(%rsp)
	movq	%rcx, %rdx
	call	__memset_chk@PLT
	leaq	0(,%rbp,8), %rcx
	xorl	%esi, %esi
	movq	%r13, %rdi
	movq	%rcx, %rdx
	call	__memset_chk@PLT
	leaq	0(,%rbp,8), %rcx
	xorl	%esi, %esi
	movq	%r12, %rdi
	movq	%rcx, %rdx
	call	__memset_chk@PLT
	leaq	0(,%rbp,8), %rcx
	movq	16(%rsp), %rdi
	xorl	%esi, %esi
	movq	%rcx, %rdx
	call	__memset_chk@PLT
	leaq	0(,%rbp,8), %rcx
	movq	24(%rsp), %rdi
	xorl	%esi, %esi
	movq	%rcx, %rdx
	call	__memset_chk@PLT
	leaq	0(,%rbp,8), %rcx
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	movq	%rcx, %rdx
	call	__memset_chk@PLT
	leaq	0(,%rbp,8), %rcx
	movq	40(%rsp), %rdi
	xorl	%esi, %esi
	movq	%rcx, %rdx
	call	__memset_chk@PLT
	movq	8(%rsp), %rcx
	movq	48(%rsp), %rdi
	xorl	%esi, %esi
	movq	%rcx, %rdx
	call	__memset_chk@PLT
	leaq	0(,%rbp,8), %rcx
	movq	56(%rsp), %rdi
	xorl	%esi, %esi
	movq	%rcx, %rdx
	call	__memset_chk@PLT
	leaq	0(,%rbp,8), %rcx
	movq	64(%rsp), %rdi
	xorl	%esi, %esi
	movq	%rcx, %rdx
	call	__memset_chk@PLT
	leaq	0(,%rbp,8), %rcx
	movq	72(%rsp), %rdi
	xorl	%esi, %esi
	movq	%rcx, %rdx
	call	__memset_chk@PLT
	movq	16(%rsp), %rax
	leaq	.LC44(%rip), %rsi
	movl	$2, %edi
	movq	%r14, US(%rip)
	movq	%rax, 24+US(%rip)
	movq	24(%rsp), %rax
	movq	%r13, 8+US(%rip)
	movq	%rax, 32+US(%rip)
	movq	32(%rsp), %rax
	movq	%r12, 16+US(%rip)
	movq	%rax, 40+US(%rip)
	movq	40(%rsp), %rax
	movq	%rbp, 56+US(%rip)
	movq	%rax, 48+US(%rip)
	xorl	%eax, %eax
	movq	%rbx, 64+US(%rip)
	call	__printf_chk@PLT
	call	_Z12getTimeStampv
	movsd	%xmm0, 80(%rsp)
	call	_Z25init_MassPositionVelocityv
	movq	%r15, %rdi
	call	pthread_attr_init@PLT
	movq	%r15, %rdi
	xorl	%esi, %esi
	xorl	%r15d, %r15d
	call	pthread_attr_setdetachstate@PLT
	leaq	272(%rsp), %rdi
.L93:
	leaq	_Z21init_Acceleration_SMTPv(%rip), %rdx
	leaq	216(%rsp), %rsi
	movq	%r15, %rcx
	movq	%rdi, 88(%rsp)
	call	pthread_create@PLT
	movq	88(%rsp), %rdi
	testl	%eax, %eax
	movl	%eax, %edx
	je	.L92
	leaq	.LC45(%rip), %rsi
.L112:
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L111:
	movl	$1, %edi
	call	exit@PLT
.L92:
	incq	%r15
	addq	$8, %rdi
	cmpq	$32, %r15
	jne	.L93
	leaq	184(%rsp), %rax
	xorl	%r15d, %r15d
	movq	%rax, 88(%rsp)
.L95:
	movq	272(%rsp,%r15,8), %rdi
	movq	88(%rsp), %rsi
	call	pthread_join@PLT
	movl	%eax, %edx
	testl	%eax, %eax
	je	.L94
	leaq	.LC46(%rip), %rsi
	jmp	.L112
.L94:
	incq	%r15
	cmpq	$32, %r15
	jne	.L95
	call	_Z12getTimeStampv
	subsd	80(%rsp), %xmm0
	leaq	.LC47(%rip), %rsi
	movb	$1, %al
	movl	$2, %edi
	leaq	.LC16(%rip), %r15
	call	__printf_chk@PLT
	movq	8(%rsp), %rsi
	leaq	128(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$378, %edx
	movq	%r15, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	(%rsp), %rsi
	leaq	136(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$379, %edx
	movq	%r15, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	(%rsp), %rsi
	leaq	144(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$380, %edx
	movq	%r15, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	(%rsp), %rsi
	leaq	152(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$381, %edx
	movq	%r15, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	(%rsp), %rsi
	leaq	160(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$382, %edx
	movq	%r15, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	(%rsp), %rsi
	leaq	168(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$383, %edx
	movq	%r15, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	(%rsp), %rsi
	leaq	176(%rsp), %rdi
	call	cudaMalloc@PLT
	movq	%r15, %rsi
	movl	$1, %ecx
	movl	$384, %edx
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	8(%rsp), %rdx
	movl	$1, %ecx
	movq	%r14, %rsi
	movq	128(%rsp), %rdi
	call	cudaMemcpy@PLT
	movq	%r15, %rsi
	movl	$1, %ecx
	movl	$387, %edx
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	(%rsp), %rdx
	movl	$1, %ecx
	movq	%r13, %rsi
	movq	136(%rsp), %rdi
	call	cudaMemcpy@PLT
	movq	%r15, %rsi
	movl	$1, %ecx
	movl	$388, %edx
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	(%rsp), %rdx
	movl	$1, %ecx
	movq	%r12, %rsi
	movq	144(%rsp), %rdi
	call	cudaMemcpy@PLT
	movq	%r15, %rsi
	movl	$1, %ecx
	movl	$389, %edx
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	(%rsp), %rdx
	movq	16(%rsp), %rsi
	movl	$1, %ecx
	movq	152(%rsp), %rdi
	call	cudaMemcpy@PLT
	movq	%r15, %rsi
	movl	$1, %ecx
	movl	$390, %edx
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	(%rsp), %rdx
	movq	24(%rsp), %rsi
	movl	$1, %ecx
	movq	160(%rsp), %rdi
	call	cudaMemcpy@PLT
	movq	%r15, %rsi
	movl	$1, %ecx
	movl	$391, %edx
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	(%rsp), %rdx
	movq	32(%rsp), %rsi
	movl	$1, %ecx
	movq	168(%rsp), %rdi
	call	cudaMemcpy@PLT
	movq	%r15, %rsi
	movl	$1, %ecx
	movl	$392, %edx
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	(%rsp), %rdx
	movq	40(%rsp), %rsi
	movl	$1, %ecx
	movq	176(%rsp), %rdi
	call	cudaMemcpy@PLT
	movq	%r15, %rsi
	movl	$1, %ecx
	movl	$393, %edx
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	leaq	1023(%rbp), %rax
	movabsq	$4294967297, %rdx
	shrq	$10, %rax
	movq	%rdx, 196(%rsp)
	movl	%eax, 204(%rsp)
	movq	%rdx, 208(%rsp)
	call	_Z12getTimeStampv
	xorl	%r15d, %r15d
	movsd	%xmm0, (%rsp)
.L96:
	cmpq	%r15, %rbx
	je	.L113
	testl	$1, %r15d
	movl	200(%rsp), %ecx
	movl	$1024, 192(%rsp)
	movl	$0, %r9d
	movq	204(%rsp), %rdi
	movl	212(%rsp), %esi
	movl	$0, %r8d
	movq	192(%rsp), %rdx
	jne	.L97
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L99
	pushq	%rbp
	.cfi_def_cfa_offset 1640
	pushq	136(%rsp)
	.cfi_def_cfa_offset 1648
	movq	184(%rsp), %r9
	movq	168(%rsp), %r8
	movq	152(%rsp), %rcx
	movq	192(%rsp), %rdx
	movq	176(%rsp), %rsi
	movq	160(%rsp), %rdi
.L110:
	call	_Z51__device_stub__Z14compute_DevicePfS_S_PKfS1_S1_S1_mPfS_S_PKfS1_S1_S1_m
	popq	%rax
	.cfi_def_cfa_offset 1640
	popq	%rdx
	.cfi_def_cfa_offset 1632
.L99:
	call	cudaDeviceSynchronize@PLT
	incq	%r15
	jmp	.L96
.L97:
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L99
	pushq	%rbp
	.cfi_remember_state
	.cfi_def_cfa_offset 1640
	pushq	136(%rsp)
	.cfi_def_cfa_offset 1648
	movq	192(%rsp), %r9
	movq	176(%rsp), %r8
	movq	160(%rsp), %rcx
	movq	184(%rsp), %rdx
	movq	168(%rsp), %rsi
	movq	152(%rsp), %rdi
	jmp	.L110
.L113:
	.cfi_restore_state
	call	_Z12getTimeStampv
	subsd	(%rsp), %xmm0
	movq	128(%rsp), %rdi
	movq	%xmm0, %rbp
	call	cudaFree@PLT
	movq	136(%rsp), %rdi
	call	cudaFree@PLT
	movq	144(%rsp), %rdi
	call	cudaFree@PLT
	movq	152(%rsp), %rdi
	call	cudaFree@PLT
	movq	160(%rsp), %rdi
	call	cudaFree@PLT
	movq	168(%rsp), %rdi
	call	cudaFree@PLT
	movq	176(%rsp), %rdi
	call	cudaFree@PLT
	call	cudaDeviceReset@PLT
	movl	$1, %ecx
	movl	$435, %edx
	leaq	.LC16(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	leaq	.LC48(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%rbp, %xmm0
	leaq	.LC49(%rip), %rsi
	movb	$1, %al
	movl	$2, %edi
	call	__printf_chk@PLT
	testq	%rbx, %rbx
	js	.L102
	cvtsi2sdq	%rbx, %xmm1
	jmp	.L103
.L102:
	movq	%rbx, %rax
	andl	$1, %ebx
	shrq	%rax
	orq	%rbx, %rax
	cvtsi2sdq	%rax, %xmm1
	addsd	%xmm1, %xmm1
.L103:
	movq	%rbp, %xmm0
	leaq	.LC50(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	divsd	%xmm1, %xmm0
	call	__printf_chk@PLT
	movq	%r14, %rdi
	call	free@PLT
	movq	%r13, %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	16(%rsp), %rdi
	call	free@PLT
	movq	24(%rsp), %rdi
	call	free@PLT
	movq	32(%rsp), %rdi
	call	free@PLT
	movq	40(%rsp), %rdi
	call	free@PLT
	movq	48(%rsp), %rdi
	call	free@PLT
	movq	56(%rsp), %rdi
	call	free@PLT
	movq	64(%rsp), %rdi
	call	free@PLT
	movq	72(%rsp), %rdi
	call	free@PLT
	leaq	216(%rsp), %rdi
	call	pthread_attr_destroy@PLT
	movq	1560(%rsp), %rax
	subq	%fs:40, %rax
	je	.L104
	call	__stack_chk_fail@PLT
.L104:
	addq	$1576, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2041:
	.size	main, .-main
	.section	.rodata.str1.1
.LC51:
	.string	"_Z14compute_DevicePfS_S_PKfS1_S1_S1_m"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2070:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC51(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z14compute_DevicePfS_S_PKfS1_S1_S1_m(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2070:
	.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
	.globl	US
	.bss
	.align 32
	.type	US, @object
	.size	US, 72
US:
	.zero	72
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC1:
	.long	981467136
	.align 4
.LC2:
	.long	1090519040
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC4:
	.long	0
	.long	1093567616
	.align 8
.LC12:
	.long	1073741824
	.long	1097104097
	.align 8
.LC13:
	.long	0
	.long	1079574528
	.section	.rodata.cst4
	.align 4
.LC14:
	.long	1325400064
	.section	.rodata.cst8
	.align 8
.LC22:
	.long	0
	.long	1041235968
	.align 8
.LC24:
	.long	0
	.long	1062207488
	.align 8
.LC35:
	.long	0
	.long	1083129856
	.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 <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <sys/time.h>
#include <pthread.h>
#include <hip/hip_runtime.h>


// global constants
#define NUM_CPU_THREADS 32
#define MAX_MASS 100.0f
#define MAX_POS_X 100.0f
#define MAX_POS_Y 100.0f
#define MAX_VEL_X 0.0f
#define MAX_VEL_Y 0.0f
#define G 8
#define DT 0.0019531255f
#define DT2 0.000003814697265625f/2
#define DAMPING 1.0f
#define SOFTENING 0.0009765625f

typedef struct {
	float *m;
	float *r1, *r2;
	float *v1, *v2;
	float *a1, *a2;
	unsigned long nElem, nIter;
} UNIVERSE;

UNIVERSE US;

#define checkCudaErrors(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(hipError_t code, const char *file, int line, bool abort=true)
{
	if (code != hipSuccess)
	{
		fprintf(stderr,"GPUassert: %s %s %d\n", hipGetErrorString(code), file, line);
		if (abort) exit(code);
	}
}

// time stamp function in seconds
double getTimeStamp()
{
	struct timeval tv;
	gettimeofday (&tv, NULL);
	return (double) tv.tv_usec/1000000 + tv.tv_sec;
}

void print_BodyStats (const float *m, const float *r, const float *v, const float *a)
{
    unsigned long nElem = US.nElem;

    printf("\n");
    // print body number
    for (unsigned long idx=0; idx<nElem; idx++) {
        if (idx == nElem-1)
            printf("Mass %ld\n", idx);
        else
            printf("Mass %ld\t", idx);
    }

    // print Mass
    for (unsigned long idx=0; idx<nElem; idx++) {
        if (idx == nElem-1)
            printf("%.2f\n", m[idx]);
        else
            printf("%.2f\t", m[idx]);
    }

    // print x-position
    for (unsigned long idx=0; idx<nElem; idx++) {
        if (idx == nElem-1)
            printf("%.2f\n", r[2*idx]);
        else
            printf("%.2f\t", r[2*idx]);
    }

    // print y-position
    for (unsigned long idx=0; idx<nElem; idx++) {
        if (idx == nElem-1)
            printf("%.2f\n", r[2*idx+1]);
        else
            printf("%.2f\t", r[2*idx+1]);
    }

    // print x-velocity
    for (unsigned long idx=0; idx<nElem; idx++) {
        if (idx == nElem-1)
            printf("%.2f\n", v[2*idx]);
        else
            printf("%.2f\t", v[2*idx]);
    }

    // print y-velocity
    for (unsigned long idx=0; idx<nElem; idx++) {
        if (idx == nElem-1)
            printf("%.2f\n", v[2*idx+1]);
        else
            printf("%.2f\t", v[2*idx+1]);
    }

    // print x-acceleration
    for (unsigned long idx=0; idx<nElem; idx++) {
        if (idx == nElem-1)
            printf("%.2f\n", a[2*idx]);
        else
            printf("%.2f\t", a[2*idx]);
    }

    // print y-acceleration
    for (unsigned long idx=0; idx<nElem; idx++) {
        if (idx == nElem-1)
            printf("%.2f\n\n", a[2*idx+1]);
        else
            printf("%.2f\t", a[2*idx+1]);
    }

}

void init_MassPositionVelocity ()
{
	// generate different seed for pseudo-random number generator
	// time_t t;
	// srand ((unsigned int) time(&t));
	srand ((unsigned int) 1000);

	// define local variables for convenience
	unsigned long nElem = US.nElem;

	// populating mass, position, & velocity arrays
	unsigned long idx;
	for (idx=0; idx<nElem; idx++)
	{
		US.m[idx]     = 100.0;//(float) ((double) rand() / (double) (RAND_MAX/MAX_MASS));
		US.r1[2*idx]   = (float) ((double) rand() / (double) (RAND_MAX/(MAX_POS_X*2)) - MAX_POS_X);
		US.r1[2*idx+1] = (float) ((double) rand() / (double) (RAND_MAX/(MAX_POS_Y*2)) - MAX_POS_Y);
		US.v1[2*idx]   = (float) ((double) rand() / (double) (RAND_MAX/(MAX_VEL_X*2)) - MAX_VEL_X);
		US.v1[2*idx+1] = (float) ((double) rand() / (double) (RAND_MAX/(MAX_VEL_Y*2)) - MAX_VEL_Y);
	}
}

void *init_Acceleration_SMT (void *arg)
{
    // define local variables for convenience
    unsigned long start, end, len, offset, nElem;

    nElem = US.nElem;
    offset = (unsigned long) arg;
    len = (unsigned long) US.nElem / NUM_CPU_THREADS;
    start = offset * len;
    end = start + len;

    unsigned long i, j;
    float ax_ip1, ay_ip1;
    float dx_ip1, dy_ip1, rDistSquared, invDistCubed;
    float **i_r = &US.r1;
    float **o_a = &US.a1;

    // calculating NEXT acceleration of each body from the position of every other bodies
    // ... and NEXT velocity of each body utilizing the next acceleration
    for (i=start; i<end; i++)
    {
        ax_ip1 = 0.0;
        ay_ip1 = 0.0;
        for (j=0; j<nElem; j++)
        {
            if (j != i)
            {
                dx_ip1 = *(*i_r + 2*j)   - *(*i_r + 2*i);
                dy_ip1 = *(*i_r + 2*j+1) - *(*i_r + 2*i+1);
                rDistSquared = dx_ip1*dx_ip1 + dy_ip1*dy_ip1 + SOFTENING;
                invDistCubed = G*US.m[j]/sqrtf(rDistSquared*rDistSquared*rDistSquared);
                ax_ip1 += dx_ip1 * invDistCubed;
                ay_ip1 += dy_ip1 * invDistCubed;
            }
        }

        *(*o_a + 2*i)   = ax_ip1;
        *(*o_a + 2*i+1) = ay_ip1;
    }

    pthread_exit (NULL);
}


__global__ void compute_Device (
	float *o_r, float *o_v, float *o_a,
	const float *i_r, const float *i_v, const float *i_a,
	const float *m, const unsigned long nElem)
{
	unsigned long tid = blockIdx.x * blockDim.x + threadIdx.x;
	// if (tid == 0)
	// 	printf("x: %.6f\ty:%.6f\n", i_r[0], i_r[1]);

	float ax_ip1 = 0.0, ay_ip1 = 0.0;
	float dx_ip1, dy_ip1, rDistSquared, invDistCubed;

	if (tid < nElem) {
		// calculating subsequent position of body (one body per thread)
		o_r[2*tid]   = i_r[2*tid]   + i_v[2*tid]*DT   + i_a[2*tid]*DT2;		// x-position
		o_r[2*tid+1] = i_r[2*tid+1] + i_v[2*tid+1]*DT + i_a[2*tid+1]*DT2;	// y-position

		// calculating the NEXT iteration's acceleration and velocity
		for (unsigned long j=0; j<nElem; j++) {
			if (j != tid) {
				dx_ip1 = o_r[2*j]   - o_r[2*tid];
				dy_ip1 = o_r[2*j+1] - o_r[2*tid+1];
				rDistSquared = dx_ip1*dx_ip1 + dy_ip1*dy_ip1 + SOFTENING;
				invDistCubed = G*m[j]*rsqrtf(rDistSquared*rDistSquared*rDistSquared);
				ax_ip1 += dx_ip1 * invDistCubed;
				ay_ip1 += dy_ip1 * invDistCubed;
			}
		}

		o_a[2*tid]   = ax_ip1;	// x-acceleration
		o_a[2*tid+1] = ay_ip1;	// y-acceleration

		o_v[2*tid]   = i_v[2*tid]   + (i_a[2*tid]   + ax_ip1)*DT/2;	// x-velocity
		o_v[2*tid+1] = i_v[2*tid+1] + (i_a[2*tid+1] + ay_ip1)*DT/2;	// y-velocity
	}
}


int main (int argc, char *argv[])
{
	if (argc > 3) {
		printf("Error: Wrong number of arguments.\n");
		exit(EXIT_FAILURE);
	}

	unsigned long nElem = 16000;
	unsigned long nIter = 10;
	char *ptr1, *ptr2;

	if (argc > 1)
		nElem = strtoul(argv[1], &ptr1, 10);
	if (argc > 2)
		nIter = strtoul(argv[2], &ptr2, 10);


	////////////////////////////////////////////////////////////////
	/// SETTING UP DEVICE
	////////////////////////////////////////////////////////////////

	int dev = 0, driverVersion = 0, runtimeVersion = 0;
	hipDeviceProp_t deviceProp;
	checkCudaErrors (hipGetDeviceProperties (&deviceProp, dev));
	checkCudaErrors (hipSetDevice (dev));
	checkCudaErrors (hipDriverGetVersion (&driverVersion));
	checkCudaErrors (hipRuntimeGetVersion (&runtimeVersion));

	printf("\n===== Device Properties ======\n\n");
	printf("  Device %d: %s\n", dev, deviceProp.name);
	printf("  CUDA Driver Version / Runtime Version: %d.%d / %d.%d\n",
		driverVersion/1000, (driverVersion%100)/10,
		runtimeVersion/1000, (runtimeVersion%100)/10);
	printf("  CUDA Capability Major/Minor version number: %d.%d\n",
		deviceProp.major, deviceProp.minor);
	printf("  Number of SMs: %d\n", deviceProp.multiProcessorCount);
	printf("  Total amount of global memory: %.2f GB (%llu B)\n",
		(float) deviceProp.totalGlobalMem/pow(1024.0,3),
		(unsigned long long) deviceProp.totalGlobalMem);
	printf("  Total amount of constant memory: %4.2f kB\n",
		deviceProp.totalConstMem/1024.0);
	printf("  Total amount of shared memory per block: %4.2f kB\n",
		deviceProp.sharedMemPerBlock/1024.0);
	printf("  Total number of registers available per block: %d\n",
		deviceProp.regsPerBlock);
	printf("  Warp size: %d\n", deviceProp.warpSize);
	printf("  Maximum number of threads per block: %d\n",
		deviceProp.maxThreadsPerBlock);
	printf("  Maximum number of threads per SM: %d\n",
		deviceProp.maxThreadsPerMultiProcessor);
	printf("  Maximum number of warps per SM: %d\n",
		deviceProp.maxThreadsPerMultiProcessor/32);
	printf("  Maximum size of each block dimension: %d x %d x %d\n",
		deviceProp.maxThreadsDim[0], deviceProp.maxThreadsDim[1],
		deviceProp.maxThreadsDim[2]);
	printf("  Maximum size of each grid dimension: %d x %d x %d\n",
		deviceProp.maxGridSize[0], deviceProp.maxGridSize[1],
		deviceProp.maxGridSize[2]);
	printf("  Maximum memory pitch: %lu B\n", deviceProp.memPitch);
	printf("  Memory Clock Rate (MHz): %.1f\n",
		deviceProp.memoryClockRate/1e3);
	printf("  Memory Bus Width (b): %d\n", deviceProp.memoryBusWidth);
	printf("  Peak Memory Bandwidth (GB/s): %.2f\n\n",
		2.0*deviceProp.memoryClockRate*(deviceProp.memoryBusWidth/8)/1e6);


	printf("\n===== Simulation Parameters =====\n\n");
	printf("  Number of Bodies = %ld\n", nElem);
	printf("  Number of Time Steps = %ld\n", nIter);
	printf("  Number of CPU Threads = %d\n\n", NUM_CPU_THREADS);
	printf("=================================\n\n\n");

	////////////////////////////////////////////////////////////////
	/// INITIALIZING SIMULATION
	////////////////////////////////////////////////////////////////

	float *h_m, *h_r1, *h_r2, *h_v1, *h_v2, *h_a1, *h_a2;	// host data
	float *d_m, *d_r1, *d_r2, *d_v1, *d_v2, *d_a1, *d_a2;	// device data
	float *gref_m, *gref_r, *gref_v, *gref_a;

	size_t nBytes = nElem * sizeof(float);
	h_m  = (float *) malloc(nBytes);
	h_r1 = (float *) malloc(nBytes*2);
	h_r2 = (float *) malloc(nBytes*2);
	h_v1 = (float *) malloc(nBytes*2);
	h_v2 = (float *) malloc(nBytes*2);
	h_a1 = (float *) malloc(nBytes*2);
	h_a2 = (float *) malloc(nBytes*2);

	gref_m  = (float *) malloc(nBytes);
	gref_r = (float *) malloc(nBytes*2);
	gref_v = (float *) malloc(nBytes*2);
	gref_a = (float *) malloc(nBytes*2);

	memset (h_m,  0, nBytes);
	memset (h_r1, 0, nBytes*2);
	memset (h_r2, 0, nBytes*2);
	memset (h_v1, 0, nBytes*2);
	memset (h_v2, 0, nBytes*2);
	memset (h_a1, 0, nBytes*2);
	memset (h_a2, 0, nBytes*2);

	memset (gref_m,  0, nBytes);
	memset (gref_r, 0, nBytes*2);
	memset (gref_v, 0, nBytes*2);
	memset (gref_a, 0, nBytes*2);

	// initialize data on host size and then transfer to device
	US.m = h_m;
	US.r1 = h_r1;
	US.r2 = h_r2;
	US.v1 = h_v1;
	US.v2 = h_v2;
	US.a1 = h_a1;
	US.a2 = h_a2;
	US.nElem = nElem;
	US.nIter = nIter;

	printf("Initializing bodies on HOST. Time taken: ");
	double time0 = getTimeStamp();
	init_MassPositionVelocity();

	// for portability, explicity create threads in a joinable state
	pthread_t threads [NUM_CPU_THREADS];
	pthread_attr_t attr;
	pthread_attr_init (&attr);
	pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_JOINABLE);

	// creating the threads to calculate initial body accelerations on HOST
	unsigned long i;
	int rc;
	void *status;
	for (i=0; i<NUM_CPU_THREADS; i++) {
		rc = pthread_create (&threads[i], &attr, init_Acceleration_SMT, (void *) i);
		if (rc) {
			printf("Error; return code from pthread_create() is %d.\n", rc);
			exit(EXIT_FAILURE);
		}
	}

	// wait on the other threads after initial body accelerations on HOST
	for (i=0; i<NUM_CPU_THREADS; i++) {
		rc = pthread_join (threads[i], &status);
		if (rc) {
			printf("ERROR; return code from pthread_join() is %d.\n", rc);
			exit(EXIT_FAILURE);
		}
	}
	printf ("%lfs\n", getTimeStamp()-time0);
	//print_BodyStats(h_m, h_r1, h_v1, h_a1);

	// allocating space in device global memory for data
	checkCudaErrors (hipMalloc ((void**) &d_m,  nBytes));
	checkCudaErrors (hipMalloc ((void**) &d_r1, nBytes*2));
	checkCudaErrors (hipMalloc ((void**) &d_r2, nBytes*2));
	checkCudaErrors (hipMalloc ((void**) &d_v1, nBytes*2));
	checkCudaErrors (hipMalloc ((void**) &d_v2, nBytes*2));
	checkCudaErrors (hipMalloc ((void**) &d_a1, nBytes*2));
	checkCudaErrors (hipMalloc ((void**) &d_a2, nBytes*2));

	// copying initialized data from host to device
	checkCudaErrors (hipMemcpy (d_m,  h_m,  nBytes,   hipMemcpyHostToDevice));
	checkCudaErrors (hipMemcpy (d_r1, h_r1, nBytes*2, hipMemcpyHostToDevice));
	checkCudaErrors (hipMemcpy (d_r2, h_r2, nBytes*2, hipMemcpyHostToDevice));
	checkCudaErrors (hipMemcpy (d_v1, h_v1, nBytes*2, hipMemcpyHostToDevice));
	checkCudaErrors (hipMemcpy (d_v2, h_v2, nBytes*2, hipMemcpyHostToDevice));
	checkCudaErrors (hipMemcpy (d_a1, h_a1, nBytes*2, hipMemcpyHostToDevice));
	checkCudaErrors (hipMemcpy (d_a2, h_a2, nBytes*2, hipMemcpyHostToDevice));

	////////////////////////////////////////////////////////////////
	/// PERFORMING SIMULATION ON DEVICE
	////////////////////////////////////////////////////////////////

	dim3 block (1024);
	dim3 grid  ((nElem+block.x-1)/(block.x));

	double timestamp_GPU_start = getTimeStamp();
	for (unsigned long iter=0; iter<nIter; iter++) {
		if (iter % 2 == 0) {
			compute_Device <<<grid, block, 0, 0>>> (d_r2, d_v2, d_a2, d_r1, d_v1, d_a1, d_m, nElem);
			hipDeviceSynchronize ();
			// cudaMemcpy(gref_m, d_m, nBytes, cudaMemcpyDeviceToHost);
			// cudaMemcpy(gref_r, d_r2, nBytes*2, cudaMemcpyDeviceToHost);
			// cudaMemcpy(gref_v, d_v2, nBytes*2, cudaMemcpyDeviceToHost);
			// cudaMemcpy(gref_a, d_a2, nBytes*2, cudaMemcpyDeviceToHost);

		} else {
			compute_Device <<<grid, block, 0, 0>>> (d_r1, d_v1, d_a1, d_r2, d_v2, d_a2, d_m, nElem);
			hipDeviceSynchronize ();
			// cudaMemcpy(gref_m, d_m, nBytes, cudaMemcpyDeviceToHost);
			// cudaMemcpy(gref_r, d_r1, nBytes*2, cudaMemcpyDeviceToHost);
			// cudaMemcpy(gref_v, d_v1, nBytes*2, cudaMemcpyDeviceToHost);
			// cudaMemcpy(gref_a, d_a1, nBytes*2, cudaMemcpyDeviceToHost);
		}
		// if (iter%1000 == 0)
		// 	print_BodyStats (gref_m, gref_r, gref_v, gref_a);
	}
	double timestamp_GPU_end = getTimeStamp();
	double elapsedTime = timestamp_GPU_end - timestamp_GPU_start;

	////////////////////////////////////////////////////////////////
	/// SIMULATION COMPLETE
	////////////////////////////////////////////////////////////////

	hipFree (d_m);
	hipFree (d_r1); hipFree (d_r2);
	hipFree (d_v1); hipFree (d_v2);
	hipFree (d_a1); hipFree (d_a2);

	checkCudaErrors (hipDeviceReset());
	printf("Device successfully reset.\n");
	printf("\nElapsed Time: %lfs\n", elapsedTime);
	printf("Average timestep simulation duration: %lfs\n", elapsedTime/nIter);


	free (h_m);
	free (h_r1); free (h_r2);
	free (h_v1); free (h_v2);
	free (h_a1); free (h_a2);

	free (gref_m);
	free (gref_r);
	free (gref_v);
	free (gref_a);

	pthread_attr_destroy (&attr);
	//pthread_exit(NULL);

	return 0;
}

	.text
	.file	"test_gpu.hip"
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z12getTimeStampv
.LCPI0_0:
	.quad	0x412e848000000000              # double 1.0E+6
	.text
	.globl	_Z12getTimeStampv
	.type	_Z12getTimeStampv,@function
_Z12getTimeStampv:                      # @_Z12getTimeStampv
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -16
	movq	%rsp, %rbx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	cvtsi2sdq	8(%rbx), %xmm1
	divsd	.LCPI0_0(%rip), %xmm1
	cvtsi2sdq	(%rbx), %xmm0
	addsd	%xmm1, %xmm0
	addq	$16, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z12getTimeStampv, .Lfunc_end0-_Z12getTimeStampv
	.cfi_endproc
                                        # -- End function
	.globl	_Z15print_BodyStatsPKfS0_S0_S0_ # -- Begin function _Z15print_BodyStatsPKfS0_S0_S0_
	.type	_Z15print_BodyStatsPKfS0_S0_S0_,@function
_Z15print_BodyStatsPKfS0_S0_S0_:        # @_Z15print_BodyStatsPKfS0_S0_S0_
	.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	$24, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rcx, %r14
	movq	%rdx, 16(%rsp)                  # 8-byte Spill
	movq	%rsi, %r12
	movq	%rdi, %r13
	movq	US+56(%rip), %rbx
	movl	$10, %edi
	callq	putchar@PLT
	testq	%rbx, %rbx
	je	.LBB1_20
# %bb.1:                                # %.lr.ph
	movq	%r14, 8(%rsp)                   # 8-byte Spill
	leaq	-1(%rbx), %r14
	xorl	%ebp, %ebp
.LBB1_2:                                # =>This Inner Loop Header: Depth=1
	cmpq	%rbp, %r14
	jne	.LBB1_4
# %bb.3:                                #   in Loop: Header=BB1_2 Depth=1
	movl	$.L.str.1, %edi
	movq	%r14, %rsi
	jmp	.LBB1_5
.LBB1_4:                                #   in Loop: Header=BB1_2 Depth=1
	movl	$.L.str.2, %edi
	movq	%rbp, %rsi
.LBB1_5:                                #   in Loop: Header=BB1_2 Depth=1
	xorl	%eax, %eax
	callq	printf
	incq	%rbp
	cmpq	%rbp, %rbx
	jne	.LBB1_2
# %bb.6:                                # %.lr.ph85
	xorl	%ebp, %ebp
	movl	$.L.str.3, %r15d
.LBB1_7:                                # =>This Inner Loop Header: Depth=1
	cmpq	%rbp, %r14
	movl	$.L.str.4, %edi
	cmoveq	%r15, %rdi
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r13,%rbp,4), %xmm0
	movb	$1, %al
	callq	printf
	incq	%rbp
	cmpq	%rbp, %rbx
	jne	.LBB1_7
# %bb.8:                                # %.lr.ph87
	xorl	%r13d, %r13d
	movl	$.L.str.3, %r15d
.LBB1_9:                                # =>This Inner Loop Header: Depth=1
	cmpq	%r13, %r14
	movl	$.L.str.4, %edi
	cmoveq	%r15, %rdi
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r12,%r13,8), %xmm0
	movb	$1, %al
	callq	printf
	incq	%r13
	cmpq	%r13, %rbx
	jne	.LBB1_9
# %bb.10:                               # %.lr.ph89
	xorl	%r13d, %r13d
	movl	$.L.str.3, %r15d
	movq	8(%rsp), %rbp                   # 8-byte Reload
.LBB1_11:                               # =>This Inner Loop Header: Depth=1
	cmpq	%r13, %r14
	movl	$.L.str.4, %edi
	cmoveq	%r15, %rdi
	xorps	%xmm0, %xmm0
	cvtss2sd	4(%r12,%r13,8), %xmm0
	movb	$1, %al
	callq	printf
	incq	%r13
	cmpq	%r13, %rbx
	jne	.LBB1_11
# %bb.12:                               # %.lr.ph91
	xorl	%r12d, %r12d
	movl	$.L.str.3, %r15d
	movq	16(%rsp), %r13                  # 8-byte Reload
.LBB1_13:                               # =>This Inner Loop Header: Depth=1
	cmpq	%r12, %r14
	movl	$.L.str.4, %edi
	cmoveq	%r15, %rdi
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r13,%r12,8), %xmm0
	movb	$1, %al
	callq	printf
	incq	%r12
	cmpq	%r12, %rbx
	jne	.LBB1_13
# %bb.14:                               # %.lr.ph93
	xorl	%r12d, %r12d
	movl	$.L.str.3, %r15d
.LBB1_15:                               # =>This Inner Loop Header: Depth=1
	cmpq	%r12, %r14
	movl	$.L.str.4, %edi
	cmoveq	%r15, %rdi
	xorps	%xmm0, %xmm0
	cvtss2sd	4(%r13,%r12,8), %xmm0
	movb	$1, %al
	callq	printf
	incq	%r12
	cmpq	%r12, %rbx
	jne	.LBB1_15
# %bb.16:                               # %.lr.ph95
	xorl	%r15d, %r15d
	movl	$.L.str.3, %r12d
.LBB1_17:                               # =>This Inner Loop Header: Depth=1
	cmpq	%r15, %r14
	movl	$.L.str.4, %edi
	cmoveq	%r12, %rdi
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rbp,%r15,8), %xmm0
	movb	$1, %al
	callq	printf
	incq	%r15
	cmpq	%r15, %rbx
	jne	.LBB1_17
# %bb.18:                               # %.lr.ph97
	xorl	%r15d, %r15d
	movl	$.L.str.5, %r12d
.LBB1_19:                               # =>This Inner Loop Header: Depth=1
	cmpq	%r15, %r14
	movl	$.L.str.4, %edi
	cmoveq	%r12, %rdi
	xorps	%xmm0, %xmm0
	cvtss2sd	4(%rbp,%r15,8), %xmm0
	movb	$1, %al
	callq	printf
	incq	%r15
	cmpq	%r15, %rbx
	jne	.LBB1_19
.LBB1_20:                               # %._crit_edge
	addq	$24, %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_end1:
	.size	_Z15print_BodyStatsPKfS0_S0_S0_, .Lfunc_end1-_Z15print_BodyStatsPKfS0_S0_S0_
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z25init_MassPositionVelocityv
.LCPI2_0:
	.quad	0x41647ae140000000              # double 10737418
.LCPI2_1:
	.quad	0xc059000000000000              # double -100
.LCPI2_2:
	.quad	0x7ff0000000000000              # double +Inf
	.text
	.globl	_Z25init_MassPositionVelocityv
	.type	_Z25init_MassPositionVelocityv,@function
_Z25init_MassPositionVelocityv:         # @_Z25init_MassPositionVelocityv
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movl	$1000, %edi                     # imm = 0x3E8
	callq	srand
	movq	US+56(%rip), %rbx
	testq	%rbx, %rbx
	je	.LBB2_3
# %bb.1:                                # %.lr.ph.preheader
	xorl	%r14d, %r14d
.LBB2_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movq	US(%rip), %rax
	movl	$1120403456, (%rax,%r14,4)      # imm = 0x42C80000
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	movsd	.LCPI2_0(%rip), %xmm1           # xmm1 = mem[0],zero
	divsd	%xmm1, %xmm0
	movsd	.LCPI2_1(%rip), %xmm1           # xmm1 = mem[0],zero
	addsd	%xmm1, %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movq	US+8(%rip), %rax
	movss	%xmm0, (%rax,%r14,8)
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	divsd	.LCPI2_0(%rip), %xmm0
	addsd	.LCPI2_1(%rip), %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movq	US+8(%rip), %rax
	movss	%xmm0, 4(%rax,%r14,8)
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	movsd	.LCPI2_2(%rip), %xmm1           # xmm1 = mem[0],zero
	divsd	%xmm1, %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movq	US+24(%rip), %rax
	movss	%xmm0, (%rax,%r14,8)
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	divsd	.LCPI2_2(%rip), %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movq	US+24(%rip), %rax
	movss	%xmm0, 4(%rax,%r14,8)
	incq	%r14
	cmpq	%r14, %rbx
	jne	.LBB2_2
.LBB2_3:                                # %._crit_edge
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z25init_MassPositionVelocityv, .Lfunc_end2-_Z25init_MassPositionVelocityv
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z21init_Acceleration_SMTPv
.LCPI3_0:
	.long	0x3a800000                      # float 9.765625E-4
.LCPI3_1:
	.long	0x41000000                      # float 8
	.text
	.globl	_Z21init_Acceleration_SMTPv
	.type	_Z21init_Acceleration_SMTPv,@function
_Z21init_Acceleration_SMTPv:            # @_Z21init_Acceleration_SMTPv
	.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	$32, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdi, %rbx
	movq	US+56(%rip), %r14
	movq	%r14, %r15
	shrq	$5, %r15
	imulq	%r15, %rbx
	addq	%rbx, %r15
	cmpq	%r15, %rbx
	jae	.LBB3_11
# %bb.1:                                # %.preheader.lr.ph
	movss	.LCPI3_0(%rip), %xmm2           # xmm2 = mem[0],zero,zero,zero
	movss	.LCPI3_1(%rip), %xmm3           # xmm3 = mem[0],zero,zero,zero
	xorps	%xmm4, %xmm4
.LBB3_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_4 Depth 2
	leaq	(%rbx,%rbx), %r12
	xorps	%xmm6, %xmm6
	xorps	%xmm5, %xmm5
	testq	%r14, %r14
	je	.LBB3_10
# %bb.3:                                # %.lr.ph.preheader
                                        #   in Loop: Header=BB3_2 Depth=1
	xorl	%r13d, %r13d
.LBB3_4:                                # %.lr.ph
                                        #   Parent Loop BB3_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	cmpq	%r13, %rbx
	je	.LBB3_9
# %bb.5:                                #   in Loop: Header=BB3_4 Depth=2
	movq	US+8(%rip), %rax
	movss	(%rax,%r13,8), %xmm8            # xmm8 = mem[0],zero,zero,zero
	movss	4(%rax,%r13,8), %xmm7           # xmm7 = mem[0],zero,zero,zero
	subss	(%rax,%r12,4), %xmm8
	subss	4(%rax,%r12,4), %xmm7
	movaps	%xmm8, %xmm0
	mulss	%xmm8, %xmm0
	movaps	%xmm7, %xmm1
	mulss	%xmm7, %xmm1
	addss	%xmm0, %xmm1
	addss	%xmm2, %xmm1
	movq	US(%rip), %rax
	movss	(%rax,%r13,4), %xmm9            # xmm9 = mem[0],zero,zero,zero
	mulss	%xmm3, %xmm9
	movaps	%xmm1, %xmm0
	mulss	%xmm1, %xmm0
	mulss	%xmm1, %xmm0
	ucomiss	%xmm4, %xmm0
	jb	.LBB3_7
# %bb.6:                                #   in Loop: Header=BB3_4 Depth=2
	sqrtss	%xmm0, %xmm0
	jmp	.LBB3_8
.LBB3_7:                                # %call.sqrt
                                        #   in Loop: Header=BB3_4 Depth=2
	movss	%xmm5, 28(%rsp)                 # 4-byte Spill
	movss	%xmm6, 24(%rsp)                 # 4-byte Spill
	movss	%xmm7, 20(%rsp)                 # 4-byte Spill
	movss	%xmm8, 16(%rsp)                 # 4-byte Spill
	movss	%xmm9, 12(%rsp)                 # 4-byte Spill
	callq	sqrtf
	movss	12(%rsp), %xmm9                 # 4-byte Reload
                                        # xmm9 = mem[0],zero,zero,zero
	movss	16(%rsp), %xmm8                 # 4-byte Reload
                                        # xmm8 = mem[0],zero,zero,zero
	movss	20(%rsp), %xmm7                 # 4-byte Reload
                                        # xmm7 = mem[0],zero,zero,zero
	movss	24(%rsp), %xmm6                 # 4-byte Reload
                                        # xmm6 = mem[0],zero,zero,zero
	movss	28(%rsp), %xmm5                 # 4-byte Reload
                                        # xmm5 = mem[0],zero,zero,zero
	xorps	%xmm4, %xmm4
	movss	.LCPI3_1(%rip), %xmm3           # xmm3 = mem[0],zero,zero,zero
	movss	.LCPI3_0(%rip), %xmm2           # xmm2 = mem[0],zero,zero,zero
.LBB3_8:                                # %.split
                                        #   in Loop: Header=BB3_4 Depth=2
	divss	%xmm0, %xmm9
	mulss	%xmm9, %xmm8
	addss	%xmm8, %xmm5
	mulss	%xmm9, %xmm7
	addss	%xmm7, %xmm6
.LBB3_9:                                #   in Loop: Header=BB3_4 Depth=2
	incq	%r13
	cmpq	%r13, %r14
	jne	.LBB3_4
.LBB3_10:                               # %._crit_edge
                                        #   in Loop: Header=BB3_2 Depth=1
	movq	US+40(%rip), %rax
	movss	%xmm5, (%rax,%r12,4)
	movss	%xmm6, 4(%rax,%r12,4)
	incq	%rbx
	cmpq	%r15, %rbx
	jne	.LBB3_2
.LBB3_11:                               # %._crit_edge50
	xorl	%edi, %edi
	callq	pthread_exit
.Lfunc_end3:
	.size	_Z21init_Acceleration_SMTPv, .Lfunc_end3-_Z21init_Acceleration_SMTPv
	.cfi_endproc
                                        # -- End function
	.globl	_Z29__device_stub__compute_DevicePfS_S_PKfS1_S1_S1_m # -- Begin function _Z29__device_stub__compute_DevicePfS_S_PKfS1_S1_S1_m
	.type	_Z29__device_stub__compute_DevicePfS_S_PKfS1_S1_S1_m,@function
_Z29__device_stub__compute_DevicePfS_S_PKfS1_S1_S1_m: # @_Z29__device_stub__compute_DevicePfS_S_PKfS1_S1_S1_m
	.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	$160, %rsp
	.cfi_def_cfa_offset 208
	.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	16(%rsp), %r8
	movq	%r9, (%r8)
	leaq	96(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	movq	%r8, 40(%rbx)
	leaq	208(%rsp), %rax
	movq	%rax, 48(%rbx)
	leaq	216(%rsp), %rax
	movq	%rax, 56(%rbx)
	leaq	80(%rsp), %r14
	leaq	64(%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	$_Z14compute_DevicePfS_S_PKfS1_S1_S1_m, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$176, %rsp
	.cfi_adjust_cfa_offset -176
	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_end4:
	.size	_Z29__device_stub__compute_DevicePfS_S_PKfS1_S1_S1_m, .Lfunc_end4-_Z29__device_stub__compute_DevicePfS_S_PKfS1_S1_S1_m
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI5_0:
	.quad	0x3e10000000000000              # double 9.3132257461547852E-10
.LCPI5_3:
	.quad	0x3f50000000000000              # double 9.765625E-4
.LCPI5_4:
	.quad	0x408f400000000000              # double 1000
.LCPI5_5:
	.quad	0x412e848000000000              # double 1.0E+6
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0
.LCPI5_1:
	.long	1127219200                      # 0x43300000
	.long	1160773632                      # 0x45300000
	.long	0                               # 0x0
	.long	0                               # 0x0
.LCPI5_2:
	.quad	0x4330000000000000              # double 4503599627370496
	.quad	0x4530000000000000              # double 1.9342813113834067E+25
	.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	$1992, %rsp                     # imm = 0x7C8
	.cfi_def_cfa_offset 2048
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	cmpl	$4, %edi
	jge	.LBB5_45
# %bb.1:
	movl	%edi, %ebp
	movl	$10, %r12d
	movl	$16000, %r14d                   # imm = 0x3E80
	cmpl	$2, %edi
	jl	.LBB5_4
# %bb.2:
	movq	%rsi, %r15
	movq	8(%rsi), %rdi
	leaq	192(%rsp), %rsi
	movl	$10, %edx
	callq	__isoc23_strtoul
	movq	%rax, %r14
	cmpl	$3, %ebp
	jne	.LBB5_4
# %bb.3:
	movq	16(%r15), %rdi
	leaq	184(%rsp), %rsi
	movl	$10, %edx
	callq	__isoc23_strtoul
	movq	%rax, %r12
.LBB5_4:                                # %.thread
	xorl	%eax, %eax
	movl	%eax, 12(%rsp)
	movl	%eax, 8(%rsp)
	leaq	256(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipGetDevicePropertiesR0600
	testl	%eax, %eax
	jne	.LBB5_47
# %bb.5:                                # %_Z9gpuAssert10hipError_tPKcib.exit
	xorl	%edi, %edi
	callq	hipSetDevice
	testl	%eax, %eax
	jne	.LBB5_48
# %bb.6:                                # %_Z9gpuAssert10hipError_tPKcib.exit136
	leaq	12(%rsp), %rdi
	callq	hipDriverGetVersion
	testl	%eax, %eax
	jne	.LBB5_49
# %bb.7:                                # %_Z9gpuAssert10hipError_tPKcib.exit138
	leaq	8(%rsp), %rdi
	callq	hipRuntimeGetVersion
	testl	%eax, %eax
	jne	.LBB5_50
# %bb.8:                                # %_Z9gpuAssert10hipError_tPKcib.exit140
	movl	$.Lstr, %edi
	callq	puts@PLT
	xorl	%ebp, %ebp
	leaq	256(%rsp), %r15
	movl	$.L.str.9, %edi
	xorl	%esi, %esi
	movq	%r15, %rdx
	xorl	%eax, %eax
	callq	printf
	movslq	12(%rsp), %rax
	imulq	$274877907, %rax, %rsi          # imm = 0x10624DD3
	movq	%rsi, %rcx
	shrq	$63, %rcx
	sarq	$38, %rsi
	addl	%ecx, %esi
	imulq	$1374389535, %rax, %rcx         # imm = 0x51EB851F
	movq	%rcx, %rdx
	shrq	$63, %rdx
	shrq	$37, %rcx
	addl	%edx, %ecx
	imull	$100, %ecx, %ecx
	subl	%ecx, %eax
	movsbl	%al, %eax
	imull	$103, %eax, %ecx
	movl	$65535, %eax                    # imm = 0xFFFF
	movl	%ecx, %edx
	andl	%eax, %edx
	shrl	$15, %edx
	shrl	$8, %ecx
	sarb	$2, %cl
	addb	%dl, %cl
	movsbl	%cl, %edx
	movslq	8(%rsp), %rdi
	imulq	$274877907, %rdi, %rcx          # imm = 0x10624DD3
	movq	%rcx, %r8
	shrq	$63, %r8
	sarq	$38, %rcx
	addl	%r8d, %ecx
	imulq	$1374389535, %rdi, %r8          # imm = 0x51EB851F
	movq	%r8, %r9
	shrq	$63, %r9
	shrq	$37, %r8
	addl	%r9d, %r8d
	imull	$100, %r8d, %r8d
	subl	%r8d, %edi
	movsbl	%dil, %edi
	imull	$103, %edi, %edi
	andl	%edi, %eax
	shrl	$15, %eax
	shrl	$8, %edi
	sarb	$2, %dil
	addb	%al, %dil
	movsbl	%dil, %r8d
	movl	$.L.str.10, %edi
                                        # kill: def $esi killed $esi killed $rsi
                                        # kill: def $ecx killed $ecx killed $rcx
	xorl	%eax, %eax
	callq	printf
	movl	360(%r15), %esi
	movl	364(%r15), %edx
	movl	$.L.str.11, %edi
	xorl	%eax, %eax
	callq	printf
	movl	388(%r15), %esi
	movl	$.L.str.12, %edi
	xorl	%eax, %eax
	callq	printf
	movq	288(%r15), %rsi
	testq	%rsi, %rsi
	js	.LBB5_10
# %bb.9:                                # %_Z9gpuAssert10hipError_tPKcib.exit140
	cvtsi2ss	%rsi, %xmm0
	jmp	.LBB5_11
.LBB5_10:
	movq	%rsi, %rax
	shrq	%rax
	movl	%esi, %ecx
	andl	$1, %ecx
	orq	%rax, %rcx
	cvtsi2ss	%rcx, %xmm0
	addss	%xmm0, %xmm0
.LBB5_11:                               # %_Z9gpuAssert10hipError_tPKcib.exit140
	cvtss2sd	%xmm0, %xmm0
	mulsd	.LCPI5_0(%rip), %xmm0
	movl	$.L.str.13, %edi
	movb	$1, %al
	callq	printf
	movsd	608(%rsp), %xmm1                # xmm1 = mem[0],zero
	unpcklps	.LCPI5_1(%rip), %xmm1           # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
	subpd	.LCPI5_2(%rip), %xmm1
	movapd	%xmm1, %xmm0
	unpckhpd	%xmm1, %xmm0                    # xmm0 = xmm0[1],xmm1[1]
	addsd	%xmm1, %xmm0
	mulsd	.LCPI5_3(%rip), %xmm0
	movl	$.L.str.14, %edi
	movb	$1, %al
	callq	printf
	movsd	552(%rsp), %xmm1                # xmm1 = mem[0],zero
	unpcklps	.LCPI5_1(%rip), %xmm1           # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
	subpd	.LCPI5_2(%rip), %xmm1
	movapd	%xmm1, %xmm0
	unpckhpd	%xmm1, %xmm0                    # xmm0 = xmm0[1],xmm1[1]
	addsd	%xmm1, %xmm0
	mulsd	.LCPI5_3(%rip), %xmm0
	movl	$.L.str.15, %edi
	movb	$1, %al
	callq	printf
	movl	560(%rsp), %esi
	movl	$.L.str.16, %edi
	xorl	%eax, %eax
	callq	printf
	movl	564(%rsp), %esi
	movl	$.L.str.17, %edi
	xorl	%eax, %eax
	callq	printf
	movl	576(%rsp), %esi
	movl	$.L.str.18, %edi
	xorl	%eax, %eax
	callq	printf
	movl	880(%rsp), %esi
	movl	$.L.str.19, %edi
	xorl	%eax, %eax
	callq	printf
	movl	880(%rsp), %eax
	leal	31(%rax), %esi
	testl	%eax, %eax
	cmovnsl	%eax, %esi
	sarl	$5, %esi
	movl	$.L.str.20, %edi
	xorl	%eax, %eax
	callq	printf
	movl	580(%rsp), %esi
	movl	584(%rsp), %edx
	movl	588(%rsp), %ecx
	movl	$.L.str.21, %edi
	xorl	%eax, %eax
	callq	printf
	movl	592(%rsp), %esi
	movl	596(%rsp), %edx
	movl	600(%rsp), %ecx
	movl	$.L.str.22, %edi
	xorl	%eax, %eax
	callq	printf
	movq	568(%rsp), %rsi
	movl	$.L.str.23, %edi
	xorl	%eax, %eax
	callq	printf
	xorps	%xmm0, %xmm0
	cvtsi2sdl	864(%rsp), %xmm0
	divsd	.LCPI5_4(%rip), %xmm0
	movl	$.L.str.24, %edi
	movb	$1, %al
	callq	printf
	movl	868(%rsp), %esi
	movl	$.L.str.25, %edi
	xorl	%eax, %eax
	callq	printf
	xorps	%xmm1, %xmm1
	cvtsi2sdl	864(%rsp), %xmm1
	movl	868(%rsp), %eax
	leal	7(%rax), %ecx
	testl	%eax, %eax
	cmovnsl	%eax, %ecx
	sarl	$3, %ecx
	xorps	%xmm0, %xmm0
	cvtsi2sd	%ecx, %xmm0
	addsd	%xmm1, %xmm1
	mulsd	%xmm1, %xmm0
	divsd	.LCPI5_5(%rip), %xmm0
	movl	$.L.str.26, %edi
	movb	$1, %al
	callq	printf
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movl	$.L.str.28, %edi
	movq	%r14, %rsi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.29, %edi
	movq	%r12, %rsi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.30, %edi
	movl	$32, %esi
	xorl	%eax, %eax
	callq	printf
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	leaq	(,%r14,4), %rsi
	movl	$1, %edi
	movq	%rsi, 80(%rsp)                  # 8-byte Spill
	callq	calloc@PLT
	movq	%rax, 96(%rsp)                  # 8-byte Spill
	leaq	(,%r14,8), %r15
	movl	$1, %edi
	movq	%r15, %rsi
	callq	calloc@PLT
	movq	%rax, 88(%rsp)                  # 8-byte Spill
	movl	$1, %edi
	movq	%r15, %rsi
	callq	calloc@PLT
	movq	%r12, 152(%rsp)                 # 8-byte Spill
	movq	%r14, 16(%rsp)                  # 8-byte Spill
	movq	%rax, %r14
	movl	$1, %edi
	movq	%r15, %rsi
	callq	calloc@PLT
	movq	%rax, %r12
	movl	$1, %edi
	movq	%r15, %rsi
	callq	calloc@PLT
	movq	%rax, %r13
	movl	$1, %edi
	movq	%r15, %rsi
	callq	calloc@PLT
	movq	%rax, %rbx
	movl	$1, %edi
	movq	%r15, %rsi
	callq	calloc@PLT
	movq	96(%rsp), %rcx                  # 8-byte Reload
	movq	%rcx, US(%rip)
	movq	88(%rsp), %rcx                  # 8-byte Reload
	movq	%rcx, US+8(%rip)
	movq	%r14, 136(%rsp)                 # 8-byte Spill
	movq	%r14, US+16(%rip)
	movq	16(%rsp), %r14                  # 8-byte Reload
	movq	152(%rsp), %rcx                 # 8-byte Reload
	movq	%r12, 128(%rsp)                 # 8-byte Spill
	movq	%r12, US+24(%rip)
	movq	%r13, 120(%rsp)                 # 8-byte Spill
	movq	%r13, US+32(%rip)
	movq	%rbx, 112(%rsp)                 # 8-byte Spill
	movq	%rbx, US+40(%rip)
	movq	%rax, 104(%rsp)                 # 8-byte Spill
	movq	%rax, US+48(%rip)
	movq	%r14, US+56(%rip)
	movq	%rcx, %rbx
	movq	%rcx, US+64(%rip)
	movl	$.L.str.32, %edi
	xorl	%eax, %eax
	callq	printf
	leaq	1728(%rsp), %r13
	movq	%r13, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	cvtsi2sdq	8(%r13), %xmm0
	divsd	.LCPI5_5(%rip), %xmm0
	cvtsi2sdq	(%r13), %xmm1
	addsd	%xmm0, %xmm1
	movsd	%xmm1, 144(%rsp)                # 8-byte Spill
	callq	_Z25init_MassPositionVelocityv
	leaq	200(%rsp), %r12
	movq	%r12, %rdi
	callq	pthread_attr_init
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	pthread_attr_setdetachstate
.LBB5_12:                               # =>This Inner Loop Header: Depth=1
	movl	$_Z21init_Acceleration_SMTPv, %edx
	movq	%r13, %rdi
	movq	%r12, %rsi
	movq	%rbp, %rcx
	callq	pthread_create
	testl	%eax, %eax
	jne	.LBB5_42
# %bb.13:                               #   in Loop: Header=BB5_12 Depth=1
	incq	%rbp
	addq	$8, %r13
	cmpq	$32, %rbp
	jne	.LBB5_12
# %bb.14:                               # %.preheader.preheader
	xorl	%r13d, %r13d
	leaq	176(%rsp), %r12
.LBB5_15:                               # %.preheader
                                        # =>This Inner Loop Header: Depth=1
	movq	1728(%rsp,%r13,8), %rdi
	movq	%r12, %rsi
	callq	pthread_join
	testl	%eax, %eax
	jne	.LBB5_43
# %bb.16:                               #   in Loop: Header=BB5_15 Depth=1
	incq	%r13
	cmpq	$32, %r13
	jne	.LBB5_15
# %bb.17:
	leaq	160(%rsp), %r12
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm1, %xmm1
	cvtsi2sdq	8(%r12), %xmm1
	divsd	.LCPI5_5(%rip), %xmm1
	xorps	%xmm0, %xmm0
	cvtsi2sdq	(%r12), %xmm0
	addsd	%xmm1, %xmm0
	subsd	144(%rsp), %xmm0                # 8-byte Folded Reload
	movl	$.L.str.35, %edi
	movb	$1, %al
	callq	printf
	leaq	72(%rsp), %rdi
	movq	80(%rsp), %r12                  # 8-byte Reload
	movq	%r12, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB5_51
# %bb.18:                               # %_Z9gpuAssert10hipError_tPKcib.exit142
	leaq	64(%rsp), %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB5_52
# %bb.19:                               # %_Z9gpuAssert10hipError_tPKcib.exit144
	leaq	56(%rsp), %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB5_53
# %bb.20:                               # %_Z9gpuAssert10hipError_tPKcib.exit146
	leaq	48(%rsp), %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB5_54
# %bb.21:                               # %_Z9gpuAssert10hipError_tPKcib.exit148
	leaq	40(%rsp), %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB5_55
# %bb.22:                               # %_Z9gpuAssert10hipError_tPKcib.exit150
	leaq	32(%rsp), %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB5_56
# %bb.23:                               # %_Z9gpuAssert10hipError_tPKcib.exit152
	leaq	24(%rsp), %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB5_57
# %bb.24:                               # %_Z9gpuAssert10hipError_tPKcib.exit154
	movq	72(%rsp), %rdi
	movq	96(%rsp), %rsi                  # 8-byte Reload
	movq	%r12, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB5_58
# %bb.25:                               # %_Z9gpuAssert10hipError_tPKcib.exit156
	movq	64(%rsp), %rdi
	movq	88(%rsp), %rsi                  # 8-byte Reload
	movq	%r15, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB5_59
# %bb.26:                               # %_Z9gpuAssert10hipError_tPKcib.exit158
	movq	56(%rsp), %rdi
	movq	136(%rsp), %rsi                 # 8-byte Reload
	movq	%r15, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB5_60
# %bb.27:                               # %_Z9gpuAssert10hipError_tPKcib.exit160
	movq	48(%rsp), %rdi
	movq	128(%rsp), %rsi                 # 8-byte Reload
	movq	%r15, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB5_61
# %bb.28:                               # %_Z9gpuAssert10hipError_tPKcib.exit162
	movq	40(%rsp), %rdi
	movq	120(%rsp), %rsi                 # 8-byte Reload
	movq	%r15, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB5_62
# %bb.29:                               # %_Z9gpuAssert10hipError_tPKcib.exit164
	movq	32(%rsp), %rdi
	movq	112(%rsp), %rsi                 # 8-byte Reload
	movq	%r15, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB5_63
# %bb.30:                               # %_Z9gpuAssert10hipError_tPKcib.exit166
	movq	24(%rsp), %rdi
	movq	104(%rsp), %rsi                 # 8-byte Reload
	movq	%r15, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB5_64
# %bb.31:                               # %_Z9gpuAssert10hipError_tPKcib.exit168
	leaq	160(%rsp), %r15
	movq	%r15, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	(%r15), %rax
	movq	%rax, 80(%rsp)                  # 8-byte Spill
	movq	8(%r15), %r13
	testq	%rbx, %rbx
	je	.LBB5_40
# %bb.32:                               # %.lr.ph.preheader
	movabsq	$4294967296, %r15               # imm = 0x100000000
	leaq	1023(%r14), %rax
	shrq	$10, %rax
	movl	%eax, %r12d
	btsq	$32, %r12
	xorl	%ebp, %ebp
	addq	$1024, %r15                     # imm = 0x400
.LBB5_33:                               # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movq	%r12, %rdi
	movl	$1, %esi
	movq	%r15, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testb	$1, %bpl
	jne	.LBB5_36
# %bb.34:                               #   in Loop: Header=BB5_33 Depth=1
	testl	%eax, %eax
	jne	.LBB5_39
# %bb.35:                               #   in Loop: Header=BB5_33 Depth=1
	movq	56(%rsp), %rdi
	movq	40(%rsp), %rsi
	movq	24(%rsp), %rdx
	movq	64(%rsp), %rcx
	movq	48(%rsp), %r8
	movq	32(%rsp), %r9
	jmp	.LBB5_38
.LBB5_36:                               #   in Loop: Header=BB5_33 Depth=1
	testl	%eax, %eax
	jne	.LBB5_39
# %bb.37:                               #   in Loop: Header=BB5_33 Depth=1
	movq	64(%rsp), %rdi
	movq	48(%rsp), %rsi
	movq	32(%rsp), %rdx
	movq	56(%rsp), %rcx
	movq	40(%rsp), %r8
	movq	24(%rsp), %r9
.LBB5_38:                               #   in Loop: Header=BB5_33 Depth=1
	pushq	%r14
	.cfi_adjust_cfa_offset 8
	pushq	80(%rsp)
	.cfi_adjust_cfa_offset 8
	callq	_Z29__device_stub__compute_DevicePfS_S_PKfS1_S1_S1_m
	addq	$16, %rsp
	.cfi_adjust_cfa_offset -16
.LBB5_39:                               #   in Loop: Header=BB5_33 Depth=1
	callq	hipDeviceSynchronize
	incq	%rbp
	cmpq	%rbp, %rbx
	jne	.LBB5_33
.LBB5_40:                               # %._crit_edge
	leaq	160(%rsp), %r14
	movq	%r14, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	(%r14), %r15
	movq	8(%r14), %r14
	movq	72(%rsp), %rdi
	callq	hipFree
	movq	64(%rsp), %rdi
	callq	hipFree
	movq	56(%rsp), %rdi
	callq	hipFree
	movq	48(%rsp), %rdi
	callq	hipFree
	movq	40(%rsp), %rdi
	callq	hipFree
	movq	32(%rsp), %rdi
	callq	hipFree
	movq	24(%rsp), %rdi
	callq	hipFree
	callq	hipDeviceReset
	testl	%eax, %eax
	jne	.LBB5_65
# %bb.41:                               # %_Z9gpuAssert10hipError_tPKcib.exit170
	cvtsi2sd	%r14, %xmm0
	movsd	.LCPI5_5(%rip), %xmm1           # xmm1 = mem[0],zero
	divsd	%xmm1, %xmm0
	cvtsi2sd	%r15, %xmm2
	addsd	%xmm0, %xmm2
	xorps	%xmm0, %xmm0
	cvtsi2sd	%r13, %xmm0
	divsd	%xmm1, %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sdq	80(%rsp), %xmm1         # 8-byte Folded Reload
	addsd	%xmm0, %xmm1
	subsd	%xmm1, %xmm2
	movsd	%xmm2, 16(%rsp)                 # 8-byte Spill
	movl	$.Lstr.3, %edi
	callq	puts@PLT
	movl	$.L.str.37, %edi
	movsd	16(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movb	$1, %al
	callq	printf
	movq	%rbx, %xmm0
	punpckldq	.LCPI5_1(%rip), %xmm0   # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
	subpd	.LCPI5_2(%rip), %xmm0
	movapd	%xmm0, %xmm1
	unpckhpd	%xmm0, %xmm1                    # xmm1 = xmm1[1],xmm0[1]
	addsd	%xmm0, %xmm1
	movsd	16(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	divsd	%xmm1, %xmm0
	movl	$.L.str.38, %edi
	movb	$1, %al
	callq	printf
	movq	96(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	88(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	136(%rsp), %rdi                 # 8-byte Reload
	callq	free
	movq	128(%rsp), %rdi                 # 8-byte Reload
	callq	free
	movq	120(%rsp), %rdi                 # 8-byte Reload
	callq	free
	movq	112(%rsp), %rdi                 # 8-byte Reload
	callq	free
	movq	104(%rsp), %rdi                 # 8-byte Reload
	callq	free
	leaq	200(%rsp), %rdi
	callq	pthread_attr_destroy
	xorl	%eax, %eax
	addq	$1992, %rsp                     # imm = 0x7C8
	.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
.LBB5_42:
	.cfi_def_cfa_offset 2048
	movl	$.L.str.33, %edi
	jmp	.LBB5_44
.LBB5_43:
	movl	$.L.str.34, %edi
.LBB5_44:
	movl	%eax, %esi
	xorl	%eax, %eax
	callq	printf
.LBB5_46:
	movl	$1, %edi
	callq	exit
.LBB5_45:
	movl	$.Lstr.4, %edi
	callq	puts@PLT
	jmp	.LBB5_46
.LBB5_47:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.39, %esi
	movl	$.L.str.7, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$249, %r8d
	jmp	.LBB5_66
.LBB5_48:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.39, %esi
	movl	$.L.str.7, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$250, %r8d
	jmp	.LBB5_66
.LBB5_49:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.39, %esi
	movl	$.L.str.7, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$251, %r8d
	jmp	.LBB5_66
.LBB5_50:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.39, %esi
	movl	$.L.str.7, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$252, %r8d
	jmp	.LBB5_66
.LBB5_51:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.39, %esi
	movl	$.L.str.7, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$378, %r8d                      # imm = 0x17A
	jmp	.LBB5_66
.LBB5_52:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.39, %esi
	movl	$.L.str.7, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$379, %r8d                      # imm = 0x17B
	jmp	.LBB5_66
.LBB5_53:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.39, %esi
	movl	$.L.str.7, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$380, %r8d                      # imm = 0x17C
	jmp	.LBB5_66
.LBB5_54:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.39, %esi
	movl	$.L.str.7, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$381, %r8d                      # imm = 0x17D
	jmp	.LBB5_66
.LBB5_55:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.39, %esi
	movl	$.L.str.7, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$382, %r8d                      # imm = 0x17E
	jmp	.LBB5_66
.LBB5_56:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.39, %esi
	movl	$.L.str.7, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$383, %r8d                      # imm = 0x17F
	jmp	.LBB5_66
.LBB5_57:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.39, %esi
	movl	$.L.str.7, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$384, %r8d                      # imm = 0x180
	jmp	.LBB5_66
.LBB5_58:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.39, %esi
	movl	$.L.str.7, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$387, %r8d                      # imm = 0x183
	jmp	.LBB5_66
.LBB5_59:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.39, %esi
	movl	$.L.str.7, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$388, %r8d                      # imm = 0x184
	jmp	.LBB5_66
.LBB5_60:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.39, %esi
	movl	$.L.str.7, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$389, %r8d                      # imm = 0x185
	jmp	.LBB5_66
.LBB5_61:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.39, %esi
	movl	$.L.str.7, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$390, %r8d                      # imm = 0x186
	jmp	.LBB5_66
.LBB5_62:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.39, %esi
	movl	$.L.str.7, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$391, %r8d                      # imm = 0x187
	jmp	.LBB5_66
.LBB5_63:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.39, %esi
	movl	$.L.str.7, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$392, %r8d                      # imm = 0x188
	jmp	.LBB5_66
.LBB5_64:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.39, %esi
	movl	$.L.str.7, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$393, %r8d                      # imm = 0x189
	jmp	.LBB5_66
.LBB5_65:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.39, %esi
	movl	$.L.str.7, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$435, %r8d                      # imm = 0x1B3
.LBB5_66:
	xorl	%eax, %eax
	callq	fprintf
	movl	%ebp, %edi
	callq	exit
.Lfunc_end5:
	.size	main, .Lfunc_end5-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB6_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB6_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z14compute_DevicePfS_S_PKfS1_S1_S1_m, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_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	US,@object                      # @US
	.bss
	.globl	US
	.p2align	3, 0x0
US:
	.zero	72
	.size	US, 72

	.type	.L.str.1,@object                # @.str.1
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.1:
	.asciz	"Mass %ld\n"
	.size	.L.str.1, 10

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Mass %ld\t"
	.size	.L.str.2, 10

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"%.2f\n"
	.size	.L.str.3, 6

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"%.2f\t"
	.size	.L.str.4, 6

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"%.2f\n\n"
	.size	.L.str.5, 7

	.type	_Z14compute_DevicePfS_S_PKfS1_S1_S1_m,@object # @_Z14compute_DevicePfS_S_PKfS1_S1_S1_m
	.section	.rodata,"a",@progbits
	.globl	_Z14compute_DevicePfS_S_PKfS1_S1_S1_m
	.p2align	3, 0x0
_Z14compute_DevicePfS_S_PKfS1_S1_S1_m:
	.quad	_Z29__device_stub__compute_DevicePfS_S_PKfS1_S1_S1_m
	.size	_Z14compute_DevicePfS_S_PKfS1_S1_S1_m, 8

	.type	.L.str.7,@object                # @.str.7
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.7:
	.asciz	"/home/ubuntu/Datasets/stackv2/train-structured-repos-hip-sm89/haldarritam/N-Body-Simulation-CUDA/master/Backup/Gianluca/test_gpu.hip"
	.size	.L.str.7, 133

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"  Device %d: %s\n"
	.size	.L.str.9, 17

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"  CUDA Driver Version / Runtime Version: %d.%d / %d.%d\n"
	.size	.L.str.10, 56

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"  CUDA Capability Major/Minor version number: %d.%d\n"
	.size	.L.str.11, 53

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"  Number of SMs: %d\n"
	.size	.L.str.12, 21

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"  Total amount of global memory: %.2f GB (%llu B)\n"
	.size	.L.str.13, 51

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	"  Total amount of constant memory: %4.2f kB\n"
	.size	.L.str.14, 45

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"  Total amount of shared memory per block: %4.2f kB\n"
	.size	.L.str.15, 53

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	"  Total number of registers available per block: %d\n"
	.size	.L.str.16, 53

	.type	.L.str.17,@object               # @.str.17
.L.str.17:
	.asciz	"  Warp size: %d\n"
	.size	.L.str.17, 17

	.type	.L.str.18,@object               # @.str.18
.L.str.18:
	.asciz	"  Maximum number of threads per block: %d\n"
	.size	.L.str.18, 43

	.type	.L.str.19,@object               # @.str.19
.L.str.19:
	.asciz	"  Maximum number of threads per SM: %d\n"
	.size	.L.str.19, 40

	.type	.L.str.20,@object               # @.str.20
.L.str.20:
	.asciz	"  Maximum number of warps per SM: %d\n"
	.size	.L.str.20, 38

	.type	.L.str.21,@object               # @.str.21
.L.str.21:
	.asciz	"  Maximum size of each block dimension: %d x %d x %d\n"
	.size	.L.str.21, 54

	.type	.L.str.22,@object               # @.str.22
.L.str.22:
	.asciz	"  Maximum size of each grid dimension: %d x %d x %d\n"
	.size	.L.str.22, 53

	.type	.L.str.23,@object               # @.str.23
.L.str.23:
	.asciz	"  Maximum memory pitch: %lu B\n"
	.size	.L.str.23, 31

	.type	.L.str.24,@object               # @.str.24
.L.str.24:
	.asciz	"  Memory Clock Rate (MHz): %.1f\n"
	.size	.L.str.24, 33

	.type	.L.str.25,@object               # @.str.25
.L.str.25:
	.asciz	"  Memory Bus Width (b): %d\n"
	.size	.L.str.25, 28

	.type	.L.str.26,@object               # @.str.26
.L.str.26:
	.asciz	"  Peak Memory Bandwidth (GB/s): %.2f\n\n"
	.size	.L.str.26, 39

	.type	.L.str.28,@object               # @.str.28
.L.str.28:
	.asciz	"  Number of Bodies = %ld\n"
	.size	.L.str.28, 26

	.type	.L.str.29,@object               # @.str.29
.L.str.29:
	.asciz	"  Number of Time Steps = %ld\n"
	.size	.L.str.29, 30

	.type	.L.str.30,@object               # @.str.30
.L.str.30:
	.asciz	"  Number of CPU Threads = %d\n\n"
	.size	.L.str.30, 31

	.type	.L.str.32,@object               # @.str.32
.L.str.32:
	.asciz	"Initializing bodies on HOST. Time taken: "
	.size	.L.str.32, 42

	.type	.L.str.33,@object               # @.str.33
.L.str.33:
	.asciz	"Error; return code from pthread_create() is %d.\n"
	.size	.L.str.33, 49

	.type	.L.str.34,@object               # @.str.34
.L.str.34:
	.asciz	"ERROR; return code from pthread_join() is %d.\n"
	.size	.L.str.34, 47

	.type	.L.str.35,@object               # @.str.35
.L.str.35:
	.asciz	"%lfs\n"
	.size	.L.str.35, 6

	.type	.L.str.37,@object               # @.str.37
.L.str.37:
	.asciz	"\nElapsed Time: %lfs\n"
	.size	.L.str.37, 21

	.type	.L.str.38,@object               # @.str.38
.L.str.38:
	.asciz	"Average timestep simulation duration: %lfs\n"
	.size	.L.str.38, 44

	.type	.L.str.39,@object               # @.str.39
.L.str.39:
	.asciz	"GPUassert: %s %s %d\n"
	.size	.L.str.39, 21

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z14compute_DevicePfS_S_PKfS1_S1_S1_m"
	.size	.L__unnamed_1, 38

	.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

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"\n===== Device Properties ======\n"
	.size	.Lstr, 33

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"\n===== Simulation Parameters =====\n"
	.size	.Lstr.1, 36

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"=================================\n\n"
	.size	.Lstr.2, 36

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"Device successfully reset."
	.size	.Lstr.3, 27

	.type	.Lstr.4,@object                 # @str.4
.Lstr.4:
	.asciz	"Error: Wrong number of arguments."
	.size	.Lstr.4, 34

	.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 _Z21init_Acceleration_SMTPv
	.addrsig_sym _Z29__device_stub__compute_DevicePfS_S_PKfS1_S1_S1_m
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z14compute_DevicePfS_S_PKfS1_S1_S1_m
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z14compute_DevicePfS_S_PKfS1_S1_S1_m ; -- Begin function _Z14compute_DevicePfS_S_PKfS1_S1_S1_m
	.globl	_Z14compute_DevicePfS_S_PKfS1_S1_S1_m
	.p2align	8
	.type	_Z14compute_DevicePfS_S_PKfS1_S1_S1_m,@function
_Z14compute_DevicePfS_S_PKfS1_S1_S1_m:  ; @_Z14compute_DevicePfS_S_PKfS1_S1_S1_m
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x4c
	s_load_b512 s[16:31], s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s0, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s0, v[0:1]
	v_mov_b32_e32 v2, 0
	s_mov_b32 s0, exec_lo
	v_cmpx_gt_u64_e64 s[30:31], v[1:2]
	s_cbranch_execz .LBB0_6
; %bb.1:
	v_lshlrev_b64 v[7:8], 3, v[1:2]
	s_add_u32 s0, s16, 4
	s_addc_u32 s1, s17, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v9, vcc_lo, s22, v7
	v_add_co_ci_u32_e32 v10, vcc_lo, s23, v8, vcc_lo
	v_add_co_u32 v3, vcc_lo, s24, v7
	v_add_co_ci_u32_e32 v4, vcc_lo, s25, v8, vcc_lo
	v_add_co_u32 v5, vcc_lo, s26, v7
	v_add_co_ci_u32_e32 v6, vcc_lo, s27, v8, vcc_lo
	global_load_b32 v11, v[9:10], off
	global_load_b32 v0, v[3:4], off
	global_load_b32 v12, v[5:6], off
	v_add_co_u32 v13, vcc_lo, s16, v7
	v_add_co_ci_u32_e32 v14, vcc_lo, s17, v8, vcc_lo
	s_waitcnt vmcnt(1)
	v_fmac_f32_e32 v11, 0x3b000002, v0
	s_waitcnt vmcnt(0)
	v_mul_f32_e32 v0, 0x36800000, v12
	s_delay_alu instid0(VALU_DEP_1)
	v_fmac_f32_e32 v11, 0.5, v0
	global_store_b32 v[13:14], v11, off
	global_load_b32 v12, v[9:10], off offset:4
	global_load_b32 v0, v[3:4], off offset:4
	global_load_b32 v7, v[5:6], off offset:4
	v_dual_mov_b32 v10, v2 :: v_dual_mov_b32 v9, v1
	s_waitcnt vmcnt(1)
	v_fmac_f32_e32 v12, 0x3b000002, v0
	s_waitcnt vmcnt(0)
	v_mul_f32_e32 v0, 0x36800000, v7
	v_lshlrev_b64 v[7:8], 1, v[1:2]
	s_delay_alu instid0(VALU_DEP_2)
	v_dual_mov_b32 v1, v2 :: v_dual_fmac_f32 v12, 0.5, v0
	v_mov_b32_e32 v0, v2
	global_store_b32 v[13:14], v12, off offset:4
.LBB0_2:                                ; =>This Inner Loop Header: Depth=1
	s_mov_b32 s2, exec_lo
	v_cmpx_ne_u64_e32 0, v[9:10]
	s_cbranch_execz .LBB0_4
; %bb.3:                                ;   in Loop: Header=BB0_2 Depth=1
	s_clause 0x1
	global_load_b64 v[13:14], v2, s[0:1] offset:-4
	global_load_b32 v15, v2, s[28:29]
	s_waitcnt vmcnt(1)
	v_dual_sub_f32 v14, v14, v12 :: v_dual_sub_f32 v13, v13, v11
	s_waitcnt vmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_dual_mul_f32 v15, 0x41000000, v15 :: v_dual_mul_f32 v16, v14, v14
	v_fmac_f32_e32 v16, v13, v13
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f32_e32 v16, 0x3a800000, v16
	v_mul_f32_e32 v17, v16, v16
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f32_e32 v16, v16, v17
	v_mul_f32_e32 v17, 0x4b800000, v16
	v_cmp_gt_f32_e32 vcc_lo, 0x800000, v16
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cndmask_b32_e32 v16, v16, v17, vcc_lo
	v_rsq_f32_e32 v16, v16
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v17, 0x45800000, v16
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cndmask_b32_e32 v16, v16, v17, vcc_lo
	v_mul_f32_e32 v15, v15, v16
	s_delay_alu instid0(VALU_DEP_1)
	v_fmac_f32_e32 v0, v13, v15
	v_fmac_f32_e32 v1, v14, v15
.LBB0_4:                                ;   in Loop: Header=BB0_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s2
	s_add_u32 s30, s30, -1
	s_addc_u32 s31, s31, -1
	v_add_co_u32 v9, vcc_lo, v9, -1
	s_add_u32 s0, s0, 8
	v_add_co_ci_u32_e32 v10, vcc_lo, -1, v10, vcc_lo
	s_addc_u32 s1, s1, 0
	s_add_u32 s28, s28, 4
	s_addc_u32 s29, s29, 0
	s_cmp_eq_u64 s[30:31], 0
	s_cbranch_scc0 .LBB0_2
; %bb.5:
	v_lshlrev_b64 v[7:8], 2, v[7:8]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v9, vcc_lo, s20, v7
	v_add_co_ci_u32_e32 v10, vcc_lo, s21, v8, vcc_lo
	v_add_co_u32 v7, vcc_lo, s18, v7
	v_add_co_ci_u32_e32 v8, vcc_lo, s19, v8, vcc_lo
	global_store_b64 v[9:10], v[0:1], off
	global_load_b32 v2, v[5:6], off
	global_load_b32 v9, v[3:4], off
	s_waitcnt vmcnt(1)
	v_add_f32_e32 v0, v0, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mul_f32_e32 v0, 0x3b000002, v0
	s_waitcnt vmcnt(0)
	v_fmac_f32_e32 v9, 0.5, v0
	global_store_b32 v[7:8], v9, off
	global_load_b32 v0, v[5:6], off offset:4
	global_load_b32 v2, v[3:4], off offset:4
	s_waitcnt vmcnt(1)
	v_add_f32_e32 v0, v1, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mul_f32_e32 v0, 0x3b000002, v0
	s_waitcnt vmcnt(0)
	v_fmac_f32_e32 v2, 0.5, v0
	global_store_b32 v[7:8], v2, off offset:4
.LBB0_6:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z14compute_DevicePfS_S_PKfS1_S1_S1_m
		.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 18
		.amdhsa_next_free_sgpr 32
		.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	_Z14compute_DevicePfS_S_PKfS1_S1_S1_m, .Lfunc_end0-_Z14compute_DevicePfS_S_PKfS1_S1_S1_m
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 648
; NumSgprs: 34
; NumVgprs: 18
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 4
; VGPRBlocks: 2
; NumSGPRsForWavesPerEU: 34
; NumVGPRsForWavesPerEU: 18
; 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
      - .address_space:  global
        .offset:         40
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         48
        .size:           8
        .value_kind:     global_buffer
      - .offset:         56
        .size:           8
        .value_kind:     by_value
      - .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:           _Z14compute_DevicePfS_S_PKfS1_S1_S1_m
    .private_segment_fixed_size: 0
    .sgpr_count:     34
    .sgpr_spill_count: 0
    .symbol:         _Z14compute_DevicePfS_S_PKfS1_S1_S1_m.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     18
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
