#include "matrix/Matrix.cuh"
#include "matrix_utils/svd.cuh"
#include <stdio.h>
#include <chrono>

// CATCH_CUDA_ERR(cudaMalloc(&dev_array, sizeof(int) * used_n));
// CATCH_CUDA_ERR(cudaMemcpy(dev_array, array, sizeof(int) * used_n, cudaMemcpyHostToDevice));

int main() {
//    int i1 = 10, i2 = 10, i3 = 10, i4 = 10, i5 = 10, i6 = 10, i7 = 10;
//    Matrix* mtr = hilbert(i1, i2, i3, i4, i5, i6, i7);
//    Matrix* mtr = hilbert(1000, 1000, 100);

    // Matrix* mtr = hilbert(m,n);
    // Matrix* mtr = hilbert(n,m);
    // int * shapes = new int[3];
    // shapes[0] = n;
    // shapes[1] = m;
    // shapes[2] = k;
    // Matrix* mtr = hilbert(n, m, k);
    // delete[] shapes;
    // auto p = QRDecompositionNaive(mtr);
    // Matrix* res = multiply(p.first, p.second);
    // auto trip = SVDDecomposition(mtr, 10, 1e-6);
    // auto svd = SVDDecompositionwCUB(mtr);
    // show(svd->first, 4, 4);
    // show(svd->second, 4, 4);
    // show(svd->third, 4, 16);
    // printf("HI");
    // auto tmp = multiply(svd->first, svd->second);
    // auto res = multiply(tmp, svd->third);

    // auto tmp = multiply(transpose(svd->third), svd->second);
    // auto res = multiply(tmp, transpose(svd->first));
    // printf("Diff: %f \n", diff(mtr, res));
    // show(res, 4, 16);
    // show(res, 16, 4);
    // printf("Size(%d %d), Diff: %f \n", n, m, diff(mtr, res));
    // Matrix* d_mtr;
    // double* d_mtr_arr;
    // int* d_dims_arr;
    // copyMatrixFromHostToDevice(mtr, &d_mtr, &d_mtr_arr, &d_dims_arr);
    // show(mtr, n, m);
    // int* newShapes = new int[2];
    // newShapes[0] = 8;
    // newShapes[1] = 2;
    // mtr->reshape(newShapes, 2);
    // show(mtr, 8, 2);
//    printf("start tt decomposition %d\n", mtr->shape_length);
//    auto start = chrono::high_resolution_clock::now();
//    auto tt    = TTDecomposition(mtr, 1e-3);
//    auto end   = chrono::high_resolution_clock::now();
//
//    auto diff = chrono::duration_cast<chrono::milliseconds>(end - start);
//    printf("Execution time %f\n", diff.count() / 1000.);

    // show(tt[2], 4, 4);
//    for(auto i : tt) {
//        printf("%d ", i->shape_length);
//    }
//    printf("\n");
//    vector<int> indexes = {0, 1, 0};
//    double val = getValueFromTrain(tt, indexes);
//    printf("Value: %f\n", val);

    // show(res, n, m);
    // show(mtr, n, m, k);
    // tensorTrain(mtr, 1e-6);
    // delete mtr;

    // printf("%d %d %d\n", d_mtr, d_mtr_arr, d_dims_arr);
    // (cudaFree(d_mtr));
    // (cudaFree(d_mtr_arr));
    // (cudaFree(d_dims_arr));
    // delete tmp;
    // delete t;
    // delete res;
    // delete trip->first;
    // delete trip->second;
    // delete trip->third;
    // delete trip;

    double res = 0;
    int r = 8;
    double step = 1. / r;

    auto *cube = sinCube(r, step);

    auto start = chrono::high_resolution_clock::now();
    printf("!%d!\n", cube->total_element_count);
//s
//    for (int i = 0; i < cube->shape_length; i++) {
//        printf("%d\n", cube->real_shape[i]);
//    }

    auto tt = TTDecomposition(cube, 1e-3);
    vector<Matrix *> u;

    for (int i = 0; i < 10; i++) {
        auto us = new Matrix(r, 1);
        for (int j = 0; j < r; j++) {
            us->set(j, 0, step);
        }
        u.push_back(us);
    }

    res = convolution(tt, u);
    auto end = chrono::high_resolution_clock::now();


    printf("Res: %.6f\n", res);

    auto diff = chrono::duration_cast<chrono::milliseconds>(end - start);
    printf("Execution time %f", diff.count() / 1000.);



    return 0;
}

	.file	"tmpxft_00365f7a_00000000-6_main.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB4240:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE4240:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB4263:
	.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
.LFE4263:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.text._ZNSt6vectorIP6MatrixSaIS1_EED2Ev,"axG",@progbits,_ZNSt6vectorIP6MatrixSaIS1_EED5Ev,comdat
	.align 2
	.weak	_ZNSt6vectorIP6MatrixSaIS1_EED2Ev
	.type	_ZNSt6vectorIP6MatrixSaIS1_EED2Ev, @function
_ZNSt6vectorIP6MatrixSaIS1_EED2Ev:
.LFB4602:
	.cfi_startproc
	endbr64
	movq	(%rdi), %rax
	testq	%rax, %rax
	je	.L4
	movq	16(%rdi), %rsi
	movq	%rax, %rdi
	subq	%rax, %rsi
	jmp	_ZdlPvm@PLT
.L4:
	ret
	.cfi_endproc
.LFE4602:
	.size	_ZNSt6vectorIP6MatrixSaIS1_EED2Ev, .-_ZNSt6vectorIP6MatrixSaIS1_EED2Ev
	.weak	_ZNSt6vectorIP6MatrixSaIS1_EED1Ev
	.set	_ZNSt6vectorIP6MatrixSaIS1_EED1Ev,_ZNSt6vectorIP6MatrixSaIS1_EED2Ev
	.section	.text._ZNSt6vectorIP6MatrixSaIS1_EEC2ERKS3_,"axG",@progbits,_ZNSt6vectorIP6MatrixSaIS1_EEC5ERKS3_,comdat
	.align 2
	.weak	_ZNSt6vectorIP6MatrixSaIS1_EEC2ERKS3_
	.type	_ZNSt6vectorIP6MatrixSaIS1_EEC2ERKS3_, @function
_ZNSt6vectorIP6MatrixSaIS1_EEC2ERKS3_:
.LFB4616:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rsi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	8(%rsi), %rbp
	movq	%rdi, %rbx
	subq	(%rsi), %rbp
	movq	$0, (%rdi)
	movq	$0, 8(%rdi)
	movq	$0, 16(%rdi)
	je	.L12
	movabsq	$9223372036854775800, %rax
	cmpq	%rbp, %rax
	jnb	.L9
	call	_ZSt28__throw_bad_array_new_lengthv@PLT
.L9:
	movq	%rbp, %rdi
	call	_Znwm@PLT
	movq	%rax, %rcx
	jmp	.L8
.L12:
	xorl	%ecx, %ecx
.L8:
	addq	%rcx, %rbp
	movq	%rcx, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rbp, 16(%rbx)
	movq	(%r12), %rsi
	movq	8(%r12), %rbp
	subq	%rsi, %rbp
	cmpq	$8, %rbp
	jle	.L10
	movq	%rcx, %rdi
	movq	%rbp, %rdx
	call	memmove@PLT
	movq	%rax, %rcx
	jmp	.L11
.L10:
	jne	.L11
	movq	(%rsi), %rax
	movq	%rax, (%rcx)
.L11:
	addq	%rbp, %rcx
	movq	%rcx, 8(%rbx)
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4616:
	.size	_ZNSt6vectorIP6MatrixSaIS1_EEC2ERKS3_, .-_ZNSt6vectorIP6MatrixSaIS1_EEC2ERKS3_
	.weak	_ZNSt6vectorIP6MatrixSaIS1_EEC1ERKS3_
	.set	_ZNSt6vectorIP6MatrixSaIS1_EEC1ERKS3_,_ZNSt6vectorIP6MatrixSaIS1_EEC2ERKS3_
	.section	.rodata._ZNSt6vectorIP6MatrixSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_.str1.1,"aMS",@progbits,1
.LC0:
	.string	"vector::_M_realloc_insert"
	.section	.text._ZNSt6vectorIP6MatrixSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_,"axG",@progbits,_ZNSt6vectorIP6MatrixSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_,comdat
	.align 2
	.weak	_ZNSt6vectorIP6MatrixSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_
	.type	_ZNSt6vectorIP6MatrixSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_, @function
_ZNSt6vectorIP6MatrixSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_:
.LFB4794:
	.cfi_startproc
	endbr64
	movabsq	$1152921504606846975, %rcx
	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	$24, %rsp
	.cfi_def_cfa_offset 80
	movq	8(%rdi), %rax
	movq	(%rdi), %r14
	movq	%rax, %rbx
	movq	%rax, (%rsp)
	subq	%r14, %rbx
	sarq	$3, %rbx
	cmpq	%rcx, %rbx
	jne	.L15
	leaq	.LC0(%rip), %rdi
	call	_ZSt20__throw_length_errorPKc@PLT
.L15:
	cmpq	%r14, (%rsp)
	movl	$1, %eax
	movq	%rsi, %r15
	movq	%rdi, %r13
	cmovne	%rbx, %rax
	movq	%rsi, %rbp
	addq	%rax, %rbx
	setc	%al
	subq	%r14, %r15
	movzbl	%al, %eax
	testq	%rax, %rax
	jne	.L25
	xorl	%r12d, %r12d
	testq	%rbx, %rbx
	je	.L20
	movabsq	$1152921504606846975, %rax
	cmpq	%rax, %rbx
	cmova	%rax, %rbx
	jmp	.L19
.L25:
	movq	%rcx, %rbx
.L19:
	leaq	0(,%rbx,8), %rdi
	movq	%rdx, 8(%rsp)
	call	_Znwm@PLT
	movq	8(%rsp), %rdx
	movq	%rax, %r12
.L20:
	movq	(%rdx), %rax
	movq	%rax, (%r12,%r15)
	testq	%r15, %r15
	jle	.L21
	movq	%r15, %rdx
	movq	%r14, %rsi
	movq	%r12, %rdi
	call	memmove@PLT
.L21:
	movq	(%rsp), %rax
	leaq	8(%r12,%r15), %rdx
	subq	%rbp, %rax
	testq	%rax, %rax
	jle	.L22
	movq	%rdx, %rdi
	movq	%rbp, %rsi
	movq	%rax, %rcx
	rep movsb
.L22:
	leaq	(%rdx,%rax), %rbp
	testq	%r14, %r14
	je	.L23
	movq	16(%r13), %rsi
	movq	%r14, %rdi
	subq	%r14, %rsi
	call	_ZdlPvm@PLT
.L23:
	leaq	(%r12,%rbx,8), %rax
	movq	%r12, 0(%r13)
	movq	%rbp, 8(%r13)
	movq	%rax, 16(%r13)
	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
.LFE4794:
	.size	_ZNSt6vectorIP6MatrixSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_, .-_ZNSt6vectorIP6MatrixSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"!%d!\n"
.LC5:
	.string	"Res: %.6f\n"
.LC7:
	.string	"Execution time %f"
	.section	.text.startup
	.globl	main
	.type	main, @function
main:
.LFB4224:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA4224
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movl	$8, %edi
	movabsq	$4294967304, %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movl	$10, %r13d
	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
	addq	$-128, %rsp
	.cfi_def_cfa_offset 176
	movsd	.LC1(%rip), %xmm0
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rbp
.LEHB0:
	call	_Z7sinCubeid@PLT
	movq	%rax, %r12
	call	_ZNSt6chrono3_V212system_clock3nowEv@PLT
	movl	24(%r12), %edx
	movl	$2, %edi
	leaq	.LC2(%rip), %rsi
	movq	%rax, %rbx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movsd	.LC3(%rip), %xmm0
	movq	%r12, %rsi
	movq	%rbp, %rdi
	call	_Z15TTDecompositionP6Matrixd@PLT
.LEHE0:
	xorl	%eax, %eax
	movq	%rax, 48(%rsp)
	movq	%rax, 56(%rsp)
	movq	%rax, 64(%rsp)
.L38:
	movl	$32, %edi
.LEHB1:
	call	_Znwm@PLT
.LEHE1:
	movl	$8, 24(%rax)
	movl	$64, %edi
	movq	%rax, %r12
.LEHB2:
	call	_Znam@PLT
	movq	%rax, (%r12)
	movl	24(%r12), %ecx
	xorl	%edx, %edx
.L33:
	cmpl	%edx, %ecx
	jle	.L53
	movq	$0x000000000, (%rax,%rdx,8)
	incq	%rdx
	jmp	.L33
.L53:
	movl	$8, %edi
	call	_Znam@PLT
.LEHE2:
	movl	$2, 8(%r12)
	movq	(%r12), %rdx
	movq	%r12, 96(%rsp)
	movq	%rax, 16(%r12)
	movq	%r14, (%rax)
	xorl	%eax, %eax
.L35:
	movq	.LC1(%rip), %rcx
	movq	%rcx, (%rdx,%rax,8)
	incq	%rax
	cmpq	$8, %rax
	jne	.L35
	movq	56(%rsp), %rsi
	cmpq	64(%rsp), %rsi
	je	.L36
	movq	%r12, (%rsi)
	addq	$8, %rsi
	movq	%rsi, 56(%rsp)
	jmp	.L37
.L36:
	leaq	96(%rsp), %rdx
	leaq	48(%rsp), %rdi
.LEHB3:
	call	_ZNSt6vectorIP6MatrixSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_
.L37:
	decl	%r13d
	jne	.L38
	leaq	48(%rsp), %r14
	leaq	96(%rsp), %r12
	movq	%r14, %rsi
	movq	%r12, %rdi
	call	_ZNSt6vectorIP6MatrixSaIS1_EEC1ERKS3_
.LEHE3:
	leaq	72(%rsp), %r13
	movq	%rbp, %rsi
	movq	%r13, %rdi
.LEHB4:
	call	_ZNSt6vectorIP6MatrixSaIS1_EEC1ERKS3_
.LEHE4:
	movq	%r12, %rsi
	movq	%r13, %rdi
.LEHB5:
	call	_Z11convolutionSt6vectorIP6MatrixSaIS1_EES3_@PLT
.LEHE5:
	movq	%r13, %rdi
	movsd	%xmm0, 8(%rsp)
	call	_ZNSt6vectorIP6MatrixSaIS1_EED1Ev
	movq	%r12, %rdi
	call	_ZNSt6vectorIP6MatrixSaIS1_EED1Ev
	call	_ZNSt6chrono3_V212system_clock3nowEv@PLT
	movsd	8(%rsp), %xmm0
	movl	$2, %edi
	leaq	.LC5(%rip), %rsi
	movq	%rax, %r12
	movb	$1, %al
.LEHB6:
	call	__printf_chk@PLT
	movq	%r12, %rax
	movl	$1000000, %ecx
	movl	$2, %edi
	subq	%rbx, %rax
	leaq	.LC7(%rip), %rsi
	cqto
	idivq	%rcx
	cvtsi2sdq	%rax, %xmm0
	movb	$1, %al
	divsd	.LC6(%rip), %xmm0
	call	__printf_chk@PLT
.LEHE6:
	movq	%r14, %rdi
	call	_ZNSt6vectorIP6MatrixSaIS1_EED1Ev
	movq	%rbp, %rdi
	call	_ZNSt6vectorIP6MatrixSaIS1_EED1Ev
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L44
	jmp	.L51
.L45:
	endbr64
	movq	%rax, %rbx
.L39:
	movl	$32, %esi
	movq	%r12, %rdi
	call	_ZdlPvm@PLT
	jmp	.L40
.L48:
	endbr64
	movq	%rax, %rbx
.L41:
	movq	%r13, %rdi
	call	_ZNSt6vectorIP6MatrixSaIS1_EED1Ev
	jmp	.L42
.L47:
	endbr64
	movq	%rax, %rbx
.L42:
	movq	%r12, %rdi
	call	_ZNSt6vectorIP6MatrixSaIS1_EED1Ev
	jmp	.L40
.L46:
	endbr64
	movq	%rax, %rbx
.L40:
	leaq	48(%rsp), %rdi
	call	_ZNSt6vectorIP6MatrixSaIS1_EED1Ev
	movq	%rbp, %rdi
	call	_ZNSt6vectorIP6MatrixSaIS1_EED1Ev
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L51
	movq	%rbx, %rdi
.LEHB7:
	call	_Unwind_Resume@PLT
.LEHE7:
.L51:
	call	__stack_chk_fail@PLT
.L44:
	subq	$-128, %rsp
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	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
.LFE4224:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table,"a",@progbits
.LLSDA4224:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE4224-.LLSDACSB4224
.LLSDACSB4224:
	.uleb128 .LEHB0-.LFB4224
	.uleb128 .LEHE0-.LEHB0
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB1-.LFB4224
	.uleb128 .LEHE1-.LEHB1
	.uleb128 .L46-.LFB4224
	.uleb128 0
	.uleb128 .LEHB2-.LFB4224
	.uleb128 .LEHE2-.LEHB2
	.uleb128 .L45-.LFB4224
	.uleb128 0
	.uleb128 .LEHB3-.LFB4224
	.uleb128 .LEHE3-.LEHB3
	.uleb128 .L46-.LFB4224
	.uleb128 0
	.uleb128 .LEHB4-.LFB4224
	.uleb128 .LEHE4-.LEHB4
	.uleb128 .L47-.LFB4224
	.uleb128 0
	.uleb128 .LEHB5-.LFB4224
	.uleb128 .LEHE5-.LEHB5
	.uleb128 .L48-.LFB4224
	.uleb128 0
	.uleb128 .LEHB6-.LFB4224
	.uleb128 .LEHE6-.LEHB6
	.uleb128 .L46-.LFB4224
	.uleb128 0
	.uleb128 .LEHB7-.LFB4224
	.uleb128 .LEHE7-.LEHB7
	.uleb128 0
	.uleb128 0
.LLSDACSE4224:
	.section	.text.startup
	.size	main, .-main
	.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	1069547520
	.align 8
.LC3:
	.long	-755914244
	.long	1062232653
	.align 8
.LC6:
	.long	0
	.long	1083129856
	.hidden	DW.ref.__gxx_personality_v0
	.weak	DW.ref.__gxx_personality_v0
	.section	.data.rel.local.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat
	.align 8
	.type	DW.ref.__gxx_personality_v0, @object
	.size	DW.ref.__gxx_personality_v0, 8
DW.ref.__gxx_personality_v0:
	.quad	__gxx_personality_v0
	.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 "matrix/Matrix.cuh"
#include "matrix_utils/svd.cuh"
#include <stdio.h>
#include <chrono>

// CATCH_CUDA_ERR(cudaMalloc(&dev_array, sizeof(int) * used_n));
// CATCH_CUDA_ERR(cudaMemcpy(dev_array, array, sizeof(int) * used_n, cudaMemcpyHostToDevice));

int main() {
//    int i1 = 10, i2 = 10, i3 = 10, i4 = 10, i5 = 10, i6 = 10, i7 = 10;
//    Matrix* mtr = hilbert(i1, i2, i3, i4, i5, i6, i7);
//    Matrix* mtr = hilbert(1000, 1000, 100);

    // Matrix* mtr = hilbert(m,n);
    // Matrix* mtr = hilbert(n,m);
    // int * shapes = new int[3];
    // shapes[0] = n;
    // shapes[1] = m;
    // shapes[2] = k;
    // Matrix* mtr = hilbert(n, m, k);
    // delete[] shapes;
    // auto p = QRDecompositionNaive(mtr);
    // Matrix* res = multiply(p.first, p.second);
    // auto trip = SVDDecomposition(mtr, 10, 1e-6);
    // auto svd = SVDDecompositionwCUB(mtr);
    // show(svd->first, 4, 4);
    // show(svd->second, 4, 4);
    // show(svd->third, 4, 16);
    // printf("HI");
    // auto tmp = multiply(svd->first, svd->second);
    // auto res = multiply(tmp, svd->third);

    // auto tmp = multiply(transpose(svd->third), svd->second);
    // auto res = multiply(tmp, transpose(svd->first));
    // printf("Diff: %f \n", diff(mtr, res));
    // show(res, 4, 16);
    // show(res, 16, 4);
    // printf("Size(%d %d), Diff: %f \n", n, m, diff(mtr, res));
    // Matrix* d_mtr;
    // double* d_mtr_arr;
    // int* d_dims_arr;
    // copyMatrixFromHostToDevice(mtr, &d_mtr, &d_mtr_arr, &d_dims_arr);
    // show(mtr, n, m);
    // int* newShapes = new int[2];
    // newShapes[0] = 8;
    // newShapes[1] = 2;
    // mtr->reshape(newShapes, 2);
    // show(mtr, 8, 2);
//    printf("start tt decomposition %d\n", mtr->shape_length);
//    auto start = chrono::high_resolution_clock::now();
//    auto tt    = TTDecomposition(mtr, 1e-3);
//    auto end   = chrono::high_resolution_clock::now();
//
//    auto diff = chrono::duration_cast<chrono::milliseconds>(end - start);
//    printf("Execution time %f\n", diff.count() / 1000.);

    // show(tt[2], 4, 4);
//    for(auto i : tt) {
//        printf("%d ", i->shape_length);
//    }
//    printf("\n");
//    vector<int> indexes = {0, 1, 0};
//    double val = getValueFromTrain(tt, indexes);
//    printf("Value: %f\n", val);

    // show(res, n, m);
    // show(mtr, n, m, k);
    // tensorTrain(mtr, 1e-6);
    // delete mtr;

    // printf("%d %d %d\n", d_mtr, d_mtr_arr, d_dims_arr);
    // (cudaFree(d_mtr));
    // (cudaFree(d_mtr_arr));
    // (cudaFree(d_dims_arr));
    // delete tmp;
    // delete t;
    // delete res;
    // delete trip->first;
    // delete trip->second;
    // delete trip->third;
    // delete trip;

    double res = 0;
    int r = 8;
    double step = 1. / r;

    auto *cube = sinCube(r, step);

    auto start = chrono::high_resolution_clock::now();
    printf("!%d!\n", cube->total_element_count);
//s
//    for (int i = 0; i < cube->shape_length; i++) {
//        printf("%d\n", cube->real_shape[i]);
//    }

    auto tt = TTDecomposition(cube, 1e-3);
    vector<Matrix *> u;

    for (int i = 0; i < 10; i++) {
        auto us = new Matrix(r, 1);
        for (int j = 0; j < r; j++) {
            us->set(j, 0, step);
        }
        u.push_back(us);
    }

    res = convolution(tt, u);
    auto end = chrono::high_resolution_clock::now();


    printf("Res: %.6f\n", res);

    auto diff = chrono::duration_cast<chrono::milliseconds>(end - start);
    printf("Execution time %f", diff.count() / 1000.);



    return 0;
}

	.text
	.file	"main.hip"
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI0_0:
	.quad	0x3fc0000000000000              # double 0.125
.LCPI0_1:
	.quad	0x3f50624dd2f1a9fc              # double 0.001
.LCPI0_2:
	.quad	0x408f400000000000              # double 1000
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
.Lfunc_begin0:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception0
# %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	$120, %rsp
	.cfi_def_cfa_offset 176
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movsd	.LCPI0_0(%rip), %xmm0           # xmm0 = mem[0],zero
	movl	$8, %edi
	callq	_Z7sinCubeid
	movq	%rax, %r14
	callq	_ZNSt6chrono3_V212system_clock3nowEv
	movq	%rax, 32(%rsp)                  # 8-byte Spill
	movl	24(%r14), %esi
	xorl	%ebp, %ebp
	movl	$.L.str, %edi
	xorl	%eax, %eax
	callq	printf
	leaq	96(%rsp), %rdi
	movsd	.LCPI0_1(%rip), %xmm0           # xmm0 = mem[0],zero
	movq	%r14, %rsi
	callq	_Z15TTDecompositionP6Matrixd
	xorps	%xmm0, %xmm0
	movq	%rsp, %r14
	movaps	%xmm0, (%r14)
	movq	$0, 16(%r14)
	movabsq	$4294967304, %rbx               # imm = 0x100000008
	movabsq	$4593671619917905920, %r15      # imm = 0x3FC0000000000000
.LBB0_1:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_5 Depth 2
.Ltmp0:
	movl	$32, %edi
	callq	_Znwm
.Ltmp1:
# %bb.2:                                #   in Loop: Header=BB0_1 Depth=1
	movq	%rax, %r12
	movl	$8, 24(%rax)
.Ltmp2:
	movl	$64, %edi
	callq	_Znam
.Ltmp3:
# %bb.3:                                # %.noexc
                                        #   in Loop: Header=BB0_1 Depth=1
	movq	%rax, %r13
	movq	%rax, (%r12)
	xorps	%xmm0, %xmm0
	movups	%xmm0, 48(%rax)
	movups	%xmm0, 32(%rax)
	movups	%xmm0, 16(%rax)
	movups	%xmm0, (%rax)
.Ltmp4:
	movl	$8, %edi
	callq	_Znam
.Ltmp5:
# %bb.4:                                #   in Loop: Header=BB0_1 Depth=1
	movq	%rax, 16(%r12)
	movq	%rbx, (%rax)
	movl	$2, 8(%r12)
	movq	%r12, 40(%rsp)
	xorl	%eax, %eax
.LBB0_5:                                #   Parent Loop BB0_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	%r15, (%r13,%rax,8)
	incq	%rax
	cmpq	$8, %rax
	jne	.LBB0_5
# %bb.6:                                #   in Loop: Header=BB0_1 Depth=1
	movq	8(%rsp), %rsi
	cmpq	16(%rsp), %rsi
	je	.LBB0_8
# %bb.7:                                #   in Loop: Header=BB0_1 Depth=1
	movq	%r12, (%rsi)
	addq	$8, 8(%rsp)
	jmp	.LBB0_9
.LBB0_8:                                #   in Loop: Header=BB0_1 Depth=1
.Ltmp7:
	movq	%r14, %rdi
	leaq	40(%rsp), %rdx
	callq	_ZNSt6vectorIP6MatrixSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_
.Ltmp8:
.LBB0_9:                                # %_ZNSt6vectorIP6MatrixSaIS1_EE9push_backERKS1_.exit
                                        #   in Loop: Header=BB0_1 Depth=1
	incl	%ebp
	cmpl	$10, %ebp
	jne	.LBB0_1
# %bb.10:
.Ltmp10:
	leaq	72(%rsp), %rdi
	leaq	96(%rsp), %rsi
	callq	_ZNSt6vectorIP6MatrixSaIS1_EEC2ERKS3_
.Ltmp11:
# %bb.11:
.Ltmp13:
	leaq	48(%rsp), %rdi
	movq	%rsp, %rsi
	callq	_ZNSt6vectorIP6MatrixSaIS1_EEC2ERKS3_
.Ltmp14:
# %bb.12:
.Ltmp16:
	leaq	72(%rsp), %rdi
	leaq	48(%rsp), %rsi
	callq	_Z11convolutionSt6vectorIP6MatrixSaIS1_EES3_
	movsd	%xmm0, 24(%rsp)                 # 8-byte Spill
.Ltmp17:
# %bb.13:
	movq	48(%rsp), %rdi
	testq	%rdi, %rdi
	je	.LBB0_15
# %bb.14:
	callq	_ZdlPv
.LBB0_15:                               # %_ZNSt6vectorIP6MatrixSaIS1_EED2Ev.exit
	movq	72(%rsp), %rdi
	testq	%rdi, %rdi
	je	.LBB0_17
# %bb.16:
	callq	_ZdlPv
.LBB0_17:
	callq	_ZNSt6chrono3_V212system_clock3nowEv
	movq	%rax, %r14
	movl	$.L.str.1, %edi
	movsd	24(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movb	$1, %al
	callq	printf
	subq	32(%rsp), %r14                  # 8-byte Folded Reload
	movabsq	$4835703278458516699, %rcx      # imm = 0x431BDE82D7B634DB
	movq	%r14, %rax
	imulq	%rcx
	movq	%rdx, %rax
	shrq	$63, %rax
	sarq	$18, %rdx
	addq	%rax, %rdx
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rdx, %xmm0
	divsd	.LCPI0_2(%rip), %xmm0
	movl	$.L.str.2, %edi
	movb	$1, %al
	callq	printf
	movq	(%rsp), %rdi
	testq	%rdi, %rdi
	je	.LBB0_19
# %bb.18:
	callq	_ZdlPv
.LBB0_19:                               # %_ZNSt6vectorIP6MatrixSaIS1_EED2Ev.exit30
	movq	96(%rsp), %rdi
	testq	%rdi, %rdi
	je	.LBB0_21
# %bb.20:
	callq	_ZdlPv
.LBB0_21:                               # %_ZNSt6vectorIP6MatrixSaIS1_EED2Ev.exit32
	xorl	%eax, %eax
	addq	$120, %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
.LBB0_22:
	.cfi_def_cfa_offset 176
.Ltmp18:
	movq	%rax, %rbx
	movq	48(%rsp), %rdi
	testq	%rdi, %rdi
	je	.LBB0_25
# %bb.23:
	callq	_ZdlPv
	jmp	.LBB0_25
.LBB0_24:
.Ltmp15:
	movq	%rax, %rbx
.LBB0_25:                               # %_ZNSt6vectorIP6MatrixSaIS1_EED2Ev.exit34
	movq	72(%rsp), %rdi
	testq	%rdi, %rdi
	jne	.LBB0_30
	jmp	.LBB0_31
.LBB0_26:
.Ltmp12:
	jmp	.LBB0_28
.LBB0_27:
.Ltmp9:
.LBB0_28:                               # %_ZNSt6vectorIP6MatrixSaIS1_EED2Ev.exit36
	movq	%rax, %rbx
	jmp	.LBB0_31
.LBB0_29:
.Ltmp6:
	movq	%rax, %rbx
	movq	%r12, %rdi
.LBB0_30:
	callq	_ZdlPv
.LBB0_31:                               # %_ZNSt6vectorIP6MatrixSaIS1_EED2Ev.exit36
	movq	(%rsp), %rdi
	testq	%rdi, %rdi
	je	.LBB0_33
# %bb.32:
	callq	_ZdlPv
.LBB0_33:                               # %_ZNSt6vectorIP6MatrixSaIS1_EED2Ev.exit38
	movq	96(%rsp), %rdi
	testq	%rdi, %rdi
	je	.LBB0_35
# %bb.34:
	callq	_ZdlPv
.LBB0_35:                               # %_ZNSt6vectorIP6MatrixSaIS1_EED2Ev.exit40
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end0:
	.size	main, .Lfunc_end0-main
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table0:
.Lexception0:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end0-.Lcst_begin0
.Lcst_begin0:
	.uleb128 .Lfunc_begin0-.Lfunc_begin0    # >> Call Site 1 <<
	.uleb128 .Ltmp0-.Lfunc_begin0           #   Call between .Lfunc_begin0 and .Ltmp0
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp0-.Lfunc_begin0           # >> Call Site 2 <<
	.uleb128 .Ltmp1-.Ltmp0                  #   Call between .Ltmp0 and .Ltmp1
	.uleb128 .Ltmp9-.Lfunc_begin0           #     jumps to .Ltmp9
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp2-.Lfunc_begin0           # >> Call Site 3 <<
	.uleb128 .Ltmp5-.Ltmp2                  #   Call between .Ltmp2 and .Ltmp5
	.uleb128 .Ltmp6-.Lfunc_begin0           #     jumps to .Ltmp6
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp7-.Lfunc_begin0           # >> Call Site 4 <<
	.uleb128 .Ltmp8-.Ltmp7                  #   Call between .Ltmp7 and .Ltmp8
	.uleb128 .Ltmp9-.Lfunc_begin0           #     jumps to .Ltmp9
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp10-.Lfunc_begin0          # >> Call Site 5 <<
	.uleb128 .Ltmp11-.Ltmp10                #   Call between .Ltmp10 and .Ltmp11
	.uleb128 .Ltmp12-.Lfunc_begin0          #     jumps to .Ltmp12
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp13-.Lfunc_begin0          # >> Call Site 6 <<
	.uleb128 .Ltmp14-.Ltmp13                #   Call between .Ltmp13 and .Ltmp14
	.uleb128 .Ltmp15-.Lfunc_begin0          #     jumps to .Ltmp15
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp16-.Lfunc_begin0          # >> Call Site 7 <<
	.uleb128 .Ltmp17-.Ltmp16                #   Call between .Ltmp16 and .Ltmp17
	.uleb128 .Ltmp18-.Lfunc_begin0          #     jumps to .Ltmp18
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp17-.Lfunc_begin0          # >> Call Site 8 <<
	.uleb128 .Lfunc_end0-.Ltmp17            #   Call between .Ltmp17 and .Lfunc_end0
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end0:
	.p2align	2, 0x0
                                        # -- End function
	.section	.text._ZNSt6vectorIP6MatrixSaIS1_EEC2ERKS3_,"axG",@progbits,_ZNSt6vectorIP6MatrixSaIS1_EEC2ERKS3_,comdat
	.weak	_ZNSt6vectorIP6MatrixSaIS1_EEC2ERKS3_ # -- Begin function _ZNSt6vectorIP6MatrixSaIS1_EEC2ERKS3_
	.p2align	1, 0x90
	.type	_ZNSt6vectorIP6MatrixSaIS1_EEC2ERKS3_,@function
_ZNSt6vectorIP6MatrixSaIS1_EEC2ERKS3_:  # @_ZNSt6vectorIP6MatrixSaIS1_EEC2ERKS3_
	.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
	movq	%rsi, %r14
	movq	%rdi, %rbx
	movq	8(%rsi), %rax
	movq	(%rsi), %rcx
	movq	%rax, %r12
	subq	%rcx, %r12
	sarq	$3, %r12
	xorps	%xmm0, %xmm0
	movups	%xmm0, (%rdi)
	movq	$0, 16(%rdi)
	cmpq	%rcx, %rax
	je	.LBB1_1
# %bb.2:
	movq	%rbx, %rdi
	movq	%r12, %rsi
	xorl	%edx, %edx
	callq	_ZNSt15__new_allocatorIP6MatrixE8allocateEmPKv
	movq	%rax, %r15
	jmp	.LBB1_3
.LBB1_1:
	xorl	%r15d, %r15d
.LBB1_3:
	movq	%r15, (%rbx)
	movq	%r15, 8(%rbx)
	leaq	(%r15,%r12,8), %rax
	movq	%rax, 16(%rbx)
	movq	(%r14), %rsi
	movq	8(%r14), %r14
	subq	%rsi, %r14
	cmpq	$9, %r14
	jl	.LBB1_5
# %bb.4:
	movq	%r15, %rdi
	movq	%r14, %rdx
	callq	memmove@PLT
.LBB1_7:
	addq	%r14, %r15
	movq	%r15, 8(%rbx)
	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
.LBB1_5:
	.cfi_def_cfa_offset 48
	cmpq	$8, %r14
	jne	.LBB1_7
# %bb.6:
	movq	(%rsi), %rax
	movq	%rax, (%r15)
	jmp	.LBB1_7
.Lfunc_end1:
	.size	_ZNSt6vectorIP6MatrixSaIS1_EEC2ERKS3_, .Lfunc_end1-_ZNSt6vectorIP6MatrixSaIS1_EEC2ERKS3_
	.cfi_endproc
                                        # -- End function
	.section	.text._ZNSt6vectorIP6MatrixSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_,"axG",@progbits,_ZNSt6vectorIP6MatrixSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_,comdat
	.weak	_ZNSt6vectorIP6MatrixSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_ # -- Begin function _ZNSt6vectorIP6MatrixSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_
	.p2align	1, 0x90
	.type	_ZNSt6vectorIP6MatrixSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_,@function
_ZNSt6vectorIP6MatrixSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_: # @_ZNSt6vectorIP6MatrixSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_
	.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	$24, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rdx, (%rsp)                    # 8-byte Spill
	movq	%rsi, %r12
	movq	%rdi, %rbx
	movl	$1, %esi
	movl	$.L.str.3, %edx
	callq	_ZNKSt6vectorIP6MatrixSaIS1_EE12_M_check_lenEmPKc
	movq	(%rbx), %r13
	movq	8(%rbx), %r15
	movq	%r12, 8(%rsp)                   # 8-byte Spill
	subq	%r13, %r12
	movq	%r12, %r14
	sarq	$3, %r14
	testq	%rax, %rax
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	je	.LBB2_1
# %bb.2:
	movq	%rbx, %rdi
	movq	%rax, %rsi
	xorl	%edx, %edx
	callq	_ZNSt15__new_allocatorIP6MatrixE8allocateEmPKv
	movq	%rax, %rbp
	jmp	.LBB2_3
.LBB2_1:
	xorl	%ebp, %ebp
.LBB2_3:                                # %_ZNSt12_Vector_baseIP6MatrixSaIS1_EE11_M_allocateEm.exit
	movq	(%rsp), %rax                    # 8-byte Reload
	movq	(%rax), %rax
	movq	%rax, (%rbp,%r14,8)
	testq	%r12, %r12
	jle	.LBB2_5
# %bb.4:
	movq	%rbp, %rdi
	movq	%r13, %rsi
	movq	%r12, %rdx
	callq	memmove@PLT
.LBB2_5:                                # %_ZNSt6vectorIP6MatrixSaIS1_EE11_S_relocateEPS1_S4_S4_RS2_.exit
	addq	%rbp, %r12
	addq	$8, %r12
	movq	8(%rsp), %rsi                   # 8-byte Reload
	subq	%rsi, %r15
	testq	%r15, %r15
	jle	.LBB2_7
# %bb.6:
	movq	%r12, %rdi
	movq	%r15, %rdx
	callq	memmove@PLT
.LBB2_7:                                # %_ZNSt6vectorIP6MatrixSaIS1_EE11_S_relocateEPS1_S4_S4_RS2_.exit16
	testq	%r13, %r13
	je	.LBB2_9
# %bb.8:
	movq	%r13, %rdi
	callq	_ZdlPv
.LBB2_9:                                # %_ZNSt12_Vector_baseIP6MatrixSaIS1_EE13_M_deallocateEPS1_m.exit
	addq	%r15, %r12
	movq	%rbp, (%rbx)
	movq	%r12, 8(%rbx)
	movq	16(%rsp), %rax                  # 8-byte Reload
	leaq	(,%rax,8), %rax
	addq	%rbp, %rax
	movq	%rax, 16(%rbx)
	addq	$24, %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_end2:
	.size	_ZNSt6vectorIP6MatrixSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_, .Lfunc_end2-_ZNSt6vectorIP6MatrixSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_
	.cfi_endproc
                                        # -- End function
	.section	.text._ZNKSt6vectorIP6MatrixSaIS1_EE12_M_check_lenEmPKc,"axG",@progbits,_ZNKSt6vectorIP6MatrixSaIS1_EE12_M_check_lenEmPKc,comdat
	.weak	_ZNKSt6vectorIP6MatrixSaIS1_EE12_M_check_lenEmPKc # -- Begin function _ZNKSt6vectorIP6MatrixSaIS1_EE12_M_check_lenEmPKc
	.p2align	1, 0x90
	.type	_ZNKSt6vectorIP6MatrixSaIS1_EE12_M_check_lenEmPKc,@function
_ZNKSt6vectorIP6MatrixSaIS1_EE12_M_check_lenEmPKc: # @_ZNKSt6vectorIP6MatrixSaIS1_EE12_M_check_lenEmPKc
	.cfi_startproc
# %bb.0:
	movabsq	$1152921504606846975, %rcx      # imm = 0xFFFFFFFFFFFFFFF
	movq	8(%rdi), %r8
	subq	(%rdi), %r8
	sarq	$3, %r8
	movq	%rcx, %rax
	subq	%r8, %rax
	cmpq	%rsi, %rax
	jb	.LBB3_2
# %bb.1:
	cmpq	%rsi, %r8
	cmovaq	%r8, %rsi
	leaq	(%rsi,%r8), %rax
	cmpq	%rcx, %rax
	cmovaeq	%rcx, %rax
	addq	%r8, %rsi
	cmovbq	%rcx, %rax
	retq
.LBB3_2:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movq	%rdx, %rdi
	callq	_ZSt20__throw_length_errorPKc
.Lfunc_end3:
	.size	_ZNKSt6vectorIP6MatrixSaIS1_EE12_M_check_lenEmPKc, .Lfunc_end3-_ZNKSt6vectorIP6MatrixSaIS1_EE12_M_check_lenEmPKc
	.cfi_endproc
                                        # -- End function
	.section	.text._ZNSt15__new_allocatorIP6MatrixE8allocateEmPKv,"axG",@progbits,_ZNSt15__new_allocatorIP6MatrixE8allocateEmPKv,comdat
	.weak	_ZNSt15__new_allocatorIP6MatrixE8allocateEmPKv # -- Begin function _ZNSt15__new_allocatorIP6MatrixE8allocateEmPKv
	.p2align	1, 0x90
	.type	_ZNSt15__new_allocatorIP6MatrixE8allocateEmPKv,@function
_ZNSt15__new_allocatorIP6MatrixE8allocateEmPKv: # @_ZNSt15__new_allocatorIP6MatrixE8allocateEmPKv
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movq	%rsi, %rax
	shrq	$60, %rax
	jne	.LBB4_1
# %bb.3:
	shlq	$3, %rsi
	movq	%rsi, %rdi
	popq	%rax
	.cfi_def_cfa_offset 8
	jmp	_Znwm                           # TAILCALL
.LBB4_1:
	.cfi_def_cfa_offset 16
	shrq	$61, %rsi
	je	.LBB4_2
# %bb.4:
	callq	_ZSt28__throw_bad_array_new_lengthv
.LBB4_2:
	callq	_ZSt17__throw_bad_allocv
.Lfunc_end4:
	.size	_ZNSt15__new_allocatorIP6MatrixE8allocateEmPKv, .Lfunc_end4-_ZNSt15__new_allocatorIP6MatrixE8allocateEmPKv
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"!%d!\n"
	.size	.L.str, 6

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"Res: %.6f\n"
	.size	.L.str.1, 11

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Execution time %f"
	.size	.L.str.2, 18

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"vector::_M_realloc_insert"
	.size	.L.str.3, 26

	.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 __gxx_personality_v0
	.addrsig_sym _Unwind_Resume
	.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
