#include <stdio.h>
#include <math.h>
#include <malloc.h>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
//#define M 12

double* polyfit(double* x, double* y, int n, int M)
{
	int m;
	m = n + 1;
	double **a = (double **)malloc(sizeof(double*)*m);
	for (int i = 0; i < m; i++)
	{
		a[i] = (double*)malloc(m * sizeof(double));
	}
	double *p = (double*)malloc(m * sizeof(double));
	double *b = (double*)malloc(m * sizeof(double));
	double *atemp = (double*)malloc(2 * m * sizeof(double));
	for (int i = 0; i < m; i++)
	{
		b[i] = 0;
		atemp[2 * i] = 0;
		atemp[2 * i + 1] = 0;
	}

	//	Էϵb[]

	for (int i = 0; i < M; i++)
	{
		for (int k = 1; k <= n * 2; k++)
		{
			atemp[k] += pow(x[i], k);
		}
		for (int h = 0; h < n + 1; h++)
		{
			b[h] += pow(x[i], h)*y[i];
		}
	}
	atemp[0] = M;

	for (int i = 0; i < m; i++)
	{
		int k = i;
		for (int g = 0; g < m; g++)
		{
			a[i][g] = atemp[k++];
		}
	}

	//ⷽ a*p = b
	//	
	for (int i = 0; i < n; i++)
	{
		if (a[i][i] == 0)
		{
			double temp = a[i][i];
			int idx = i;
			while (temp == 0)
			{
				temp = a[idx + 1][i];
				idx = idx + 1;
			}
			//iк͵idx
			double change, change_b;
			for (int g = 0; g < m; g++)
			{
				change = a[i][g];
				a[i][g] = a[idx][g];
				a[idx][g] = change;
			}
			change_b = b[i];
			b[i] = b[idx];
			b[idx] = change_b;
		}

		if (a[i][i] != 1)
		{
			double temp = a[i][i];
			for (int g = 0; g < m; g++)
			{
				a[i][g] = a[i][g] / temp;
			}
			b[i] = b[i] / temp;
		}

		for (int k = i + 1; k < m; k++)
		{
			if (a[k][i] != 0)
			{
				double temp = -a[k][i];
				for (int p = 0; p < m; p++)
				{
					a[k][p] = a[k][p] + a[i][p] * temp;
				}
				b[k] = b[k] + b[i] * temp;
			}
		}
	}

	if (a[n][n] != 1)
	{
		double temp = a[n][n];
		a[n][n] = 1;
		b[n] = b[n] / temp;
	}

	//Ԫ
	for (int i = n; i > 0; i--)
	{
		for (int g = 0; g < i; g++)
		{
			double temp = -a[g][i];
			b[g] = b[g] + b[i] * temp;
		}
	}

	for (int i = 0; i < m; i++)
	{
		p[i] = b[n - i];
	}

	free(b);
	free(atemp);
	for (int i = 0; i < m; i++)
		free(a[i]);/*ͷ*/

	free(a);/*ͷ*/
	return p;
	free(p);

}
	.file	"tmpxft_00371e07_00000000-6_polyfit.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
	.globl	_Z7polyfitPdS_ii
	.type	_Z7polyfitPdS_ii, @function
_Z7polyfitPdS_ii:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rdi, %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leal	1(%rdx), %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movslq	%ebp, %r13
	movl	%edx, %ebx
	leaq	0(,%r13,8), %rax
	movq	%rax, %rdi
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movq	%rsi, 40(%rsp)
	movl	%ecx, 32(%rsp)
	movq	%rax, 8(%rsp)
	call	malloc@PLT
	movq	%rax, %r13
.L3:
	movq	8(%rsp), %rdi
	cmpl	%r12d, %ebp
	jle	.L51
	call	malloc@PLT
	movq	%rax, 0(%r13,%r12,8)
	incq	%r12
	jmp	.L3
.L51:
	call	malloc@PLT
	movq	8(%rsp), %rdi
	movq	%rax, 24(%rsp)
	call	malloc@PLT
	leal	(%rbp,%rbp), %edi
	movslq	%edi, %rdi
	movq	%rax, %r14
	salq	$3, %rdi
	call	malloc@PLT
	movq	%rax, 16(%rsp)
	movq	%rax, %r12
	movq	%rax, %rcx
	xorl	%eax, %eax
.L5:
	cmpl	%eax, %ebp
	jle	.L52
	movq	$0x000000000, (%r14,%rax,8)
	addq	$16, %rcx
	incq	%rax
	movq	$0x000000000, -16(%rcx)
	movq	$0x000000000, -8(%rcx)
	jmp	.L5
.L52:
	leal	(%rbx,%rbx), %eax
	movl	%eax, 36(%rsp)
	xorl	%eax, %eax
.L7:
	cmpl	%eax, 32(%rsp)
	jle	.L53
	movl	$1, %ecx
.L11:
	cmpl	%ecx, 36(%rsp)
	jl	.L54
	cvtsi2sdl	%ecx, %xmm1
	movsd	(%r15,%rax,8), %xmm0
	movq	%rax, 56(%rsp)
	movq	%rcx, 48(%rsp)
	call	pow@PLT
	movq	48(%rsp), %rcx
	movq	56(%rsp), %rax
	addsd	(%r12,%rcx,8), %xmm0
	movsd	%xmm0, (%r12,%rcx,8)
	incq	%rcx
	jmp	.L11
.L54:
	xorl	%ecx, %ecx
.L9:
	cmpl	%ecx, %ebx
	jl	.L55
	cvtsi2sdl	%ecx, %xmm1
	movsd	(%r15,%rax,8), %xmm0
	movq	%rax, 56(%rsp)
	movq	%rcx, 48(%rsp)
	call	pow@PLT
	movq	40(%rsp), %rdx
	movq	56(%rsp), %rax
	movq	48(%rsp), %rcx
	mulsd	(%rdx,%rax,8), %xmm0
	addsd	(%r14,%rcx,8), %xmm0
	movsd	%xmm0, (%r14,%rcx,8)
	incq	%rcx
	jmp	.L9
.L55:
	incq	%rax
	jmp	.L7
.L53:
	cvtsi2sdl	32(%rsp), %xmm0
	movl	%ebx, %eax
	leaq	8(,%rax,8), %r9
	xorl	%eax, %eax
	movsd	%xmm0, (%r12)
.L13:
	cmpl	%eax, %ebp
	jle	.L38
	movq	0(%r13,%rax,8), %rdi
	movq	16(%rsp), %rsi
	movq	%r9, %rcx
	incq	%rax
	rep movsb
	addq	$8, 16(%rsp)
	jmp	.L13
.L38:
	movsd	.LC1(%rip), %xmm3
	xorl	%eax, %eax
	xorl	%edi, %edi
	xorps	%xmm1, %xmm1
	movq	.LC2(%rip), %xmm4
.L12:
	cmpl	%edi, %ebx
	jle	.L56
	movq	0(%r13,%rax), %rsi
	leaq	(%rsi,%rax), %r10
	ucomisd	(%r10), %xmm1
	jp	.L14
	jne	.L14
	leaq	8(%rax), %rcx
.L16:
	movq	0(%r13,%rcx), %r11
	movq	%rcx, %r9
	addq	$8, %rcx
	ucomisd	(%r11,%rax), %xmm1
	jp	.L40
	je	.L16
.L40:
	xorl	%ecx, %ecx
.L18:
	movsd	(%rsi,%rcx,8), %xmm0
	movsd	(%r11,%rcx,8), %xmm2
	movsd	%xmm2, (%rsi,%rcx,8)
	movsd	%xmm0, (%r11,%rcx,8)
	incq	%rcx
	leal	-1(%rcx), %edx
	cmpl	%ebx, %edx
	jl	.L18
	leaq	(%r14,%r9), %rcx
	movsd	(%r14,%rax), %xmm0
	movsd	(%rcx), %xmm2
	movsd	%xmm2, (%r14,%rax)
	movsd	%xmm0, (%rcx)
.L14:
	movsd	(%r10), %xmm2
	ucomisd	%xmm3, %xmm2
	jp	.L41
	je	.L19
.L41:
	xorl	%ecx, %ecx
.L21:
	movsd	(%rsi,%rcx,8), %xmm0
	divsd	%xmm2, %xmm0
	movsd	%xmm0, (%rsi,%rcx,8)
	incq	%rcx
	leal	-1(%rcx), %r9d
	cmpl	%r9d, %ebx
	jg	.L21
	movsd	(%r14,%rax), %xmm0
	divsd	%xmm2, %xmm0
	movsd	%xmm0, (%r14,%rax)
.L19:
	incq	%rdi
	movq	%rdi, %rcx
.L22:
	cmpl	%ecx, %ebp
	jle	.L57
	movq	0(%r13,%rcx,8), %r10
	movsd	(%r10,%rax), %xmm0
	ucomisd	%xmm1, %xmm0
	jp	.L42
	je	.L23
.L42:
	xorps	%xmm4, %xmm0
	xorl	%r9d, %r9d
.L25:
	movsd	(%rsi,%r9,8), %xmm2
	mulsd	%xmm0, %xmm2
	addsd	(%r10,%r9,8), %xmm2
	movsd	%xmm2, (%r10,%r9,8)
	incq	%r9
	leal	-1(%r9), %r11d
	cmpl	%r11d, %ebx
	jg	.L25
	mulsd	(%r14,%rax), %xmm0
	addsd	(%r14,%rcx,8), %xmm0
	movsd	%xmm0, (%r14,%rcx,8)
.L23:
	incq	%rcx
	jmp	.L22
.L57:
	addq	$8, %rax
	jmp	.L12
.L56:
	movq	8(%rsp), %rdx
	movq	8(%rsp), %rax
	movslq	%ebx, %rbx
	movsd	.LC1(%rip), %xmm0
	movq	-8(%r13,%rdx), %rcx
	subq	$8, %rax
	addq	%rax, %rcx
	movsd	(%rcx), %xmm1
	ucomisd	%xmm0, %xmm1
	jp	.L43
	je	.L28
.L43:
	movsd	%xmm0, (%rcx)
	leaq	(%r14,%rax), %rcx
	movsd	(%rcx), %xmm0
	divsd	%xmm1, %xmm0
	movsd	%xmm0, (%rcx)
.L28:
	movq	.LC2(%rip), %xmm1
.L30:
	movl	%ebx, %esi
	testl	%ebx, %ebx
	jle	.L58
	leaq	0(,%rbx,8), %rdi
	xorl	%ecx, %ecx
.L31:
	movq	0(%r13,%rcx,8), %r9
	movsd	(%r9,%rdi), %xmm0
	xorps	%xmm1, %xmm0
	mulsd	(%r14,%rbx,8), %xmm0
	addsd	(%r14,%rcx,8), %xmm0
	movsd	%xmm0, (%r14,%rcx,8)
	incq	%rcx
	cmpl	%ecx, %esi
	jg	.L31
	decq	%rbx
	jmp	.L30
.L58:
	addq	%r14, %rax
	xorl	%ecx, %ecx
.L33:
	cmpl	%ecx, %ebp
	jle	.L59
	movsd	(%rax), %xmm0
	movq	24(%rsp), %rsi
	subq	$8, %rax
	movsd	%xmm0, (%rsi,%rcx,8)
	incq	%rcx
	jmp	.L33
.L59:
	movq	%r14, %rdi
	xorl	%ebx, %ebx
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
.L35:
	cmpl	%ebx, %ebp
	jle	.L60
	movq	0(%r13,%rbx,8), %rdi
	incq	%rbx
	call	free@PLT
	jmp	.L35
.L60:
	movq	%r13, %rdi
	call	free@PLT
	movq	24(%rsp), %rax
	addq	$72, %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	_Z7polyfitPdS_ii, .-_Z7polyfitPdS_ii
	.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	1072693248
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC2:
	.long	0
	.long	-2147483648
	.long	0
	.long	0
	.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 <math.h>
#include <malloc.h>
#include "hip/hip_runtime.h"

//#define M 12

double* polyfit(double* x, double* y, int n, int M)
{
	int m;
	m = n + 1;
	double **a = (double **)malloc(sizeof(double*)*m);
	for (int i = 0; i < m; i++)
	{
		a[i] = (double*)malloc(m * sizeof(double));
	}
	double *p = (double*)malloc(m * sizeof(double));
	double *b = (double*)malloc(m * sizeof(double));
	double *atemp = (double*)malloc(2 * m * sizeof(double));
	for (int i = 0; i < m; i++)
	{
		b[i] = 0;
		atemp[2 * i] = 0;
		atemp[2 * i + 1] = 0;
	}

	//	Էϵb[]

	for (int i = 0; i < M; i++)
	{
		for (int k = 1; k <= n * 2; k++)
		{
			atemp[k] += pow(x[i], k);
		}
		for (int h = 0; h < n + 1; h++)
		{
			b[h] += pow(x[i], h)*y[i];
		}
	}
	atemp[0] = M;

	for (int i = 0; i < m; i++)
	{
		int k = i;
		for (int g = 0; g < m; g++)
		{
			a[i][g] = atemp[k++];
		}
	}

	//ⷽ a*p = b
	//	
	for (int i = 0; i < n; i++)
	{
		if (a[i][i] == 0)
		{
			double temp = a[i][i];
			int idx = i;
			while (temp == 0)
			{
				temp = a[idx + 1][i];
				idx = idx + 1;
			}
			//iк͵idx
			double change, change_b;
			for (int g = 0; g < m; g++)
			{
				change = a[i][g];
				a[i][g] = a[idx][g];
				a[idx][g] = change;
			}
			change_b = b[i];
			b[i] = b[idx];
			b[idx] = change_b;
		}

		if (a[i][i] != 1)
		{
			double temp = a[i][i];
			for (int g = 0; g < m; g++)
			{
				a[i][g] = a[i][g] / temp;
			}
			b[i] = b[i] / temp;
		}

		for (int k = i + 1; k < m; k++)
		{
			if (a[k][i] != 0)
			{
				double temp = -a[k][i];
				for (int p = 0; p < m; p++)
				{
					a[k][p] = a[k][p] + a[i][p] * temp;
				}
				b[k] = b[k] + b[i] * temp;
			}
		}
	}

	if (a[n][n] != 1)
	{
		double temp = a[n][n];
		a[n][n] = 1;
		b[n] = b[n] / temp;
	}

	//Ԫ
	for (int i = n; i > 0; i--)
	{
		for (int g = 0; g < i; g++)
		{
			double temp = -a[g][i];
			b[g] = b[g] + b[i] * temp;
		}
	}

	for (int i = 0; i < m; i++)
	{
		p[i] = b[n - i];
	}

	free(b);
	free(atemp);
	for (int i = 0; i < m; i++)
		free(a[i]);/*ͷ*/

	free(a);/*ͷ*/
	return p;
	free(p);

}
	.text
	.file	"polyfit.hip"
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z7polyfitPdS_ii
.LCPI0_0:
	.quad	0x3ff0000000000000              # double 1
	.text
	.globl	_Z7polyfitPdS_ii
	.type	_Z7polyfitPdS_ii,@function
_Z7polyfitPdS_ii:                       # @_Z7polyfitPdS_ii
	.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	$72, %rsp
	.cfi_def_cfa_offset 128
	.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	%ecx, 4(%rsp)                   # 4-byte Spill
	movl	%edx, %ebx
	movq	%rsi, 64(%rsp)                  # 8-byte Spill
	movq	%rdi, %r15
	leal	1(%rbx), %ebp
	movslq	%ebp, %r12
	shlq	$3, %r12
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, %r13
	movl	%ebp, %r14d
	movq	%rbx, 8(%rsp)                   # 8-byte Spill
	testl	%ebx, %ebx
	js	.LBB0_3
# %bb.1:                                # %.lr.ph.preheader
	xorl	%ebx, %ebx
.LBB0_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, (%r13,%rbx,8)
	incq	%rbx
	cmpq	%rbx, %r14
	jne	.LBB0_2
.LBB0_3:                                # %._crit_edge
	movq	%r13, 24(%rsp)                  # 8-byte Spill
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, %r12
	addl	%ebp, %ebp
	movslq	%ebp, %rdi
	shlq	$3, %rdi
	callq	malloc
	movq	%rax, %r13
	movq	8(%rsp), %rbx                   # 8-byte Reload
	testl	%ebx, %ebx
	js	.LBB0_5
# %bb.4:                                # %.lr.ph243.preheader
	leaq	(,%r14,8), %rdx
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
	movq	%r14, %rdx
	shlq	$4, %rdx
	movq	%r13, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
.LBB0_5:                                # %.preheader237
	movq	%r13, 32(%rsp)                  # 8-byte Spill
	cmpl	$0, 4(%rsp)                     # 4-byte Folded Reload
	jle	.LBB0_14
# %bb.6:                                # %.preheader236.lr.ph
	leal	(%rbx,%rbx), %eax
	cmpl	$2, %eax
	movl	$1, %ecx
	cmovgel	%eax, %ecx
	movl	4(%rsp), %eax                   # 4-byte Reload
	movq	%rax, 40(%rsp)                  # 8-byte Spill
	negq	%rcx
	movq	%rcx, 56(%rsp)                  # 8-byte Spill
	xorl	%ebp, %ebp
	movq	%r12, 48(%rsp)                  # 8-byte Spill
.LBB0_7:                                # %.preheader236
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_9 Depth 2
                                        #     Child Loop BB0_12 Depth 2
	testl	%ebx, %ebx
	movq	32(%rsp), %r13                  # 8-byte Reload
	movq	56(%rsp), %r12                  # 8-byte Reload
	jle	.LBB0_10
# %bb.8:                                # %.lr.ph246
                                        #   in Loop: Header=BB0_7 Depth=1
	movl	$1, %ebx
.LBB0_9:                                #   Parent Loop BB0_7 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movsd	(%r15,%rbp,8), %xmm0            # xmm0 = mem[0],zero
	xorps	%xmm1, %xmm1
	cvtsi2sd	%ebx, %xmm1
	callq	pow
	addsd	(%r13,%rbx,8), %xmm0
	movsd	%xmm0, (%r13,%rbx,8)
	leaq	(%r12,%rbx), %rax
	incq	%rax
	incq	%rbx
	cmpq	$1, %rax
	jne	.LBB0_9
.LBB0_10:                               # %.preheader235
                                        #   in Loop: Header=BB0_7 Depth=1
	cmpl	$0, 8(%rsp)                     # 4-byte Folded Reload
	movq	64(%rsp), %r13                  # 8-byte Reload
	movq	48(%rsp), %r12                  # 8-byte Reload
	js	.LBB0_13
# %bb.11:                               # %.lr.ph249
                                        #   in Loop: Header=BB0_7 Depth=1
	xorl	%ebx, %ebx
.LBB0_12:                               #   Parent Loop BB0_7 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movsd	(%r15,%rbp,8), %xmm0            # xmm0 = mem[0],zero
	xorps	%xmm1, %xmm1
	cvtsi2sd	%ebx, %xmm1
	callq	pow
	mulsd	(%r13,%rbp,8), %xmm0
	addsd	(%r12,%rbx,8), %xmm0
	movsd	%xmm0, (%r12,%rbx,8)
	incq	%rbx
	cmpq	%rbx, %r14
	jne	.LBB0_12
.LBB0_13:                               # %._crit_edge250
                                        #   in Loop: Header=BB0_7 Depth=1
	incq	%rbp
	cmpq	40(%rsp), %rbp                  # 8-byte Folded Reload
	movq	8(%rsp), %rbx                   # 8-byte Reload
	jne	.LBB0_7
.LBB0_14:                               # %._crit_edge252
	xorps	%xmm0, %xmm0
	cvtsi2sdl	4(%rsp), %xmm0          # 4-byte Folded Reload
	movq	32(%rsp), %rbp                  # 8-byte Reload
	movsd	%xmm0, (%rbp)
	testl	%ebx, %ebx
	js	.LBB0_15
# %bb.18:                               # %.preheader234.lr.ph
	leaq	(,%r14,8), %r15
	xorl	%ebx, %ebx
	movq	24(%rsp), %r13                  # 8-byte Reload
.LBB0_19:                               # %._crit_edge257
                                        # =>This Inner Loop Header: Depth=1
	leaq	(,%rbx,8), %rsi
	addq	%rbp, %rsi
	movq	(%r13,%rbx,8), %rdi
	movq	%r15, %rdx
	callq	memcpy@PLT
	incq	%rbx
	cmpq	%rbx, %r14
	jne	.LBB0_19
# %bb.16:                               # %.preheader233
	movq	8(%rsp), %rbx                   # 8-byte Reload
	testl	%ebx, %ebx
	setne	%al
	movq	16(%rsp), %r15                  # 8-byte Reload
	je	.LBB0_17
# %bb.34:                               # %.lr.ph280
	movl	%ebx, %ecx
	movl	$1, %edx
	xorl	%esi, %esi
	xorpd	%xmm0, %xmm0
	movsd	.LCPI0_0(%rip), %xmm1           # xmm1 = mem[0],zero
.LBB0_35:                               # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_36 Depth 2
                                        #     Child Loop BB0_38 Depth 2
                                        #     Child Loop BB0_42 Depth 2
                                        #     Child Loop BB0_45 Depth 2
                                        #       Child Loop BB0_47 Depth 3
	movq	(%r13,%rsi,8), %rdi
	movsd	(%rdi,%rsi,8), %xmm2            # xmm2 = mem[0],zero
	ucomisd	%xmm0, %xmm2
	movq	%rsi, %r8
	jne	.LBB0_40
	jp	.LBB0_40
.LBB0_36:                               # %.lr.ph261
                                        #   Parent Loop BB0_35 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	8(%r13,%r8,8), %r9
	incq	%r8
	movsd	(%r9,%rsi,8), %xmm2             # xmm2 = mem[0],zero
	ucomisd	%xmm0, %xmm2
	jne	.LBB0_37
	jnp	.LBB0_36
.LBB0_37:                               # %.lr.ph264
                                        #   in Loop: Header=BB0_35 Depth=1
	movl	%r8d, %r8d
	movq	(%r13,%r8,8), %r9
	xorl	%r10d, %r10d
.LBB0_38:                               #   Parent Loop BB0_35 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movsd	(%rdi,%r10,8), %xmm2            # xmm2 = mem[0],zero
	movsd	(%r9,%r10,8), %xmm3             # xmm3 = mem[0],zero
	movsd	%xmm3, (%rdi,%r10,8)
	movsd	%xmm2, (%r9,%r10,8)
	incq	%r10
	cmpq	%r10, %r14
	jne	.LBB0_38
# %bb.39:                               # %._crit_edge265
                                        #   in Loop: Header=BB0_35 Depth=1
	movsd	(%r12,%r8,8), %xmm3             # xmm3 = mem[0],zero
	movsd	(%rdi,%rsi,8), %xmm2            # xmm2 = mem[0],zero
	movsd	(%r12,%rsi,8), %xmm4            # xmm4 = mem[0],zero
	movsd	%xmm3, (%r12,%rsi,8)
	movsd	%xmm4, (%r12,%r8,8)
.LBB0_40:                               #   in Loop: Header=BB0_35 Depth=1
	ucomisd	%xmm1, %xmm2
	jne	.LBB0_41
	jnp	.LBB0_44
.LBB0_41:                               # %.lr.ph268.preheader
                                        #   in Loop: Header=BB0_35 Depth=1
	xorl	%r8d, %r8d
.LBB0_42:                               # %.lr.ph268
                                        #   Parent Loop BB0_35 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movsd	(%rdi,%r8,8), %xmm3             # xmm3 = mem[0],zero
	divsd	%xmm2, %xmm3
	movsd	%xmm3, (%rdi,%r8,8)
	incq	%r8
	cmpq	%r8, %r14
	jne	.LBB0_42
# %bb.43:                               # %._crit_edge269
                                        #   in Loop: Header=BB0_35 Depth=1
	movsd	(%r12,%rsi,8), %xmm3            # xmm3 = mem[0],zero
	divsd	%xmm2, %xmm3
	movsd	%xmm3, (%r12,%rsi,8)
.LBB0_44:                               # %.lr.ph277
                                        #   in Loop: Header=BB0_35 Depth=1
	leaq	1(%rsi), %r8
	movq	%rdx, %r9
.LBB0_45:                               #   Parent Loop BB0_35 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB0_47 Depth 3
	movq	(%r13,%r9,8), %r10
	movsd	(%r10,%rsi,8), %xmm2            # xmm2 = mem[0],zero
	ucomisd	%xmm0, %xmm2
	jne	.LBB0_46
	jnp	.LBB0_49
.LBB0_46:                               # %.lr.ph272.preheader
                                        #   in Loop: Header=BB0_45 Depth=2
	xorl	%r11d, %r11d
.LBB0_47:                               # %.lr.ph272
                                        #   Parent Loop BB0_35 Depth=1
                                        #     Parent Loop BB0_45 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movsd	(%r10,%r11,8), %xmm3            # xmm3 = mem[0],zero
	movsd	(%rdi,%r11,8), %xmm4            # xmm4 = mem[0],zero
	mulsd	%xmm2, %xmm4
	subsd	%xmm4, %xmm3
	movsd	%xmm3, (%r10,%r11,8)
	incq	%r11
	cmpq	%r11, %r14
	jne	.LBB0_47
# %bb.48:                               # %._crit_edge273
                                        #   in Loop: Header=BB0_45 Depth=2
	movsd	(%r12,%r9,8), %xmm3             # xmm3 = mem[0],zero
	mulsd	(%r12,%rsi,8), %xmm2
	subsd	%xmm2, %xmm3
	movsd	%xmm3, (%r12,%r9,8)
.LBB0_49:                               #   in Loop: Header=BB0_45 Depth=2
	incq	%r9
	cmpq	%r14, %r9
	jne	.LBB0_45
# %bb.20:                               # %.loopexit
                                        #   in Loop: Header=BB0_35 Depth=1
	incq	%rdx
	movq	%r8, %rsi
	cmpq	%rcx, %r8
	jne	.LBB0_35
	jmp	.LBB0_21
.LBB0_15:
	xorl	%eax, %eax
	movq	24(%rsp), %r13                  # 8-byte Reload
	movq	16(%rsp), %r15                  # 8-byte Reload
	jmp	.LBB0_21
.LBB0_17:
	xorl	%eax, %eax
.LBB0_21:                               # %._crit_edge281
	movslq	%ebx, %rcx
	movq	(%r13,%rcx,8), %rdx
	movsd	(%rdx,%rcx,8), %xmm0            # xmm0 = mem[0],zero
	ucomisd	.LCPI0_0(%rip), %xmm0
	jne	.LBB0_22
	jnp	.LBB0_23
.LBB0_22:
	movabsq	$4607182418800017408, %rsi      # imm = 0x3FF0000000000000
	movq	%rsi, (%rdx,%rcx,8)
	movsd	(%r12,%rcx,8), %xmm1            # xmm1 = mem[0],zero
	divsd	%xmm0, %xmm1
	movsd	%xmm1, (%r12,%rcx,8)
.LBB0_23:
	testb	%al, %al
	je	.LBB0_28
# %bb.24:                               # %.preheader228.preheader
	movl	%ebx, %eax
.LBB0_25:                               # %.preheader228
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_26 Depth 2
	xorl	%edx, %edx
.LBB0_26:                               #   Parent Loop BB0_25 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	(%r13,%rdx,8), %rsi
	movsd	(%rsi,%rax,8), %xmm0            # xmm0 = mem[0],zero
	movsd	(%r12,%rdx,8), %xmm1            # xmm1 = mem[0],zero
	mulsd	(%r12,%rax,8), %xmm0
	subsd	%xmm0, %xmm1
	movsd	%xmm1, (%r12,%rdx,8)
	incq	%rdx
	cmpq	%rdx, %rax
	jne	.LBB0_26
# %bb.27:                               #   in Loop: Header=BB0_25 Depth=1
	leaq	-1(%rax), %rdx
	cmpq	$1, %rax
	movq	%rdx, %rax
	jg	.LBB0_25
.LBB0_28:                               # %.preheader
	testl	%ebx, %ebx
	js	.LBB0_50
# %bb.29:                               # %.lr.ph286.preheader
	leaq	(%r12,%rcx,8), %rax
	xorl	%ecx, %ecx
.LBB0_30:                               # %.lr.ph286
                                        # =>This Inner Loop Header: Depth=1
	movsd	(%rax), %xmm0                   # xmm0 = mem[0],zero
	movsd	%xmm0, (%r15,%rcx,8)
	incq	%rcx
	addq	$-8, %rax
	cmpq	%rcx, %r14
	jne	.LBB0_30
# %bb.31:                               # %._crit_edge287
	movq	%r12, %rdi
	callq	free
	movq	%rbp, %rdi
	callq	free
	testl	%ebx, %ebx
	js	.LBB0_51
# %bb.32:                               # %.lr.ph291.preheader
	xorl	%ebx, %ebx
.LBB0_33:                               # %.lr.ph291
                                        # =>This Inner Loop Header: Depth=1
	movq	(%r13,%rbx,8), %rdi
	callq	free
	incq	%rbx
	cmpq	%rbx, %r14
	jne	.LBB0_33
	jmp	.LBB0_51
.LBB0_50:                               # %._crit_edge292.critedge
	movq	%r12, %rdi
	callq	free
	movq	%rbp, %rdi
	callq	free
.LBB0_51:                               # %._crit_edge292
	movq	%r13, %rdi
	callq	free
	movq	%r15, %rax
	addq	$72, %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
.Lfunc_end0:
	.size	_Z7polyfitPdS_ii, .Lfunc_end0-_Z7polyfitPdS_ii
	.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
