
#include<stdio.h>
#include<math.h>
const int lena = 83;
const int lenb = 1543;
float a[ lena ], b[ lenb ], x[ lena ], xnew[ lena ], tau[ lenb ];
int De[ lena * lenb ];
int tDe[ lenb * lena ];

inline float sum(float* a, const int lena) {
  float res = *a;
  for(int i = 1; i < lena; ++i) {
    res += a[ i ];
  }
  return res;
}
void transpose(int* tm, int* m, const int nrow, const int ncol) {
  for(int i = 0; i < nrow; ++i) {
    for(int j = 0; j < ncol; ++j) {
      tm[ j * nrow + i ] = m[ i * ncol + j ];
    }
  }
}
float M_v(int* M, int row, float* v, const int len) {
  float res = 0.;
  int* p = M + row * len;
  for(int i = 0; i < len; ++i) {
    if(*p++) res += v[ i ];
  }
  return res;
}


void cpuweaver(float tol) {
  float sa = sum(a, lena);
  for(int i = 0; i < lena; ++i) x[ i ] = a[ i ] / sa;
  float m = sa + sum(b, lenb);

  int iter = 0;
  float e = 999, tmp;
  for(iter = 0; e > 1e-15; ++iter) {
    for(int j = 0; j < lenb; ++j) {
      tau[ j ] = b[ j ] / M_v(tDe, j, x, lena);
    }
    for(int i = 0; i < lena; ++i) {
      xnew[ i ] = a[ i ] / (m - M_v(De, i, tau, lenb));
    }
    e = 0.;
    for(int i = 0; i < lena; ++i) {
      tmp = fabs(xnew[ i ] - x[ i ]);
      if(e < tmp) e = tmp;
    };
    for(int i = 0; i < lena; ++i) {
      x[ i ] = xnew[ i ];
    }
  }
}


void test_weaver() {
  FILE* fp;
  //load a
  fp = fopen("C:/Users/easttiger/Dropbox/Subjects/W/Weaver Paper Reading list/Hunter matlab code/a.txt", "r");
  for(int i = 0; i < lena; ++i) {
    fscanf(fp, "%f\n", a + i);
  }
  fclose(fp);
  //load b
  fp = fopen("C:/Users/easttiger/Dropbox/Subjects/W/Weaver Paper Reading list/Hunter matlab code/b.txt", "r");
  for(int i = 0; i < lenb; ++i) {
    fscanf(fp, "%f\n", b + i);
  }
  fclose(fp);
  //load b
  fp = fopen("C:/Users/easttiger/Dropbox/Subjects/W/Weaver Paper Reading list/Hunter matlab code/tDe.txt", "r");
  for(int j = 0; j < lenb; ++j) {
    for(int i = 0; i < lena - 1; ++i) {
      fscanf(fp, "%d ", tDe + j * lena + i);
    }
    fscanf(fp, "%d\n", tDe + (j + 1) * lena - 1);
  }
  fclose(fp);

  //initialize De as transpose of tDe
  transpose(De, tDe, lenb, lena);


  cpuweaver(0.00000001);
  for(int i = 0; i < lena; ++i) {
    printf("%f,", x[ i ]);
  }
}
	.file	"tmpxft_00301168_00000000-6_weaver.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2034:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2034:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z9transposePiS_ii
	.type	_Z9transposePiS_ii, @function
_Z9transposePiS_ii:
.LFB2028:
	.cfi_startproc
	endbr64
	movslq	%edx, %r11
	xorl	%r10d, %r10d
	movq	%rsi, %r8
	xorl	%r9d, %r9d
	salq	$2, %r11
	cmpl	%edx, %r10d
	jl	.L11
	ret
.L11:
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
.L9:
	movslq	%r9d, %rax
	movq	%rdi, %rsi
	leaq	(%r8,%rax,4), %rbx
	xorl	%eax, %eax
.L6:
	cmpl	%eax, %ecx
	jle	.L13
	movl	(%rbx,%rax,4), %r14d
	incq	%rax
	movl	%r14d, (%rsi)
	addq	%r11, %rsi
	jmp	.L6
.L13:
	incl	%r10d
	addq	$4, %rdi
	addl	%ecx, %r9d
	cmpl	%edx, %r10d
	jl	.L9
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z9transposePiS_ii, .-_Z9transposePiS_ii
	.globl	_Z3M_vPiiPfi
	.type	_Z3M_vPiiPfi, @function
_Z3M_vPiiPfi:
.LFB2029:
	.cfi_startproc
	endbr64
	imull	%ecx, %esi
	xorl	%eax, %eax
	xorps	%xmm0, %xmm0
	movslq	%esi, %rsi
	leaq	(%rdi,%rsi,4), %rsi
.L15:
	cmpl	%eax, %ecx
	jle	.L18
	cmpl	$0, (%rsi,%rax,4)
	je	.L16
	addss	(%rdx,%rax,4), %xmm0
.L16:
	incq	%rax
	jmp	.L15
.L18:
	ret
	.cfi_endproc
.LFE2029:
	.size	_Z3M_vPiiPfi, .-_Z3M_vPiiPfi
	.globl	_Z9cpuweaverf
	.type	_Z9cpuweaverf, @function
_Z9cpuweaverf:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	a(%rip), %rax
	movss	a(%rip), %xmm0
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	leaq	328(%rax), %rdx
	movq	%rax, %r14
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
.L20:
	addss	4(%rax), %xmm0
	addq	$4, %rax
	cmpq	%rax, %rdx
	jne	.L20
	leaq	x(%rip), %r9
	xorl	%eax, %eax
	movq	%r9, %r11
.L21:
	movss	(%r14,%rax), %xmm1
	divss	%xmm0, %xmm1
	movss	%xmm1, (%r9,%rax)
	addq	$4, %rax
	cmpq	$332, %rax
	jne	.L21
	leaq	b(%rip), %rax
	movss	b(%rip), %xmm1
	leaq	6168(%rax), %rdx
	movq	%rax, %rbp
.L22:
	addss	4(%rax), %xmm1
	addq	$4, %rax
	cmpq	%rax, %rdx
	jne	.L22
	addss	%xmm0, %xmm1
	movsd	.LC3(%rip), %xmm3
	movss	.LC1(%rip), %xmm0
	leaq	tDe(%rip), %r12
	leaq	tau(%rip), %rbx
	leaq	De(%rip), %r13
	movss	.LC2(%rip), %xmm4
	leaq	xnew(%rip), %r10
.L23:
	cvtss2sd	%xmm0, %xmm0
	comisd	%xmm3, %xmm0
	jbe	.L37
	xorl	%r8d, %r8d
.L24:
	movss	0(%rbp,%r8,4), %xmm2
	movl	%r8d, %esi
	movq	%r9, %rdx
	movq	%r12, %rdi
	movl	$83, %ecx
	call	_Z3M_vPiiPfi
	divss	%xmm0, %xmm2
	movss	%xmm2, (%rbx,%r8,4)
	incq	%r8
	cmpq	$1543, %r8
	jne	.L24
	xorl	%r8d, %r8d
.L25:
	movl	%r8d, %esi
	movl	$1543, %ecx
	movq	%rbx, %rdx
	movq	%r13, %rdi
	call	_Z3M_vPiiPfi
	movss	(%r14,%r8,4), %xmm2
	movaps	%xmm0, %xmm5
	movaps	%xmm1, %xmm0
	subss	%xmm5, %xmm0
	divss	%xmm0, %xmm2
	movss	%xmm2, (%r10,%r8,4)
	incq	%r8
	cmpq	$83, %r8
	jne	.L25
	xorl	%eax, %eax
	xorps	%xmm0, %xmm0
.L27:
	movss	(%r10,%rax), %xmm2
	subss	(%r9,%rax), %xmm2
	addq	$4, %rax
	andps	%xmm4, %xmm2
	maxss	%xmm0, %xmm2
	movaps	%xmm2, %xmm0
	cmpq	$332, %rax
	jne	.L27
	movl	$83, %ecx
	movq	%r11, %rdi
	movq	%r10, %rsi
	rep movsl
	jmp	.L23
.L37:
	popq	%rbx
	.cfi_def_cfa_offset 40
	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
	ret
	.cfi_endproc
.LFE2030:
	.size	_Z9cpuweaverf, .-_Z9cpuweaverf
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC6:
	.string	"r"
.LC7:
	.string	"C:/Users/easttiger/Dropbox/Subjects/W/Weaver Paper Reading list/Hunter matlab code/a.txt"
.LC8:
	.string	"%f\n"
.LC9:
	.string	"C:/Users/easttiger/Dropbox/Subjects/W/Weaver Paper Reading list/Hunter matlab code/b.txt"
.LC10:
	.string	"C:/Users/easttiger/Dropbox/Subjects/W/Weaver Paper Reading list/Hunter matlab code/tDe.txt"
.LC11:
	.string	"%d "
.LC12:
	.string	"%d\n"
.LC14:
	.string	"%f,"
	.text
	.globl	_Z11test_weaverv
	.type	_Z11test_weaverv, @function
_Z11test_weaverv:
.LFB2031:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC7(%rip), %rdi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	.LC8(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	.LC6(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r12, %rsi
	leaq	a(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	332(%rbp), %r14
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	call	fopen@PLT
	movq	%rax, %rbx
.L39:
	movq	%rbp, %rdx
	movq	%r13, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc23_fscanf@PLT
	addq	$4, %rbp
	cmpq	%r14, %rbp
	jne	.L39
	movq	%rbx, %rdi
	leaq	b(%rip), %rbp
	call	fclose@PLT
	movq	%r12, %rsi
	leaq	.LC9(%rip), %rdi
	leaq	6172(%rbp), %r14
	call	fopen@PLT
	movq	%rax, %rbx
.L40:
	movq	%rbp, %rdx
	movq	%r13, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc23_fscanf@PLT
	addq	$4, %rbp
	cmpq	%r14, %rbp
	jne	.L40
	movq	%rbx, %rdi
	leaq	tDe(%rip), %rbp
	xorl	%r13d, %r13d
	call	fclose@PLT
	movq	%r12, %rsi
	movq	%rbp, %r14
	leaq	.LC10(%rip), %rdi
	call	fopen@PLT
	leaq	.LC11(%rip), %r15
	movq	%rax, 8(%rsp)
.L41:
	movq	%rbp, %rbx
	movl	$82, %r12d
.L42:
	movq	8(%rsp), %rdi
	movq	%rbx, %rdx
	movq	%r15, %rsi
	xorl	%eax, %eax
	addq	$4, %rbx
	call	__isoc23_fscanf@PLT
	decl	%r12d
	jne	.L42
	movq	8(%rsp), %rdi
	leaq	328(%rbp), %rdx
	xorl	%eax, %eax
	addq	$83, %r13
	leaq	.LC12(%rip), %rsi
	addq	$332, %rbp
	call	__isoc23_fscanf@PLT
	cmpq	$128069, %r13
	jne	.L41
	movq	8(%rsp), %rdi
	leaq	x(%rip), %rbx
	leaq	.LC14(%rip), %r12
	leaq	332(%rbx), %rbp
	call	fclose@PLT
	movl	$83, %ecx
	movq	%r14, %rsi
	movl	$1543, %edx
	leaq	De(%rip), %rdi
	call	_Z9transposePiS_ii
	movss	.LC13(%rip), %xmm0
	call	_Z9cpuweaverf
.L44:
	cvtss2sd	(%rbx), %xmm0
	movq	%r12, %rsi
	movl	$2, %edi
	movb	$1, %al
	call	__printf_chk@PLT
	addq	$4, %rbx
	cmpq	%rbp, %rbx
	jne	.L44
	addq	$24, %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
.LFE2031:
	.size	_Z11test_weaverv, .-_Z11test_weaverv
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2057:
	.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
.LFE2057:
	.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	tDe
	.bss
	.align 32
	.type	tDe, @object
	.size	tDe, 512276
tDe:
	.zero	512276
	.globl	De
	.align 32
	.type	De, @object
	.size	De, 512276
De:
	.zero	512276
	.globl	tau
	.align 32
	.type	tau, @object
	.size	tau, 6172
tau:
	.zero	6172
	.globl	xnew
	.align 32
	.type	xnew, @object
	.size	xnew, 332
xnew:
	.zero	332
	.globl	x
	.align 32
	.type	x, @object
	.size	x, 332
x:
	.zero	332
	.globl	b
	.align 32
	.type	b, @object
	.size	b, 6172
b:
	.zero	6172
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 332
a:
	.zero	332
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC1:
	.long	1148829696
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC2:
	.long	2147483647
	.long	0
	.long	0
	.long	0
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC3:
	.long	-1629006314
	.long	1020396463
	.section	.rodata.cst4
	.align 4
.LC13:
	.long	841731191
	.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<math.h>
const int lena = 83;
const int lenb = 1543;
float a[ lena ], b[ lenb ], x[ lena ], xnew[ lena ], tau[ lenb ];
int De[ lena * lenb ];
int tDe[ lenb * lena ];

inline float sum(float* a, const int lena) {
  float res = *a;
  for(int i = 1; i < lena; ++i) {
    res += a[ i ];
  }
  return res;
}
void transpose(int* tm, int* m, const int nrow, const int ncol) {
  for(int i = 0; i < nrow; ++i) {
    for(int j = 0; j < ncol; ++j) {
      tm[ j * nrow + i ] = m[ i * ncol + j ];
    }
  }
}
float M_v(int* M, int row, float* v, const int len) {
  float res = 0.;
  int* p = M + row * len;
  for(int i = 0; i < len; ++i) {
    if(*p++) res += v[ i ];
  }
  return res;
}


void cpuweaver(float tol) {
  float sa = sum(a, lena);
  for(int i = 0; i < lena; ++i) x[ i ] = a[ i ] / sa;
  float m = sa + sum(b, lenb);

  int iter = 0;
  float e = 999, tmp;
  for(iter = 0; e > 1e-15; ++iter) {
    for(int j = 0; j < lenb; ++j) {
      tau[ j ] = b[ j ] / M_v(tDe, j, x, lena);
    }
    for(int i = 0; i < lena; ++i) {
      xnew[ i ] = a[ i ] / (m - M_v(De, i, tau, lenb));
    }
    e = 0.;
    for(int i = 0; i < lena; ++i) {
      tmp = fabs(xnew[ i ] - x[ i ]);
      if(e < tmp) e = tmp;
    };
    for(int i = 0; i < lena; ++i) {
      x[ i ] = xnew[ i ];
    }
  }
}


void test_weaver() {
  FILE* fp;
  //load a
  fp = fopen("C:/Users/easttiger/Dropbox/Subjects/W/Weaver Paper Reading list/Hunter matlab code/a.txt", "r");
  for(int i = 0; i < lena; ++i) {
    fscanf(fp, "%f\n", a + i);
  }
  fclose(fp);
  //load b
  fp = fopen("C:/Users/easttiger/Dropbox/Subjects/W/Weaver Paper Reading list/Hunter matlab code/b.txt", "r");
  for(int i = 0; i < lenb; ++i) {
    fscanf(fp, "%f\n", b + i);
  }
  fclose(fp);
  //load b
  fp = fopen("C:/Users/easttiger/Dropbox/Subjects/W/Weaver Paper Reading list/Hunter matlab code/tDe.txt", "r");
  for(int j = 0; j < lenb; ++j) {
    for(int i = 0; i < lena - 1; ++i) {
      fscanf(fp, "%d ", tDe + j * lena + i);
    }
    fscanf(fp, "%d\n", tDe + (j + 1) * lena - 1);
  }
  fclose(fp);

  //initialize De as transpose of tDe
  transpose(De, tDe, lenb, lena);


  cpuweaver(0.00000001);
  for(int i = 0; i < lena; ++i) {
    printf("%f,", x[ i ]);
  }
}
	.text
	.file	"weaver.hip"
	.globl	_Z9transposePiS_ii              # -- Begin function _Z9transposePiS_ii
	.type	_Z9transposePiS_ii,@function
_Z9transposePiS_ii:                     # @_Z9transposePiS_ii
	.cfi_startproc
# %bb.0:
	testl	%edx, %edx
	jle	.LBB0_7
# %bb.1:                                # %.preheader.lr.ph
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %rbp, -16
	movl	%edx, %eax
	movl	%ecx, %edx
	leaq	(,%rax,4), %r8
	xorl	%r9d, %r9d
	xorl	%r10d, %r10d
.LBB0_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_4 Depth 2
	testl	%ecx, %ecx
	jle	.LBB0_5
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB0_2 Depth=1
	movl	%r9d, %r11d
	leaq	(%rsi,%r11,4), %r11
	movq	%rdi, %rbx
	xorl	%r14d, %r14d
.LBB0_4:                                #   Parent Loop BB0_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	(%r11,%r14,4), %ebp
	movl	%ebp, (%rbx)
	incq	%r14
	addq	%r8, %rbx
	cmpq	%r14, %rdx
	jne	.LBB0_4
.LBB0_5:                                # %._crit_edge
                                        #   in Loop: Header=BB0_2 Depth=1
	incq	%r10
	addl	%ecx, %r9d
	addq	$4, %rdi
	cmpq	%rax, %r10
	jne	.LBB0_2
# %bb.6:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r14
	.cfi_restore %rbp
.LBB0_7:                                # %._crit_edge18
	retq
.Lfunc_end0:
	.size	_Z9transposePiS_ii, .Lfunc_end0-_Z9transposePiS_ii
	.cfi_endproc
                                        # -- End function
	.globl	_Z3M_vPiiPfi                    # -- Begin function _Z3M_vPiiPfi
	.type	_Z3M_vPiiPfi,@function
_Z3M_vPiiPfi:                           # @_Z3M_vPiiPfi
	.cfi_startproc
# %bb.0:
	testl	%ecx, %ecx
	jle	.LBB1_1
# %bb.3:                                # %.lr.ph.preheader
	imull	%ecx, %esi
	movslq	%esi, %rax
	leaq	(%rdi,%rax,4), %rax
	movl	%ecx, %ecx
	xorps	%xmm0, %xmm0
	xorl	%esi, %esi
.LBB1_4:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	cmpl	$0, (%rax,%rsi,4)
	je	.LBB1_6
# %bb.5:                                #   in Loop: Header=BB1_4 Depth=1
	addss	(%rdx,%rsi,4), %xmm0
.LBB1_6:                                #   in Loop: Header=BB1_4 Depth=1
	incq	%rsi
	cmpq	%rsi, %rcx
	jne	.LBB1_4
# %bb.2:                                # %._crit_edge
	retq
.LBB1_1:
	xorps	%xmm0, %xmm0
	retq
.Lfunc_end1:
	.size	_Z3M_vPiiPfi, .Lfunc_end1-_Z3M_vPiiPfi
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function _Z9cpuweaverf
.LCPI2_0:
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI2_1:
	.quad	0x3cd203af9ee75616              # double 1.0000000000000001E-15
	.text
	.globl	_Z9cpuweaverf
	.type	_Z9cpuweaverf,@function
_Z9cpuweaverf:                          # @_Z9cpuweaverf
	.cfi_startproc
# %bb.0:
	movq	$-328, %rax                     # imm = 0xFEB8
	movss	a(%rip), %xmm3                  # xmm3 = mem[0],zero,zero,zero
.LBB2_1:                                # %.lr.ph.i
                                        # =>This Inner Loop Header: Depth=1
	addss	a+332(%rax), %xmm3
	addq	$4, %rax
	jne	.LBB2_1
# %bb.2:                                # %_Z3sumPfi.exit.preheader
	movq	$-332, %rax                     # imm = 0xFEB4
.LBB2_3:                                # %_Z3sumPfi.exit
                                        # =>This Inner Loop Header: Depth=1
	movss	a+332(%rax), %xmm0              # xmm0 = mem[0],zero,zero,zero
	divss	%xmm3, %xmm0
	movss	%xmm0, x+332(%rax)
	addq	$4, %rax
	jne	.LBB2_3
# %bb.4:
	movq	$-6168, %rax                    # imm = 0xE7E8
	movss	b(%rip), %xmm0                  # xmm0 = mem[0],zero,zero,zero
.LBB2_5:                                # %.lr.ph.i36
                                        # =>This Inner Loop Header: Depth=1
	addss	b+6172(%rax), %xmm0
	addq	$4, %rax
	jne	.LBB2_5
# %bb.6:                                # %_Z3sumPfi.exit41
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	addss	%xmm0, %xmm3
	xorl	%eax, %eax
	movaps	.LCPI2_0(%rip), %xmm4           # xmm4 = [NaN,NaN,NaN,NaN]
	movss	%xmm3, 12(%rsp)                 # 4-byte Spill
.LBB2_7:                                # %.preheader57
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_8 Depth 2
                                        #     Child Loop BB2_13 Depth 2
                                        #       Child Loop BB2_14 Depth 3
                                        #     Child Loop BB2_19 Depth 2
	movss	b(,%rax,4), %xmm0               # xmm0 = mem[0],zero,zero,zero
	imulq	$83, %rax, %rcx
	xorps	%xmm1, %xmm1
	xorl	%edx, %edx
.LBB2_8:                                # %.lr.ph.i42
                                        #   Parent Loop BB2_7 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	cmpl	$0, tDe(%rdx,%rcx,4)
	je	.LBB2_10
# %bb.9:                                #   in Loop: Header=BB2_8 Depth=2
	addss	x(%rdx), %xmm1
.LBB2_10:                               #   in Loop: Header=BB2_8 Depth=2
	addq	$4, %rdx
	cmpq	$332, %rdx                      # imm = 0x14C
	jne	.LBB2_8
# %bb.11:                               # %_Z3M_vPiiPfi.exit
                                        #   in Loop: Header=BB2_7 Depth=1
	divss	%xmm1, %xmm0
	movss	%xmm0, tau(,%rax,4)
	incq	%rax
	cmpq	$1543, %rax                     # imm = 0x607
	jne	.LBB2_7
# %bb.12:                               # %.preheader56.preheader
                                        #   in Loop: Header=BB2_7 Depth=1
	movl	$De, %eax
	xorl	%ecx, %ecx
.LBB2_13:                               # %.preheader56
                                        #   Parent Loop BB2_7 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB2_14 Depth 3
	movss	a(,%rcx,4), %xmm0               # xmm0 = mem[0],zero,zero,zero
	xorps	%xmm1, %xmm1
	xorl	%edx, %edx
.LBB2_14:                               # %.lr.ph.i46
                                        #   Parent Loop BB2_7 Depth=1
                                        #     Parent Loop BB2_13 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	cmpl	$0, (%rax,%rdx)
	je	.LBB2_16
# %bb.15:                               #   in Loop: Header=BB2_14 Depth=3
	addss	tau(%rdx), %xmm1
.LBB2_16:                               #   in Loop: Header=BB2_14 Depth=3
	addq	$4, %rdx
	cmpq	$6172, %rdx                     # imm = 0x181C
	jne	.LBB2_14
# %bb.17:                               # %_Z3M_vPiiPfi.exit54
                                        #   in Loop: Header=BB2_13 Depth=2
	movaps	%xmm3, %xmm2
	subss	%xmm1, %xmm2
	divss	%xmm2, %xmm0
	movss	%xmm0, xnew(,%rcx,4)
	incq	%rcx
	addq	$6172, %rax                     # imm = 0x181C
	cmpq	$83, %rcx
	jne	.LBB2_13
# %bb.18:                               # %.preheader55.preheader
                                        #   in Loop: Header=BB2_7 Depth=1
	xorps	%xmm1, %xmm1
	movq	$-332, %rax                     # imm = 0xFEB4
.LBB2_19:                               # %.preheader55
                                        #   Parent Loop BB2_7 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movaps	%xmm1, %xmm0
	movss	xnew+332(%rax), %xmm1           # xmm1 = mem[0],zero,zero,zero
	subss	x+332(%rax), %xmm1
	andps	%xmm4, %xmm1
	maxss	%xmm0, %xmm1
	addq	$4, %rax
	jne	.LBB2_19
# %bb.20:                               # %.preheader
                                        #   in Loop: Header=BB2_7 Depth=1
	movl	$x, %edi
	movl	$xnew, %esi
	movl	$332, %edx                      # imm = 0x14C
	movaps	%xmm1, 16(%rsp)                 # 16-byte Spill
	callq	memcpy@PLT
	movaps	.LCPI2_0(%rip), %xmm4           # xmm4 = [NaN,NaN,NaN,NaN]
	xorps	%xmm0, %xmm0
	cvtss2sd	16(%rsp), %xmm0                 # 16-byte Folded Reload
	ucomisd	.LCPI2_1(%rip), %xmm0
	movl	$0, %eax
	movss	12(%rsp), %xmm3                 # 4-byte Reload
                                        # xmm3 = mem[0],zero,zero,zero
	ja	.LBB2_7
# %bb.21:
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z9cpuweaverf, .Lfunc_end2-_Z9cpuweaverf
	.cfi_endproc
                                        # -- End function
	.globl	_Z11test_weaverv                # -- Begin function _Z11test_weaverv
	.type	_Z11test_weaverv,@function
_Z11test_weaverv:                       # @_Z11test_weaverv
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	callq	fopen
	movq	%rax, %rbx
	xorl	%r14d, %r14d
.LBB3_1:                                # =>This Inner Loop Header: Depth=1
	leaq	a(%r14), %rdx
	movl	$.L.str.2, %esi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	addq	$4, %r14
	cmpq	$332, %r14                      # imm = 0x14C
	jne	.LBB3_1
# %bb.2:
	movq	%rbx, %rdi
	callq	fclose
	movl	$.L.str.3, %edi
	movl	$.L.str.1, %esi
	callq	fopen
	movq	%rax, %rbx
	xorl	%r14d, %r14d
.LBB3_3:                                # =>This Inner Loop Header: Depth=1
	leaq	b(%r14), %rdx
	movl	$.L.str.2, %esi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	addq	$4, %r14
	cmpq	$6172, %r14                     # imm = 0x181C
	jne	.LBB3_3
# %bb.4:
	movq	%rbx, %rdi
	callq	fclose
	movl	$.L.str.4, %edi
	movl	$.L.str.1, %esi
	callq	fopen
	movq	%rax, %rbx
	movl	$tDe, %r14d
	xorl	%r15d, %r15d
.LBB3_5:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_6 Depth 2
	xorl	%r12d, %r12d
.LBB3_6:                                #   Parent Loop BB3_5 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	leaq	(%r14,%r12), %rdx
	movl	$.L.str.5, %esi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	addq	$4, %r12
	cmpq	$328, %r12                      # imm = 0x148
	jne	.LBB3_6
# %bb.7:                                #   in Loop: Header=BB3_5 Depth=1
	incq	%r15
	imulq	$332, %r15, %rax                # imm = 0x14C
	leaq	tDe-4(%rax), %rdx
	movl	$.L.str.6, %esi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	addq	$332, %r14                      # imm = 0x14C
	cmpq	$1543, %r15                     # imm = 0x607
	jne	.LBB3_5
# %bb.8:
	movq	%rbx, %rdi
	callq	fclose
	movl	$De, %eax
	movl	$tDe, %ecx
	xorl	%edx, %edx
.LBB3_9:                                # %.preheader.i
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_10 Depth 2
	movq	%rax, %rsi
	xorl	%edi, %edi
.LBB3_10:                               #   Parent Loop BB3_9 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	(%rcx,%rdi,4), %r8d
	movl	%r8d, (%rsi)
	incq	%rdi
	addq	$6172, %rsi                     # imm = 0x181C
	cmpq	$83, %rdi
	jne	.LBB3_10
# %bb.11:                               # %._crit_edge.i
                                        #   in Loop: Header=BB3_9 Depth=1
	incq	%rdx
	addq	$4, %rax
	addq	$332, %rcx                      # imm = 0x14C
	cmpq	$1543, %rdx                     # imm = 0x607
	jne	.LBB3_9
# %bb.12:                               # %_Z9transposePiS_ii.exit
	callq	_Z9cpuweaverf
	movq	$-332, %rbx                     # imm = 0xFEB4
.LBB3_13:                               # =>This Inner Loop Header: Depth=1
	xorps	%xmm0, %xmm0
	cvtss2sd	x+332(%rbx), %xmm0
	movl	$.L.str.7, %edi
	movb	$1, %al
	callq	printf
	addq	$4, %rbx
	jne	.LBB3_13
# %bb.14:
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	_Z11test_weaverv, .Lfunc_end3-_Z11test_weaverv
	.cfi_endproc
                                        # -- End function
	.type	a,@object                       # @a
	.bss
	.globl	a
	.p2align	4, 0x0
a:
	.zero	332
	.size	a, 332

	.type	b,@object                       # @b
	.globl	b
	.p2align	4, 0x0
b:
	.zero	6172
	.size	b, 6172

	.type	x,@object                       # @x
	.globl	x
	.p2align	4, 0x0
x:
	.zero	332
	.size	x, 332

	.type	xnew,@object                    # @xnew
	.globl	xnew
	.p2align	4, 0x0
xnew:
	.zero	332
	.size	xnew, 332

	.type	tau,@object                     # @tau
	.globl	tau
	.p2align	4, 0x0
tau:
	.zero	6172
	.size	tau, 6172

	.type	De,@object                      # @De
	.globl	De
	.p2align	4, 0x0
De:
	.zero	512276
	.size	De, 512276

	.type	tDe,@object                     # @tDe
	.globl	tDe
	.p2align	4, 0x0
tDe:
	.zero	512276
	.size	tDe, 512276

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"C:/Users/easttiger/Dropbox/Subjects/W/Weaver Paper Reading list/Hunter matlab code/a.txt"
	.size	.L.str, 89

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

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

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"C:/Users/easttiger/Dropbox/Subjects/W/Weaver Paper Reading list/Hunter matlab code/b.txt"
	.size	.L.str.3, 89

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"C:/Users/easttiger/Dropbox/Subjects/W/Weaver Paper Reading list/Hunter matlab code/tDe.txt"
	.size	.L.str.4, 91

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

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"%d\n"
	.size	.L.str.6, 4

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"%f,"
	.size	.L.str.7, 4

	.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 a
	.addrsig_sym b
	.addrsig_sym tDe
	.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
