// File: /workspace/github_cpp_makefile_star2_O1/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, -0x48(%rbp)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rdi)
movq $0x0, 0x18(%rdi)
leaq -0x408(%rbp), %rdi
movl $0x8, %edx
callq 0x2300
leaq -0x58(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x4a4a(%rip), %rax      # 0x706c
cmpq %rax, %rbx
je 0x27a1
leaq -0x390(%rbp), %rdi
callq 0x2060
movl $0x11, %edx
leaq 0x4a67(%rip), %rsi      # 0x70aa
testb %al, %al
je 0x27ad
movq -0x408(%rbp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, -0x3e8(%rbp,%rax)
jne 0x27ad
movq $0x0, -0x40(%rbp)
xorl %r15d, %r15d
xorl %r12d, %r12d
xorl %r13d, %r13d
movq %r14, -0x70(%rbp)
movq -0x408(%rbp), %rax
movq -0x18(%rax), %rdi
leaq -0x408(%rbp), %rbx
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %edx
movq %rbx, %rdi
leaq -0x68(%rbp), %rsi
callq 0x2310
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x28cc
leaq -0x200(%rbp), %rdi
leaq -0x68(%rbp), %rsi
movl $0x18, %edx
callq 0x2270
incl %r15d
movslq %r12d, %r12
movq %r12, -0x30(%rbp)
leaq (,%r12,8), %r12
movq $0x0, -0x40(%rbp)
movl %r15d, -0x34(%rbp)
leaq -0x200(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x2110
movq -0x200(%rbp), %rax
movq -0x18(%rax), %rax
testb $0x5, -0x1e0(%rbp,%rax)
jne 0x2775
movq %r12, %rbx
addq $0x8, %r12
movq -0x30(%rbp), %r14
cmpq $-0x1, %r14
movq %r12, %rdi
movq $-0x1, %rax
cmovlq %rax, %rdi
callq 0x2030
movq %rax, %r15
testq %r14, %r14
je 0x2749
movq %r15, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x2290
movsd -0x78(%rbp), %xmm0
movq -0x30(%rbp), %rax
movsd %xmm0, (%r15,%rax,8)
incq %rax
movq %rax, -0x30(%rbp)
movq -0x40(%rbp), %rax
incl %eax
movq %rax, -0x40(%rbp)
movq %r15, %r13
movl -0x34(%rbp), %r15d
jmp 0x26ec
leaq -0x200(%rbp), %rdi
movq 0x883d(%rip), %rsi      # 0xafc0
callq 0x2160
leaq -0x180(%rbp), %rdi
callq 0x2090
movq -0x70(%rbp), %r14
movq -0x30(%rbp), %r12
jmp 0x2679
movl $0x37, %edx
leaq 0x48c5(%rip), %rsi      # 0x7072
movq 0x8824(%rip), %rdi      # 0xafd8
callq 0x2200
xorl %r12d, %r12d
xorl %r15d, %r15d
movq $0x0, -0x30(%rbp)
movl %r15d, %ebx
movq -0x48(%rbp), %rdi
movq %rbx, %rsi
callq 0x3d1c
movq %rbx, -0x40(%rbp)
movl %r15d, -0x34(%rbp)
movq 0x8(%r14), %rax
cmpq %rax, 0x10(%r14)
je 0x2830
movq %r12, %rbx
movslq %r12d, %r12
movl $0x1, %r13d
xorl %ecx, %ecx
movabsq $-0x5555555555555555, %r15 # imm = 0xAAAAAAAAAAAAAAAB
leaq (%rcx,%rcx,2), %rcx
leaq (%rax,%rcx,8), %rdi
movq %r12, %rsi
callq 0x3df6
movl %r13d, %ecx
movq 0x8(%r14), %rax
movq 0x10(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r15, %rdx
incl %r13d
cmpq %rcx, %rdx
ja 0x2800
jmp 0x2833
movq %r12, %rbx
movl -0x34(%rbp), %r10d
testl %r10d, %r10d
movq %rbx, %r11
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %r15
je 0x2884
movl %r11d, %ecx
xorl %edx, %edx
xorl %esi, %esi
testl %r11d, %r11d
jle 0x287c
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 0x2865
addl %r8d, %esi
incq %rdx
cmpq %r15, %rdx
jne 0x284e
movl %r11d, 0x4(%r14)
movl %r10d, (%r14)
testq %rdi, %rdi
je 0x2895
callq 0x2210
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x28ae
movq -0x58(%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 %r13, -0x30(%rbp)
movq -0x40(%rbp), %r12
jmp 0x27c7
jmp 0x28e6
jmp 0x28e6
movq %rax, %rbx
jmp 0x2934
jmp 0x28e6
jmp 0x28e6
movq %rax, %rbx
jmp 0x290f
jmp 0x28ed
movq %rax, %rbx
movq 0x86c9(%rip), %rsi      # 0xafc0
leaq -0x200(%rbp), %rdi
callq 0x2160
leaq -0x180(%rbp), %rdi
callq 0x2090
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x2928
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x21d0
leaq -0x408(%rbp), %rdi
callq 0x2070
movq -0x48(%rbp), %rdi
callq 0x3d9a
movq %rbx, %rdi
callq 0x22c0
nop