#include <iostream>
#include <math.h>
#include <ctime>
#include <cmath>
#include <stdlib.h>
#include <fstream>
#include <sstream>


double density(double Xold, double  Xnew, double sigma, double r, double delta, double delta_t);

double* three_dim_index(double* matrix, int i, int j, int k, double m, int b);

double kahansum(double* sortvector, int b){
double sum=0, c=0, y, t;

        for(int i=0; i<b; i++){
                y=sortvector[i]-c;
                t=sum+y;
                c=(t-sum)-y;
                sum=t;
        }

return sum;
}


void meshweights(double* W, double m, int b, double sigma[], double delta[], double r, double delta_t, double* X, int num_assets){
double wdenominator, w;
double* sortvector;
sortvector=new double[b];

for(int I=0; I<m; I++){
	
	if(I==0){
		for(int k=0; k<b; k++){
        	
			for(int j=0; j<b; j++){

				if(j==0){
					
					*three_dim_index(W, I, k, j, m, b)=1;
				}// all weights from the starting node are equal to 1

				else{
					
					*three_dim_index(W, I, k, j, m, b)=0;
				}
			}

		}
	}


	if(I>0){

		for(int k=0; k<b; k++){	
		//dim1temp.clear();
		//sortvector.clear();

		wdenominator=0;

			for(int j=0; j<b; j++){
			//std::cout<<j<<std::endl;	
				w=1;
				//w=0; //set w to 1 since it will be equal to a product
				for(int jj=0; jj<num_assets; jj++){
				w = w * density(*three_dim_index(X, (I-1), j, jj, m, b), *three_dim_index(X, I, k, jj, m, b), sigma[jj], r, delta[jj], delta_t);

				}
			//w = exp(w);
			//dim1temp.push_back(w);
			//sortvector.push_back(w);   
			sortvector[j]=w;                                                                                                              
			}
			//std::sort(sortvector.begin(), sortvector.end());
			wdenominator=kahansum(sortvector, b);
				//devide each element by the denominator
			for(int t=0; t<b; t++){
				*three_dim_index(W, (I), k, t, m, b)=(((double)b)*(sortvector[t]))/wdenominator;
			}
		}	
	
	}


}

delete[] sortvector;
}

	.file	"tmpxft_002ba434_00000000-6_cuda_meshweights.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3827:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3827:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z8kahansumPdi
	.type	_Z8kahansumPdi, @function
_Z8kahansumPdi:
.LFB3823:
	.cfi_startproc
	endbr64
	xorps	%xmm1, %xmm1
	xorl	%eax, %eax
	movaps	%xmm1, %xmm0
.L3:
	cmpl	%eax, %esi
	jle	.L6
	movsd	(%rdi,%rax,8), %xmm2
	movaps	%xmm0, %xmm3
	incq	%rax
	subsd	%xmm1, %xmm2
	addsd	%xmm2, %xmm3
	movaps	%xmm3, %xmm1
	subsd	%xmm0, %xmm1
	movaps	%xmm3, %xmm0
	subsd	%xmm2, %xmm1
	jmp	.L3
.L6:
	ret
	.cfi_endproc
.LFE3823:
	.size	_Z8kahansumPdi, .-_Z8kahansumPdi
	.globl	_Z11meshweightsPddiS_S_ddS_i
	.type	_Z11meshweightsPddiS_S_ddS_i, @function
_Z11meshweightsPddiS_S_ddS_i:
.LFB3824:
	.cfi_startproc
	endbr64
	movabsq	$1152921504606846975, %rax
	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
	movslq	%esi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$136, %rsp
	.cfi_def_cfa_offset 192
	movq	%rdi, 24(%rsp)
	movq	%rdx, 48(%rsp)
	movq	%rcx, 56(%rsp)
	movq	%r8, 32(%rsp)
	movl	%r9d, 84(%rsp)
	movsd	%xmm0, 8(%rsp)
	movsd	%xmm1, 64(%rsp)
	movsd	%xmm2, 72(%rsp)
	cmpq	%r13, %rax
	jb	.L8
	leaq	0(,%r13,8), %rdi
	movq	%r13, %rbx
	xorl	%ebp, %ebp
	call	_Znam@PLT
	movq	%rax, 16(%rsp)
	jmp	.L9
.L8:
	call	__cxa_throw_bad_array_new_length@PLT
.L15:
	incl	%ebp
.L9:
	cvtsi2sdl	%ebp, %xmm0
	movsd	8(%rsp), %xmm3
	comisd	%xmm0, %xmm3
	jbe	.L28
	testl	%ebp, %ebp
	je	.L22
	xorl	%eax, %eax
	movl	%eax, 80(%rsp)
	jmp	.L11
.L22:
	xorl	%r12d, %r12d
.L10:
	cmpl	%ebx, %r12d
	jge	.L15
	xorl	%r14d, %r14d
.L14:
	movsd	8(%rsp), %xmm0
	movl	%ebx, %r8d
	testq	%r14, %r14
	jne	.L12
	movq	24(%rsp), %rdi
	movl	%r12d, %edx
	xorl	%ecx, %ecx
	xorl	%esi, %esi
	call	_Z15three_dim_indexPdiiidi@PLT
	movq	.LC1(%rip), %rdx
	movq	%rdx, (%rax)
	jmp	.L13
.L12:
	movq	24(%rsp), %rdi
	movl	%r14d, %ecx
	movl	%r12d, %edx
	xorl	%esi, %esi
	call	_Z15three_dim_indexPdiiidi@PLT
	movq	$0x000000000, (%rax)
.L13:
	incq	%r14
	cmpq	%r13, %r14
	jne	.L14
	incl	%r12d
	jmp	.L10
.L17:
	movq	16(%rsp), %rdi
	movl	%ebx, %esi
	xorl	%r14d, %r14d
	call	_Z8kahansumPdi
	cvtsi2sdl	%ebx, %xmm1
	movsd	%xmm0, 40(%rsp)
.L19:
	movq	16(%rsp), %rax
	movaps	%xmm1, %xmm0
	movl	80(%rsp), %edx
	movl	%r14d, %ecx
	movq	24(%rsp), %rdi
	movl	%ebx, %r8d
	movl	%ebp, %esi
	movsd	%xmm1, 88(%rsp)
	mulsd	(%rax,%r14,8), %xmm0
	divsd	40(%rsp), %xmm0
	movq	%xmm0, %r15
	movsd	8(%rsp), %xmm0
	call	_Z15three_dim_indexPdiiidi@PLT
	movsd	88(%rsp), %xmm1
	movq	%r15, (%rax)
	movq	%r14, %rax
	incq	%r14
	cmpq	%r12, %rax
	jne	.L19
	incl	80(%rsp)
.L11:
	cmpl	%ebx, 80(%rsp)
	jge	.L15
	leal	-1(%rbp), %eax
	xorl	%r12d, %r12d
	movl	%eax, 88(%rsp)
.L20:
	movl	%r12d, 40(%rsp)
	movsd	.LC1(%rip), %xmm6
	xorl	%r15d, %r15d
.L18:
	movl	%r15d, %r14d
	cmpl	%r15d, 84(%rsp)
	jle	.L29
	movq	56(%rsp), %rax
	movsd	8(%rsp), %xmm0
	movl	%ebx, %r8d
	movl	%ebp, %esi
	movl	80(%rsp), %edx
	movq	32(%rsp), %rdi
	movl	%r14d, %ecx
	movsd	%xmm6, 120(%rsp)
	movsd	(%rax,%r15,8), %xmm4
	movq	48(%rsp), %rax
	movsd	(%rax,%r15,8), %xmm2
	movsd	%xmm4, 112(%rsp)
	incq	%r15
	movsd	%xmm2, 104(%rsp)
	call	_Z15three_dim_indexPdiiidi@PLT
	movl	40(%rsp), %edx
	movl	88(%rsp), %esi
	movl	%ebx, %r8d
	movsd	(%rax), %xmm1
	movsd	8(%rsp), %xmm0
	movl	%r14d, %ecx
	movq	32(%rsp), %rdi
	movsd	%xmm1, 96(%rsp)
	call	_Z15three_dim_indexPdiiidi@PLT
	movsd	72(%rsp), %xmm5
	movsd	112(%rsp), %xmm4
	movsd	64(%rsp), %xmm3
	movsd	104(%rsp), %xmm2
	movsd	96(%rsp), %xmm1
	movsd	(%rax), %xmm0
	call	_Z7densitydddddd@PLT
	movsd	120(%rsp), %xmm6
	mulsd	%xmm0, %xmm6
	jmp	.L18
.L29:
	movq	16(%rsp), %rax
	movsd	%xmm6, (%rax,%r12,8)
	leaq	1(%r12), %rax
	cmpq	%rax, %r13
	je	.L17
	movq	%rax, %r12
	jmp	.L20
.L28:
	movq	16(%rsp), %rdi
	addq	$136, %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
	jmp	_ZdaPv@PLT
	.cfi_endproc
.LFE3824:
	.size	_Z11meshweightsPddiS_S_ddS_i, .-_Z11meshweightsPddiS_S_ddS_i
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3850:
	.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
.LFE3850:
	.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	1072693248
	.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 <iostream>
#include <math.h>
#include <ctime>
#include <cmath>
#include <stdlib.h>
#include <fstream>
#include <sstream>


double density(double Xold, double  Xnew, double sigma, double r, double delta, double delta_t);

double* three_dim_index(double* matrix, int i, int j, int k, double m, int b);

double kahansum(double* sortvector, int b){
double sum=0, c=0, y, t;

        for(int i=0; i<b; i++){
                y=sortvector[i]-c;
                t=sum+y;
                c=(t-sum)-y;
                sum=t;
        }

return sum;
}


void meshweights(double* W, double m, int b, double sigma[], double delta[], double r, double delta_t, double* X, int num_assets){
double wdenominator, w;
double* sortvector;
sortvector=new double[b];

for(int I=0; I<m; I++){
	
	if(I==0){
		for(int k=0; k<b; k++){
        	
			for(int j=0; j<b; j++){

				if(j==0){
					
					*three_dim_index(W, I, k, j, m, b)=1;
				}// all weights from the starting node are equal to 1

				else{
					
					*three_dim_index(W, I, k, j, m, b)=0;
				}
			}

		}
	}


	if(I>0){

		for(int k=0; k<b; k++){	
		//dim1temp.clear();
		//sortvector.clear();

		wdenominator=0;

			for(int j=0; j<b; j++){
			//std::cout<<j<<std::endl;	
				w=1;
				//w=0; //set w to 1 since it will be equal to a product
				for(int jj=0; jj<num_assets; jj++){
				w = w * density(*three_dim_index(X, (I-1), j, jj, m, b), *three_dim_index(X, I, k, jj, m, b), sigma[jj], r, delta[jj], delta_t);

				}
			//w = exp(w);
			//dim1temp.push_back(w);
			//sortvector.push_back(w);   
			sortvector[j]=w;                                                                                                              
			}
			//std::sort(sortvector.begin(), sortvector.end());
			wdenominator=kahansum(sortvector, b);
				//devide each element by the denominator
			for(int t=0; t<b; t++){
				*three_dim_index(W, (I), k, t, m, b)=(((double)b)*(sortvector[t]))/wdenominator;
			}
		}	
	
	}


}

delete[] sortvector;
}

	.text
	.file	"cuda_meshweights.hip"
                                        # Start of file scope inline assembly
	.globl	_ZSt21ios_base_library_initv

                                        # End of file scope inline assembly
	.globl	_Z8kahansumPdi                  # -- Begin function _Z8kahansumPdi
	.type	_Z8kahansumPdi,@function
_Z8kahansumPdi:                         # @_Z8kahansumPdi
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	jle	.LBB0_1
# %bb.3:                                # %.lr.ph.preheader
	movl	%esi, %eax
	xorpd	%xmm1, %xmm1
	xorl	%ecx, %ecx
	xorpd	%xmm2, %xmm2
	xorpd	%xmm0, %xmm0
.LBB0_4:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movsd	(%rdi,%rcx,8), %xmm3            # xmm3 = mem[0],zero
	subsd	%xmm2, %xmm3
	addsd	%xmm3, %xmm0
	movapd	%xmm0, %xmm2
	subsd	%xmm1, %xmm2
	subsd	%xmm3, %xmm2
	incq	%rcx
	movapd	%xmm0, %xmm1
	cmpq	%rcx, %rax
	jne	.LBB0_4
# %bb.2:                                # %._crit_edge
	retq
.LBB0_1:
	xorps	%xmm0, %xmm0
	retq
.Lfunc_end0:
	.size	_Z8kahansumPdi, .Lfunc_end0-_Z8kahansumPdi
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z11meshweightsPddiS_S_ddS_i
.LCPI1_0:
	.quad	0x3ff0000000000000              # double 1
	.text
	.globl	_Z11meshweightsPddiS_S_ddS_i
	.type	_Z11meshweightsPddiS_S_ddS_i,@function
_Z11meshweightsPddiS_S_ddS_i:           # @_Z11meshweightsPddiS_S_ddS_i
	.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	$136, %rsp
	.cfi_def_cfa_offset 192
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%r9d, 24(%rsp)                  # 4-byte Spill
	movq	%r8, 96(%rsp)                   # 8-byte Spill
	movsd	%xmm2, 128(%rsp)                # 8-byte Spill
	movsd	%xmm1, 120(%rsp)                # 8-byte Spill
	movq	%rcx, 112(%rsp)                 # 8-byte Spill
	movq	%rdx, 104(%rsp)                 # 8-byte Spill
	movl	%esi, %ebp
	movsd	%xmm0, (%rsp)                   # 8-byte Spill
	movq	%rdi, %r13
	movl	%esi, %ebx
	leaq	(,%rbx,8), %rax
	testl	%esi, %esi
	movq	$-1, %rdi
	cmovnsq	%rax, %rdi
	callq	_Znam
	movq	%rax, %r15
	xorpd	%xmm0, %xmm0
	movsd	(%rsp), %xmm1                   # 8-byte Reload
                                        # xmm1 = mem[0],zero
	ucomisd	%xmm0, %xmm1
	jbe	.LBB1_23
# %bb.1:                                # %.lr.ph99
	xorps	%xmm1, %xmm1
	cvtsi2sd	%ebp, %xmm1
	movsd	%xmm1, 80(%rsp)                 # 8-byte Spill
	movl	24(%rsp), %eax                  # 4-byte Reload
	movq	%rax, 72(%rsp)                  # 8-byte Spill
	xorl	%r14d, %r14d
	movq	%rbx, 88(%rsp)                  # 8-byte Spill
	movq	%r15, 48(%rsp)                  # 8-byte Spill
	movq	%r13, 64(%rsp)                  # 8-byte Spill
	movl	%ebp, 28(%rsp)                  # 4-byte Spill
.LBB1_2:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_12 Depth 2
                                        #       Child Loop BB1_13 Depth 3
                                        #         Child Loop BB1_15 Depth 4
                                        #       Child Loop BB1_18 Depth 3
                                        #       Child Loop BB1_20 Depth 3
                                        #     Child Loop BB1_5 Depth 2
                                        #       Child Loop BB1_6 Depth 3
	testl	%r14d, %r14d
	je	.LBB1_3
# %bb.10:                               #   in Loop: Header=BB1_2 Depth=1
	testl	%ebp, %ebp
	jle	.LBB1_22
# %bb.11:                               # %.preheader80.lr.ph
                                        #   in Loop: Header=BB1_2 Depth=1
	leal	-1(%r14), %eax
	movl	%eax, 44(%rsp)                  # 4-byte Spill
	xorl	%ecx, %ecx
	movq	%r14, 56(%rsp)                  # 8-byte Spill
.LBB1_12:                               # %.preheader80
                                        #   Parent Loop BB1_2 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB1_13 Depth 3
                                        #         Child Loop BB1_15 Depth 4
                                        #       Child Loop BB1_18 Depth 3
                                        #       Child Loop BB1_20 Depth 3
	movl	%ecx, 20(%rsp)                  # 4-byte Spill
	xorl	%r12d, %r12d
.LBB1_13:                               # %.preheader
                                        #   Parent Loop BB1_2 Depth=1
                                        #     Parent Loop BB1_12 Depth=2
                                        # =>    This Loop Header: Depth=3
                                        #         Child Loop BB1_15 Depth 4
	movsd	.LCPI1_0(%rip), %xmm0           # xmm0 = mem[0],zero
	cmpl	$0, 24(%rsp)                    # 4-byte Folded Reload
	movsd	(%rsp), %xmm1                   # 8-byte Reload
                                        # xmm1 = mem[0],zero
	movq	72(%rsp), %r15                  # 8-byte Reload
	movq	96(%rsp), %rbp                  # 8-byte Reload
	movl	28(%rsp), %ebx                  # 4-byte Reload
	movl	20(%rsp), %r14d                 # 4-byte Reload
	jle	.LBB1_16
# %bb.14:                               # %.lr.ph88.preheader
                                        #   in Loop: Header=BB1_13 Depth=3
	xorl	%r13d, %r13d
	movsd	.LCPI1_0(%rip), %xmm0           # xmm0 = mem[0],zero
.LBB1_15:                               # %.lr.ph88
                                        #   Parent Loop BB1_2 Depth=1
                                        #     Parent Loop BB1_12 Depth=2
                                        #       Parent Loop BB1_13 Depth=3
                                        # =>      This Inner Loop Header: Depth=4
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
	movq	%rbp, %rdi
	movl	44(%rsp), %esi                  # 4-byte Reload
	movl	%r12d, %edx
	movl	%r13d, %ecx
	movapd	%xmm1, %xmm0
	movl	%ebx, %r8d
	callq	_Z15three_dim_indexPdiiidi
	movsd	(%rax), %xmm0                   # xmm0 = mem[0],zero
	movsd	%xmm0, 32(%rsp)                 # 8-byte Spill
	movq	%rbp, %rdi
	movq	56(%rsp), %rsi                  # 8-byte Reload
                                        # kill: def $esi killed $esi killed $rsi
	movl	%r14d, %edx
	movl	%r13d, %ecx
	movsd	(%rsp), %xmm0                   # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movl	%ebx, %r8d
	callq	_Z15three_dim_indexPdiiidi
	movsd	(%rax), %xmm1                   # xmm1 = mem[0],zero
	movq	104(%rsp), %rax                 # 8-byte Reload
	movsd	(%rax,%r13,8), %xmm2            # xmm2 = mem[0],zero
	movq	112(%rsp), %rax                 # 8-byte Reload
	movsd	(%rax,%r13,8), %xmm4            # xmm4 = mem[0],zero
	movsd	32(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movsd	120(%rsp), %xmm3                # 8-byte Reload
                                        # xmm3 = mem[0],zero
	movsd	128(%rsp), %xmm5                # 8-byte Reload
                                        # xmm5 = mem[0],zero
	callq	_Z7densitydddddd
	movsd	8(%rsp), %xmm1                  # 8-byte Reload
                                        # xmm1 = mem[0],zero
	mulsd	%xmm0, %xmm1
	movsd	%xmm1, 8(%rsp)                  # 8-byte Spill
	movsd	(%rsp), %xmm1                   # 8-byte Reload
                                        # xmm1 = mem[0],zero
	movsd	8(%rsp), %xmm0                  # 8-byte Reload
                                        # xmm0 = mem[0],zero
	incq	%r13
	cmpq	%r13, %r15
	jne	.LBB1_15
.LBB1_16:                               # %._crit_edge89
                                        #   in Loop: Header=BB1_13 Depth=3
	movq	48(%rsp), %r15                  # 8-byte Reload
	movsd	%xmm0, (%r15,%r12,8)
	incq	%r12
	movq	88(%rsp), %rbx                  # 8-byte Reload
	cmpq	%rbx, %r12
	jne	.LBB1_13
# %bb.17:                               # %.lr.ph.i.preheader
                                        #   in Loop: Header=BB1_12 Depth=2
	xorpd	%xmm3, %xmm3
	xorl	%eax, %eax
	xorpd	%xmm0, %xmm0
.LBB1_18:                               # %.lr.ph.i
                                        #   Parent Loop BB1_2 Depth=1
                                        #     Parent Loop BB1_12 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movapd	%xmm3, %xmm1
	movsd	(%r15,%rax,8), %xmm2            # xmm2 = mem[0],zero
	subsd	%xmm0, %xmm2
	addsd	%xmm2, %xmm3
	movapd	%xmm3, %xmm0
	subsd	%xmm1, %xmm0
	subsd	%xmm2, %xmm0
	incq	%rax
	cmpq	%rax, %rbx
	jne	.LBB1_18
# %bb.19:                               # %.lr.ph93.preheader
                                        #   in Loop: Header=BB1_12 Depth=2
	xorl	%r12d, %r12d
	movq	64(%rsp), %r13                  # 8-byte Reload
	movl	28(%rsp), %ebp                  # 4-byte Reload
	movq	56(%rsp), %r14                  # 8-byte Reload
	movsd	%xmm3, 32(%rsp)                 # 8-byte Spill
.LBB1_20:                               # %.lr.ph93
                                        #   Parent Loop BB1_2 Depth=1
                                        #     Parent Loop BB1_12 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movsd	(%r15,%r12,8), %xmm0            # xmm0 = mem[0],zero
	mulsd	80(%rsp), %xmm0                 # 8-byte Folded Reload
	divsd	%xmm3, %xmm0
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
	movq	%r13, %rdi
	movl	%r14d, %esi
	movl	20(%rsp), %edx                  # 4-byte Reload
	movl	%r12d, %ecx
	movsd	(%rsp), %xmm0                   # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movl	%ebp, %r8d
	callq	_Z15three_dim_indexPdiiidi
	movsd	32(%rsp), %xmm3                 # 8-byte Reload
                                        # xmm3 = mem[0],zero
	movl	20(%rsp), %ecx                  # 4-byte Reload
	movsd	8(%rsp), %xmm0                  # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movsd	%xmm0, (%rax)
	incq	%r12
	cmpq	%r12, %rbx
	jne	.LBB1_20
# %bb.21:                               # %._crit_edge94
                                        #   in Loop: Header=BB1_12 Depth=2
	incl	%ecx
	cmpl	%ebx, %ecx
	jne	.LBB1_12
	jmp	.LBB1_22
.LBB1_3:                                # %.preheader82
                                        #   in Loop: Header=BB1_2 Depth=1
	testl	%ebp, %ebp
	jle	.LBB1_22
# %bb.4:                                # %.preheader81.preheader
                                        #   in Loop: Header=BB1_2 Depth=1
	xorl	%ebx, %ebx
.LBB1_5:                                # %.preheader81
                                        #   Parent Loop BB1_2 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB1_6 Depth 3
	xorl	%r15d, %r15d
.LBB1_6:                                #   Parent Loop BB1_2 Depth=1
                                        #     Parent Loop BB1_5 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movsd	.LCPI1_0(%rip), %xmm1           # xmm1 = mem[0],zero
	testl	%r15d, %r15d
	movsd	(%rsp), %xmm0                   # 8-byte Reload
                                        # xmm0 = mem[0],zero
	je	.LBB1_8
# %bb.7:                                #   in Loop: Header=BB1_6 Depth=3
	xorpd	%xmm1, %xmm1
.LBB1_8:                                #   in Loop: Header=BB1_6 Depth=3
	movsd	%xmm1, 8(%rsp)                  # 8-byte Spill
	movq	%r13, %rdi
	xorl	%esi, %esi
	movl	%ebx, %edx
	movl	%r15d, %ecx
	movl	%ebp, %r8d
	callq	_Z15three_dim_indexPdiiidi
	movsd	8(%rsp), %xmm0                  # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movsd	%xmm0, (%rax)
	incl	%r15d
	cmpl	%r15d, %ebp
	jne	.LBB1_6
# %bb.9:                                # %._crit_edge
                                        #   in Loop: Header=BB1_5 Depth=2
	incl	%ebx
	cmpl	%ebp, %ebx
	movq	48(%rsp), %r15                  # 8-byte Reload
	jne	.LBB1_5
.LBB1_22:                               # %._crit_edge85
                                        #   in Loop: Header=BB1_2 Depth=1
	incl	%r14d
	xorps	%xmm0, %xmm0
	cvtsi2sd	%r14d, %xmm0
	movsd	(%rsp), %xmm1                   # 8-byte Reload
                                        # xmm1 = mem[0],zero
	ucomisd	%xmm0, %xmm1
	ja	.LBB1_2
.LBB1_23:                               # %._crit_edge100
	movq	%r15, %rdi
	addq	$136, %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	_ZdaPv                          # TAILCALL
.Lfunc_end1:
	.size	_Z11meshweightsPddiS_S_ddS_i, .Lfunc_end1-_Z11meshweightsPddiS_S_ddS_i
	.cfi_endproc
                                        # -- End function
	.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
