#include <stdio.h>

void check_cells(float *rx, float *ry, float *rz, int *head, int *list, int mx, int my, int mz, int natoms, int step, int pstep)
{
   int i, icell, ix, iy, iz, icount;

   icount = 0;
   for(icell=0;icell<(mx+2)*(my+2)*(mz+2);icell++){
       ix = icell%(mx+2);
       iy = (icell/(mx+2))%(my+2);
       iz = icell/((mx+2)*(my+2));
       i = head[icell];
       if(step==pstep) printf("\nCell number %d at (%d,%d,%d) contains particles:",icell,ix,iy,iz);
       while(i>=0){
           if(ix>0&&ix<(mx+1)&&iy>0&&iy<(my+1)&&iz>0&&iz<(mz+1)) icount++;
//	       if(step==pstep) {
//	           if(rx[i] < -0.5 || rx[i] > 0.5 || ry[i] < -0.5 || ry[i] > 0.5 || rz[i] < -0.5 || rz[i] > 0.5) printf("%d, r = (%f,%f,%f) ",i,rx[i],ry[i],rz[i]);
 //              }
            printf(" (%f,%f,%f);",rx[i],ry[i],rz[i]);
	    i = list[i];
	}
    }
    if (icount != natoms) printf("\nNumber of particles in cells = %d\n",icount);
}

	.file	"tmpxft_002c1b61_00000000-6_check_cells.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2030:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2030:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"\nCell number %d at (%d,%d,%d) contains particles:"
.LC1:
	.string	" (%f,%f,%f);"
.LC2:
	.string	"\nNumber of particles in cells = %d\n"
	.text
	.globl	_Z11check_cellsPfS_S_PiS0_iiiiii
	.type	_Z11check_cellsPfS_S_PiS0_iiiiii, @function
_Z11check_cellsPfS_S_PiS0_iiiiii:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	xorl	%r13d, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%r9d, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	xorl	%ebx, %ebx
	subq	$104, %rsp
	.cfi_def_cfa_offset 160
	movl	176(%rsp), %eax
	movl	160(%rsp), %r14d
	movq	%rdi, 32(%rsp)
	movl	168(%rsp), %r15d
	movq	%rsi, 40(%rsp)
	movl	%eax, 76(%rsp)
	movl	184(%rsp), %eax
	movq	%rdx, 48(%rsp)
	movl	%eax, 80(%rsp)
	movl	192(%rsp), %eax
	movq	%rcx, 56(%rsp)
	movl	%eax, 84(%rsp)
	leal	2(%r9), %eax
	movl	%eax, 24(%rsp)
	movl	24(%rsp), %r12d
	leal	2(%r14), %eax
	movl	%eax, 28(%rsp)
	imull	%eax, %r12d
	leal	2(%r15), %eax
	movq	%r8, 64(%rsp)
	imull	%r12d, %eax
	movl	%eax, 72(%rsp)
.L3:
	movl	%r13d, %esi
	cmpl	%r13d, 72(%rsp)
	jle	.L29
	movl	%esi, %eax
	movl	84(%rsp), %edi
	cltd
	idivl	24(%rsp)
	movl	%edx, 12(%rsp)
	cltd
	idivl	28(%rsp)
	movl	%esi, %eax
	movl	%edx, 16(%rsp)
	cltd
	idivl	%r12d
	movl	%eax, 20(%rsp)
	movq	56(%rsp), %rax
	movslq	(%rax,%r13,4), %r10
	cmpl	%edi, 80(%rsp)
	jne	.L5
	movl	20(%rsp), %r9d
	movl	16(%rsp), %r8d
	movl	%esi, %edx
	xorl	%eax, %eax
	movl	12(%rsp), %ecx
	movl	$2, %edi
	movl	%r10d, 88(%rsp)
	leaq	.LC0(%rip), %rsi
	call	__printf_chk@PLT
	movslq	88(%rsp), %r10
	jmp	.L5
.L7:
	cmpl	$0, 12(%rsp)
	jg	.L30
.L6:
	movq	32(%rsp), %rax
	movl	$2, %edi
	movq	%r10, 88(%rsp)
	leaq	.LC1(%rip), %rsi
	cvtss2sd	(%rax,%r10,4), %xmm0
	movq	48(%rsp), %rax
	cvtss2sd	(%rax,%r10,4), %xmm2
	movq	40(%rsp), %rax
	cvtss2sd	(%rax,%r10,4), %xmm1
	movb	$3, %al
	call	__printf_chk@PLT
	movq	64(%rsp), %rax
	movq	88(%rsp), %r10
	movslq	(%rax,%r10,4), %r10
.L5:
	testl	%r10d, %r10d
	jns	.L7
	jmp	.L31
.L30:
	movl	12(%rsp), %eax
	cmpl	%eax, %ebp
	jl	.L6
	cmpl	$0, 16(%rsp)
	jle	.L6
	movl	16(%rsp), %eax
	cmpl	%eax, %r14d
	jl	.L6
	cmpl	$0, 20(%rsp)
	jle	.L6
	movl	20(%rsp), %eax
	cmpl	%eax, %r15d
	setge	%al
	cmpb	$1, %al
	sbbl	$-1, %ebx
	jmp	.L6
.L31:
	incq	%r13
	jmp	.L3
.L29:
	movl	76(%rsp), %eax
	cmpl	%eax, %ebx
	je	.L2
	addq	$104, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	movl	%ebx, %edx
	leaq	.LC2(%rip), %rsi
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	movl	$2, %edi
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	__printf_chk@PLT
.L2:
	.cfi_restore_state
	addq	$104, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z11check_cellsPfS_S_PiS0_iiiiii, .-_Z11check_cellsPfS_S_PiS0_iiiiii
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2053:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	movq	%rax, %rdi
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2053:
	.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
	.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>

void check_cells(float *rx, float *ry, float *rz, int *head, int *list, int mx, int my, int mz, int natoms, int step, int pstep)
{
   int i, icell, ix, iy, iz, icount;

   icount = 0;
   for(icell=0;icell<(mx+2)*(my+2)*(mz+2);icell++){
       ix = icell%(mx+2);
       iy = (icell/(mx+2))%(my+2);
       iz = icell/((mx+2)*(my+2));
       i = head[icell];
       if(step==pstep) printf("\nCell number %d at (%d,%d,%d) contains particles:",icell,ix,iy,iz);
       while(i>=0){
           if(ix>0&&ix<(mx+1)&&iy>0&&iy<(my+1)&&iz>0&&iz<(mz+1)) icount++;
//	       if(step==pstep) {
//	           if(rx[i] < -0.5 || rx[i] > 0.5 || ry[i] < -0.5 || ry[i] > 0.5 || rz[i] < -0.5 || rz[i] > 0.5) printf("%d, r = (%f,%f,%f) ",i,rx[i],ry[i],rz[i]);
 //              }
            printf(" (%f,%f,%f);",rx[i],ry[i],rz[i]);
	    i = list[i];
	}
    }
    if (icount != natoms) printf("\nNumber of particles in cells = %d\n",icount);
}

	.text
	.file	"check_cells.hip"
	.globl	_Z11check_cellsPfS_S_PiS0_iiiiii # -- Begin function _Z11check_cellsPfS_S_PiS0_iiiiii
	.type	_Z11check_cellsPfS_S_PiS0_iiiiii,@function
_Z11check_cellsPfS_S_PiS0_iiiiii:       # @_Z11check_cellsPfS_S_PiS0_iiiiii
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$120, %rsp
	.cfi_def_cfa_offset 176
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
                                        # kill: def $r9d killed $r9d def $r9
	movq	%rcx, 104(%rsp)                 # 8-byte Spill
	movl	192(%rsp), %eax
	movl	%eax, 12(%rsp)                  # 4-byte Spill
	movl	184(%rsp), %ecx
	movl	176(%rsp), %r10d
	movq	%r9, %rax
	movq	%r9, 88(%rsp)                   # 8-byte Spill
	leal	2(%r9), %eax
	movq	%r10, 72(%rsp)                  # 8-byte Spill
	leal	2(%r10), %r9d
	movl	%r9d, 28(%rsp)                  # 4-byte Spill
	movl	%eax, 32(%rsp)                  # 4-byte Spill
	imull	%eax, %r9d
	movq	%rcx, 80(%rsp)                  # 8-byte Spill
	leal	2(%rcx), %eax
	movl	%r9d, 24(%rsp)                  # 4-byte Spill
	imull	%r9d, %eax
	testl	%eax, %eax
	jle	.LBB0_1
# %bb.2:                                # %.lr.ph61
	movq	%rdi, 40(%rsp)                  # 8-byte Spill
	movq	%rsi, 48(%rsp)                  # 8-byte Spill
	movq	%rdx, 56(%rsp)                  # 8-byte Spill
	movq	%r8, 64(%rsp)                   # 8-byte Spill
	movl	208(%rsp), %ecx
	movl	%ecx, 20(%rsp)                  # 4-byte Spill
	movl	200(%rsp), %ecx
	movl	%ecx, 16(%rsp)                  # 4-byte Spill
	movl	%eax, %eax
	movq	%rax, 96(%rsp)                  # 8-byte Spill
	xorl	%r14d, %r14d
	xorl	%ebx, %ebx
.LBB0_3:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_7 Depth 2
	movl	%r14d, %eax
	cltd
	idivl	32(%rsp)                        # 4-byte Folded Reload
	movl	%edx, %ebp
	cltd
	idivl	28(%rsp)                        # 4-byte Folded Reload
	movl	%edx, %r12d
	movl	%r14d, %eax
	cltd
	idivl	24(%rsp)                        # 4-byte Folded Reload
	movl	%eax, %r13d
	movq	104(%rsp), %rax                 # 8-byte Reload
	movl	(%rax,%r14,4), %r15d
	movl	16(%rsp), %eax                  # 4-byte Reload
	cmpl	20(%rsp), %eax                  # 4-byte Folded Reload
	jne	.LBB0_5
# %bb.4:                                #   in Loop: Header=BB0_3 Depth=1
	movl	$.L.str, %edi
	movl	%r14d, %esi
	movl	%ebp, %edx
	movl	%r12d, %ecx
	movl	%r13d, %r8d
	xorl	%eax, %eax
	callq	printf
.LBB0_5:                                #   in Loop: Header=BB0_3 Depth=1
	movq	%r14, 112(%rsp)                 # 8-byte Spill
	testl	%r15d, %r15d
	js	.LBB0_8
# %bb.6:                                # %.lr.ph
                                        #   in Loop: Header=BB0_3 Depth=1
	testl	%ebp, %ebp
	setne	%al
	cmpl	88(%rsp), %ebp                  # 4-byte Folded Reload
	setle	%cl
	testl	%r12d, %r12d
	setg	%dl
	andb	%cl, %dl
	cmpl	72(%rsp), %r12d                 # 4-byte Folded Reload
	setle	%cl
	testl	%r13d, %r13d
	setg	%sil
	cmpl	80(%rsp), %r13d                 # 4-byte Folded Reload
	setle	%dil
	andb	%sil, %dil
	andb	%cl, %dil
	andb	%dl, %dil
	andb	%al, %dil
	movzbl	%dil, %eax
	movl	%eax, 36(%rsp)                  # 4-byte Spill
	movq	64(%rsp), %r12                  # 8-byte Reload
	movq	56(%rsp), %r13                  # 8-byte Reload
	movq	48(%rsp), %rbp                  # 8-byte Reload
	movq	40(%rsp), %r14                  # 8-byte Reload
.LBB0_7:                                #   Parent Loop BB0_3 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	addl	36(%rsp), %ebx                  # 4-byte Folded Reload
	movl	%r15d, %r15d
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r14,%r15,4), %xmm0
	xorps	%xmm1, %xmm1
	cvtss2sd	(%rbp,%r15,4), %xmm1
	xorps	%xmm2, %xmm2
	cvtss2sd	(%r13,%r15,4), %xmm2
	movl	$.L.str.1, %edi
	movb	$3, %al
	callq	printf
	movl	(%r12,%r15,4), %r15d
	testl	%r15d, %r15d
	jns	.LBB0_7
.LBB0_8:                                # %._crit_edge
                                        #   in Loop: Header=BB0_3 Depth=1
	movq	112(%rsp), %r14                 # 8-byte Reload
	incq	%r14
	cmpq	96(%rsp), %r14                  # 8-byte Folded Reload
	jne	.LBB0_3
	jmp	.LBB0_9
.LBB0_1:
	xorl	%ebx, %ebx
.LBB0_9:                                # %._crit_edge62
	cmpl	12(%rsp), %ebx                  # 4-byte Folded Reload
	jne	.LBB0_11
# %bb.10:
	addq	$120, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB0_11:
	.cfi_def_cfa_offset 176
	movl	$.L.str.2, %edi
	movl	%ebx, %esi
	xorl	%eax, %eax
	addq	$120, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	printf                          # TAILCALL
.Lfunc_end0:
	.size	_Z11check_cellsPfS_S_PiS0_iiiiii, .Lfunc_end0-_Z11check_cellsPfS_S_PiS0_iiiiii
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"\nCell number %d at (%d,%d,%d) contains particles:"
	.size	.L.str, 50

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	" (%f,%f,%f);"
	.size	.L.str.1, 13

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"\nNumber of particles in cells = %d\n"
	.size	.L.str.2, 36

	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_

	.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_
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.amdgpu_metadata
---
amdhsa.kernels:  []
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
