#include <iostream>
#include <memory>
#include "cuda.h"
bool allclose(float x, float y, float threshold = 1e-4) {
	return abs(x - y) < threshold;
}
	
void dotc(float*dst, float*src1, float*src2, int xa, int ya, int za, int wa) {
	//xy * zw -> xz * yw
	int ywa = ya * wa;
	for(int xi = 0; xi < xa; xi++) {
		for(int yi = 0; yi < ya; yi++) {
			for(int zi = 0; zi < za; zi++) {
				for(int wi = 0; wi < wa; wi++) {
					int xzi = xi * za + zi;
					int ywi = yi * wa + wi;
					int i = xzi * ywa + ywi;
					int xyi = xi * ya + yi;
					int zwi = zi * wa + wi;
	 				dst[i] = src1[xyi] * src2[zwi];
	 			}
			}
		}
	}
}

double checkpointc(int us = 1e3) {
	static clock_t timer = -1;
	clock_t newtime = clock();
	double ustime = us * ((newtime - timer) / (double)CLOCKS_PER_SEC);
	timer = newtime;
	return ustime;
}
	

int main(int argc, char* argv[]) {
	const int defdim = 89;
	int xa = argc > 1 ? std::atoi(argv[1]) : defdim;
  int ya = argc > 2 ? std::atoi(argv[2]) : defdim;
	int za = argc > 3 ? std::atoi(argv[3]) : defdim;
  int wa = argc > 4 ? std::atoi(argv[4]) : defdim;
	float* src1 = (float*)malloc(sizeof(float) * xa * ya);
	float* src2 = (float*)malloc(sizeof(float) * za * wa);
	float* dst = (float*)malloc(sizeof(float)* xa * ya * za * wa);
	std::cout<<"------SRC1 / SRC2--------"<<std::endl;
	for(int xi = 0; xi < xa; xi++) {
		for(int yi = 0; yi < ya; yi++) {
			src1[xi * ya + yi] = xi * ya + yi;
			std::cout<<src1[xi * ya + yi]<<" ";
		}
		std::cout<<std::endl;
	}
	std::cout<<"+++++THRES+++++++"<<std::endl;
	  std::cout<<"------SRC1 / SRC2--------"<<std::endl;
  for(int zi = 0; zi < za; zi++) {
    for(int wi = 0; wi < wa; wi++) {
			src2[zi * wa + wi] = zi * wa + wi;
      std::cout<<src2[zi * wa + wi]<<" ";
    }
		std::cout<<std::endl;
	}
	std::cout<<"SRC -> DST"<<std::endl;
	checkpointc();
	dotc(dst, src1 ,src2, xa, ya, za, wa);
	double cstime = checkpointc();
	std::cout<<"******CPU DST*********"<<std::endl;
	int xza = xa * za;
	int ywa = ya * wa;
	/*for(int xzi = 0; xzi < xza; xzi++) {
		for(int ywi = 0; ywi < ywa; ywi++) {
			std::cout<<dst[xzi * ywa + ywi]<<" ";
		}
		std::cout<<std::endl;
	}*/
	std::cout<<"CSTIME: "<<cstime<<std::endl;
}

	.file	"tmpxft_002381e8_00000000-6_dot.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB4285:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE4285:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.align 2
	.type	_ZNSolsEPFRSoS_E.isra.0, @function
_ZNSolsEPFRSoS_E.isra.0:
.LFB4957:
	.cfi_startproc
	jmp	*%rsi
	.cfi_endproc
.LFE4957:
	.size	_ZNSolsEPFRSoS_E.isra.0, .-_ZNSolsEPFRSoS_E.isra.0
	.globl	_Z8allclosefff
	.type	_Z8allclosefff, @function
_Z8allclosefff:
.LFB4279:
	.cfi_startproc
	endbr64
	subss	%xmm1, %xmm0
	andps	.LC0(%rip), %xmm0
	comiss	%xmm0, %xmm2
	seta	%al
	ret
	.cfi_endproc
.LFE4279:
	.size	_Z8allclosefff, .-_Z8allclosefff
	.globl	_Z4dotcPfS_S_iiii
	.type	_Z4dotcPfS_S_iiii, @function
_Z4dotcPfS_S_iiii:
.LFB4280:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	%r9d, %eax
	xorl	%r11d, %r11d
	xorl	%r10d, %r10d
	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
	movl	%r8d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	56(%rsp), %r14d
	imull	%r14d, %r12d
	movq	%rdx, -24(%rsp)
	xorl	%edx, %edx
	movl	%ecx, -12(%rsp)
	imull	%r12d, %eax
	movl	%edx, -48(%rsp)
	movl	%eax, -16(%rsp)
.L5:
	movl	-12(%rsp), %ebx
	cmpl	%ebx, -48(%rsp)
	jge	.L4
	xorl	%eax, %eax
	xorl	%edx, %edx
	movl	%eax, -44(%rsp)
.L12:
	cmpl	%r8d, %edx
	jge	.L9
	leal	(%rdx,%r11), %eax
	movl	%r10d, %r15d
	xorl	%ebp, %ebp
	xorl	%ebx, %ebx
	cltq
	leaq	(%rsi,%rax,4), %r13
	movslq	-44(%rsp), %rax
	movq	%rax, -8(%rsp)
.L10:
	cmpl	%r9d, %ebx
	jge	.L7
	movq	-24(%rsp), %rcx
	movslq	%ebp, %rax
	leaq	(%rcx,%rax,4), %rax
	movq	-8(%rsp), %rcx
	movq	%rax, -40(%rsp)
	movslq	%r15d, %rax
	addq	%rcx, %rax
	leaq	(%rdi,%rax,4), %rax
	movq	%rax, -32(%rsp)
	xorl	%eax, %eax
.L8:
	cmpl	%eax, %r14d
	jle	.L15
	movq	-40(%rsp), %rcx
	movss	0(%r13), %xmm0
	mulss	(%rcx,%rax,4), %xmm0
	movq	-32(%rsp), %rcx
	movss	%xmm0, (%rcx,%rax,4)
	incq	%rax
	jmp	.L8
.L15:
	incl	%ebx
	addl	%r12d, %r15d
	addl	%r14d, %ebp
	jmp	.L10
.L7:
	addl	%r14d, -44(%rsp)
	incl	%edx
	jmp	.L12
.L9:
	movl	-16(%rsp), %eax
	incl	-48(%rsp)
	addl	%r8d, %r11d
	addl	%eax, %r10d
	jmp	.L5
.L4:
	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
.LFE4280:
	.size	_Z4dotcPfS_S_iiii, .-_Z4dotcPfS_S_iiii
	.globl	_Z11checkpointci
	.type	_Z11checkpointci, @function
_Z11checkpointci:
.LFB4281:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movl	%edi, %ebx
	call	clock@PLT
	cvtsi2sdl	%ebx, %xmm1
	popq	%rbx
	.cfi_def_cfa_offset 8
	movq	%rax, %rdx
	subq	_ZZ11checkpointciE5timer(%rip), %rdx
	movq	%rax, _ZZ11checkpointciE5timer(%rip)
	cvtsi2sdq	%rdx, %xmm0
	divsd	.LC1(%rip), %xmm0
	mulsd	%xmm1, %xmm0
	ret
	.cfi_endproc
.LFE4281:
	.size	_Z11checkpointci, .-_Z11checkpointci
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"------SRC1 / SRC2--------"
.LC3:
	.string	" "
.LC4:
	.string	"+++++THRES+++++++"
.LC5:
	.string	"SRC -> DST"
.LC6:
	.string	"******CPU DST*********"
.LC7:
	.string	"CSTIME: "
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB4282:
	.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
	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	$56, %rsp
	.cfi_def_cfa_offset 112
	cmpl	$1, %edi
	jle	.L28
	movl	%edi, %r14d
	movq	8(%rsi), %rdi
	movq	%rsi, %r13
	call	atoi@PLT
	movl	%eax, %r15d
	cmpl	$2, %r14d
	je	.L29
	movq	16(%r13), %rdi
	call	atoi@PLT
	movl	%eax, %ebp
	cmpl	$3, %r14d
	je	.L30
	movq	24(%r13), %rdi
	movl	$89, %ebx
	call	atoi@PLT
	movl	%eax, %r12d
	cmpl	$4, %r14d
	je	.L19
	movq	32(%r13), %rdi
	call	atoi@PLT
	movl	%eax, %ebx
	jmp	.L19
.L28:
	movl	$89, %r12d
	movl	$89, %ebp
	movl	$89, %r15d
	jmp	.L33
.L29:
	movl	$89, %r12d
	movl	$89, %ebp
	jmp	.L33
.L30:
	movl	$89, %r12d
.L33:
	movl	$89, %ebx
.L19:
	movslq	%ebp, %rax
	movslq	%r15d, %r13
	movslq	%r12d, %r14
	imulq	%rax, %r13
	leaq	0(,%r13,4), %rdi
	call	malloc@PLT
	movq	%rax, 8(%rsp)
	movslq	%ebx, %rax
	imulq	%rax, %r14
	imulq	%r14, %r13
	leaq	0(,%r14,4), %rdi
	xorl	%r14d, %r14d
	call	malloc@PLT
	movq	%rax, 16(%rsp)
	leaq	0(,%r13,4), %rdi
	xorl	%r13d, %r13d
	call	malloc@PLT
	leaq	.LC2(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	movq	%rax, 24(%rsp)
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
.L20:
	cmpl	%r15d, %r14d
	jge	.L22
	movq	8(%rsp), %rcx
	movslq	%r13d, %rax
	xorl	%edx, %edx
	leaq	(%rcx,%rax,4), %rcx
.L23:
	cmpl	%edx, %ebp
	jle	.L34
	leal	0(%r13,%rdx), %eax
	leaq	_ZSt4cout(%rip), %rdi
	movq	%rcx, 40(%rsp)
	cvtsi2ssl	%eax, %xmm0
	movq	%rdx, 32(%rsp)
	movss	%xmm0, (%rcx,%rdx,4)
	cvtss2sd	%xmm0, %xmm0
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	leaq	.LC3(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	32(%rsp), %rdx
	movq	40(%rsp), %rcx
	incq	%rdx
	jmp	.L23
.L34:
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	incl	%r14d
	addl	%ebp, %r13d
	call	_ZNSolsEPFRSoS_E.isra.0
	jmp	.L20
.L22:
	leaq	.LC4(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	xorl	%r13d, %r13d
	xorl	%r14d, %r14d
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	leaq	.LC2(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
.L24:
	cmpl	%r12d, %r14d
	jge	.L26
	movq	16(%rsp), %rcx
	movslq	%r13d, %rax
	xorl	%edx, %edx
	leaq	(%rcx,%rax,4), %rcx
.L27:
	cmpl	%edx, %ebx
	jle	.L35
	leal	0(%r13,%rdx), %eax
	leaq	_ZSt4cout(%rip), %rdi
	movq	%rcx, 40(%rsp)
	cvtsi2ssl	%eax, %xmm0
	movq	%rdx, 32(%rsp)
	movss	%xmm0, (%rcx,%rdx,4)
	cvtss2sd	%xmm0, %xmm0
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	leaq	.LC3(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	32(%rsp), %rdx
	movq	40(%rsp), %rcx
	incq	%rdx
	jmp	.L27
.L35:
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	incl	%r14d
	addl	%ebx, %r13d
	call	_ZNSolsEPFRSoS_E.isra.0
	jmp	.L24
.L26:
	leaq	.LC5(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movl	$1000, %edi
	call	_Z11checkpointci
	movl	%r12d, %r9d
	movl	%ebp, %r8d
	movl	%r15d, %ecx
	pushq	%rax
	.cfi_def_cfa_offset 120
	pushq	%rbx
	.cfi_def_cfa_offset 128
	movq	24(%rsp), %rsi
	movq	32(%rsp), %rdx
	movq	40(%rsp), %rdi
	call	_Z4dotcPfS_S_iiii
	movl	$1000, %edi
	call	_Z11checkpointci
	leaq	.LC6(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	movsd	%xmm0, 24(%rsp)
	popq	%rdx
	.cfi_def_cfa_offset 120
	popq	%rcx
	.cfi_def_cfa_offset 112
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	leaq	.LC7(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movsd	8(%rsp), %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	addq	$56, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	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
.LFE4282:
	.size	main, .-main
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB4308:
	.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
.LFE4308:
	.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
	.data
	.align 8
	.type	_ZZ11checkpointciE5timer, @object
	.size	_ZZ11checkpointciE5timer, 8
_ZZ11checkpointciE5timer:
	.quad	-1
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	2147483647
	.long	0
	.long	0
	.long	0
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC1:
	.long	0
	.long	1093567616
	.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 <iostream>
#include <memory>
#include "hip/hip_runtime.h"
bool allclose(float x, float y, float threshold = 1e-4) {
	return abs(x - y) < threshold;
}
	
void dotc(float*dst, float*src1, float*src2, int xa, int ya, int za, int wa) {
	//xy * zw -> xz * yw
	int ywa = ya * wa;
	for(int xi = 0; xi < xa; xi++) {
		for(int yi = 0; yi < ya; yi++) {
			for(int zi = 0; zi < za; zi++) {
				for(int wi = 0; wi < wa; wi++) {
					int xzi = xi * za + zi;
					int ywi = yi * wa + wi;
					int i = xzi * ywa + ywi;
					int xyi = xi * ya + yi;
					int zwi = zi * wa + wi;
	 				dst[i] = src1[xyi] * src2[zwi];
	 			}
			}
		}
	}
}

double checkpointc(int us = 1e3) {
	static clock_t timer = -1;
	clock_t newtime = clock();
	double ustime = us * ((newtime - timer) / (double)CLOCKS_PER_SEC);
	timer = newtime;
	return ustime;
}
	

int main(int argc, char* argv[]) {
	const int defdim = 89;
	int xa = argc > 1 ? std::atoi(argv[1]) : defdim;
  int ya = argc > 2 ? std::atoi(argv[2]) : defdim;
	int za = argc > 3 ? std::atoi(argv[3]) : defdim;
  int wa = argc > 4 ? std::atoi(argv[4]) : defdim;
	float* src1 = (float*)malloc(sizeof(float) * xa * ya);
	float* src2 = (float*)malloc(sizeof(float) * za * wa);
	float* dst = (float*)malloc(sizeof(float)* xa * ya * za * wa);
	std::cout<<"------SRC1 / SRC2--------"<<std::endl;
	for(int xi = 0; xi < xa; xi++) {
		for(int yi = 0; yi < ya; yi++) {
			src1[xi * ya + yi] = xi * ya + yi;
			std::cout<<src1[xi * ya + yi]<<" ";
		}
		std::cout<<std::endl;
	}
	std::cout<<"+++++THRES+++++++"<<std::endl;
	  std::cout<<"------SRC1 / SRC2--------"<<std::endl;
  for(int zi = 0; zi < za; zi++) {
    for(int wi = 0; wi < wa; wi++) {
			src2[zi * wa + wi] = zi * wa + wi;
      std::cout<<src2[zi * wa + wi]<<" ";
    }
		std::cout<<std::endl;
	}
	std::cout<<"SRC -> DST"<<std::endl;
	checkpointc();
	dotc(dst, src1 ,src2, xa, ya, za, wa);
	double cstime = checkpointc();
	std::cout<<"******CPU DST*********"<<std::endl;
	int xza = xa * za;
	int ywa = ya * wa;
	/*for(int xzi = 0; xzi < xza; xzi++) {
		for(int ywi = 0; ywi < ywa; ywi++) {
			std::cout<<dst[xzi * ywa + ywi]<<" ";
		}
		std::cout<<std::endl;
	}*/
	std::cout<<"CSTIME: "<<cstime<<std::endl;
}

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

                                        # End of file scope inline assembly
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function _Z8allclosefff
.LCPI0_0:
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.text
	.globl	_Z8allclosefff
	.type	_Z8allclosefff,@function
_Z8allclosefff:                         # @_Z8allclosefff
	.cfi_startproc
# %bb.0:
	subss	%xmm1, %xmm0
	andps	.LCPI0_0(%rip), %xmm0
	ucomiss	%xmm0, %xmm2
	seta	%al
	retq
.Lfunc_end0:
	.size	_Z8allclosefff, .Lfunc_end0-_Z8allclosefff
	.cfi_endproc
                                        # -- End function
	.globl	_Z4dotcPfS_S_iiii               # -- Begin function _Z4dotcPfS_S_iiii
	.type	_Z4dotcPfS_S_iiii,@function
_Z4dotcPfS_S_iiii:                      # @_Z4dotcPfS_S_iiii
	.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
	.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, -52(%rsp)                 # 4-byte Spill
	movl	%r8d, -56(%rsp)                 # 4-byte Spill
	movq	%rdx, -8(%rsp)                  # 8-byte Spill
	movq	%rsi, -32(%rsp)                 # 8-byte Spill
	testl	%ecx, %ecx
	jle	.LBB1_12
# %bb.1:                                # %.preheader41.lr.ph
	movl	56(%rsp), %eax
	movslq	%eax, %r10
	movl	%ecx, %ecx
	movq	%rcx, -16(%rsp)                 # 8-byte Spill
	movl	-56(%rsp), %edx                 # 4-byte Reload
	movl	%edx, %r9d
	movl	-52(%rsp), %ecx                 # 4-byte Reload
	movl	%ecx, %ebx
	movl	%r10d, %r14d
	shlq	$2, %r10
	movl	%eax, %r15d
	imull	%edx, %r15d
	movl	%r15d, %edx
	imull	%ecx, %edx
	movq	%rdx, -24(%rsp)                 # 8-byte Spill
	xorl	%ecx, %ecx
	movq	%rcx, -40(%rsp)                 # 8-byte Spill
	xorl	%ecx, %ecx
	movq	%rcx, -48(%rsp)                 # 8-byte Spill
.LBB1_2:                                # %.preheader41
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_4 Depth 2
                                        #       Child Loop BB1_6 Depth 3
                                        #         Child Loop BB1_8 Depth 4
	cmpl	$0, -56(%rsp)                   # 4-byte Folded Reload
	jle	.LBB1_11
# %bb.3:                                # %.preheader40.lr.ph
                                        #   in Loop: Header=BB1_2 Depth=1
	movq	-48(%rsp), %rcx                 # 8-byte Reload
                                        # kill: def $ecx killed $ecx killed $rcx def $rcx
	imull	-56(%rsp), %ecx                 # 4-byte Folded Reload
	movq	-32(%rsp), %rdx                 # 8-byte Reload
	leaq	(%rdx,%rcx,4), %rcx
	movq	-40(%rsp), %rsi                 # 8-byte Reload
	xorl	%r12d, %r12d
.LBB1_4:                                # %.preheader40
                                        #   Parent Loop BB1_2 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB1_6 Depth 3
                                        #         Child Loop BB1_8 Depth 4
	cmpl	$0, -52(%rsp)                   # 4-byte Folded Reload
	jle	.LBB1_10
# %bb.5:                                # %.preheader.lr.ph
                                        #   in Loop: Header=BB1_4 Depth=2
	movq	%rsi, %r13
	movq	-8(%rsp), %rdx                  # 8-byte Reload
	xorl	%ebp, %ebp
.LBB1_6:                                # %.preheader
                                        #   Parent Loop BB1_2 Depth=1
                                        #     Parent Loop BB1_4 Depth=2
                                        # =>    This Loop Header: Depth=3
                                        #         Child Loop BB1_8 Depth 4
	testl	%eax, %eax
	jle	.LBB1_9
# %bb.7:                                # %.lr.ph
                                        #   in Loop: Header=BB1_6 Depth=3
	xorl	%r8d, %r8d
.LBB1_8:                                #   Parent Loop BB1_2 Depth=1
                                        #     Parent Loop BB1_4 Depth=2
                                        #       Parent Loop BB1_6 Depth=3
                                        # =>      This Inner Loop Header: Depth=4
	leal	(%r8,%r13), %r11d
	movss	(%rcx,%r12,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	mulss	(%rdx,%r8,4), %xmm0
	movslq	%r11d, %r11
	movss	%xmm0, (%rdi,%r11,4)
	incq	%r8
	cmpq	%r8, %r14
	jne	.LBB1_8
.LBB1_9:                                # %._crit_edge
                                        #   in Loop: Header=BB1_6 Depth=3
	incq	%rbp
	addq	%r10, %rdx
	addq	%r15, %r13
	cmpq	%rbx, %rbp
	jne	.LBB1_6
.LBB1_10:                               # %._crit_edge44
                                        #   in Loop: Header=BB1_4 Depth=2
	incq	%r12
	addq	%r14, %rsi
	cmpq	%r9, %r12
	jne	.LBB1_4
.LBB1_11:                               # %._crit_edge46
                                        #   in Loop: Header=BB1_2 Depth=1
	movq	-48(%rsp), %rdx                 # 8-byte Reload
	incq	%rdx
	movq	-40(%rsp), %rcx                 # 8-byte Reload
	addq	-24(%rsp), %rcx                 # 8-byte Folded Reload
	movq	%rcx, -40(%rsp)                 # 8-byte Spill
	movq	%rdx, %rcx
	movq	%rdx, -48(%rsp)                 # 8-byte Spill
	cmpq	-16(%rsp), %rdx                 # 8-byte Folded Reload
	jne	.LBB1_2
.LBB1_12:                               # %._crit_edge48
	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_end1:
	.size	_Z4dotcPfS_S_iiii, .Lfunc_end1-_Z4dotcPfS_S_iiii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z11checkpointci
.LCPI2_0:
	.quad	0x412e848000000000              # double 1.0E+6
	.text
	.globl	_Z11checkpointci
	.type	_Z11checkpointci,@function
_Z11checkpointci:                       # @_Z11checkpointci
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movl	%edi, %ebx
	callq	clock
	cvtsi2sd	%ebx, %xmm1
	movq	%rax, %rcx
	subq	_ZZ11checkpointciE5timer(%rip), %rcx
	cvtsi2sd	%rcx, %xmm0
	divsd	.LCPI2_0(%rip), %xmm0
	mulsd	%xmm1, %xmm0
	movq	%rax, _ZZ11checkpointciE5timer(%rip)
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z11checkpointci, .Lfunc_end2-_Z11checkpointci
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI3_0:
	.quad	0x412e848000000000              # double 1.0E+6
.LCPI3_1:
	.quad	0x408f400000000000              # double 1000
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.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	$56, %rsp
	.cfi_def_cfa_offset 112
	.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	$89, 8(%rsp)                    # 4-byte Folded Spill
	cmpl	$2, %edi
	jl	.LBB3_3
# %bb.1:
	movq	%rsi, %r12
	movl	%edi, %r13d
	movq	8(%rsi), %rdi
	callq	atoi
	movl	%eax, %ebx
	cmpl	$2, %r13d
	jne	.LBB3_18
# %bb.2:
	movl	$89, %r15d
	jmp	.LBB3_4
.LBB3_3:
	movl	$89, %r15d
	movl	$89, %ebx
.LBB3_4:                                # %.thread73
	movl	$89, %r14d
.LBB3_5:                                # %.thread73
	movl	%ebx, 24(%rsp)                  # 4-byte Spill
	movslq	%ebx, %rbx
	movslq	%r14d, %rbp
	imulq	%rbx, %rbp
	shlq	$2, %rbp
	movq	%rbp, %rdi
	callq	malloc
	movq	%rax, 40(%rsp)                  # 8-byte Spill
	movl	%r15d, 20(%rsp)                 # 4-byte Spill
	movslq	%r15d, %rax
	movslq	8(%rsp), %r15                   # 4-byte Folded Reload
	imulq	%rax, %r15
	leaq	(,%r15,4), %rdi
	callq	malloc
	movq	%rax, 32(%rsp)                  # 8-byte Spill
	imulq	%rbp, %r15
	movq	%r15, %rdi
	callq	malloc
	movq	%rax, 48(%rsp)                  # 8-byte Spill
	movl	$_ZSt4cout, %r15d
	movl	$_ZSt4cout, %edi
	movl	$.L.str, %esi
	movl	$25, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%r15, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	testl	%ebx, %ebx
	movl	%r14d, 28(%rsp)                 # 4-byte Spill
	jle	.LBB3_11
# %bb.6:                                # %.preheader75.lr.ph
	movl	24(%rsp), %ebp                  # 4-byte Reload
	movl	%r14d, %r12d
	xorl	%r13d, %r13d
	xorl	%ebx, %ebx
.LBB3_7:                                # %.preheader75
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_9 Depth 2
	testl	%r14d, %r14d
	jle	.LBB3_10
# %bb.8:                                # %.lr.ph
                                        #   in Loop: Header=BB3_7 Depth=1
	movl	%r13d, %eax
	movq	40(%rsp), %rcx                  # 8-byte Reload
	leaq	(%rcx,%rax,4), %r14
	xorl	%r15d, %r15d
.LBB3_9:                                #   Parent Loop BB3_7 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	leal	(%r15,%r13), %eax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	movss	%xmm0, (%r14,%r15,4)
	cvtss2sd	%xmm0, %xmm0
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movl	$.L.str.1, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	incq	%r15
	cmpq	%r15, %r12
	jne	.LBB3_9
.LBB3_10:                               # %._crit_edge
                                        #   in Loop: Header=BB3_7 Depth=1
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	movl	$_ZSt4cout, %eax
	addq	%rax, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	incq	%rbx
	addq	%r12, %r13
	cmpq	%rbp, %rbx
	movl	28(%rsp), %r14d                 # 4-byte Reload
	jne	.LBB3_7
.LBB3_11:                               # %._crit_edge78
	movl	$_ZSt4cout, %edi
	movl	$.L.str.2, %esi
	movl	$17, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	movl	$_ZSt4cout, %ebx
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$_ZSt4cout, %edi
	movl	$.L.str, %esi
	movl	$25, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	cmpl	$0, 20(%rsp)                    # 4-byte Folded Reload
	jle	.LBB3_17
# %bb.12:                               # %.preheader.lr.ph
	movl	20(%rsp), %r15d                 # 4-byte Reload
	movl	8(%rsp), %ebp                   # 4-byte Reload
	xorl	%r12d, %r12d
	xorl	%ebx, %ebx
.LBB3_13:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_15 Depth 2
	cmpl	$0, 8(%rsp)                     # 4-byte Folded Reload
	jle	.LBB3_16
# %bb.14:                               # %.lr.ph80
                                        #   in Loop: Header=BB3_13 Depth=1
	movl	%r12d, %eax
	movq	32(%rsp), %rcx                  # 8-byte Reload
	leaq	(%rcx,%rax,4), %r14
	xorl	%r13d, %r13d
.LBB3_15:                               #   Parent Loop BB3_13 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	leal	(%r12,%r13), %eax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	movss	%xmm0, (%r14,%r13,4)
	cvtss2sd	%xmm0, %xmm0
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movl	$.L.str.1, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	incq	%r13
	cmpq	%r13, %rbp
	jne	.LBB3_15
.LBB3_16:                               # %._crit_edge81
                                        #   in Loop: Header=BB3_13 Depth=1
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	movl	$_ZSt4cout, %eax
	addq	%rax, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	incq	%rbx
	addq	%rbp, %r12
	cmpq	%r15, %rbx
	jne	.LBB3_13
.LBB3_17:                               # %._crit_edge83
	movl	$_ZSt4cout, %ebx
	movl	$_ZSt4cout, %edi
	movl	$.L.str.3, %esi
	movl	$10, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	callq	clock
	movq	%rax, _ZZ11checkpointciE5timer(%rip)
	movl	8(%rsp), %eax                   # 4-byte Reload
	movl	%eax, (%rsp)
	movq	48(%rsp), %rdi                  # 8-byte Reload
	movq	40(%rsp), %rsi                  # 8-byte Reload
	movq	32(%rsp), %rdx                  # 8-byte Reload
	movl	24(%rsp), %ecx                  # 4-byte Reload
	movl	28(%rsp), %r8d                  # 4-byte Reload
	movl	20(%rsp), %r9d                  # 4-byte Reload
	callq	_Z4dotcPfS_S_iiii
	callq	clock
	movq	%rax, %rcx
	subq	_ZZ11checkpointciE5timer(%rip), %rcx
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rcx, %xmm0
	divsd	.LCPI3_0(%rip), %xmm0
	mulsd	.LCPI3_1(%rip), %xmm0
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
	movq	%rax, _ZZ11checkpointciE5timer(%rip)
	movl	$_ZSt4cout, %edi
	movl	$.L.str.4, %esi
	movl	$22, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$_ZSt4cout, %edi
	movl	$.L.str.5, %esi
	movl	$8, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movsd	8(%rsp), %xmm0                  # 8-byte Reload
                                        # xmm0 = mem[0],zero
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %rbx
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%rbx, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	xorl	%eax, %eax
	addq	$56, %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
.LBB3_18:
	.cfi_def_cfa_offset 112
	movq	16(%r12), %rdi
	callq	atoi
	movl	%eax, %r14d
	cmpl	$4, %r13d
	jb	.LBB3_21
# %bb.19:
	movq	24(%r12), %rdi
	callq	atoi
	movl	%eax, %r15d
	cmpl	$4, %r13d
	je	.LBB3_5
# %bb.20:
	movq	32(%r12), %rdi
	callq	atoi
	movl	%eax, 8(%rsp)                   # 4-byte Spill
	jmp	.LBB3_5
.LBB3_21:
	movl	$89, %r15d
	jmp	.LBB3_5
.Lfunc_end3:
	.size	main, .Lfunc_end3-main
	.cfi_endproc
                                        # -- End function
	.type	_ZZ11checkpointciE5timer,@object # @_ZZ11checkpointciE5timer
	.data
	.p2align	3, 0x0
_ZZ11checkpointciE5timer:
	.quad	-1                              # 0xffffffffffffffff
	.size	_ZZ11checkpointciE5timer, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"------SRC1 / SRC2--------"
	.size	.L.str, 26

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

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"+++++THRES+++++++"
	.size	.L.str.2, 18

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"SRC -> DST"
	.size	.L.str.3, 11

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"******CPU DST*********"
	.size	.L.str.4, 23

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"CSTIME: "
	.size	.L.str.5, 9

	.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 _ZSt4cout
	.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
