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


/* Function prototypes */

float ran2(long *);


void condini(long n, long *idum, double p0, double theta0, double r[], double p[])
{

   long i;
   double lt,ptot;
 
   lt=0.0; 
   for (i=0;i<n;i++)
       {
       r[i]=((double) ran2(idum))*theta0;
       p[i]=(((double) ran2(idum))-0.5)*p0;
       lt+=p[i];
       };
   lt=lt/((double) n);

   ptot=0.0;
   for (i=0;i<n;i++)
       {
       p[i]=p[i]-lt;
       ptot+=p[i];     
       };

   printf("Total initial momentum: %lf\n",ptot);

   return;
}

	.file	"tmpxft_0023a095_00000000-6_condini.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
.LC2:
	.string	"Total initial momentum: %lf\n"
	.text
	.globl	_Z7condinilPlddPdS0_
	.type	_Z7condinilPlddPdS0_, @function
_Z7condinilPlddPdS0_:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	xorl	%r14d, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movq	%rcx, %r13
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movq	%rdx, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movq	%rsi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movq	%rdi, %rbx
	subq	$32, %rsp
	.cfi_def_cfa_offset 80
	movsd	%xmm1, 16(%rsp)
	xorps	%xmm1, %xmm1
	movsd	%xmm0, 8(%rsp)
.L3:
	cmpq	%rbx, %r14
	jge	.L9
	movq	%rbp, %rdi
	movsd	%xmm1, 24(%rsp)
	call	_Z4ran2Pl@PLT
	movq	%rbp, %rdi
	cvtss2sd	%xmm0, %xmm0
	mulsd	16(%rsp), %xmm0
	movsd	%xmm0, (%r12,%r14,8)
	call	_Z4ran2Pl@PLT
	movsd	24(%rsp), %xmm1
	cvtss2sd	%xmm0, %xmm0
	subsd	.LC1(%rip), %xmm0
	mulsd	8(%rsp), %xmm0
	movsd	%xmm0, 0(%r13,%r14,8)
	addsd	%xmm0, %xmm1
	incq	%r14
	jmp	.L3
.L9:
	cvtsi2sdq	%rbx, %xmm0
	xorps	%xmm2, %xmm2
	xorl	%eax, %eax
	divsd	%xmm0, %xmm1
.L5:
	cmpq	%rbx, %rax
	jge	.L10
	movsd	0(%r13,%rax,8), %xmm0
	subsd	%xmm1, %xmm0
	movsd	%xmm0, 0(%r13,%rax,8)
	addsd	%xmm0, %xmm2
	incq	%rax
	jmp	.L5
.L10:
	addq	$32, %rsp
	.cfi_def_cfa_offset 48
	movaps	%xmm2, %xmm0
	leaq	.LC2(%rip), %rsi
	movb	$1, %al
	popq	%rbx
	.cfi_def_cfa_offset 40
	movl	$2, %edi
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE2027:
	.size	_Z7condinilPlddPdS0_, .-_Z7condinilPlddPdS0_
	.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
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC1:
	.long	0
	.long	1071644672
	.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 <stdlib.h>
#include <math.h>
#include <stdio.h>


/* Function prototypes */

float ran2(long *);


void condini(long n, long *idum, double p0, double theta0, double r[], double p[])
{

   long i;
   double lt,ptot;
 
   lt=0.0; 
   for (i=0;i<n;i++)
       {
       r[i]=((double) ran2(idum))*theta0;
       p[i]=(((double) ran2(idum))-0.5)*p0;
       lt+=p[i];
       };
   lt=lt/((double) n);

   ptot=0.0;
   for (i=0;i<n;i++)
       {
       p[i]=p[i]-lt;
       ptot+=p[i];     
       };

   printf("Total initial momentum: %lf\n",ptot);

   return;
}

	.text
	.file	"condini.hip"
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z7condinilPlddPdS0_
.LCPI0_0:
	.quad	0xbfe0000000000000              # double -0.5
	.text
	.globl	_Z7condinilPlddPdS0_
	.type	_Z7condinilPlddPdS0_,@function
_Z7condinilPlddPdS0_:                   # @_Z7condinilPlddPdS0_
	.cfi_startproc
# %bb.0:
	testq	%rdi, %rdi
	jle	.LBB0_1
# %bb.3:                                # %.lr.ph.preheader
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$32, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rcx, %rbx
	movq	%rdx, %r15
	movaps	%xmm0, %xmm3
	movq	%rsi, %r12
	movq	%rdi, %r14
	xorpd	%xmm2, %xmm2
	xorl	%r13d, %r13d
	movsd	%xmm1, 8(%rsp)                  # 8-byte Spill
	movsd	%xmm0, 16(%rsp)                 # 8-byte Spill
.LBB0_4:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movsd	%xmm2, 24(%rsp)                 # 8-byte Spill
	movq	%r12, %rdi
	callq	_Z4ran2Pl
	cvtss2sd	%xmm0, %xmm0
	mulsd	8(%rsp), %xmm0                  # 8-byte Folded Reload
	movsd	%xmm0, (%r15,%r13,8)
	movq	%r12, %rdi
	callq	_Z4ran2Pl
	movsd	16(%rsp), %xmm3                 # 8-byte Reload
                                        # xmm3 = mem[0],zero
	movsd	24(%rsp), %xmm2                 # 8-byte Reload
                                        # xmm2 = mem[0],zero
	cvtss2sd	%xmm0, %xmm0
	addsd	.LCPI0_0(%rip), %xmm0
	mulsd	%xmm3, %xmm0
	movsd	%xmm0, (%rbx,%r13,8)
	addsd	%xmm0, %xmm2
	incq	%r13
	cmpq	%r13, %r14
	jne	.LBB0_4
# %bb.5:                                # %._crit_edge
	testq	%r14, %r14
	jle	.LBB0_6
# %bb.7:                                # %.lr.ph35.preheader
	xorps	%xmm0, %xmm0
	cvtsi2sd	%r14, %xmm0
	divsd	%xmm0, %xmm2
	xorpd	%xmm0, %xmm0
	xorl	%eax, %eax
.LBB0_8:                                # %.lr.ph35
                                        # =>This Inner Loop Header: Depth=1
	movsd	(%rbx,%rax,8), %xmm1            # xmm1 = mem[0],zero
	subsd	%xmm2, %xmm1
	movsd	%xmm1, (%rbx,%rax,8)
	addsd	%xmm1, %xmm0
	incq	%rax
	cmpq	%rax, %r14
	jne	.LBB0_8
	jmp	.LBB0_9
.LBB0_1:
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r12
	.cfi_restore %r13
	.cfi_restore %r14
	.cfi_restore %r15
	xorpd	%xmm0, %xmm0
	jmp	.LBB0_2
.LBB0_6:
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	xorps	%xmm0, %xmm0
.LBB0_9:
	addq	$32, %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
	.cfi_restore %rbx
	.cfi_restore %r12
	.cfi_restore %r13
	.cfi_restore %r14
	.cfi_restore %r15
.LBB0_2:                                # %._crit_edge36
	movl	$.L.str, %edi
	movb	$1, %al
	jmp	printf                          # TAILCALL
.Lfunc_end0:
	.size	_Z7condinilPlddPdS0_, .Lfunc_end0-_Z7condinilPlddPdS0_
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Total initial momentum: %lf\n"
	.size	.L.str, 29

	.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
