#include <stdio.h>
#include <unistd.h>
#include <sys/time.h>
#include <time.h>

// #define NUM_SPHERES 2
#define NUM_SPHERES 200
// #define BLOCK_SIZE 1
#define BLOCK_SIZE 256

struct Sphere {
  float posX, posY, posZ;
  float velX, velY, velZ;
  float radius;
  unsigned id;
};

float *d_posBuf, *d_velBuf, *d_radBuf, *d_velBuf_temp;
unsigned *d_idBuf;
size_t d_posBuf_size, d_velBuf_size, d_radBuf_size, d_idBuf_size;

__global__ void swapVelBufKernel(float *d_velBuf, float *d_velBuf_temp) {
  unsigned index, i;

  index = threadIdx.x + blockDim.x * blockIdx.x;

  if(index < NUM_SPHERES) {
    for(i = 0; i < 3; i++) {
      d_velBuf[index * 3 + i] = d_velBuf_temp[index * 3 + i];
    }
  }
}

__global__ void fillTempVelKernel(float *d_posBuf, float *d_velBuf,
  float *d_radBuf, float *d_velBuf_temp) {
  __shared__ float posBufLocal[BLOCK_SIZE * 3];
  __shared__ float velBufLocal[BLOCK_SIZE * 3];
  __shared__ float radBufLocal[BLOCK_SIZE];
  unsigned i, j, k, index, otherIndex; // otherIndex = index of other sphere
  float pos[3], vel[3], outVel[3], rad, mass; // outVel = output velocity
  float otherPos[3], otherVel[3], otherRad, otherMass; // data of other sphere
  float delta[3]; // Used to compare distance between sphere centers
  float distanceSquared, radiusSumSquared;
  bool didImpact;

  index = threadIdx.x + blockDim.x * blockIdx.x;

  for(i = 0; i < 3; i++) {
    pos[i] = d_posBuf[index * 3 + i];
    vel[i] = d_velBuf[index * 3 + i];
    outVel[i] = 0;
  }

  rad = d_radBuf[index];
  mass = rad * rad * rad;  

  didImpact = false;

  for(i = 0; i < gridDim.x; i++) {
    // For each block, load posBufLocal and velBufLocal
    posBufLocal[threadIdx.x * 3 + 0] = d_posBuf[blockDim.x * 3 * i +
      threadIdx.x * 3 + 0];
    posBufLocal[threadIdx.x * 3 + 1] = d_posBuf[blockDim.x * 3 * i +
      threadIdx.x * 3 + 1];
    posBufLocal[threadIdx.x * 3 + 2] = d_posBuf[blockDim.x * 3 * i +
      threadIdx.x * 3 + 2];

    velBufLocal[threadIdx.x * 3 + 0] = d_velBuf[blockDim.x * 3 * i +
      threadIdx.x * 3 + 0];
    velBufLocal[threadIdx.x * 3 + 1] = d_velBuf[blockDim.x * 3 * i +
      threadIdx.x * 3 + 1];
    velBufLocal[threadIdx.x * 3 + 2] = d_velBuf[blockDim.x * 3 * i +
      threadIdx.x * 3 + 2];

    radBufLocal[threadIdx.x] = d_radBuf[blockDim.x * i + threadIdx.x];

    __syncthreads();

    // Now all of the local data is filled

    // Check against each sphere in local data
    for(j = 0; j < blockDim.x; j++) {
      otherIndex = j + blockDim.x * i; // j = threadIdx.x, i = blockIdx.x
      // Check if the sphere data is not garbage data or the same data
      if((otherIndex < NUM_SPHERES) && (otherIndex != index)) {
        // Fill data of other sphere
        for(k = 0; k < 3; k++) {
          otherPos[k] = posBufLocal[j * 3 + k];
          otherVel[k] = velBufLocal[j * 3 + k];
        }

        otherRad = radBufLocal[j];

        // Check to see if they collide
      
        // Get difference in x, y, and z (0, 1, 2) for indexes
        for(k = 0; k < 3; k++) {
          delta[k] = pos[k] - otherPos[k];
        }

        // Calculate distanceSquared and radiusSumSquared
        distanceSquared = 0;
        radiusSumSquared = 0;

        for(k = 0; k < 3; k++) {
          distanceSquared = distanceSquared + delta[k] * delta[k];
        }
      
        radiusSumSquared = (rad + otherRad) * (rad + otherRad);

        if(distanceSquared < radiusSumSquared) {
          // We collide
          didImpact = true;

          // Calculate the mass of the other sphere
          otherMass = otherRad * otherRad * otherRad;

          for(k = 0; k < 3; k++) {
            outVel[k] = outVel[k] +
              (mass - otherMass) / (mass + otherMass) * vel[k] +
              (2 * otherMass) / (mass + otherMass) * otherVel[k];
          }
        }
      }
    }
    
    __syncthreads();
    // Now that all threads in this block have processed the local data
    // We can now move to the next set of local data
  }

  // Put the new velocity in outVel into the velocity buffer
  if(!didImpact) {
    // If the object did not impact with anything, continue with current
    // velocity
    for(i = 0; i < 3; i++) {
      outVel[i] = vel[i];
    }
  }

  for(i = 0; i < 3; i++) {
    d_velBuf_temp[index * 3 + i] = outVel[i];
  }
}

void updateVelocity() {
  unsigned numBlocks;

  numBlocks = NUM_SPHERES / BLOCK_SIZE;
  if(NUM_SPHERES % BLOCK_SIZE) numBlocks++; 

  dim3 dimGrid(numBlocks, 1, 1);
  dim3 dimBlock(BLOCK_SIZE, 1, 1);

  // Fill the temporary velocity buffer
  fillTempVelKernel<<<dimGrid, dimBlock>>>(d_posBuf, d_velBuf, d_radBuf,
    d_velBuf_temp);
  // Copy from the temporary buffer to the real buffer
  swapVelBufKernel<<<dimGrid, dimBlock>>>(d_velBuf, d_velBuf_temp);
}

double time_diff(struct timeval x, struct timeval y) {
  double x_ms, y_ms, diff;

  x_ms = (double) x.tv_sec * 1000000 + (double) x.tv_usec;
  y_ms = (double) y.tv_sec * 1000000 + (double) y.tv_usec;

  diff = (double) y_ms - (double) x_ms;

  return diff;
}

void updateVelocitySerial() {
  float posBuf[NUM_SPHERES * 3];
  float velBuf[NUM_SPHERES * 3];
  float temp_velBuf[NUM_SPHERES * 3];
  float radBuf[NUM_SPHERES];
  struct Sphere s1, s2;
  unsigned i, j, k;
  float delta[3];
  float distanceSquared, radiusSumSquared;
  float s1Mass, s2Mass;
  float outVel[3];
  bool didImpact;
  struct timeval before, after;

  for(i = 0; i < 3; i++) {
    outVel[i] = 0;
  }

  // Get the buffers from the GPU
  cudaMemcpy(posBuf, d_posBuf, d_posBuf_size, cudaMemcpyDeviceToHost);
  cudaMemcpy(velBuf, d_velBuf, d_velBuf_size, cudaMemcpyDeviceToHost);
  cudaMemcpy(radBuf, d_radBuf, d_radBuf_size, cudaMemcpyDeviceToHost);

  gettimeofday(&before, NULL);

  for(i = 0; i < NUM_SPHERES; i++) {
    didImpact = false;

    outVel[0] = 0;
    outVel[1] = 0;
    outVel[2] = 0;

    s1.posX = posBuf[i * 3 + 0];
    s1.posY = posBuf[i * 3 + 1];
    s1.posZ = posBuf[i * 3 + 2];

    s1.velX = velBuf[i * 3 + 0];
    s1.velY = velBuf[i * 3 + 1];
    s1.velZ = velBuf[i * 3 + 2];

    s1.radius = radBuf[i];

    s1Mass = s1.radius * s1.radius * s1.radius;

    for(j = 0; j < NUM_SPHERES; j++) {
      if(j == i) {
        continue;
      }

      s2.posX = posBuf[j * 3 + 0];
      s2.posY = posBuf[j * 3 + 1];
      s2.posZ = posBuf[j * 3 + 2];
      
      s2.velX = velBuf[j * 3 + 0];
      s2.velY = velBuf[j * 3 + 1];
      s2.velZ = velBuf[j * 3 + 2];

      s2.radius = radBuf[j];

      delta[0] = s1.posX - s2.posX;
      delta[1] = s1.posY - s2.posY;
      delta[2] = s1.posZ - s2.posZ;

      distanceSquared = 0;
      radiusSumSquared = 0;

      for(k = 0; k < 3; k++) {
        distanceSquared = distanceSquared + delta[k] * delta[k];
      }

      radiusSumSquared = (s1.radius + s2.radius) * (s1.radius + s2.radius);

      if(distanceSquared < radiusSumSquared) {
        // We collide
        didImpact = true;

        s2Mass = s2.radius * s2.radius * s2.radius;

        outVel[0] = outVel[0] +
          (s1Mass - s2Mass) / (s1Mass + s2Mass) * s1.velX +
          (2 * s2Mass) / (s1Mass + s2Mass) * s2.velX;
        outVel[1] = outVel[1] +
          (s1Mass - s2Mass) / (s1Mass + s2Mass) * s1.velY +
          (2 * s2Mass) / (s1Mass + s2Mass) * s2.velY;
        outVel[2] = outVel[2] +
          (s1Mass - s2Mass) / (s1Mass + s2Mass) * s1.velZ +
          (2 * s2Mass) / (s1Mass + s2Mass) * s2.velZ;
      }
    }
    if(!didImpact) {
      for(k = 0; k < 3; k++) {
        outVel[k] = velBuf[i * 3 + k];
      }
    }

    for(k = 0; k < 3; k++) {
      temp_velBuf[i * 3 + k] = outVel[k];
    }

    didImpact = false;
  }

  gettimeofday(&after, NULL);

  printf("Total time elapsed: %.01f us\n", time_diff(before, after));

  // Copy temp_velBuf into GPU
  cudaMemcpy(d_velBuf, temp_velBuf, d_velBuf_size, cudaMemcpyHostToDevice);
}

__global__ void updatePositionKernel(float *d_posBuf, float *d_velBuf) {
  unsigned index, i;

  index = threadIdx.x + blockDim.x * blockIdx.x;

  // Each thread updates its portion
  if(index < NUM_SPHERES) {
    for(i = 0; i < 3; i++) {
      // d_posBuf[index * 3 + i] += d_velBuf[index * 3 + i];
      d_posBuf[index * 3 + i] += d_velBuf[index * 3 + i];;
    }
  }
}

void updatePosition() {
  unsigned numBlocks;

  numBlocks = (d_posBuf_size / 3) / BLOCK_SIZE;
  if((d_posBuf_size / 3) % BLOCK_SIZE) numBlocks++;

  dim3 dimGrid(numBlocks, 1, 1);
  dim3 dimBlock(BLOCK_SIZE, 1, 1);

  // Kernel
  updatePositionKernel<<<dimGrid, dimBlock>>>(d_posBuf, d_velBuf);
}

void printPosition() {
  float temp_posBuf[d_posBuf_size];
  float temp_velBuf[d_velBuf_size];
  unsigned temp_idBuf[d_idBuf_size];
  unsigned i;

  // Copy from GPU to CPU
  cudaMemcpy(temp_posBuf, d_posBuf, d_posBuf_size, cudaMemcpyDeviceToHost);
  cudaMemcpy(temp_velBuf, d_velBuf, d_velBuf_size, cudaMemcpyDeviceToHost);
  cudaMemcpy(temp_idBuf, d_idBuf, d_idBuf_size, cudaMemcpyDeviceToHost);

  for(i = 0; i < NUM_SPHERES; i++) {
    printf("sphere %u\n", temp_idBuf[i]);
    printf("  pos: %f %f %f\n", temp_posBuf[i * 3 + 0], temp_posBuf[i * 3 + 1],
      temp_posBuf[i * 3 + 2]);
    printf("  vel: %f %f %f\n", temp_velBuf[i * 3 + 0], temp_velBuf[i * 3 + 1],
      temp_velBuf[i * 3 + 2]);
  }
}

void loop() {
  printf("--- TICK ---\n");
  updatePosition();
  updateVelocity();
  // updateVelocitySerial();
  // printPosition();
  // sleep(1);
}

int main() {
  // Initialize the object data
  struct Sphere spheres[NUM_SPHERES];
  unsigned i;  

  // Uncomment any of the test cases

  // Test case: Different velocities -----
  // UNCOMMENT START
  /* // First sphere
  spheres[0].posX = 0;
  spheres[0].posY = 0;
  spheres[0].posZ = 0;

  spheres[0].velX = 0.2;
  spheres[0].velY = 0;
  spheres[0].velZ = 0;

  spheres[0].radius = 1;

  spheres[0].id = 0;
  
  // Second sphere
  spheres[1].posX = 3;
  spheres[1].posY = 0;
  spheres[1].posZ = 0;
  
  spheres[1].velX = 0.1;
  spheres[1].velY = 0;
  spheres[1].velZ = 0;

  spheres[1].radius = 1;

  spheres[1].id = 1; */
  // UNCOMMENT END

  // Test case: Different directions -----
  // UNCOMMENT START
  /* // First sphere
  spheres[0].posX = 0;
  spheres[0].posY = 0;
  spheres[0].posZ = 0;

  spheres[0].velX = .1;
  spheres[0].velY = 0;
  spheres[0].velZ = 0;

  spheres[0].radius = 1;
 
  spheres[0].id = 0;

  // Second sphere
  spheres[1].posX = 2;
  spheres[1].posY = 4;
  spheres[1].posZ = 0;

  spheres[1].velX = 0;
  spheres[1].velY = -.1;
  spheres[1].velZ = 0;

  spheres[1].radius = 1;

  spheres[1].id = 1; */
  // UNCOMMENT END

  // Test case: Different masses -----
  // UNCOMMENT START
  // First sphere
  spheres[0].posX = 0;
  spheres[0].posY = 0;
  spheres[0].posZ = 0;
  
  spheres[0].velX = .1;
  spheres[0].velY = 0;
  spheres[0].velZ = 0;

  spheres[0].radius = 1;
  
  spheres[0].id = 0;

  // Second sphere
  spheres[1].posX = 3;
  spheres[1].posY = 0;
  spheres[1].posZ = 0;

  spheres[1].velX = 0;
  spheres[1].velY = 0;
  spheres[1].velZ = 0;

  spheres[1].radius = 1.26;

  spheres[1].id = 1;
  // UNCOMMENT END

  for(i = 2; i < 200; i++) {
    spheres[i].posX = i * 2;
    spheres[i].posY = i * 2;
    spheres[i].posZ = 10;

    spheres[i].velX = 1;
    spheres[i].velY = 1;
    spheres[i].velZ = 0;
    
    spheres[i].radius = 1;
    
    spheres[i].id = i;
  }

  // Create the position buffer
  float posBuf[NUM_SPHERES * 3];
  // Create the velocity buffer
  float velBuf[NUM_SPHERES * 3];
  // Create the radius buffer
  float radBuf[NUM_SPHERES];
  // Create the ID buffer
  unsigned idBuf[NUM_SPHERES];

  // Fill posradBuf
  for(i = 0; i < NUM_SPHERES; i++) {
    posBuf[i * 3 + 0] = spheres[i].posX;
    posBuf[i * 3 + 1] = spheres[i].posY;
    posBuf[i * 3 + 2] = spheres[i].posZ;
  }

  // Fill velocity buffer
  for(i = 0; i < NUM_SPHERES; i++) {
    velBuf[i * 3 + 0] = spheres[i].velX;
    velBuf[i * 3 + 1] = spheres[i].velY;
    velBuf[i * 3 + 2] = spheres[i].velZ;
  }

  // Fill radius buffer
  for(i = 0; i < NUM_SPHERES; i++) {
    radBuf[i] = spheres[i].radius;
  }

  // Fill id buffer
  for(i = 0; i < NUM_SPHERES; i++) {
    idBuf[i] = spheres[i].id;
  }

  // Allocate space on the GPU for storing these buffers
  d_posBuf_size = sizeof(float) * NUM_SPHERES * 3;
  d_velBuf_size = sizeof(float) * NUM_SPHERES * 3;
  d_radBuf_size = sizeof(float) * NUM_SPHERES;
  d_idBuf_size = sizeof(unsigned) * NUM_SPHERES;

  cudaMalloc((void **) &d_posBuf, d_posBuf_size);
  cudaMalloc((void **) &d_velBuf, d_velBuf_size);
  cudaMalloc((void **) &d_radBuf, d_radBuf_size);
  cudaMalloc((void **) &d_idBuf, d_idBuf_size);
  cudaMalloc((void **) &d_velBuf_temp, d_velBuf_size);

  // Copy into GPU
  cudaMemcpy(d_posBuf, posBuf, d_posBuf_size, cudaMemcpyHostToDevice);
  cudaMemcpy(d_velBuf, velBuf, d_velBuf_size, cudaMemcpyHostToDevice);
  cudaMemcpy(d_radBuf, radBuf, d_radBuf_size, cudaMemcpyHostToDevice);
  cudaMemcpy(d_idBuf, idBuf, d_idBuf_size, cudaMemcpyHostToDevice);

  /* while(true) {
    loop();
  } */

  for(i = 0; i < 100; i++) {
    loop();
  }

  cudaFree(d_posBuf);
  cudaFree(d_velBuf);
  cudaFree(d_radBuf);
  cudaFree(d_idBuf);
  cudaFree(d_velBuf_temp);

  return 0;
}


	.file	"tmpxft_0027319b_00000000-6_main.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2049:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2049:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z9time_diff7timevalS_
	.type	_Z9time_diff7timevalS_, @function
_Z9time_diff7timevalS_:
.LFB2041:
	.cfi_startproc
	endbr64
	cvtsi2sdq	%rdx, %xmm0
	movsd	.LC0(%rip), %xmm2
	cvtsi2sdq	%rcx, %xmm1
	mulsd	%xmm2, %xmm0
	addsd	%xmm1, %xmm0
	cvtsi2sdq	%rdi, %xmm1
	mulsd	%xmm2, %xmm1
	cvtsi2sdq	%rsi, %xmm2
	addsd	%xmm2, %xmm1
	subsd	%xmm1, %xmm0
	ret
	.cfi_endproc
.LFE2041:
	.size	_Z9time_diff7timevalS_, .-_Z9time_diff7timevalS_
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"Total time elapsed: %.01f us\n"
	.text
	.globl	_Z20updateVelocitySerialv
	.type	_Z20updateVelocitySerialv, @function
_Z20updateVelocitySerialv:
.LFB2042:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$4096, %rsp
	.cfi_def_cfa_offset 4128
	orq	$0, (%rsp)
	subq	$3952, %rsp
	.cfi_def_cfa_offset 8080
	movq	d_posBuf_size(%rip), %rdx
	movq	d_posBuf(%rip), %rsi
	movl	$2, %ecx
	movq	%fs:40, %rax
	movq	%rax, 8040(%rsp)
	xorl	%eax, %eax
	leaq	840(%rsp), %rbx
	leaq	40(%rsp), %r12
	movq	%rbx, %rdi
	leaq	3240(%rsp), %rbp
	call	cudaMemcpy@PLT
	movq	d_velBuf_size(%rip), %rdx
	movl	$2, %ecx
	movq	%rbp, %rdi
	movq	d_velBuf(%rip), %rsi
	call	cudaMemcpy@PLT
	movq	d_radBuf_size(%rip), %rdx
	movl	$2, %ecx
	movq	%r12, %rdi
	movq	d_radBuf(%rip), %rsi
	call	cudaMemcpy@PLT
	xorl	%esi, %esi
	leaq	8(%rsp), %rdi
	call	gettimeofday@PLT
	movq	%rbp, %rcx
	movq	%rbx, %rsi
	xorl	%eax, %eax
	leaq	5640(%rsp), %rdx
	xorps	%xmm9, %xmm9
.L8:
	movss	(%r12,%rax,4), %xmm4
	movss	(%rsi), %xmm13
	movq	%rbx, %r8
	xorl	%edi, %edi
	movss	(%rcx), %xmm8
	movss	4(%rcx), %xmm7
	movq	%rbp, %r9
	xorl	%r10d, %r10d
	movaps	%xmm4, %xmm5
	xorps	%xmm10, %xmm10
	movss	8(%rcx), %xmm6
	movss	4(%rsi), %xmm14
	mulss	%xmm4, %xmm5
	movss	8(%rsi), %xmm15
	movaps	%xmm10, %xmm3
	movaps	%xmm10, %xmm2
	mulss	%xmm4, %xmm5
.L6:
	cmpl	%edi, %eax
	je	.L4
	movaps	%xmm13, %xmm11
	subss	(%r8), %xmm11
	movaps	%xmm14, %xmm1
	movss	(%r12,%rdi,4), %xmm12
	subss	4(%r8), %xmm1
	movaps	%xmm15, %xmm0
	subss	8(%r8), %xmm0
	mulss	%xmm11, %xmm11
	mulss	%xmm1, %xmm1
	mulss	%xmm0, %xmm0
	addss	%xmm9, %xmm11
	addss	%xmm11, %xmm1
	movaps	%xmm4, %xmm11
	addss	%xmm12, %xmm11
	addss	%xmm1, %xmm0
	mulss	%xmm11, %xmm11
	comiss	%xmm0, %xmm11
	jbe	.L4
	movaps	%xmm12, %xmm0
	movaps	%xmm5, %xmm11
	movaps	%xmm5, %xmm1
	movb	$1, %r10b
	mulss	%xmm12, %xmm0
	mulss	%xmm12, %xmm0
	addss	%xmm0, %xmm11
	subss	%xmm0, %xmm1
	addss	%xmm0, %xmm0
	divss	%xmm11, %xmm1
	divss	%xmm11, %xmm0
	movaps	%xmm8, %xmm11
	mulss	%xmm1, %xmm11
	addss	%xmm2, %xmm11
	movss	(%r9), %xmm2
	mulss	%xmm0, %xmm2
	addss	%xmm11, %xmm2
	movaps	%xmm7, %xmm11
	mulss	%xmm1, %xmm11
	mulss	%xmm6, %xmm1
	addss	%xmm3, %xmm11
	movss	4(%r9), %xmm3
	addss	%xmm10, %xmm1
	mulss	%xmm0, %xmm3
	mulss	8(%r9), %xmm0
	addss	%xmm11, %xmm3
	addss	%xmm0, %xmm1
	movaps	%xmm1, %xmm10
.L4:
	incq	%rdi
	addq	$12, %r9
	addq	$12, %r8
	cmpq	$200, %rdi
	jne	.L6
	testb	%r10b, %r10b
	je	.L7
	movaps	%xmm10, %xmm6
	movaps	%xmm3, %xmm7
	movaps	%xmm2, %xmm8
.L7:
	incq	%rax
	movss	%xmm8, (%rdx)
	addq	$12, %rsi
	addq	$12, %rcx
	movss	%xmm7, 4(%rdx)
	addq	$12, %rdx
	movss	%xmm6, -4(%rdx)
	cmpq	$200, %rax
	jne	.L8
	xorl	%esi, %esi
	leaq	24(%rsp), %rdi
	call	gettimeofday@PLT
	movq	24(%rsp), %rdx
	movq	32(%rsp), %rcx
	movb	$1, %al
	movq	8(%rsp), %rdi
	movq	16(%rsp), %rsi
	call	_Z9time_diff7timevalS_
	leaq	.LC2(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	d_velBuf_size(%rip), %rdx
	movl	$1, %ecx
	movq	d_velBuf(%rip), %rdi
	leaq	5640(%rsp), %rsi
	call	cudaMemcpy@PLT
	movq	8040(%rsp), %rax
	subq	%fs:40, %rax
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	addq	$8048, %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
.LFE2042:
	.size	_Z20updateVelocitySerialv, .-_Z20updateVelocitySerialv
	.section	.rodata.str1.1
.LC3:
	.string	"sphere %u\n"
.LC4:
	.string	"  pos: %f %f %f\n"
.LC5:
	.string	"  vel: %f %f %f\n"
	.text
	.globl	_Z13printPositionv
	.type	_Z13printPositionv, @function
_Z13printPositionv:
.LFB2044:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$24, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	d_posBuf_size(%rip), %rsi
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rcx
	leaq	15(,%rsi,4), %rdx
	movq	%rdx, %rax
	andq	$-4096, %rdx
	andq	$-16, %rax
	subq	%rdx, %rcx
.L19:
	cmpq	%rcx, %rsp
	je	.L20
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L19
.L20:
	andl	$4095, %eax
	subq	%rax, %rsp
	testq	%rax, %rax
	je	.L21
	orq	$0, -8(%rsp,%rax)
.L21:
	movq	d_velBuf_size(%rip), %rax
	movq	%rsp, %rcx
	movq	%rsp, %r14
	leaq	15(,%rax,4), %rdx
	movq	%rdx, %rax
	andq	$-4096, %rdx
	andq	$-16, %rax
	subq	%rdx, %rcx
.L22:
	cmpq	%rcx, %rsp
	je	.L23
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L22
.L23:
	andl	$4095, %eax
	subq	%rax, %rsp
	testq	%rax, %rax
	je	.L24
	orq	$0, -8(%rsp,%rax)
.L24:
	movq	d_idBuf_size(%rip), %rax
	movq	%rsp, %rcx
	movq	%rsp, %r13
	leaq	15(,%rax,4), %rdx
	movq	%rdx, %rax
	andq	$-4096, %rdx
	andq	$-16, %rax
	subq	%rdx, %rcx
.L25:
	cmpq	%rcx, %rsp
	je	.L26
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L25
.L26:
	andl	$4095, %eax
	subq	%rax, %rsp
	testq	%rax, %rax
	je	.L27
	orq	$0, -8(%rsp,%rax)
.L27:
	movq	%rsi, %rdx
	movq	d_posBuf(%rip), %rsi
	movq	%r14, %rdi
	movq	%rsp, %r12
	movl	$2, %ecx
	xorl	%ebx, %ebx
	leaq	.LC3(%rip), %r15
	call	cudaMemcpy@PLT
	movq	d_velBuf_size(%rip), %rdx
	movl	$2, %ecx
	movq	%r13, %rdi
	movq	d_velBuf(%rip), %rsi
	call	cudaMemcpy@PLT
	movq	d_idBuf_size(%rip), %rdx
	movl	$2, %ecx
	movq	%r12, %rdi
	movq	d_idBuf(%rip), %rsi
	call	cudaMemcpy@PLT
.L28:
	movl	(%r12), %edx
	movq	%r15, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	addq	$4, %r12
	call	__printf_chk@PLT
	leaq	.LC4(%rip), %rsi
	movl	$2, %edi
	movb	$3, %al
	cvtss2sd	(%r14,%rbx), %xmm0
	cvtss2sd	8(%r14,%rbx), %xmm2
	cvtss2sd	4(%r14,%rbx), %xmm1
	call	__printf_chk@PLT
	cvtss2sd	0(%r13,%rbx), %xmm0
	cvtss2sd	8(%r13,%rbx), %xmm2
	movb	$3, %al
	cvtss2sd	4(%r13,%rbx), %xmm1
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	addq	$12, %rbx
	call	__printf_chk@PLT
	cmpq	$2400, %rbx
	jne	.L28
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	je	.L29
	call	__stack_chk_fail@PLT
.L29:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2044:
	.size	_Z13printPositionv, .-_Z13printPositionv
	.globl	_Z38__device_stub__Z16swapVelBufKernelPfS_PfS_
	.type	_Z38__device_stub__Z16swapVelBufKernelPfS_PfS_, @function
_Z38__device_stub__Z16swapVelBufKernelPfS_PfS_:
.LFB2071:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	32(%rsp), %rcx
	leaq	24(%rsp), %rdx
	movq	%rsi, (%rsp)
	leaq	40(%rsp), %rdi
	leaq	52(%rsp), %rsi
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 48(%rsp)
	movq	%rax, 88(%rsp)
	movq	%rsp, %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 40(%rsp)
	movq	%rax, 52(%rsp)
	movl	$1, 60(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L41
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z16swapVelBufKernelPfS_(%rip), %rdi
	pushq	32(%rsp)
	.cfi_def_cfa_offset 144
	movq	68(%rsp), %rcx
	movl	76(%rsp), %r8d
	movq	56(%rsp), %rsi
	movl	64(%rsp), %edx
	leaq	104(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L41:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L43
	call	__stack_chk_fail@PLT
.L43:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2071:
	.size	_Z38__device_stub__Z16swapVelBufKernelPfS_PfS_, .-_Z38__device_stub__Z16swapVelBufKernelPfS_PfS_
	.globl	_Z16swapVelBufKernelPfS_
	.type	_Z16swapVelBufKernelPfS_, @function
_Z16swapVelBufKernelPfS_:
.LFB2072:
	.cfi_startproc
	endbr64
	jmp	_Z38__device_stub__Z16swapVelBufKernelPfS_PfS_
	.cfi_endproc
.LFE2072:
	.size	_Z16swapVelBufKernelPfS_, .-_Z16swapVelBufKernelPfS_
	.globl	_Z43__device_stub__Z17fillTempVelKernelPfS_S_S_PfS_S_S_
	.type	_Z43__device_stub__Z17fillTempVelKernelPfS_S_S_PfS_S_S_, @function
_Z43__device_stub__Z17fillTempVelKernelPfS_S_S_PfS_S_S_:
.LFB2073:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	40(%rsp), %rdx
	movq	%rcx, (%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	movq	%rsp, %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L46
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z17fillTempVelKernelPfS_S_S_(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 176
	movq	84(%rsp), %rcx
	movl	92(%rsp), %r8d
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	leaq	120(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L46:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L48
	call	__stack_chk_fail@PLT
.L48:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2073:
	.size	_Z43__device_stub__Z17fillTempVelKernelPfS_S_S_PfS_S_S_, .-_Z43__device_stub__Z17fillTempVelKernelPfS_S_S_PfS_S_S_
	.globl	_Z17fillTempVelKernelPfS_S_S_
	.type	_Z17fillTempVelKernelPfS_S_S_, @function
_Z17fillTempVelKernelPfS_S_S_:
.LFB2074:
	.cfi_startproc
	endbr64
	jmp	_Z43__device_stub__Z17fillTempVelKernelPfS_S_S_PfS_S_S_
	.cfi_endproc
.LFE2074:
	.size	_Z17fillTempVelKernelPfS_S_S_, .-_Z17fillTempVelKernelPfS_S_S_
	.globl	_Z14updateVelocityv
	.type	_Z14updateVelocityv, @function
_Z14updateVelocityv:
.LFB2040:
	.cfi_startproc
	endbr64
	movl	$16777217, %edx
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	salq	$8, %rdx
	movl	$1, %ecx
	movabsq	$4294967297, %rdi
	movl	$1, %esi
	movq	%rdi, 8(%rsp)
	movl	$1, 16(%rsp)
	movq	%rdx, 20(%rsp)
	movl	$1, 28(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L52
	movq	d_velBuf_temp(%rip), %rcx
	movq	d_radBuf(%rip), %rdx
	movq	d_velBuf(%rip), %rsi
	movq	d_posBuf(%rip), %rdi
	call	_Z43__device_stub__Z17fillTempVelKernelPfS_S_S_PfS_S_S_
.L52:
	movl	28(%rsp), %ecx
	movq	20(%rsp), %rdx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	8(%rsp), %rdi
	movl	16(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L51
	movq	d_velBuf_temp(%rip), %rsi
	movq	d_velBuf(%rip), %rdi
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	jmp	_Z38__device_stub__Z16swapVelBufKernelPfS_PfS_
.L51:
	.cfi_restore_state
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2040:
	.size	_Z14updateVelocityv, .-_Z14updateVelocityv
	.globl	_Z42__device_stub__Z20updatePositionKernelPfS_PfS_
	.type	_Z42__device_stub__Z20updatePositionKernelPfS_PfS_, @function
_Z42__device_stub__Z20updatePositionKernelPfS_PfS_:
.LFB2075:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	32(%rsp), %rcx
	leaq	24(%rsp), %rdx
	movq	%rsi, (%rsp)
	leaq	40(%rsp), %rdi
	leaq	52(%rsp), %rsi
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 48(%rsp)
	movq	%rax, 88(%rsp)
	movq	%rsp, %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 40(%rsp)
	movq	%rax, 52(%rsp)
	movl	$1, 60(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L55
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z20updatePositionKernelPfS_(%rip), %rdi
	pushq	32(%rsp)
	.cfi_def_cfa_offset 144
	movq	68(%rsp), %rcx
	movl	76(%rsp), %r8d
	movq	56(%rsp), %rsi
	movl	64(%rsp), %edx
	leaq	104(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L55:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L57
	call	__stack_chk_fail@PLT
.L57:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2075:
	.size	_Z42__device_stub__Z20updatePositionKernelPfS_PfS_, .-_Z42__device_stub__Z20updatePositionKernelPfS_PfS_
	.globl	_Z20updatePositionKernelPfS_
	.type	_Z20updatePositionKernelPfS_, @function
_Z20updatePositionKernelPfS_:
.LFB2076:
	.cfi_startproc
	endbr64
	jmp	_Z42__device_stub__Z20updatePositionKernelPfS_PfS_
	.cfi_endproc
.LFE2076:
	.size	_Z20updatePositionKernelPfS_, .-_Z20updatePositionKernelPfS_
	.globl	_Z14updatePositionv
	.type	_Z14updatePositionv, @function
_Z14updatePositionv:
.LFB2043:
	.cfi_startproc
	endbr64
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movl	$768, %ecx
	xorl	%edx, %edx
	movl	$3, %esi
	movq	d_posBuf_size(%rip), %rax
	divq	%rcx
	xorl	%edx, %edx
	movq	%rax, %rcx
	movq	d_posBuf_size(%rip), %rax
	divq	%rsi
	movl	$16777217, %edx
	cmpb	$1, %al
	movabsq	$4294967297, %rax
	sbbl	$-1, %ecx
	movq	%rax, 12(%rsp)
	movl	16(%rsp), %esi
	xorl	%r9d, %r9d
	movl	%ecx, 8(%rsp)
	movq	8(%rsp), %rdi
	xorl	%r8d, %r8d
	salq	$8, %rdx
	movl	$1, %ecx
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L60
	movq	d_velBuf(%rip), %rsi
	movq	d_posBuf(%rip), %rdi
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	jmp	_Z42__device_stub__Z20updatePositionKernelPfS_PfS_
.L60:
	.cfi_restore_state
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2043:
	.size	_Z14updatePositionv, .-_Z14updatePositionv
	.section	.rodata.str1.1
.LC6:
	.string	"--- TICK ---\n"
	.text
	.globl	_Z4loopv
	.type	_Z4loopv, @function
_Z4loopv:
.LFB2045:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	call	_Z14updatePositionv
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	_Z14updateVelocityv
	.cfi_endproc
.LFE2045:
	.size	_Z4loopv, .-_Z4loopv
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2046:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$4096, %rsp
	.cfi_def_cfa_offset 4136
	orq	$0, (%rsp)
	subq	$4096, %rsp
	.cfi_def_cfa_offset 8232
	orq	$0, (%rsp)
	subq	$4096, %rsp
	.cfi_def_cfa_offset 12328
	orq	$0, (%rsp)
	subq	$536, %rsp
	.cfi_def_cfa_offset 12864
	xorl	%edx, %edx
	xorl	%ecx, %ecx
	movss	.LC7(%rip), %xmm2
	movss	.LC8(%rip), %xmm0
	movq	%fs:40, %rax
	movq	%rax, 12808(%rsp)
	xorl	%eax, %eax
	xorl	%eax, %eax
	movq	$1065353216, 6432(%rsp)
	movq	%rax, 6408(%rsp)
	movl	$1036831949, %eax
	salq	$32, %rax
	movq	%rdx, 6424(%rsp)
	leaq	6408(%rsp), %rdx
	movq	%rax, 6416(%rsp)
	movl	$2681250775, %eax
	movq	$1077936128, 6440(%rsp)
	addq	%rax, %rax
	movq	%rcx, 6448(%rsp)
	movq	%rcx, 6456(%rsp)
	movl	$2, %ecx
	movq	%rax, 6464(%rsp)
	movq	%rdx, %rax
.L69:
	leal	(%rcx,%rcx), %esi
	movl	%ecx, 92(%rax)
	incl	%ecx
	addq	$32, %rax
	cvtsi2ssl	%esi, %xmm1
	movss	%xmm2, 40(%rax)
	movss	%xmm0, 44(%rax)
	movss	%xmm0, 48(%rax)
	movl	$0x00000000, 52(%rax)
	movss	%xmm1, 32(%rax)
	movss	%xmm1, 36(%rax)
	movss	%xmm0, 56(%rax)
	cmpl	$200, %ecx
	jne	.L69
	leaq	1608(%rsp), %rcx
	leaq	6400(%rdx), %rsi
	movq	%rdx, %rax
	movq	%rcx, %rbx
.L70:
	movss	(%rax), %xmm0
	addq	$32, %rax
	addq	$12, %rcx
	movss	%xmm0, -12(%rcx)
	movss	-28(%rax), %xmm0
	movss	%xmm0, -8(%rcx)
	movss	-24(%rax), %xmm0
	movss	%xmm0, -4(%rcx)
	cmpq	%rsi, %rax
	jne	.L70
	leaq	4008(%rsp), %rcx
	movq	%rdx, %rax
	movq	%rcx, %rbp
.L71:
	movss	12(%rax), %xmm0
	addq	$32, %rax
	addq	$12, %rcx
	movss	%xmm0, -12(%rcx)
	movss	-16(%rax), %xmm0
	movss	%xmm0, -8(%rcx)
	movss	-12(%rax), %xmm0
	movss	%xmm0, -4(%rcx)
	cmpq	%rsi, %rax
	jne	.L71
	movq	%rdx, %rcx
	xorl	%eax, %eax
	leaq	8(%rsp), %r13
.L72:
	movss	24(%rcx), %xmm0
	addq	$32, %rcx
	movss	%xmm0, 0(%r13,%rax,4)
	incq	%rax
	cmpq	$200, %rax
	jne	.L72
	xorl	%eax, %eax
.L73:
	movl	28(%rdx), %ecx
	leaq	808(%rsp), %r12
	addq	$32, %rdx
	movl	%ecx, (%r12,%rax,4)
	incq	%rax
	cmpq	$200, %rax
	jne	.L73
	movl	$2400, %esi
	leaq	d_posBuf(%rip), %rdi
	movq	$2400, d_posBuf_size(%rip)
	movq	$2400, d_velBuf_size(%rip)
	movq	$800, d_radBuf_size(%rip)
	movq	$800, d_idBuf_size(%rip)
	call	cudaMalloc@PLT
	movq	d_velBuf_size(%rip), %rsi
	leaq	d_velBuf(%rip), %rdi
	call	cudaMalloc@PLT
	movq	d_radBuf_size(%rip), %rsi
	leaq	d_radBuf(%rip), %rdi
	call	cudaMalloc@PLT
	movq	d_idBuf_size(%rip), %rsi
	leaq	d_idBuf(%rip), %rdi
	call	cudaMalloc@PLT
	movq	d_velBuf_size(%rip), %rsi
	leaq	d_velBuf_temp(%rip), %rdi
	call	cudaMalloc@PLT
	movq	d_posBuf_size(%rip), %rdx
	movq	%rbx, %rsi
	movq	d_posBuf(%rip), %rdi
	movl	$1, %ecx
	movl	$100, %ebx
	call	cudaMemcpy@PLT
	movq	d_velBuf_size(%rip), %rdx
	movl	$1, %ecx
	movq	%rbp, %rsi
	movq	d_velBuf(%rip), %rdi
	call	cudaMemcpy@PLT
	movq	d_radBuf_size(%rip), %rdx
	movl	$1, %ecx
	movq	%r13, %rsi
	movq	d_radBuf(%rip), %rdi
	call	cudaMemcpy@PLT
	movq	d_idBuf_size(%rip), %rdx
	movl	$1, %ecx
	movq	%r12, %rsi
	movq	d_idBuf(%rip), %rdi
	call	cudaMemcpy@PLT
.L74:
	call	_Z4loopv
	decl	%ebx
	jne	.L74
	movq	d_posBuf(%rip), %rdi
	call	cudaFree@PLT
	movq	d_velBuf(%rip), %rdi
	call	cudaFree@PLT
	movq	d_radBuf(%rip), %rdi
	call	cudaFree@PLT
	movq	d_idBuf(%rip), %rdi
	call	cudaFree@PLT
	movq	d_velBuf_temp(%rip), %rdi
	call	cudaFree@PLT
	movq	12808(%rsp), %rax
	subq	%fs:40, %rax
	je	.L75
	call	__stack_chk_fail@PLT
.L75:
	addq	$12824, %rsp
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2046:
	.size	main, .-main
	.section	.rodata.str1.1
.LC9:
	.string	"_Z20updatePositionKernelPfS_"
.LC10:
	.string	"_Z17fillTempVelKernelPfS_S_S_"
.LC11:
	.string	"_Z16swapVelBufKernelPfS_"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2078:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC9(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z20updatePositionKernelPfS_(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC10(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z17fillTempVelKernelPfS_S_S_(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC11(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z16swapVelBufKernelPfS_(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2078:
	.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	d_idBuf_size
	.bss
	.align 8
	.type	d_idBuf_size, @object
	.size	d_idBuf_size, 8
d_idBuf_size:
	.zero	8
	.globl	d_radBuf_size
	.align 8
	.type	d_radBuf_size, @object
	.size	d_radBuf_size, 8
d_radBuf_size:
	.zero	8
	.globl	d_velBuf_size
	.align 8
	.type	d_velBuf_size, @object
	.size	d_velBuf_size, 8
d_velBuf_size:
	.zero	8
	.globl	d_posBuf_size
	.align 8
	.type	d_posBuf_size, @object
	.size	d_posBuf_size, 8
d_posBuf_size:
	.zero	8
	.globl	d_idBuf
	.align 8
	.type	d_idBuf, @object
	.size	d_idBuf, 8
d_idBuf:
	.zero	8
	.globl	d_velBuf_temp
	.align 8
	.type	d_velBuf_temp, @object
	.size	d_velBuf_temp, 8
d_velBuf_temp:
	.zero	8
	.globl	d_radBuf
	.align 8
	.type	d_radBuf, @object
	.size	d_radBuf, 8
d_radBuf:
	.zero	8
	.globl	d_velBuf
	.align 8
	.type	d_velBuf, @object
	.size	d_velBuf, 8
d_velBuf:
	.zero	8
	.globl	d_posBuf
	.align 8
	.type	d_posBuf, @object
	.size	d_posBuf, 8
d_posBuf:
	.zero	8
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC0:
	.long	0
	.long	1093567616
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC7:
	.long	1092616192
	.align 4
.LC8:
	.long	1065353216
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <hip/hip_runtime.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/time.h>
#include <time.h>

// #define NUM_SPHERES 2
#define NUM_SPHERES 200
// #define BLOCK_SIZE 1
#define BLOCK_SIZE 256

struct Sphere {
  float posX, posY, posZ;
  float velX, velY, velZ;
  float radius;
  unsigned id;
};

float *d_posBuf, *d_velBuf, *d_radBuf, *d_velBuf_temp;
unsigned *d_idBuf;
size_t d_posBuf_size, d_velBuf_size, d_radBuf_size, d_idBuf_size;

__global__ void swapVelBufKernel(float *d_velBuf, float *d_velBuf_temp) {
  unsigned index, i;

  index = threadIdx.x + blockDim.x * blockIdx.x;

  if(index < NUM_SPHERES) {
    for(i = 0; i < 3; i++) {
      d_velBuf[index * 3 + i] = d_velBuf_temp[index * 3 + i];
    }
  }
}

__global__ void fillTempVelKernel(float *d_posBuf, float *d_velBuf,
  float *d_radBuf, float *d_velBuf_temp) {
  __shared__ float posBufLocal[BLOCK_SIZE * 3];
  __shared__ float velBufLocal[BLOCK_SIZE * 3];
  __shared__ float radBufLocal[BLOCK_SIZE];
  unsigned i, j, k, index, otherIndex; // otherIndex = index of other sphere
  float pos[3], vel[3], outVel[3], rad, mass; // outVel = output velocity
  float otherPos[3], otherVel[3], otherRad, otherMass; // data of other sphere
  float delta[3]; // Used to compare distance between sphere centers
  float distanceSquared, radiusSumSquared;
  bool didImpact;

  index = threadIdx.x + blockDim.x * blockIdx.x;

  for(i = 0; i < 3; i++) {
    pos[i] = d_posBuf[index * 3 + i];
    vel[i] = d_velBuf[index * 3 + i];
    outVel[i] = 0;
  }

  rad = d_radBuf[index];
  mass = rad * rad * rad;  

  didImpact = false;

  for(i = 0; i < gridDim.x; i++) {
    // For each block, load posBufLocal and velBufLocal
    posBufLocal[threadIdx.x * 3 + 0] = d_posBuf[blockDim.x * 3 * i +
      threadIdx.x * 3 + 0];
    posBufLocal[threadIdx.x * 3 + 1] = d_posBuf[blockDim.x * 3 * i +
      threadIdx.x * 3 + 1];
    posBufLocal[threadIdx.x * 3 + 2] = d_posBuf[blockDim.x * 3 * i +
      threadIdx.x * 3 + 2];

    velBufLocal[threadIdx.x * 3 + 0] = d_velBuf[blockDim.x * 3 * i +
      threadIdx.x * 3 + 0];
    velBufLocal[threadIdx.x * 3 + 1] = d_velBuf[blockDim.x * 3 * i +
      threadIdx.x * 3 + 1];
    velBufLocal[threadIdx.x * 3 + 2] = d_velBuf[blockDim.x * 3 * i +
      threadIdx.x * 3 + 2];

    radBufLocal[threadIdx.x] = d_radBuf[blockDim.x * i + threadIdx.x];

    __syncthreads();

    // Now all of the local data is filled

    // Check against each sphere in local data
    for(j = 0; j < blockDim.x; j++) {
      otherIndex = j + blockDim.x * i; // j = threadIdx.x, i = blockIdx.x
      // Check if the sphere data is not garbage data or the same data
      if((otherIndex < NUM_SPHERES) && (otherIndex != index)) {
        // Fill data of other sphere
        for(k = 0; k < 3; k++) {
          otherPos[k] = posBufLocal[j * 3 + k];
          otherVel[k] = velBufLocal[j * 3 + k];
        }

        otherRad = radBufLocal[j];

        // Check to see if they collide
      
        // Get difference in x, y, and z (0, 1, 2) for indexes
        for(k = 0; k < 3; k++) {
          delta[k] = pos[k] - otherPos[k];
        }

        // Calculate distanceSquared and radiusSumSquared
        distanceSquared = 0;
        radiusSumSquared = 0;

        for(k = 0; k < 3; k++) {
          distanceSquared = distanceSquared + delta[k] * delta[k];
        }
      
        radiusSumSquared = (rad + otherRad) * (rad + otherRad);

        if(distanceSquared < radiusSumSquared) {
          // We collide
          didImpact = true;

          // Calculate the mass of the other sphere
          otherMass = otherRad * otherRad * otherRad;

          for(k = 0; k < 3; k++) {
            outVel[k] = outVel[k] +
              (mass - otherMass) / (mass + otherMass) * vel[k] +
              (2 * otherMass) / (mass + otherMass) * otherVel[k];
          }
        }
      }
    }
    
    __syncthreads();
    // Now that all threads in this block have processed the local data
    // We can now move to the next set of local data
  }

  // Put the new velocity in outVel into the velocity buffer
  if(!didImpact) {
    // If the object did not impact with anything, continue with current
    // velocity
    for(i = 0; i < 3; i++) {
      outVel[i] = vel[i];
    }
  }

  for(i = 0; i < 3; i++) {
    d_velBuf_temp[index * 3 + i] = outVel[i];
  }
}

void updateVelocity() {
  unsigned numBlocks;

  numBlocks = NUM_SPHERES / BLOCK_SIZE;
  if(NUM_SPHERES % BLOCK_SIZE) numBlocks++; 

  dim3 dimGrid(numBlocks, 1, 1);
  dim3 dimBlock(BLOCK_SIZE, 1, 1);

  // Fill the temporary velocity buffer
  fillTempVelKernel<<<dimGrid, dimBlock>>>(d_posBuf, d_velBuf, d_radBuf,
    d_velBuf_temp);
  // Copy from the temporary buffer to the real buffer
  swapVelBufKernel<<<dimGrid, dimBlock>>>(d_velBuf, d_velBuf_temp);
}

double time_diff(struct timeval x, struct timeval y) {
  double x_ms, y_ms, diff;

  x_ms = (double) x.tv_sec * 1000000 + (double) x.tv_usec;
  y_ms = (double) y.tv_sec * 1000000 + (double) y.tv_usec;

  diff = (double) y_ms - (double) x_ms;

  return diff;
}

void updateVelocitySerial() {
  float posBuf[NUM_SPHERES * 3];
  float velBuf[NUM_SPHERES * 3];
  float temp_velBuf[NUM_SPHERES * 3];
  float radBuf[NUM_SPHERES];
  struct Sphere s1, s2;
  unsigned i, j, k;
  float delta[3];
  float distanceSquared, radiusSumSquared;
  float s1Mass, s2Mass;
  float outVel[3];
  bool didImpact;
  struct timeval before, after;

  for(i = 0; i < 3; i++) {
    outVel[i] = 0;
  }

  // Get the buffers from the GPU
  hipMemcpy(posBuf, d_posBuf, d_posBuf_size, hipMemcpyDeviceToHost);
  hipMemcpy(velBuf, d_velBuf, d_velBuf_size, hipMemcpyDeviceToHost);
  hipMemcpy(radBuf, d_radBuf, d_radBuf_size, hipMemcpyDeviceToHost);

  gettimeofday(&before, NULL);

  for(i = 0; i < NUM_SPHERES; i++) {
    didImpact = false;

    outVel[0] = 0;
    outVel[1] = 0;
    outVel[2] = 0;

    s1.posX = posBuf[i * 3 + 0];
    s1.posY = posBuf[i * 3 + 1];
    s1.posZ = posBuf[i * 3 + 2];

    s1.velX = velBuf[i * 3 + 0];
    s1.velY = velBuf[i * 3 + 1];
    s1.velZ = velBuf[i * 3 + 2];

    s1.radius = radBuf[i];

    s1Mass = s1.radius * s1.radius * s1.radius;

    for(j = 0; j < NUM_SPHERES; j++) {
      if(j == i) {
        continue;
      }

      s2.posX = posBuf[j * 3 + 0];
      s2.posY = posBuf[j * 3 + 1];
      s2.posZ = posBuf[j * 3 + 2];
      
      s2.velX = velBuf[j * 3 + 0];
      s2.velY = velBuf[j * 3 + 1];
      s2.velZ = velBuf[j * 3 + 2];

      s2.radius = radBuf[j];

      delta[0] = s1.posX - s2.posX;
      delta[1] = s1.posY - s2.posY;
      delta[2] = s1.posZ - s2.posZ;

      distanceSquared = 0;
      radiusSumSquared = 0;

      for(k = 0; k < 3; k++) {
        distanceSquared = distanceSquared + delta[k] * delta[k];
      }

      radiusSumSquared = (s1.radius + s2.radius) * (s1.radius + s2.radius);

      if(distanceSquared < radiusSumSquared) {
        // We collide
        didImpact = true;

        s2Mass = s2.radius * s2.radius * s2.radius;

        outVel[0] = outVel[0] +
          (s1Mass - s2Mass) / (s1Mass + s2Mass) * s1.velX +
          (2 * s2Mass) / (s1Mass + s2Mass) * s2.velX;
        outVel[1] = outVel[1] +
          (s1Mass - s2Mass) / (s1Mass + s2Mass) * s1.velY +
          (2 * s2Mass) / (s1Mass + s2Mass) * s2.velY;
        outVel[2] = outVel[2] +
          (s1Mass - s2Mass) / (s1Mass + s2Mass) * s1.velZ +
          (2 * s2Mass) / (s1Mass + s2Mass) * s2.velZ;
      }
    }
    if(!didImpact) {
      for(k = 0; k < 3; k++) {
        outVel[k] = velBuf[i * 3 + k];
      }
    }

    for(k = 0; k < 3; k++) {
      temp_velBuf[i * 3 + k] = outVel[k];
    }

    didImpact = false;
  }

  gettimeofday(&after, NULL);

  printf("Total time elapsed: %.01f us\n", time_diff(before, after));

  // Copy temp_velBuf into GPU
  hipMemcpy(d_velBuf, temp_velBuf, d_velBuf_size, hipMemcpyHostToDevice);
}

__global__ void updatePositionKernel(float *d_posBuf, float *d_velBuf) {
  unsigned index, i;

  index = threadIdx.x + blockDim.x * blockIdx.x;

  // Each thread updates its portion
  if(index < NUM_SPHERES) {
    for(i = 0; i < 3; i++) {
      // d_posBuf[index * 3 + i] += d_velBuf[index * 3 + i];
      d_posBuf[index * 3 + i] += d_velBuf[index * 3 + i];;
    }
  }
}

void updatePosition() {
  unsigned numBlocks;

  numBlocks = (d_posBuf_size / 3) / BLOCK_SIZE;
  if((d_posBuf_size / 3) % BLOCK_SIZE) numBlocks++;

  dim3 dimGrid(numBlocks, 1, 1);
  dim3 dimBlock(BLOCK_SIZE, 1, 1);

  // Kernel
  updatePositionKernel<<<dimGrid, dimBlock>>>(d_posBuf, d_velBuf);
}

void printPosition() {
  float temp_posBuf[d_posBuf_size];
  float temp_velBuf[d_velBuf_size];
  unsigned temp_idBuf[d_idBuf_size];
  unsigned i;

  // Copy from GPU to CPU
  hipMemcpy(temp_posBuf, d_posBuf, d_posBuf_size, hipMemcpyDeviceToHost);
  hipMemcpy(temp_velBuf, d_velBuf, d_velBuf_size, hipMemcpyDeviceToHost);
  hipMemcpy(temp_idBuf, d_idBuf, d_idBuf_size, hipMemcpyDeviceToHost);

  for(i = 0; i < NUM_SPHERES; i++) {
    printf("sphere %u\n", temp_idBuf[i]);
    printf("  pos: %f %f %f\n", temp_posBuf[i * 3 + 0], temp_posBuf[i * 3 + 1],
      temp_posBuf[i * 3 + 2]);
    printf("  vel: %f %f %f\n", temp_velBuf[i * 3 + 0], temp_velBuf[i * 3 + 1],
      temp_velBuf[i * 3 + 2]);
  }
}

void loop() {
  printf("--- TICK ---\n");
  updatePosition();
  updateVelocity();
  // updateVelocitySerial();
  // printPosition();
  // sleep(1);
}

int main() {
  // Initialize the object data
  struct Sphere spheres[NUM_SPHERES];
  unsigned i;  

  // Uncomment any of the test cases

  // Test case: Different velocities -----
  // UNCOMMENT START
  /* // First sphere
  spheres[0].posX = 0;
  spheres[0].posY = 0;
  spheres[0].posZ = 0;

  spheres[0].velX = 0.2;
  spheres[0].velY = 0;
  spheres[0].velZ = 0;

  spheres[0].radius = 1;

  spheres[0].id = 0;
  
  // Second sphere
  spheres[1].posX = 3;
  spheres[1].posY = 0;
  spheres[1].posZ = 0;
  
  spheres[1].velX = 0.1;
  spheres[1].velY = 0;
  spheres[1].velZ = 0;

  spheres[1].radius = 1;

  spheres[1].id = 1; */
  // UNCOMMENT END

  // Test case: Different directions -----
  // UNCOMMENT START
  /* // First sphere
  spheres[0].posX = 0;
  spheres[0].posY = 0;
  spheres[0].posZ = 0;

  spheres[0].velX = .1;
  spheres[0].velY = 0;
  spheres[0].velZ = 0;

  spheres[0].radius = 1;
 
  spheres[0].id = 0;

  // Second sphere
  spheres[1].posX = 2;
  spheres[1].posY = 4;
  spheres[1].posZ = 0;

  spheres[1].velX = 0;
  spheres[1].velY = -.1;
  spheres[1].velZ = 0;

  spheres[1].radius = 1;

  spheres[1].id = 1; */
  // UNCOMMENT END

  // Test case: Different masses -----
  // UNCOMMENT START
  // First sphere
  spheres[0].posX = 0;
  spheres[0].posY = 0;
  spheres[0].posZ = 0;
  
  spheres[0].velX = .1;
  spheres[0].velY = 0;
  spheres[0].velZ = 0;

  spheres[0].radius = 1;
  
  spheres[0].id = 0;

  // Second sphere
  spheres[1].posX = 3;
  spheres[1].posY = 0;
  spheres[1].posZ = 0;

  spheres[1].velX = 0;
  spheres[1].velY = 0;
  spheres[1].velZ = 0;

  spheres[1].radius = 1.26;

  spheres[1].id = 1;
  // UNCOMMENT END

  for(i = 2; i < 200; i++) {
    spheres[i].posX = i * 2;
    spheres[i].posY = i * 2;
    spheres[i].posZ = 10;

    spheres[i].velX = 1;
    spheres[i].velY = 1;
    spheres[i].velZ = 0;
    
    spheres[i].radius = 1;
    
    spheres[i].id = i;
  }

  // Create the position buffer
  float posBuf[NUM_SPHERES * 3];
  // Create the velocity buffer
  float velBuf[NUM_SPHERES * 3];
  // Create the radius buffer
  float radBuf[NUM_SPHERES];
  // Create the ID buffer
  unsigned idBuf[NUM_SPHERES];

  // Fill posradBuf
  for(i = 0; i < NUM_SPHERES; i++) {
    posBuf[i * 3 + 0] = spheres[i].posX;
    posBuf[i * 3 + 1] = spheres[i].posY;
    posBuf[i * 3 + 2] = spheres[i].posZ;
  }

  // Fill velocity buffer
  for(i = 0; i < NUM_SPHERES; i++) {
    velBuf[i * 3 + 0] = spheres[i].velX;
    velBuf[i * 3 + 1] = spheres[i].velY;
    velBuf[i * 3 + 2] = spheres[i].velZ;
  }

  // Fill radius buffer
  for(i = 0; i < NUM_SPHERES; i++) {
    radBuf[i] = spheres[i].radius;
  }

  // Fill id buffer
  for(i = 0; i < NUM_SPHERES; i++) {
    idBuf[i] = spheres[i].id;
  }

  // Allocate space on the GPU for storing these buffers
  d_posBuf_size = sizeof(float) * NUM_SPHERES * 3;
  d_velBuf_size = sizeof(float) * NUM_SPHERES * 3;
  d_radBuf_size = sizeof(float) * NUM_SPHERES;
  d_idBuf_size = sizeof(unsigned) * NUM_SPHERES;

  hipMalloc((void **) &d_posBuf, d_posBuf_size);
  hipMalloc((void **) &d_velBuf, d_velBuf_size);
  hipMalloc((void **) &d_radBuf, d_radBuf_size);
  hipMalloc((void **) &d_idBuf, d_idBuf_size);
  hipMalloc((void **) &d_velBuf_temp, d_velBuf_size);

  // Copy into GPU
  hipMemcpy(d_posBuf, posBuf, d_posBuf_size, hipMemcpyHostToDevice);
  hipMemcpy(d_velBuf, velBuf, d_velBuf_size, hipMemcpyHostToDevice);
  hipMemcpy(d_radBuf, radBuf, d_radBuf_size, hipMemcpyHostToDevice);
  hipMemcpy(d_idBuf, idBuf, d_idBuf_size, hipMemcpyHostToDevice);

  /* while(true) {
    loop();
  } */

  for(i = 0; i < 100; i++) {
    loop();
  }

  hipFree(d_posBuf);
  hipFree(d_velBuf);
  hipFree(d_radBuf);
  hipFree(d_idBuf);
  hipFree(d_velBuf_temp);

  return 0;
}


	.text
	.file	"main.hip"
	.globl	_Z31__device_stub__swapVelBufKernelPfS_ # -- Begin function _Z31__device_stub__swapVelBufKernelPfS_
	.type	_Z31__device_stub__swapVelBufKernelPfS_,@function
_Z31__device_stub__swapVelBufKernelPfS_: # @_Z31__device_stub__swapVelBufKernelPfS_
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$80, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	16(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%rsp, %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z16swapVelBufKernelPfS_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z31__device_stub__swapVelBufKernelPfS_, .Lfunc_end0-_Z31__device_stub__swapVelBufKernelPfS_
	.cfi_endproc
                                        # -- End function
	.globl	_Z32__device_stub__fillTempVelKernelPfS_S_S_ # -- Begin function _Z32__device_stub__fillTempVelKernelPfS_S_S_
	.type	_Z32__device_stub__fillTempVelKernelPfS_S_S_,@function
_Z32__device_stub__fillTempVelKernelPfS_S_S_: # @_Z32__device_stub__fillTempVelKernelPfS_S_S_
	.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	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	24(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	16(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%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	$_Z17fillTempVelKernelPfS_S_S_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z32__device_stub__fillTempVelKernelPfS_S_S_, .Lfunc_end1-_Z32__device_stub__fillTempVelKernelPfS_S_S_
	.cfi_endproc
                                        # -- End function
	.globl	_Z14updateVelocityv             # -- Begin function _Z14updateVelocityv
	.type	_Z14updateVelocityv,@function
_Z14updateVelocityv:                    # @_Z14updateVelocityv
	.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
	movabsq	$4294967297, %r14               # imm = 0x100000001
	leaq	255(%r14), %rbx
	movq	%r14, %rdi
	movl	$1, %esi
	movq	%rbx, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB2_2
# %bb.1:
	movq	d_posBuf(%rip), %rdi
	movq	d_velBuf(%rip), %rsi
	movq	d_radBuf(%rip), %rdx
	movq	d_velBuf_temp(%rip), %rcx
	callq	_Z32__device_stub__fillTempVelKernelPfS_S_S_
.LBB2_2:
	movq	%r14, %rdi
	movl	$1, %esi
	movq	%rbx, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	je	.LBB2_4
# %bb.3:
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.LBB2_4:
	.cfi_def_cfa_offset 32
	movq	d_velBuf(%rip), %rdi
	movq	d_velBuf_temp(%rip), %rsi
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	jmp	_Z31__device_stub__swapVelBufKernelPfS_ # TAILCALL
.Lfunc_end2:
	.size	_Z14updateVelocityv, .Lfunc_end2-_Z14updateVelocityv
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z9time_diff7timevalS_
.LCPI3_0:
	.quad	0x412e848000000000              # double 1.0E+6
	.text
	.globl	_Z9time_diff7timevalS_
	.type	_Z9time_diff7timevalS_,@function
_Z9time_diff7timevalS_:                 # @_Z9time_diff7timevalS_
	.cfi_startproc
# %bb.0:
	cvtsi2sd	%rdi, %xmm0
	movsd	.LCPI3_0(%rip), %xmm1           # xmm1 = mem[0],zero
	mulsd	%xmm1, %xmm0
	cvtsi2sd	%rsi, %xmm2
	addsd	%xmm0, %xmm2
	cvtsi2sd	%rdx, %xmm3
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rcx, %xmm0
	mulsd	%xmm1, %xmm3
	addsd	%xmm3, %xmm0
	subsd	%xmm2, %xmm0
	retq
.Lfunc_end3:
	.size	_Z9time_diff7timevalS_, .Lfunc_end3-_Z9time_diff7timevalS_
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z20updateVelocitySerialv
.LCPI4_0:
	.quad	0x412e848000000000              # double 1.0E+6
	.text
	.globl	_Z20updateVelocitySerialv
	.type	_Z20updateVelocitySerialv,@function
_Z20updateVelocitySerialv:              # @_Z20updateVelocitySerialv
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$8064, %rsp                     # imm = 0x1F80
	.cfi_def_cfa_offset 8080
	.cfi_offset %rbx, -16
	movq	d_posBuf(%rip), %rsi
	movq	d_posBuf_size(%rip), %rdx
	leaq	3264(%rsp), %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movq	d_velBuf(%rip), %rsi
	movq	d_velBuf_size(%rip), %rdx
	leaq	864(%rsp), %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movq	d_radBuf(%rip), %rsi
	movq	d_radBuf_size(%rip), %rdx
	leaq	64(%rsp), %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	xorl	%ebx, %ebx
	leaq	32(%rsp), %rdi
	xorl	%esi, %esi
	callq	gettimeofday
.LBB4_1:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_2 Depth 2
                                        #       Child Loop BB4_4 Depth 3
	leaq	(,%rbx,4), %rax
	leaq	(%rax,%rax,2), %rax
	movss	3264(%rsp,%rax), %xmm3          # xmm3 = mem[0],zero,zero,zero
	movss	3268(%rsp,%rax), %xmm4          # xmm4 = mem[0],zero,zero,zero
	movss	3272(%rsp,%rax), %xmm5          # xmm5 = mem[0],zero,zero,zero
	movss	864(%rsp,%rax), %xmm0           # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, 16(%rsp)                 # 4-byte Spill
	movss	868(%rsp,%rax), %xmm0           # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, 12(%rsp)                 # 4-byte Spill
	movss	872(%rsp,%rax), %xmm2           # xmm2 = mem[0],zero,zero,zero
	movss	64(%rsp,%rbx,4), %xmm6          # xmm6 = mem[0],zero,zero,zero
	movaps	%xmm6, %xmm7
	mulss	%xmm6, %xmm7
	mulss	%xmm6, %xmm7
	xorps	%xmm10, %xmm10
	xorl	%ecx, %ecx
	xorl	%edx, %edx
	xorps	%xmm9, %xmm9
	xorps	%xmm8, %xmm8
.LBB4_2:                                #   Parent Loop BB4_1 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB4_4 Depth 3
	cmpq	%rbx, %rcx
	je	.LBB4_7
# %bb.3:                                #   in Loop: Header=BB4_2 Depth=2
	leaq	(,%rcx,4), %rsi
	leaq	(%rsi,%rsi,2), %rsi
	movss	864(%rsp,%rsi), %xmm11          # xmm11 = mem[0],zero,zero,zero
	movss	868(%rsp,%rsi), %xmm12          # xmm12 = mem[0],zero,zero,zero
	movss	872(%rsp,%rsi), %xmm13          # xmm13 = mem[0],zero,zero,zero
	movaps	%xmm3, %xmm14
	subss	3264(%rsp,%rsi), %xmm14
	movss	%xmm14, 20(%rsp)
	movaps	%xmm4, %xmm14
	subss	3268(%rsp,%rsi), %xmm14
	movss	%xmm14, 24(%rsp)
	movaps	%xmm5, %xmm14
	subss	3272(%rsp,%rsi), %xmm14
	movss	64(%rsp,%rcx,4), %xmm15         # xmm15 = mem[0],zero,zero,zero
	movss	%xmm14, 28(%rsp)
	xorps	%xmm14, %xmm14
	xorl	%esi, %esi
.LBB4_4:                                #   Parent Loop BB4_1 Depth=1
                                        #     Parent Loop BB4_2 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movss	20(%rsp,%rsi,4), %xmm0          # xmm0 = mem[0],zero,zero,zero
	mulss	%xmm0, %xmm0
	addss	%xmm0, %xmm14
	incq	%rsi
	cmpq	$3, %rsi
	jne	.LBB4_4
# %bb.5:                                #   in Loop: Header=BB4_2 Depth=2
	movaps	%xmm6, %xmm0
	addss	%xmm15, %xmm0
	mulss	%xmm0, %xmm0
	ucomiss	%xmm14, %xmm0
	jbe	.LBB4_7
# %bb.6:                                #   in Loop: Header=BB4_2 Depth=2
	movaps	%xmm15, %xmm14
	mulss	%xmm15, %xmm14
	mulss	%xmm15, %xmm14
	movaps	%xmm7, %xmm15
	subss	%xmm14, %xmm15
	movaps	%xmm7, %xmm0
	addss	%xmm14, %xmm0
	divss	%xmm0, %xmm15
	movss	16(%rsp), %xmm1                 # 4-byte Reload
                                        # xmm1 = mem[0],zero,zero,zero
	mulss	%xmm15, %xmm1
	addss	%xmm10, %xmm1
	addss	%xmm14, %xmm14
	divss	%xmm0, %xmm14
	mulss	%xmm14, %xmm11
	addss	%xmm1, %xmm11
	movss	12(%rsp), %xmm0                 # 4-byte Reload
                                        # xmm0 = mem[0],zero,zero,zero
	mulss	%xmm15, %xmm0
	addss	%xmm9, %xmm0
	mulss	%xmm14, %xmm12
	addss	%xmm0, %xmm12
	mulss	%xmm2, %xmm15
	addss	%xmm8, %xmm15
	mulss	%xmm14, %xmm13
	addss	%xmm15, %xmm13
	movb	$1, %dl
	movaps	%xmm13, %xmm8
	movaps	%xmm12, %xmm9
	movaps	%xmm11, %xmm10
.LBB4_7:                                #   in Loop: Header=BB4_2 Depth=2
	incq	%rcx
	cmpq	$200, %rcx
	jne	.LBB4_2
# %bb.8:                                # %.loopexit
                                        #   in Loop: Header=BB4_1 Depth=1
	testb	$1, %dl
	je	.LBB4_10
# %bb.9:                                # %.loopexit
                                        #   in Loop: Header=BB4_1 Depth=1
	movss	%xmm10, 16(%rsp)                # 4-byte Spill
	movss	%xmm9, 12(%rsp)                 # 4-byte Spill
	movaps	%xmm8, %xmm2
.LBB4_10:                               # %.loopexit
                                        #   in Loop: Header=BB4_1 Depth=1
	movss	16(%rsp), %xmm0                 # 4-byte Reload
                                        # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, 5664(%rsp,%rax)
	movss	12(%rsp), %xmm0                 # 4-byte Reload
                                        # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, 5668(%rsp,%rax)
	movss	%xmm2, 5672(%rsp,%rax)
	incq	%rbx
	cmpq	$200, %rbx
	jne	.LBB4_1
# %bb.11:
	leaq	48(%rsp), %rbx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm0, %xmm0
	cvtsi2sdq	32(%rsp), %xmm0
	movsd	.LCPI4_0(%rip), %xmm1           # xmm1 = mem[0],zero
	mulsd	%xmm1, %xmm0
	xorps	%xmm2, %xmm2
	cvtsi2sdq	40(%rsp), %xmm2
	addsd	%xmm0, %xmm2
	xorps	%xmm3, %xmm3
	cvtsi2sdq	(%rbx), %xmm3
	mulsd	%xmm1, %xmm3
	xorps	%xmm0, %xmm0
	cvtsi2sdq	8(%rbx), %xmm0
	addsd	%xmm3, %xmm0
	subsd	%xmm2, %xmm0
	movl	$.L.str, %edi
	movb	$1, %al
	callq	printf
	movq	d_velBuf(%rip), %rdi
	movq	d_velBuf_size(%rip), %rdx
	leaq	5664(%rsp), %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	addq	$8064, %rsp                     # imm = 0x1F80
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end4:
	.size	_Z20updateVelocitySerialv, .Lfunc_end4-_Z20updateVelocitySerialv
	.cfi_endproc
                                        # -- End function
	.globl	_Z35__device_stub__updatePositionKernelPfS_ # -- Begin function _Z35__device_stub__updatePositionKernelPfS_
	.type	_Z35__device_stub__updatePositionKernelPfS_,@function
_Z35__device_stub__updatePositionKernelPfS_: # @_Z35__device_stub__updatePositionKernelPfS_
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$80, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	16(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%rsp, %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z20updatePositionKernelPfS_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end5:
	.size	_Z35__device_stub__updatePositionKernelPfS_, .Lfunc_end5-_Z35__device_stub__updatePositionKernelPfS_
	.cfi_endproc
                                        # -- End function
	.globl	_Z14updatePositionv             # -- Begin function _Z14updatePositionv
	.type	_Z14updatePositionv,@function
_Z14updatePositionv:                    # @_Z14updatePositionv
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movabsq	$-6148914691236517205, %rax     # imm = 0xAAAAAAAAAAAAAAAB
	mulq	d_posBuf_size(%rip)
	movq	%rdx, %rdi
	movl	%edi, %eax
	shrl	%eax
	shrq	$9, %rdi
	cmpb	$1, %al
	sbbl	$-1, %edi
	btsq	$32, %rdi
	movabsq	$4294967296, %rdx               # imm = 0x100000000
	orq	$256, %rdx                      # imm = 0x100
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	je	.LBB6_2
# %bb.1:
	popq	%rax
	.cfi_def_cfa_offset 8
	retq
.LBB6_2:
	.cfi_def_cfa_offset 16
	movq	d_posBuf(%rip), %rdi
	movq	d_velBuf(%rip), %rsi
	popq	%rax
	.cfi_def_cfa_offset 8
	jmp	_Z35__device_stub__updatePositionKernelPfS_ # TAILCALL
.Lfunc_end6:
	.size	_Z14updatePositionv, .Lfunc_end6-_Z14updatePositionv
	.cfi_endproc
                                        # -- End function
	.globl	_Z13printPositionv              # -- Begin function _Z13printPositionv
	.type	_Z13printPositionv,@function
_Z13printPositionv:                     # @_Z13printPositionv
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%r15
	pushq	%r14
	pushq	%r12
	pushq	%rbx
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	d_posBuf_size(%rip), %rdx
	movq	%rsp, %rbx
	leaq	15(,%rdx,4), %rax
	andq	$-16, %rax
	subq	%rax, %rbx
	movq	%rbx, %rsp
	movq	d_velBuf_size(%rip), %rax
	movq	%rsp, %r14
	leaq	15(,%rax,4), %rax
	andq	$-16, %rax
	subq	%rax, %r14
	movq	%r14, %rsp
	movq	d_idBuf_size(%rip), %rax
	movq	%rsp, %r15
	leaq	15(,%rax,4), %rax
	andq	$-16, %rax
	subq	%rax, %r15
	movq	%r15, %rsp
	movq	d_posBuf(%rip), %rsi
	movq	%rbx, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movq	d_velBuf(%rip), %rsi
	movq	d_velBuf_size(%rip), %rdx
	movq	%r14, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movq	d_idBuf(%rip), %rsi
	movq	d_idBuf_size(%rip), %rdx
	movq	%r15, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movl	$2, %r12d
.LBB7_1:                                # =>This Inner Loop Header: Depth=1
	movl	(%r15), %esi
	movl	$.L.str.1, %edi
	xorl	%eax, %eax
	callq	printf
	xorps	%xmm0, %xmm0
	cvtss2sd	-8(%rbx,%r12,4), %xmm0
	xorps	%xmm1, %xmm1
	cvtss2sd	-4(%rbx,%r12,4), %xmm1
	xorps	%xmm2, %xmm2
	cvtss2sd	(%rbx,%r12,4), %xmm2
	movl	$.L.str.2, %edi
	movb	$3, %al
	callq	printf
	xorps	%xmm0, %xmm0
	cvtss2sd	-8(%r14,%r12,4), %xmm0
	xorps	%xmm1, %xmm1
	cvtss2sd	-4(%r14,%r12,4), %xmm1
	xorps	%xmm2, %xmm2
	cvtss2sd	(%r14,%r12,4), %xmm2
	movl	$.L.str.3, %edi
	movb	$3, %al
	callq	printf
	addq	$3, %r12
	addq	$4, %r15
	cmpq	$602, %r12                      # imm = 0x25A
	jne	.LBB7_1
# %bb.2:
	leaq	-32(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa %rsp, 8
	retq
.Lfunc_end7:
	.size	_Z13printPositionv, .Lfunc_end7-_Z13printPositionv
	.cfi_endproc
                                        # -- End function
	.globl	_Z4loopv                        # -- Begin function _Z4loopv
	.type	_Z4loopv,@function
_Z4loopv:                               # @_Z4loopv
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movl	$.Lstr, %edi
	callq	puts@PLT
	callq	_Z14updatePositionv
	popq	%rax
	.cfi_def_cfa_offset 8
	jmp	_Z14updateVelocityv             # TAILCALL
.Lfunc_end8:
	.size	_Z4loopv, .Lfunc_end8-_Z4loopv
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function main
.LCPI9_0:
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	1036831949                      # 0x3dcccccd
.LCPI9_1:
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	1065353216                      # 0x3f800000
	.long	0                               # 0x0
.LCPI9_2:
	.long	0x41200000                      # float 10
	.long	0x3f800000                      # float 1
	.long	0x3f800000                      # float 1
	.long	0x00000000                      # float 0
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$12800, %rsp                    # imm = 0x3200
	.cfi_def_cfa_offset 12816
	.cfi_offset %rbx, -16
	movaps	.LCPI9_0(%rip), %xmm0           # xmm0 = [0,0,0,1036831949]
	movaps	%xmm0, 1600(%rsp)
	movaps	.LCPI9_1(%rip), %xmm0           # xmm0 = [0,0,1065353216,0]
	movaps	%xmm0, 1616(%rsp)
	movl	$1077936128, 1632(%rsp)         # imm = 0x40400000
	xorps	%xmm0, %xmm0
	movups	%xmm0, 1636(%rsp)
	movl	$0, 1652(%rsp)
	movabsq	$5362501550, %rax               # imm = 0x13FA147AE
	movq	%rax, 1656(%rsp)
	movl	$4, %eax
	movl	$2, %ecx
	movl	$46, %edx
	movaps	.LCPI9_2(%rip), %xmm0           # xmm0 = [1.0E+1,1.0E+0,1.0E+0,0.0E+0]
.LBB9_1:                                # =>This Inner Loop Header: Depth=1
	movl	%eax, %esi
	xorps	%xmm1, %xmm1
	cvtsi2ss	%rsi, %xmm1
	movss	%xmm1, 1572(%rsp,%rdx,2)
	movss	%xmm1, 1576(%rsp,%rdx,2)
	movups	%xmm0, 1580(%rsp,%rdx,2)
	movl	$1065353216, 1596(%rsp,%rdx,2)  # imm = 0x3F800000
	movl	%ecx, 1600(%rsp,%rdx,2)
	addl	$2, %eax
	incl	%ecx
	addq	$16, %rdx
	cmpq	$3214, %rdx                     # imm = 0xC8E
	jne	.LBB9_1
# %bb.2:
	movl	$8, %eax
	leaq	1608(%rsp), %rcx
.LBB9_3:                                # =>This Inner Loop Header: Depth=1
	movss	-8(%rcx), %xmm0                 # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, 10392(%rsp,%rax)
	movss	-4(%rcx), %xmm0                 # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, 10396(%rsp,%rax)
	movss	(%rcx), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, 10400(%rsp,%rax)
	addq	$12, %rax
	addq	$32, %rcx
	cmpq	$2408, %rax                     # imm = 0x968
	jne	.LBB9_3
# %bb.4:                                # %.preheader40.preheader
	movl	$8, %eax
	leaq	1620(%rsp), %rcx
.LBB9_5:                                # %.preheader40
                                        # =>This Inner Loop Header: Depth=1
	movss	-8(%rcx), %xmm0                 # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, 7992(%rsp,%rax)
	movss	-4(%rcx), %xmm0                 # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, 7996(%rsp,%rax)
	movss	(%rcx), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, 8000(%rsp,%rax)
	addq	$12, %rax
	addq	$32, %rcx
	cmpq	$2408, %rax                     # imm = 0x968
	jne	.LBB9_5
# %bb.6:                                # %.preheader39.preheader
	movl	$3, %eax
.LBB9_7:                                # %.preheader39
                                        # =>This Inner Loop Header: Depth=1
	movss	1600(%rsp,%rax,8), %xmm0        # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, 797(%rsp,%rax)
	addq	$4, %rax
	cmpq	$803, %rax                      # imm = 0x323
	jne	.LBB9_7
# %bb.8:                                # %.preheader.preheader
	xorl	%eax, %eax
.LBB9_9:                                # %.preheader
                                        # =>This Inner Loop Header: Depth=1
	movl	1628(%rsp,%rax,8), %ecx
	movl	%ecx, (%rsp,%rax)
	addq	$4, %rax
	cmpq	$800, %rax                      # imm = 0x320
	jne	.LBB9_9
# %bb.10:
	movl	$2400, %eax                     # imm = 0x960
	movq	%rax, d_posBuf_size(%rip)
	movq	%rax, d_velBuf_size(%rip)
	movl	$800, %eax                      # imm = 0x320
	movq	%rax, d_radBuf_size(%rip)
	movq	%rax, d_idBuf_size(%rip)
	movl	$d_posBuf, %edi
	movl	$2400, %esi                     # imm = 0x960
	callq	hipMalloc
	movq	d_velBuf_size(%rip), %rsi
	movl	$d_velBuf, %edi
	callq	hipMalloc
	movq	d_radBuf_size(%rip), %rsi
	movl	$d_radBuf, %edi
	callq	hipMalloc
	movq	d_idBuf_size(%rip), %rsi
	movl	$d_idBuf, %edi
	callq	hipMalloc
	movq	d_velBuf_size(%rip), %rsi
	movl	$d_velBuf_temp, %edi
	callq	hipMalloc
	movq	d_posBuf(%rip), %rdi
	movq	d_posBuf_size(%rip), %rdx
	leaq	10400(%rsp), %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	d_velBuf(%rip), %rdi
	movq	d_velBuf_size(%rip), %rdx
	leaq	8000(%rsp), %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	d_radBuf(%rip), %rdi
	movq	d_radBuf_size(%rip), %rdx
	leaq	800(%rsp), %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	d_idBuf(%rip), %rdi
	movq	d_idBuf_size(%rip), %rdx
	movq	%rsp, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movl	$100, %ebx
.LBB9_11:                               # =>This Inner Loop Header: Depth=1
	movl	$.Lstr, %edi
	callq	puts@PLT
	callq	_Z14updatePositionv
	callq	_Z14updateVelocityv
	decl	%ebx
	jne	.LBB9_11
# %bb.12:
	movq	d_posBuf(%rip), %rdi
	callq	hipFree
	movq	d_velBuf(%rip), %rdi
	callq	hipFree
	movq	d_radBuf(%rip), %rdi
	callq	hipFree
	movq	d_idBuf(%rip), %rdi
	callq	hipFree
	movq	d_velBuf_temp(%rip), %rdi
	callq	hipFree
	xorl	%eax, %eax
	addq	$12800, %rsp                    # imm = 0x3200
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end9:
	.size	main, .Lfunc_end9-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB10_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB10_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z16swapVelBufKernelPfS_, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z17fillTempVelKernelPfS_S_S_, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z20updatePositionKernelPfS_, %esi
	movl	$.L__unnamed_3, %edx
	movl	$.L__unnamed_3, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end10:
	.size	__hip_module_ctor, .Lfunc_end10-__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	.LBB11_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
.LBB11_2:
	retq
.Lfunc_end11:
	.size	__hip_module_dtor, .Lfunc_end11-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	d_posBuf,@object                # @d_posBuf
	.bss
	.globl	d_posBuf
	.p2align	3, 0x0
d_posBuf:
	.quad	0
	.size	d_posBuf, 8

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

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

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

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

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

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

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

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

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

	.type	_Z17fillTempVelKernelPfS_S_S_,@object # @_Z17fillTempVelKernelPfS_S_S_
	.globl	_Z17fillTempVelKernelPfS_S_S_
	.p2align	3, 0x0
_Z17fillTempVelKernelPfS_S_S_:
	.quad	_Z32__device_stub__fillTempVelKernelPfS_S_S_
	.size	_Z17fillTempVelKernelPfS_S_S_, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Total time elapsed: %.01f us\n"
	.size	.L.str, 30

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

	.type	.L.str.1,@object                # @.str.1
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.1:
	.asciz	"sphere %u\n"
	.size	.L.str.1, 11

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

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

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z16swapVelBufKernelPfS_"
	.size	.L__unnamed_1, 25

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z17fillTempVelKernelPfS_S_S_"
	.size	.L__unnamed_2, 30

	.type	.L__unnamed_3,@object           # @2
.L__unnamed_3:
	.asciz	"_Z20updatePositionKernelPfS_"
	.size	.L__unnamed_3, 29

	.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	"--- TICK ---"
	.size	.Lstr, 13

	.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 _Z31__device_stub__swapVelBufKernelPfS_
	.addrsig_sym _Z32__device_stub__fillTempVelKernelPfS_S_S_
	.addrsig_sym _Z35__device_stub__updatePositionKernelPfS_
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym d_posBuf
	.addrsig_sym d_velBuf
	.addrsig_sym d_radBuf
	.addrsig_sym d_velBuf_temp
	.addrsig_sym d_idBuf
	.addrsig_sym _Z16swapVelBufKernelPfS_
	.addrsig_sym _Z17fillTempVelKernelPfS_S_S_
	.addrsig_sym _Z20updatePositionKernelPfS_
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z16swapVelBufKernelPfS_ ; -- Begin function _Z16swapVelBufKernelPfS_
	.globl	_Z16swapVelBufKernelPfS_
	.p2align	8
	.type	_Z16swapVelBufKernelPfS_,@function
_Z16swapVelBufKernelPfS_:               ; @_Z16swapVelBufKernelPfS_
; %bb.0:
	s_load_b32 s2, s[0:1], 0x1c
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_mov_b32 s2, exec_lo
	v_cmpx_gt_u32_e32 0xc8, v1
	s_cbranch_execz .LBB0_3
; %bb.1:                                ; %.preheader
	s_load_b128 s[0:3], s[0:1], 0x0
	v_lshl_add_u32 v0, v1, 1, v1
	v_mov_b32_e32 v1, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[2:3], 2, v[0:1]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v0, vcc_lo, s2, v2
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v1, vcc_lo, s3, v3, vcc_lo
	v_add_co_u32 v2, vcc_lo, s0, v2
	v_add_co_ci_u32_e32 v3, vcc_lo, s1, v3, vcc_lo
	s_mov_b64 s[0:1], 0
.LBB0_2:                                ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(SALU_CYCLE_1)
	v_add_co_u32 v4, vcc_lo, v0, s0
	v_add_co_ci_u32_e32 v5, vcc_lo, s1, v1, vcc_lo
	global_load_b32 v6, v[4:5], off
	v_add_co_u32 v4, vcc_lo, v2, s0
	v_add_co_ci_u32_e32 v5, vcc_lo, s1, v3, vcc_lo
	s_add_u32 s0, s0, 4
	s_addc_u32 s1, s1, 0
	s_cmp_lg_u32 s0, 12
	s_waitcnt vmcnt(0)
	global_store_b32 v[4:5], v6, off
	s_cbranch_scc1 .LBB0_2
.LBB0_3:                                ; %.loopexit
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z16swapVelBufKernelPfS_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 272
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 7
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z16swapVelBufKernelPfS_, .Lfunc_end0-_Z16swapVelBufKernelPfS_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 192
; NumSgprs: 18
; NumVgprs: 7
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 7
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z17fillTempVelKernelPfS_S_S_ ; -- Begin function _Z17fillTempVelKernelPfS_S_S_
	.globl	_Z17fillTempVelKernelPfS_S_S_
	.p2align	8
	.type	_Z17fillTempVelKernelPfS_S_S_,@function
_Z17fillTempVelKernelPfS_S_S_:          ; @_Z17fillTempVelKernelPfS_S_S_
; %bb.0:
	s_clause 0x2
	s_load_b32 s2, s[0:1], 0x2c
	s_load_b32 s12, s[0:1], 0x20
	s_load_b256 s[4:11], s[0:1], 0x0
	v_mov_b32_e32 v4, 0
                                        ; implicit-def: $vgpr21
                                        ; implicit-def: $vgpr22
                                        ; implicit-def: $vgpr23
                                        ; implicit-def: $vgpr18
                                        ; implicit-def: $vgpr19
                                        ; implicit-def: $vgpr20
                                        ; implicit-def: $vgpr17
	s_waitcnt lgkmcnt(0)
	s_and_b32 s13, s2, 0xffff
	s_mov_b64 s[2:3], 0
	s_mul_i32 s15, s15, s13
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_i32 s0, s15, 3
	v_mad_u32_u24 v16, v0, 3, s0
                                        ; implicit-def: $vgpr0_vgpr1_vgpr2
                                        ; implicit-def: $vgpr0_vgpr1_vgpr2
.LBB1_1:                                ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v3, s2, v16
	s_cmp_eq_u32 s2, 2
	v_lshlrev_b64 v[5:6], 2, v[3:4]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v7, vcc_lo, s4, v5
	v_add_co_ci_u32_e32 v8, vcc_lo, s5, v6, vcc_lo
	v_add_co_u32 v5, vcc_lo, s6, v5
	v_add_co_ci_u32_e32 v6, vcc_lo, s7, v6, vcc_lo
	s_cselect_b32 vcc_lo, -1, 0
	global_load_b32 v3, v[7:8], off
	global_load_b32 v5, v[5:6], off
	s_cmp_eq_u32 s2, 1
	v_cndmask_b32_e64 v2, v2, 0, vcc_lo
	s_cselect_b32 s0, -1, 0
	s_cmp_eq_u32 s2, 0
	v_cndmask_b32_e64 v1, v1, 0, s0
	s_cselect_b32 s1, -1, 0
	s_add_u32 s2, s2, 1
	v_cndmask_b32_e64 v17, v17, 0, s1
	s_addc_u32 s3, s3, 0
	s_cmp_lg_u32 s2, 3
	s_waitcnt vmcnt(0)
	v_dual_cndmask_b32 v23, v23, v3 :: v_dual_cndmask_b32 v20, v20, v5
	v_cndmask_b32_e64 v22, v22, v3, s0
	v_cndmask_b32_e64 v21, v21, v3, s1
	v_cndmask_b32_e64 v19, v19, v5, s0
	v_cndmask_b32_e64 v18, v18, v5, s1
	s_cbranch_scc1 .LBB1_1
; %bb.2:
	s_cmp_eq_u32 s12, 0
	s_mov_b32 s14, 0
	s_cbranch_scc1 .LBB1_21
; %bb.3:                                ; %.lr.ph164
	v_dual_mov_b32 v13, 0 :: v_dual_add_nc_u32 v14, s15, v0
	v_lshl_add_u32 v26, v0, 2, 0x1800
	s_cmp_lg_u32 s13, 0
	s_mul_i32 s16, s13, 3
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_mov_b32_e32 v15, v13
	s_cselect_b32 s15, -1, 0
	s_mov_b32 s17, 0
                                        ; implicit-def: $vgpr6_vgpr7_vgpr8
                                        ; implicit-def: $vgpr9_vgpr10_vgpr11
	v_lshlrev_b64 v[3:4], 2, v[14:15]
	v_mul_u32_u24_e32 v15, 3, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_lshlrev_b32_e32 v25, 2, v15
	v_add_co_u32 v3, vcc_lo, s8, v3
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_ci_u32_e32 v4, vcc_lo, s9, v4, vcc_lo
	v_add_nc_u32_e32 v27, 0xc00, v25
	global_load_b32 v24, v[3:4], off
	s_waitcnt vmcnt(0)
	v_mul_f32_e32 v3, v24, v24
	s_delay_alu instid0(VALU_DEP_1)
	v_mul_f32_e32 v28, v24, v3
                                        ; implicit-def: $vgpr3_vgpr4_vgpr5
.LBB1_4:                                ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB1_6 Depth 2
                                        ;       Child Loop BB1_8 Depth 3
                                        ;       Child Loop BB1_10 Depth 3
                                        ;       Child Loop BB1_13 Depth 3
	v_mad_u64_u32 v[29:30], null, s16, s17, v[15:16]
	v_mov_b32_e32 v30, v13
	s_mul_i32 s18, s17, s13
	s_and_not1_b32 s0, s14, exec_lo
	s_and_b32 s1, s14, exec_lo
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	s_or_b32 s19, s0, s1
	v_add_nc_u32_e32 v12, 1, v29
	v_lshlrev_b64 v[30:31], 2, v[29:30]
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_lshlrev_b64 v[32:33], 2, v[12:13]
	v_add_nc_u32_e32 v12, 2, v29
	v_add_co_u32 v34, vcc_lo, s4, v30
	s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_1) | instid1(VALU_DEP_4)
	v_add_co_ci_u32_e32 v35, vcc_lo, s5, v31, vcc_lo
	v_add_co_u32 v29, vcc_lo, s6, v30
	v_lshlrev_b64 v[36:37], 2, v[12:13]
	v_add_co_ci_u32_e32 v30, vcc_lo, s7, v31, vcc_lo
	v_add_co_u32 v38, vcc_lo, s4, v32
	v_add_nc_u32_e32 v12, s18, v0
	v_add_co_ci_u32_e32 v39, vcc_lo, s5, v33, vcc_lo
	v_add_co_u32 v40, vcc_lo, s4, v36
	v_add_co_ci_u32_e32 v41, vcc_lo, s5, v37, vcc_lo
	v_add_co_u32 v31, vcc_lo, s6, v32
	v_lshlrev_b64 v[42:43], 2, v[12:13]
	v_add_co_ci_u32_e32 v32, vcc_lo, s7, v33, vcc_lo
	v_add_co_u32 v36, vcc_lo, s6, v36
	v_add_co_ci_u32_e32 v37, vcc_lo, s7, v37, vcc_lo
	s_delay_alu instid0(VALU_DEP_4)
	v_add_co_u32 v42, vcc_lo, s8, v42
	v_add_co_ci_u32_e32 v43, vcc_lo, s9, v43, vcc_lo
	s_clause 0x2
	global_load_b32 v12, v[34:35], off
	global_load_b32 v33, v[38:39], off
	global_load_b32 v34, v[40:41], off
	s_clause 0x2
	global_load_b32 v29, v[29:30], off
	global_load_b32 v30, v[31:32], off
	global_load_b32 v31, v[36:37], off
	global_load_b32 v32, v[42:43], off
	s_and_not1_b32 vcc_lo, exec_lo, s15
	s_waitcnt vmcnt(5)
	ds_store_2addr_b32 v25, v12, v33 offset1:1
	s_waitcnt vmcnt(4)
	ds_store_b32 v25, v34 offset:8
	s_waitcnt vmcnt(2)
	ds_store_2addr_b32 v27, v29, v30 offset1:1
	s_waitcnt vmcnt(1)
	ds_store_b32 v27, v31 offset:8
	s_waitcnt vmcnt(0)
	ds_store_b32 v26, v32
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_cbranch_vccnz .LBB1_19
; %bb.5:                                ; %.lr.ph.preheader
                                        ;   in Loop: Header=BB1_4 Depth=1
	s_mov_b32 s20, 0
	s_mov_b32 s21, 0
                                        ; implicit-def: $sgpr22
.LBB1_6:                                ; %.lr.ph
                                        ;   Parent Loop BB1_4 Depth=1
                                        ; =>  This Loop Header: Depth=2
                                        ;       Child Loop BB1_8 Depth 3
                                        ;       Child Loop BB1_10 Depth 3
                                        ;       Child Loop BB1_13 Depth 3
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_add_i32 s0, s21, s18
	v_cmp_ne_u32_e32 vcc_lo, s0, v14
	s_cmpk_lt_u32 s0, 0xc8
	s_cselect_b32 s0, -1, 0
	s_and_not1_b32 s1, s22, exec_lo
	s_and_b32 s2, s14, exec_lo
	s_and_b32 s0, s0, vcc_lo
	s_or_b32 s22, s1, s2
	s_and_saveexec_b32 s23, s0
	s_cbranch_execz .LBB1_16
; %bb.7:                                ; %.preheader133
                                        ;   in Loop: Header=BB1_6 Depth=2
	s_mov_b64 s[2:3], 0
	s_mov_b32 s24, s20
.LBB1_8:                                ;   Parent Loop BB1_4 Depth=1
                                        ;     Parent Loop BB1_6 Depth=2
                                        ; =>    This Inner Loop Header: Depth=3
	s_cmp_eq_u32 s2, 2
	s_cselect_b32 vcc_lo, -1, 0
	v_mov_b32_e32 v12, s24
	s_cmp_eq_u32 s2, 1
	s_cselect_b32 s0, -1, 0
	s_cmp_eq_u32 s2, 0
	ds_load_2addr_stride64_b32 v[29:30], v12 offset1:12
	s_cselect_b32 s1, -1, 0
	s_add_u32 s2, s2, 1
	s_addc_u32 s3, s3, 0
	s_add_i32 s24, s24, 4
	s_cmp_lg_u32 s2, 3
	s_waitcnt lgkmcnt(0)
	v_cndmask_b32_e32 v5, v5, v29, vcc_lo
	v_cndmask_b32_e64 v4, v4, v29, s0
	v_cndmask_b32_e64 v3, v3, v29, s1
	v_cndmask_b32_e32 v8, v8, v30, vcc_lo
	v_cndmask_b32_e64 v7, v7, v30, s0
	v_cndmask_b32_e64 v6, v6, v30, s1
	s_cbranch_scc1 .LBB1_8
; %bb.9:                                ;   in Loop: Header=BB1_6 Depth=2
	s_lshl_b32 s0, s21, 2
	s_mov_b64 s[2:3], 0
	v_mov_b32_e32 v12, s0
	ds_load_b32 v12, v12 offset:6144
.LBB1_10:                               ;   Parent Loop BB1_4 Depth=1
                                        ;     Parent Loop BB1_6 Depth=2
                                        ; =>    This Inner Loop Header: Depth=3
	s_cmp_eq_u32 s2, 1
	s_cselect_b32 vcc_lo, -1, 0
	s_cmp_eq_u32 s2, 2
	v_dual_cndmask_b32 v29, v21, v22 :: v_dual_cndmask_b32 v30, v3, v4
	s_cselect_b32 s0, -1, 0
	s_cmp_eq_u32 s2, 0
	s_cselect_b32 s1, -1, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_4) | instid1(VALU_DEP_1)
	v_cndmask_b32_e64 v29, v29, v23, s0
	v_cndmask_b32_e64 v30, v30, v5, s0
	s_add_u32 s2, s2, 1
	s_addc_u32 s3, s3, 0
	s_cmp_eq_u32 s2, 3
	v_sub_f32_e32 v29, v29, v30
	s_delay_alu instid0(VALU_DEP_1)
	v_cndmask_b32_e64 v11, v11, v29, s0
	v_cndmask_b32_e32 v10, v10, v29, vcc_lo
	v_cndmask_b32_e64 v9, v9, v29, s1
	s_cbranch_scc0 .LBB1_10
; %bb.11:                               ; %.preheader132
                                        ;   in Loop: Header=BB1_6 Depth=2
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_dual_mul_f32 v29, v10, v10 :: v_dual_add_f32 v30, v24, v12
	s_mov_b32 s24, exec_lo
	v_dual_fmac_f32 v29, v9, v9 :: v_dual_mul_f32 v30, v30, v30
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v29, v11, v11
	v_cmpx_lt_f32_e32 v29, v30
	s_cbranch_execz .LBB1_15
; %bb.12:                               ;   in Loop: Header=BB1_6 Depth=2
	v_mul_f32_e32 v29, v12, v12
	s_mov_b64 s[2:3], 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f32_e32 v30, v12, v29
	v_add_f32_e32 v30, v30, v30
	v_fma_f32 v31, -v12, v29, v28
	v_fma_f32 v29, v12, v29, v28
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_div_scale_f32 v12, null, v29, v29, v31
	v_div_scale_f32 v32, null, v29, v29, v30
	v_div_scale_f32 v37, vcc_lo, v31, v29, v31
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_rcp_f32_e32 v33, v12
	v_rcp_f32_e32 v34, v32
	s_waitcnt_depctr 0xfff
	v_fma_f32 v35, -v12, v33, 1.0
	v_fma_f32 v36, -v32, v34, 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_dual_fmac_f32 v33, v35, v33 :: v_dual_fmac_f32 v34, v36, v34
	v_div_scale_f32 v35, s0, v30, v29, v30
	v_mul_f32_e32 v36, v37, v33
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_mul_f32_e32 v38, v35, v34
	v_fma_f32 v39, -v12, v36, v37
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fma_f32 v40, -v32, v38, v35
	v_fmac_f32_e32 v36, v39, v33
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fmac_f32_e32 v38, v40, v34
	v_fma_f32 v12, -v12, v36, v37
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fma_f32 v32, -v32, v38, v35
	v_div_fmas_f32 v12, v12, v33, v36
	s_mov_b32 vcc_lo, s0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_div_fmas_f32 v32, v32, v34, v38
	v_div_fixup_f32 v12, v12, v29, v31
	s_delay_alu instid0(VALU_DEP_2)
	v_div_fixup_f32 v29, v32, v29, v30
.LBB1_13:                               ;   Parent Loop BB1_4 Depth=1
                                        ;     Parent Loop BB1_6 Depth=2
                                        ; =>    This Inner Loop Header: Depth=3
	s_cmp_eq_u32 s2, 1
	s_cselect_b32 vcc_lo, -1, 0
	s_cmp_eq_u32 s2, 2
	v_dual_cndmask_b32 v30, v17, v1 :: v_dual_cndmask_b32 v31, v18, v19
	s_cselect_b32 s0, -1, 0
	v_cndmask_b32_e32 v32, v6, v7, vcc_lo
	s_cmp_eq_u32 s2, 0
	s_delay_alu instid0(VALU_DEP_2)
	v_cndmask_b32_e64 v30, v30, v2, s0
	v_cndmask_b32_e64 v31, v31, v20, s0
	s_cselect_b32 s1, -1, 0
	v_cndmask_b32_e64 v32, v32, v8, s0
	s_add_u32 s2, s2, 1
	s_addc_u32 s3, s3, 0
	v_fmac_f32_e32 v30, v12, v31
	s_cmp_lg_u32 s2, 3
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v30, v29, v32
	v_cndmask_b32_e32 v1, v1, v30, vcc_lo
	v_cndmask_b32_e64 v2, v2, v30, s0
	v_cndmask_b32_e64 v17, v17, v30, s1
	s_cbranch_scc1 .LBB1_13
; %bb.14:                               ; %Flow272
                                        ;   in Loop: Header=BB1_6 Depth=2
	s_or_b32 s14, s14, exec_lo
.LBB1_15:                               ; %Flow273
                                        ;   in Loop: Header=BB1_6 Depth=2
	s_or_b32 exec_lo, exec_lo, s24
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	s_and_not1_b32 s0, s22, exec_lo
	s_and_b32 s1, s14, exec_lo
	s_or_b32 s22, s0, s1
.LBB1_16:                               ; %Flow274
                                        ;   in Loop: Header=BB1_6 Depth=2
	s_or_b32 exec_lo, exec_lo, s23
	s_add_i32 s21, s21, 1
	s_add_i32 s20, s20, 12
	s_cmp_lg_u32 s21, s13
	s_cbranch_scc0 .LBB1_18
; %bb.17:                               ;   in Loop: Header=BB1_6 Depth=2
	s_mov_b32 s14, s22
	s_branch .LBB1_6
.LBB1_18:                               ; %Flow275
                                        ;   in Loop: Header=BB1_4 Depth=1
	s_and_not1_b32 s0, s19, exec_lo
	s_and_b32 s1, s22, exec_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 s14, s0, s1
	s_branch .LBB1_20
.LBB1_19:                               ;   in Loop: Header=BB1_4 Depth=1
	s_mov_b32 s14, s19
.LBB1_20:                               ; %._crit_edge
                                        ;   in Loop: Header=BB1_4 Depth=1
	s_add_i32 s17, s17, 1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_lg_u32 s17, s12
	s_barrier
	buffer_gl0_inv
	s_cbranch_scc1 .LBB1_4
.LBB1_21:                               ; %._crit_edge165
	s_xor_b32 s0, s14, -1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_saveexec_b32 s4, s0
	s_cbranch_execz .LBB1_24
; %bb.22:                               ; %.preheader.preheader
	s_mov_b64 s[2:3], 0
.LBB1_23:                               ; %.preheader
                                        ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_eq_u32 s2, 1
	s_cselect_b32 vcc_lo, -1, 0
	s_cmp_eq_u32 s2, 2
	v_cndmask_b32_e32 v0, v18, v19, vcc_lo
	s_cselect_b32 s0, -1, 0
	s_cmp_eq_u32 s2, 0
	s_cselect_b32 s1, -1, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_1)
	v_cndmask_b32_e64 v0, v0, v20, s0
	s_add_u32 s2, s2, 1
	s_addc_u32 s3, s3, 0
	s_cmp_lg_u32 s2, 3
	v_cndmask_b32_e64 v2, v2, v0, s0
	v_cndmask_b32_e32 v1, v1, v0, vcc_lo
	v_cndmask_b32_e64 v17, v17, v0, s1
	s_cbranch_scc1 .LBB1_23
.LBB1_24:                               ; %Flow271
	s_or_b32 exec_lo, exec_lo, s4
	v_mov_b32_e32 v4, 0
	s_mov_b64 s[0:1], 0
.LBB1_25:                               ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_4) | instid1(VALU_DEP_1)
	s_cmp_eq_u32 s0, 1
	s_cselect_b32 vcc_lo, -1, 0
	v_dual_cndmask_b32 v0, v17, v1 :: v_dual_add_nc_u32 v3, s0, v16
	s_cmp_eq_u32 s0, 2
	s_cselect_b32 vcc_lo, -1, 0
	v_lshlrev_b64 v[5:6], 2, v[3:4]
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_3) | instid1(VALU_DEP_2)
	v_cndmask_b32_e32 v0, v0, v2, vcc_lo
	s_add_u32 s0, s0, 1
	s_addc_u32 s1, s1, 0
	s_cmp_lg_u32 s0, 3
	v_add_co_u32 v5, vcc_lo, s10, v5
	v_add_co_ci_u32_e32 v6, vcc_lo, s11, v6, vcc_lo
	global_store_b32 v[5:6], v0, off
	s_cbranch_scc1 .LBB1_25
; %bb.26:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z17fillTempVelKernelPfS_S_S_
		.amdhsa_group_segment_fixed_size 7168
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 288
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 44
		.amdhsa_next_free_sgpr 25
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end1:
	.size	_Z17fillTempVelKernelPfS_S_S_, .Lfunc_end1-_Z17fillTempVelKernelPfS_S_S_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 1644
; NumSgprs: 27
; NumVgprs: 44
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 7168 bytes/workgroup (compile time only)
; SGPRBlocks: 3
; VGPRBlocks: 5
; NumSGPRsForWavesPerEU: 27
; NumVGPRsForWavesPerEU: 44
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z20updatePositionKernelPfS_ ; -- Begin function _Z20updatePositionKernelPfS_
	.globl	_Z20updatePositionKernelPfS_
	.p2align	8
	.type	_Z20updatePositionKernelPfS_,@function
_Z20updatePositionKernelPfS_:           ; @_Z20updatePositionKernelPfS_
; %bb.0:
	s_load_b32 s2, s[0:1], 0x1c
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_mov_b32 s2, exec_lo
	v_cmpx_gt_u32_e32 0xc8, v1
	s_cbranch_execz .LBB2_3
; %bb.1:                                ; %.preheader
	s_load_b128 s[0:3], s[0:1], 0x0
	v_lshl_add_u32 v0, v1, 1, v1
	v_mov_b32_e32 v1, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[2:3], 2, v[0:1]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v0, vcc_lo, s2, v2
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v1, vcc_lo, s3, v3, vcc_lo
	v_add_co_u32 v2, vcc_lo, s0, v2
	v_add_co_ci_u32_e32 v3, vcc_lo, s1, v3, vcc_lo
	s_mov_b64 s[0:1], 0
.LBB2_2:                                ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(SALU_CYCLE_1)
	v_add_co_u32 v4, vcc_lo, v0, s0
	v_add_co_ci_u32_e32 v5, vcc_lo, s1, v1, vcc_lo
	v_add_co_u32 v6, vcc_lo, v2, s0
	v_add_co_ci_u32_e32 v7, vcc_lo, s1, v3, vcc_lo
	s_add_u32 s0, s0, 4
	global_load_b32 v4, v[4:5], off
	global_load_b32 v5, v[6:7], off
	s_addc_u32 s1, s1, 0
	s_cmp_lg_u32 s0, 12
	s_waitcnt vmcnt(0)
	v_add_f32_e32 v4, v4, v5
	global_store_b32 v[6:7], v4, off
	s_cbranch_scc1 .LBB2_2
.LBB2_3:                                ; %.loopexit
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z20updatePositionKernelPfS_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 272
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 8
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end2:
	.size	_Z20updatePositionKernelPfS_, .Lfunc_end2-_Z20updatePositionKernelPfS_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 204
; NumSgprs: 18
; NumVgprs: 8
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 8
; 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
      - .offset:         16
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         20
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         28
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         30
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         32
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         34
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         36
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         38
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         56
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         80
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 272
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z16swapVelBufKernelPfS_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z16swapVelBufKernelPfS_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     7
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         24
        .size:           8
        .value_kind:     global_buffer
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         36
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         44
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         46
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         48
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         50
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         52
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         54
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         96
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 7168
    .kernarg_segment_align: 8
    .kernarg_segment_size: 288
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z17fillTempVelKernelPfS_S_S_
    .private_segment_fixed_size: 0
    .sgpr_count:     27
    .sgpr_spill_count: 0
    .symbol:         _Z17fillTempVelKernelPfS_S_S_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     44
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .offset:         16
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         20
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         28
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         30
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         32
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         34
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         36
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         38
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         56
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         80
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 272
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z20updatePositionKernelPfS_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z20updatePositionKernelPfS_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     8
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
