// File: /workspace/github_cpp_makefile_star2_O3/Krymancer[P]Matrix-cpp/src/Matrix.cpp
// Function: Matrix::Matrix(char const*)
Matrix::Matrix(const char *fileName) {
    std::ifstream file_A(fileName);
    int colSize = 0;
    int rowSize = 0;
    std::string line_A;
    int idx = 0;
    double element_A;
    double *vector_A = nullptr;

    if (fileName == "Error") {
        std::cout << "The dimentions of Matrix are wrong for this operation!\n";
    } else {
        if (file_A.is_open() && file_A.good()) {
            // cout << "File A.txt is open. \n";
            while (getline(file_A, line_A)) {
                rowSize += 1;
                std::stringstream stream_A(line_A);
                colSize = 0;
                while (1) {
                    stream_A >> element_A;
                    if (!stream_A)
                        break;
                    colSize += 1;
                    double *tempArr = new double[idx + 1];
                    std::copy(vector_A, vector_A + idx, tempArr);
                    tempArr[idx] = element_A;
                    vector_A = tempArr;
                    idx += 1;
                }
            }
        } else {
            std::cout << " Failed to open.\n";
        }
    }
    int j;
    idx = 0;
    data.resize(rowSize);
    for (unsigned i = 0; i < data.size(); i++) {
        data[i].resize(colSize);
    }
    for (int i = 0; i < rowSize; i++) {
        for (j = 0; j < colSize; j++) {
            this->data[i][j] = vector_A[idx];
            idx++;
        }
    }
    cols = colSize;
    rows = rowSize;
    delete[] vector_A;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3e8, %rsp            # imm = 0x3E8
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x8(%rdi), %rax
movq %rax, -0x60(%rbp)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rdi)
movq $0x0, 0x18(%rdi)
leaq -0x408(%rbp), %rdi
movl $0x8, %edx
callq 0x2300
leaq -0x48(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x4a4a(%rip), %rax      # 0x706c
cmpq %rax, %rbx
je 0x279d
leaq -0x390(%rbp), %rdi
callq 0x2060
movl $0x11, %edx
leaq 0x4a67(%rip), %rsi      # 0x70aa
testb %al, %al
je 0x27a9
movq -0x408(%rbp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, -0x3e8(%rbp,%rax)
jne 0x27a9
movq $0x0, -0x30(%rbp)
xorl %r13d, %r13d
xorl %r15d, %r15d
xorl %r12d, %r12d
movq %r14, -0x70(%rbp)
leaq (%rax,%rbp), %rdi
addq $-0x408, %rdi           # imm = 0xFBF8
movl $0xa, %esi
callq 0x21b0
movsbl %al, %edx
leaq -0x408(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x2310
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x28c8
leaq -0x200(%rbp), %rdi
leaq -0x58(%rbp), %rsi
movl $0x18, %edx
callq 0x2270
incl %r13d
movslq %r15d, %r15
movq %r15, %r14
leaq (,%r15,8), %rax
movq %rax, -0x38(%rbp)
movq $0x0, -0x30(%rbp)
leaq -0x200(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x2110
movq -0x200(%rbp), %rax
movq -0x18(%rax), %rax
testb $0x5, -0x1e0(%rbp,%rax)
movq %r14, %r15
jne 0x276a
movq -0x38(%rbp), %rax
leaq 0x8(%rax), %rbx
cmpq $-0x1, %r15
movq %rbx, %rdi
movq $-0x1, %rax
cmovlq %rax, %rdi
callq 0x2030
movq %r15, %rcx
movq %rax, %r15
testq %rcx, %rcx
je 0x2746
movq %r15, %rdi
movq %r12, %rsi
movq -0x38(%rbp), %rdx
callq 0x2290
movsd -0x78(%rbp), %xmm0
movsd %xmm0, (%r15,%r14,8)
incq %r14
movq -0x30(%rbp), %rax
incl %eax
movq %rax, -0x30(%rbp)
movq %rbx, -0x38(%rbp)
movq %r15, %r12
jmp 0x26e5
leaq -0x200(%rbp), %rdi
movq 0x8848(%rip), %rsi      # 0xafc0
callq 0x2160
leaq -0x180(%rbp), %rdi
callq 0x2090
movq -0x408(%rbp), %rax
movq -0x18(%rax), %rax
movq -0x70(%rbp), %r14
jmp 0x2679
movl $0x37, %edx
leaq 0x48c9(%rip), %rsi      # 0x7072
movq 0x8828(%rip), %rdi      # 0xafd8
callq 0x2200
xorl %r15d, %r15d
xorl %r13d, %r13d
movq $0x0, -0x38(%rbp)
movl %r13d, %r12d
movq -0x60(%rbp), %rdi
movq %r12, %rsi
callq 0x3cfc
movq %r12, -0x68(%rbp)
movl %r13d, -0x30(%rbp)
movq 0x8(%r14), %rax
cmpq %rax, 0x10(%r14)
je 0x282c
movq %r15, %r13
movslq %r15d, %r12
movl $0x1, %r15d
xorl %ecx, %ecx
movabsq $-0x5555555555555555, %rbx # imm = 0xAAAAAAAAAAAAAAAB
leaq (%rcx,%rcx,2), %rcx
leaq (%rax,%rcx,8), %rdi
movq %r12, %rsi
callq 0x3ddc
movl %r15d, %ecx
movq 0x8(%r14), %rax
movq 0x10(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %rbx, %rdx
incl %r15d
cmpq %rcx, %rdx
ja 0x27fc
jmp 0x282f
movq %r15, %r13
movl -0x30(%rbp), %r10d
testl %r10d, %r10d
movq %r13, %r11
movq -0x38(%rbp), %rdi
movq -0x68(%rbp), %r15
je 0x2880
movl %r11d, %ecx
xorl %edx, %edx
xorl %esi, %esi
testl %r11d, %r11d
jle 0x2878
leaq (%rdx,%rdx,2), %r8
movq (%rax,%r8,8), %rbx
movslq %esi, %r8
leaq (%rdi,%r8,8), %r9
xorl %r8d, %r8d
movsd (%r9,%r8,8), %xmm0
movsd %xmm0, (%rbx,%r8,8)
incq %r8
cmpq %r8, %rcx
jne 0x2861
addl %r8d, %esi
incq %rdx
cmpq %r15, %rdx
jne 0x284a
movl %r11d, 0x4(%r14)
movl %r10d, (%r14)
testq %rdi, %rdi
je 0x2891
callq 0x2210
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x28aa
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x21d0
leaq -0x408(%rbp), %rdi
callq 0x2070
addq $0x3e8, %rsp            # imm = 0x3E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r12, -0x38(%rbp)
movq -0x30(%rbp), %r15
jmp 0x27c3
jmp 0x28e2
jmp 0x28e2
movq %rax, %rbx
jmp 0x2934
jmp 0x28e2
jmp 0x28e2
movq %rax, %rbx
leaq -0x48(%rbp), %r14
jmp 0x2913
jmp 0x28ed
movq %rax, %rbx
leaq -0x48(%rbp), %r14
movq 0x86c5(%rip), %rsi      # 0xafc0
leaq -0x200(%rbp), %rdi
callq 0x2160
leaq -0x180(%rbp), %rdi
callq 0x2090
movq -0x58(%rbp), %rdi
cmpq %r14, %rdi
je 0x2928
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x21d0
leaq -0x408(%rbp), %rdi
callq 0x2070
movq -0x60(%rbp), %rdi
callq 0x3d7a
movq %rbx, %rdi
callq 0x22c0
nop