#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cuda.h>
#include <cuda_runtime.h>

#define dT 0.2f
#define G 0.6f
#define BLOCK_SIZE 64

// Global variables
int num_planets;
int num_timesteps;

// Host arrays
float2* velocities;
float4* planets;

// Device arrays 
float2* velocities_d;
float4* planets_d;


// Parse command line arguments
void parse_args(int argc, char** argv){
    if(argc != 2){
        printf("Useage: nbody num_timesteps\n");
        exit(-1);
    }
    
    num_timesteps = strtol(argv[1], 0, 10);
}

// Reads planets from planets.txt
void read_planets(){

    FILE* file = fopen("planets.txt", "r");
    if(file == NULL){
        printf("'planets.txt' not found. Exiting\n");
        exit(-1);
    }

    char line[200];
    fgets(line, 200, file);
    sscanf(line, "%d", &num_planets);

    planets = (float4*)malloc(sizeof(float4)*num_planets);
    velocities = (float2*)malloc(sizeof(float2)*num_planets);

    for(int p = 0; p < num_planets; p++){
        fgets(line, 200, file);
        sscanf(line, "%f %f %f %f %f",
                &planets[p].x,
                &planets[p].y,
                &velocities[p].x,
                &velocities[p].y,
                &planets[p].z);
    }

    fclose(file);
}

// Writes planets to file
void write_planets(int timestep){
    char name[20];
    int n = sprintf(name, "planets_out.txt");

    FILE* file = fopen(name, "wr+");

    for(int p = 0; p < num_planets; p++){
        fprintf(file, "%f %f %f %f %f\n",
                planets[p].x,
                planets[p].y,
                velocities[p].x,
                velocities[p].y,
                planets[p].z);
    }

    fclose(file);
}

// TODO 7. Calculate the change in velocity for p, caused by the interaction with q
__device__ float2 calculate_velocity_change_planet(float4 p, float4 q){

}

// TODO 5. Calculate the change in velocity for my_planet, caused by the interactions with a block of planets
__device__ float2 calculate_velocity_change_block(float4 my_planet, float4* shared_planets){

}

// TODO 4. Update the velocities by calculating the planet interactions
__global__ void update_velocities(float4* planets, float2* velocities, int num_planets){

}

// TODO 7. Update the positions of the planets using the new velocities
__global__ void update_positions(float4* planets, float2* velocities, int num_planets){

}


int main(int argc, char** argv){

    parse_args(argc, argv);
    read_planets();

    // TODO 1. Allocate device memory, and transfer data to device 

    // Calculating the number of blocks
    int num_blocks = num_planets/BLOCK_SIZE + ((num_planets%BLOCK_SIZE == 0) ? 0 : 1);

    // Main loop
    for(int t = 0; t < num_timesteps; t++){
        // TODO 2. Call kernels
    }

    // TODO 3. Transfer data back to host

    // Output
    write_planets(num_timesteps);
}

	.file	"tmpxft_0028dc73_00000000-6_nbody_cuda.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2035:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2035:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"Useage: nbody num_timesteps\n"
	.text
	.globl	_Z10parse_argsiPPc
	.type	_Z10parse_argsiPPc, @function
_Z10parse_argsiPPc:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%rdx
	.cfi_def_cfa_offset 16
	cmpl	$2, %edi
	je	.L3
	movl	$2, %edi
	leaq	.LC0(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	orl	$-1, %edi
	call	exit@PLT
.L3:
	movq	8(%rsi), %rdi
	movl	$10, %edx
	xorl	%esi, %esi
	call	__isoc23_strtol@PLT
	movl	%eax, num_timesteps(%rip)
	popq	%rax
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z10parse_argsiPPc, .-_Z10parse_argsiPPc
	.section	.rodata.str1.1
.LC1:
	.string	"r"
.LC2:
	.string	"planets.txt"
.LC3:
	.string	"'planets.txt' not found. Exiting\n"
.LC4:
	.string	"%d"
.LC5:
	.string	"%f %f %f %f %f"
	.text
	.globl	_Z12read_planetsv
	.type	_Z12read_planetsv, @function
_Z12read_planetsv:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC1(%rip), %rsi
	leaq	.LC2(%rip), %rdi
	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	$216, %rsp
	.cfi_def_cfa_offset 256
	movq	%fs:40, %rax
	movq	%rax, 200(%rsp)
	xorl	%eax, %eax
	call	fopen@PLT
	testq	%rax, %rax
	jne	.L7
	movl	$2, %edi
	leaq	.LC3(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	orl	$-1, %edi
	call	exit@PLT
.L7:
	movq	%rsp, %r12
	movq	%rax, %rcx
	movl	$200, %edx
	movl	$200, %esi
	movq	%r12, %rdi
	movq	%rax, %rbx
	leaq	.LC5(%rip), %r13
	call	__fgets_chk@PLT
	leaq	num_planets(%rip), %rdx
	leaq	.LC4(%rip), %rsi
	xorl	%eax, %eax
	movq	%r12, %rdi
	call	__isoc23_sscanf@PLT
	movslq	num_planets(%rip), %rbp
	movq	%rbp, %rdi
	salq	$4, %rdi
	call	malloc@PLT
	leaq	0(,%rbp,8), %rdi
	xorl	%ebp, %ebp
	movq	%rax, planets(%rip)
	call	malloc@PLT
	movq	%rax, velocities(%rip)
.L8:
	cmpl	%ebp, num_planets(%rip)
	jle	.L12
	movq	%rbx, %rcx
	movl	$200, %edx
	movl	$200, %esi
	movq	%r12, %rdi
	call	__fgets_chk@PLT
	movq	%rbp, %rdx
	movq	%r13, %rsi
	movq	%r12, %rdi
	movq	velocities(%rip), %rax
	salq	$4, %rdx
	addq	planets(%rip), %rdx
	leaq	4(%rdx), %rcx
	leaq	(%rax,%rbp,8), %r8
	pushq	%rax
	.cfi_def_cfa_offset 264
	leaq	8(%rdx), %rax
	incq	%rbp
	pushq	%rax
	.cfi_def_cfa_offset 272
	leaq	4(%r8), %r9
	xorl	%eax, %eax
	call	__isoc23_sscanf@PLT
	popq	%rdx
	.cfi_def_cfa_offset 264
	popq	%rcx
	.cfi_def_cfa_offset 256
	jmp	.L8
.L12:
	movq	%rbx, %rdi
	call	fclose@PLT
	movq	200(%rsp), %rax
	subq	%fs:40, %rax
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	addq	$216, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z12read_planetsv, .-_Z12read_planetsv
	.section	.rodata.str1.1
.LC6:
	.string	"planets_out.txt"
.LC7:
	.string	"wr+"
.LC8:
	.string	"%f %f %f %f %f\n"
	.text
	.globl	_Z13write_planetsi
	.type	_Z13write_planetsi, @function
_Z13write_planetsi:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	.LC6(%rip), %rsi
	leaq	.LC8(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	xorl	%ebx, %ebx
	subq	$32, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rdi
	call	strcpy@PLT
	leaq	.LC7(%rip), %rsi
	movq	%rax, %rdi
	call	fopen@PLT
	movq	%rax, %rbp
.L14:
	cmpl	%ebx, num_planets(%rip)
	jle	.L18
	movq	velocities(%rip), %rdx
	movq	%rbx, %rax
	movl	$2, %esi
	movq	%rbp, %rdi
	salq	$4, %rax
	addq	planets(%rip), %rax
	leaq	(%rdx,%rbx,8), %rdx
	cvtss2sd	(%rax), %xmm0
	cvtss2sd	8(%rax), %xmm4
	cvtss2sd	4(%rax), %xmm1
	cvtss2sd	4(%rdx), %xmm3
	cvtss2sd	(%rdx), %xmm2
	movb	$5, %al
	movq	%r12, %rdx
	call	__fprintf_chk@PLT
	incq	%rbx
	jmp	.L14
.L18:
	movq	%rbp, %rdi
	call	fclose@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	addq	$32, %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
.LFE2029:
	.size	_Z13write_planetsi, .-_Z13write_planetsi
	.globl	_Z32calculate_velocity_change_planet6float4S_
	.type	_Z32calculate_velocity_change_planet6float4S_, @function
_Z32calculate_velocity_change_planet6float4S_:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2030:
	.size	_Z32calculate_velocity_change_planet6float4S_, .-_Z32calculate_velocity_change_planet6float4S_
	.globl	_Z31calculate_velocity_change_block6float4PS_
	.type	_Z31calculate_velocity_change_block6float4PS_, @function
_Z31calculate_velocity_change_block6float4PS_:
.LFB2031:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2031:
	.size	_Z31calculate_velocity_change_block6float4PS_, .-_Z31calculate_velocity_change_block6float4PS_
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2032:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	call	_Z10parse_argsiPPc
	call	_Z12read_planetsv
	movl	num_timesteps(%rip), %edi
	call	_Z13write_planetsi
	xorl	%eax, %eax
	popq	%rdx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2032:
	.size	main, .-main
	.text
	.globl	_Z52__device_stub__Z17update_velocitiesP6float4P6float2iP6float4P6float2i
	.type	_Z52__device_stub__Z17update_velocitiesP6float4P6float2iP6float4P6float2i, @function
_Z52__device_stub__Z17update_velocitiesP6float4P6float2iP6float4P6float2i:
.LFB2057:
	.cfi_startproc
	endbr64
	subq	$136, %rsp
	.cfi_def_cfa_offset 144
	movq	%rdi, 24(%rsp)
	leaq	40(%rsp), %rcx
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	32(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 112(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L25
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z17update_velocitiesP6float4P6float2i(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 160
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 152
	popq	%rdx
	.cfi_def_cfa_offset 144
.L25:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L27
	call	__stack_chk_fail@PLT
.L27:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2057:
	.size	_Z52__device_stub__Z17update_velocitiesP6float4P6float2iP6float4P6float2i, .-_Z52__device_stub__Z17update_velocitiesP6float4P6float2iP6float4P6float2i
	.globl	_Z17update_velocitiesP6float4P6float2i
	.type	_Z17update_velocitiesP6float4P6float2i, @function
_Z17update_velocitiesP6float4P6float2i:
.LFB2058:
	.cfi_startproc
	endbr64
	jmp	_Z52__device_stub__Z17update_velocitiesP6float4P6float2iP6float4P6float2i
	.cfi_endproc
.LFE2058:
	.size	_Z17update_velocitiesP6float4P6float2i, .-_Z17update_velocitiesP6float4P6float2i
	.globl	_Z51__device_stub__Z16update_positionsP6float4P6float2iP6float4P6float2i
	.type	_Z51__device_stub__Z16update_positionsP6float4P6float2iP6float4P6float2i, @function
_Z51__device_stub__Z16update_positionsP6float4P6float2iP6float4P6float2i:
.LFB2059:
	.cfi_startproc
	endbr64
	subq	$136, %rsp
	.cfi_def_cfa_offset 144
	movq	%rdi, 24(%rsp)
	leaq	40(%rsp), %rcx
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	32(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 112(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L30
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z16update_positionsP6float4P6float2i(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 160
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 152
	popq	%rdx
	.cfi_def_cfa_offset 144
.L30:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L32
	call	__stack_chk_fail@PLT
.L32:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2059:
	.size	_Z51__device_stub__Z16update_positionsP6float4P6float2iP6float4P6float2i, .-_Z51__device_stub__Z16update_positionsP6float4P6float2iP6float4P6float2i
	.globl	_Z16update_positionsP6float4P6float2i
	.type	_Z16update_positionsP6float4P6float2i, @function
_Z16update_positionsP6float4P6float2i:
.LFB2060:
	.cfi_startproc
	endbr64
	jmp	_Z51__device_stub__Z16update_positionsP6float4P6float2iP6float4P6float2i
	.cfi_endproc
.LFE2060:
	.size	_Z16update_positionsP6float4P6float2i, .-_Z16update_positionsP6float4P6float2i
	.section	.rodata.str1.1
.LC9:
	.string	"_Z16update_positionsP6float4P6float2i"
.LC10:
	.string	"_Z17update_velocitiesP6float4P6float2i"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2062:
	.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	_Z16update_positionsP6float4P6float2i(%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	_Z17update_velocitiesP6float4P6float2i(%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
.LFE2062:
	.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	planets_d
	.bss
	.align 8
	.type	planets_d, @object
	.size	planets_d, 8
planets_d:
	.zero	8
	.globl	velocities_d
	.align 8
	.type	velocities_d, @object
	.size	velocities_d, 8
velocities_d:
	.zero	8
	.globl	planets
	.align 8
	.type	planets, @object
	.size	planets, 8
planets:
	.zero	8
	.globl	velocities
	.align 8
	.type	velocities, @object
	.size	velocities, 8
velocities:
	.zero	8
	.globl	num_timesteps
	.align 4
	.type	num_timesteps, @object
	.size	num_timesteps, 4
num_timesteps:
	.zero	4
	.globl	num_planets
	.align 4
	.type	num_planets, @object
	.size	num_planets, 4
num_planets:
	.zero	4
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <hip/hip_runtime.h>


#define dT 0.2f
#define G 0.6f
#define BLOCK_SIZE 64

// Global variables
int num_planets;
int num_timesteps;

// Host arrays
float2* velocities;
float4* planets;

// Device arrays 
float2* velocities_d;
float4* planets_d;


// Parse command line arguments
void parse_args(int argc, char** argv){
    if(argc != 2){
        printf("Useage: nbody num_timesteps\n");
        exit(-1);
    }
    
    num_timesteps = strtol(argv[1], 0, 10);
}

// Reads planets from planets.txt
void read_planets(){

    FILE* file = fopen("planets.txt", "r");
    if(file == NULL){
        printf("'planets.txt' not found. Exiting\n");
        exit(-1);
    }

    char line[200];
    fgets(line, 200, file);
    sscanf(line, "%d", &num_planets);

    planets = (float4*)malloc(sizeof(float4)*num_planets);
    velocities = (float2*)malloc(sizeof(float2)*num_planets);

    for(int p = 0; p < num_planets; p++){
        fgets(line, 200, file);
        sscanf(line, "%f %f %f %f %f",
                &planets[p].x,
                &planets[p].y,
                &velocities[p].x,
                &velocities[p].y,
                &planets[p].z);
    }

    fclose(file);
}

// Writes planets to file
void write_planets(int timestep){
    char name[20];
    int n = sprintf(name, "planets_out.txt");

    FILE* file = fopen(name, "wr+");

    for(int p = 0; p < num_planets; p++){
        fprintf(file, "%f %f %f %f %f\n",
                planets[p].x,
                planets[p].y,
                velocities[p].x,
                velocities[p].y,
                planets[p].z);
    }

    fclose(file);
}

// TODO 7. Calculate the change in velocity for p, caused by the interaction with q
__device__ float2 calculate_velocity_change_planet(float4 p, float4 q){

}

// TODO 5. Calculate the change in velocity for my_planet, caused by the interactions with a block of planets
__device__ float2 calculate_velocity_change_block(float4 my_planet, float4* shared_planets){

}

// TODO 4. Update the velocities by calculating the planet interactions
__global__ void update_velocities(float4* planets, float2* velocities, int num_planets){

}

// TODO 7. Update the positions of the planets using the new velocities
__global__ void update_positions(float4* planets, float2* velocities, int num_planets){

}


int main(int argc, char** argv){

    parse_args(argc, argv);
    read_planets();

    // TODO 1. Allocate device memory, and transfer data to device 

    // Calculating the number of blocks
    int num_blocks = num_planets/BLOCK_SIZE + ((num_planets%BLOCK_SIZE == 0) ? 0 : 1);

    // Main loop
    for(int t = 0; t < num_timesteps; t++){
        // TODO 2. Call kernels
    }

    // TODO 3. Transfer data back to host

    // Output
    write_planets(num_timesteps);
}

	.text
	.file	"nbody_cuda.hip"
	.globl	_Z10parse_argsiPPc              # -- Begin function _Z10parse_argsiPPc
	.type	_Z10parse_argsiPPc,@function
_Z10parse_argsiPPc:                     # @_Z10parse_argsiPPc
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	cmpl	$2, %edi
	jne	.LBB0_2
# %bb.1:
	movq	8(%rsi), %rdi
	xorl	%esi, %esi
	movl	$10, %edx
	callq	__isoc23_strtol
	movl	%eax, num_timesteps(%rip)
	popq	%rax
	.cfi_def_cfa_offset 8
	retq
.LBB0_2:
	.cfi_def_cfa_offset 16
	movl	$.Lstr, %edi
	callq	puts@PLT
	movl	$-1, %edi
	callq	exit
.Lfunc_end0:
	.size	_Z10parse_argsiPPc, .Lfunc_end0-_Z10parse_argsiPPc
	.cfi_endproc
                                        # -- End function
	.globl	_Z12read_planetsv               # -- Begin function _Z12read_planetsv
	.type	_Z12read_planetsv,@function
_Z12read_planetsv:                      # @_Z12read_planetsv
	.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	$224, %rsp
	.cfi_def_cfa_offset 272
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	$.L.str.1, %edi
	movl	$.L.str.2, %esi
	callq	fopen
	testq	%rax, %rax
	je	.LBB1_5
# %bb.1:
	movq	%rax, %rbx
	leaq	16(%rsp), %r14
	movq	%r14, %rdi
	movl	$200, %esi
	movq	%rax, %rdx
	callq	fgets
	movl	$.L.str.4, %esi
	movl	$num_planets, %edx
	movq	%r14, %rdi
	xorl	%eax, %eax
	callq	__isoc23_sscanf
	movslq	num_planets(%rip), %r14
	movq	%r14, %rdi
	shlq	$4, %rdi
	callq	malloc
	movq	%rax, planets(%rip)
	leaq	(,%r14,8), %rdi
	callq	malloc
	movq	%rax, velocities(%rip)
	testq	%r14, %r14
	jle	.LBB1_4
# %bb.2:                                # %.lr.ph.preheader
	movl	$4, %r15d
	movl	$8, %r12d
	leaq	16(%rsp), %r14
	xorl	%r13d, %r13d
.LBB1_3:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movq	%r14, %rdi
	movl	$200, %esi
	movq	%rbx, %rdx
	callq	fgets
	movq	planets(%rip), %rax
	leaq	(%rax,%r12), %rsi
	leaq	(%rax,%r12), %rdx
	addq	$-8, %rdx
	leaq	(%rax,%r12), %rcx
	addq	$-4, %rcx
	movq	velocities(%rip), %r9
	leaq	(%r9,%r15), %r8
	addq	$-4, %r8
	addq	%r15, %r9
	movq	%rsi, (%rsp)
	movl	$.L.str.5, %esi
	movq	%r14, %rdi
	xorl	%eax, %eax
	callq	__isoc23_sscanf
	incq	%r13
	movslq	num_planets(%rip), %rax
	addq	$8, %r15
	addq	$16, %r12
	cmpq	%rax, %r13
	jl	.LBB1_3
.LBB1_4:                                # %._crit_edge
	movq	%rbx, %rdi
	callq	fclose
	addq	$224, %rsp
	.cfi_def_cfa_offset 48
	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
.LBB1_5:
	.cfi_def_cfa_offset 272
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movl	$-1, %edi
	callq	exit
.Lfunc_end1:
	.size	_Z12read_planetsv, .Lfunc_end1-_Z12read_planetsv
	.cfi_endproc
                                        # -- End function
	.globl	_Z13write_planetsi              # -- Begin function _Z13write_planetsi
	.type	_Z13write_planetsi,@function
_Z13write_planetsi:                     # @_Z13write_planetsi
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	subq	$32, %rsp
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movaps	.L.str.6(%rip), %xmm0
	movq	%rsp, %rdi
	movaps	%xmm0, (%rdi)
	movl	$.L.str.7, %esi
	callq	fopen
	movq	%rax, %rbx
	cmpl	$0, num_planets(%rip)
	jle	.LBB2_3
# %bb.1:                                # %.lr.ph.preheader
	movl	$4, %r14d
	xorl	%r15d, %r15d
.LBB2_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movq	planets(%rip), %rax
	xorps	%xmm0, %xmm0
	cvtss2sd	-8(%rax,%r14,2), %xmm0
	xorps	%xmm1, %xmm1
	cvtss2sd	-4(%rax,%r14,2), %xmm1
	movq	velocities(%rip), %rcx
	xorps	%xmm2, %xmm2
	cvtss2sd	-4(%rcx,%r14), %xmm2
	xorps	%xmm3, %xmm3
	cvtss2sd	(%rcx,%r14), %xmm3
	xorps	%xmm4, %xmm4
	cvtss2sd	(%rax,%r14,2), %xmm4
	movl	$.L.str.8, %esi
	movq	%rbx, %rdi
	movb	$5, %al
	callq	fprintf
	incq	%r15
	movslq	num_planets(%rip), %rax
	addq	$8, %r14
	cmpq	%rax, %r15
	jl	.LBB2_2
.LBB2_3:                                # %._crit_edge
	movq	%rbx, %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	fclose                          # TAILCALL
.Lfunc_end2:
	.size	_Z13write_planetsi, .Lfunc_end2-_Z13write_planetsi
	.cfi_endproc
                                        # -- End function
	.globl	_Z32__device_stub__update_velocitiesP15HIP_vector_typeIfLj4EEPS_IfLj2EEi # -- Begin function _Z32__device_stub__update_velocitiesP15HIP_vector_typeIfLj4EEPS_IfLj2EEi
	.type	_Z32__device_stub__update_velocitiesP15HIP_vector_typeIfLj4EEPS_IfLj2EEi,@function
_Z32__device_stub__update_velocitiesP15HIP_vector_typeIfLj4EEPS_IfLj2EEi: # @_Z32__device_stub__update_velocitiesP15HIP_vector_typeIfLj4EEPS_IfLj2EEi
	.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), %rcx
	movq	%rsi, (%rcx)
	leaq	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%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	$_Z17update_velocitiesP15HIP_vector_typeIfLj4EEPS_IfLj2EEi, %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_end3:
	.size	_Z32__device_stub__update_velocitiesP15HIP_vector_typeIfLj4EEPS_IfLj2EEi, .Lfunc_end3-_Z32__device_stub__update_velocitiesP15HIP_vector_typeIfLj4EEPS_IfLj2EEi
	.cfi_endproc
                                        # -- End function
	.globl	_Z31__device_stub__update_positionsP15HIP_vector_typeIfLj4EEPS_IfLj2EEi # -- Begin function _Z31__device_stub__update_positionsP15HIP_vector_typeIfLj4EEPS_IfLj2EEi
	.type	_Z31__device_stub__update_positionsP15HIP_vector_typeIfLj4EEPS_IfLj2EEi,@function
_Z31__device_stub__update_positionsP15HIP_vector_typeIfLj4EEPS_IfLj2EEi: # @_Z31__device_stub__update_positionsP15HIP_vector_typeIfLj4EEPS_IfLj2EEi
	.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), %rcx
	movq	%rsi, (%rcx)
	leaq	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%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	$_Z16update_positionsP15HIP_vector_typeIfLj4EEPS_IfLj2EEi, %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_end4:
	.size	_Z31__device_stub__update_positionsP15HIP_vector_typeIfLj4EEPS_IfLj2EEi, .Lfunc_end4-_Z31__device_stub__update_positionsP15HIP_vector_typeIfLj4EEPS_IfLj2EEi
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	_Z10parse_argsiPPc
	callq	_Z12read_planetsv
	callq	_Z13write_planetsi
	xorl	%eax, %eax
	popq	%rcx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end5:
	.size	main, .Lfunc_end5-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB6_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB6_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z17update_velocitiesP15HIP_vector_typeIfLj4EEPS_IfLj2EEi, %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	$_Z16update_positionsP15HIP_vector_typeIfLj4EEPS_IfLj2EEi, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end6:
	.size	__hip_module_ctor, .Lfunc_end6-__hip_module_ctor
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_dtor
	.type	__hip_module_dtor,@function
__hip_module_dtor:                      # @__hip_module_dtor
	.cfi_startproc
# %bb.0:
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	je	.LBB7_2
# %bb.1:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	__hipUnregisterFatBinary
	movq	$0, __hip_gpubin_handle(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
.LBB7_2:
	retq
.Lfunc_end7:
	.size	__hip_module_dtor, .Lfunc_end7-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	num_planets,@object             # @num_planets
	.bss
	.globl	num_planets
	.p2align	2, 0x0
num_planets:
	.long	0                               # 0x0
	.size	num_planets, 4

	.type	num_timesteps,@object           # @num_timesteps
	.globl	num_timesteps
	.p2align	2, 0x0
num_timesteps:
	.long	0                               # 0x0
	.size	num_timesteps, 4

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

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

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

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

	.type	.L.str.1,@object                # @.str.1
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.1:
	.asciz	"planets.txt"
	.size	.L.str.1, 12

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

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"%d"
	.size	.L.str.4, 3

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"%f %f %f %f %f"
	.size	.L.str.5, 15

	.type	.L.str.6,@object                # @.str.6
	.section	.rodata.str1.16,"aMS",@progbits,1
	.p2align	4, 0x0
.L.str.6:
	.asciz	"planets_out.txt"
	.size	.L.str.6, 16

	.type	.L.str.7,@object                # @.str.7
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.7:
	.asciz	"wr+"
	.size	.L.str.7, 4

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"%f %f %f %f %f\n"
	.size	.L.str.8, 16

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

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

	.type	.L__unnamed_1,@object           # @0
	.section	.rodata.str1.1,"aMS",@progbits,1
.L__unnamed_1:
	.asciz	"_Z17update_velocitiesP15HIP_vector_typeIfLj4EEPS_IfLj2EEi"
	.size	.L__unnamed_1, 58

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z16update_positionsP15HIP_vector_typeIfLj4EEPS_IfLj2EEi"
	.size	.L__unnamed_2, 57

	.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	"Useage: nbody num_timesteps"
	.size	.Lstr, 28

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"'planets.txt' not found. Exiting"
	.size	.Lstr.1, 33

	.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 _Z32__device_stub__update_velocitiesP15HIP_vector_typeIfLj4EEPS_IfLj2EEi
	.addrsig_sym _Z31__device_stub__update_positionsP15HIP_vector_typeIfLj4EEPS_IfLj2EEi
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym num_planets
	.addrsig_sym _Z17update_velocitiesP15HIP_vector_typeIfLj4EEPS_IfLj2EEi
	.addrsig_sym _Z16update_positionsP15HIP_vector_typeIfLj4EEPS_IfLj2EEi
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z17update_velocitiesP15HIP_vector_typeIfLj4EEPS_IfLj2EEi ; -- Begin function _Z17update_velocitiesP15HIP_vector_typeIfLj4EEPS_IfLj2EEi
	.globl	_Z17update_velocitiesP15HIP_vector_typeIfLj4EEPS_IfLj2EEi
	.p2align	8
	.type	_Z17update_velocitiesP15HIP_vector_typeIfLj4EEPS_IfLj2EEi,@function
_Z17update_velocitiesP15HIP_vector_typeIfLj4EEPS_IfLj2EEi: ; @_Z17update_velocitiesP15HIP_vector_typeIfLj4EEPS_IfLj2EEi
; %bb.0:
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z17update_velocitiesP15HIP_vector_typeIfLj4EEPS_IfLj2EEi
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 20
		.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 1
		.amdhsa_next_free_sgpr 1
		.amdhsa_reserve_vcc 0
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z17update_velocitiesP15HIP_vector_typeIfLj4EEPS_IfLj2EEi, .Lfunc_end0-_Z17update_velocitiesP15HIP_vector_typeIfLj4EEPS_IfLj2EEi
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 4
; NumSgprs: 0
; NumVgprs: 0
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 0
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 1
; NumVGPRsForWavesPerEU: 1
; 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	_Z16update_positionsP15HIP_vector_typeIfLj4EEPS_IfLj2EEi ; -- Begin function _Z16update_positionsP15HIP_vector_typeIfLj4EEPS_IfLj2EEi
	.globl	_Z16update_positionsP15HIP_vector_typeIfLj4EEPS_IfLj2EEi
	.p2align	8
	.type	_Z16update_positionsP15HIP_vector_typeIfLj4EEPS_IfLj2EEi,@function
_Z16update_positionsP15HIP_vector_typeIfLj4EEPS_IfLj2EEi: ; @_Z16update_positionsP15HIP_vector_typeIfLj4EEPS_IfLj2EEi
; %bb.0:
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z16update_positionsP15HIP_vector_typeIfLj4EEPS_IfLj2EEi
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 20
		.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 1
		.amdhsa_next_free_sgpr 1
		.amdhsa_reserve_vcc 0
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end1:
	.size	_Z16update_positionsP15HIP_vector_typeIfLj4EEPS_IfLj2EEi, .Lfunc_end1-_Z16update_positionsP15HIP_vector_typeIfLj4EEPS_IfLj2EEi
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 4
; NumSgprs: 0
; NumVgprs: 0
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 0
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 1
; NumVGPRsForWavesPerEU: 1
; 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:     by_value
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 20
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z17update_velocitiesP15HIP_vector_typeIfLj4EEPS_IfLj2EEi
    .private_segment_fixed_size: 0
    .sgpr_count:     0
    .sgpr_spill_count: 0
    .symbol:         _Z17update_velocitiesP15HIP_vector_typeIfLj4EEPS_IfLj2EEi.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     0
    .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:     by_value
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 20
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z16update_positionsP15HIP_vector_typeIfLj4EEPS_IfLj2EEi
    .private_segment_fixed_size: 0
    .sgpr_count:     0
    .sgpr_spill_count: 0
    .symbol:         _Z16update_positionsP15HIP_vector_typeIfLj4EEPS_IfLj2EEi.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     0
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
