// File: /workspace/github_cpp_makefile_star2_O2/fanyazhi[P]Spline-Fitting/src/CRSmatrix.cpp
// Function: CRSmatrix::CRSmatrix(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
CRSmatrix::CRSmatrix(std::string valueFilePath, std::string rowPtrFilePath, std::string colIndFilePath) {
    //Read in files
    std::ifstream rowFile, valueFile, colFile;

    rowFile.open(rowPtrFilePath);
    valueFile.open(valueFilePath);
    colFile.open(colIndFilePath);

    // Check if the file is open
    if (!rowFile || !valueFile || !colFile) {
        std::cout << "Unable to open file" << std::endl;
        exit(1);
    }

    // Declare a variable to load the contents from the file
    std::string line = "";

    // Loading the value vector
    std::string myValue;
    while (valueFile.good()) {
        getline(valueFile, myValue, '\n');
        //convert string value to double value
        double myDoubleValue = atof(myValue.c_str());
        value.push_back(myDoubleValue);
    }

    // Loading the row pointer vector
    while (rowFile >> line) {
        int rowNum = stoi(line);
        rowPtr.push_back(rowNum);
    }

    // Loading the column indice vector
    while (colFile >> line) {
        int colIndex = stoi(line);
        colInd.push_back(colIndex);
    }

    //find total number of rows
    rowNum = rowPtr.size() - 1;

    //find total number of columns
    colNum = 0;
    for (unsigned int i = 0; i < colInd.size(); i++) {
        if (colInd[i] > colNum) colNum = colInd[i];
    }
    colNum++;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x678, %rsp            # imm = 0x678
movq %rcx, %rbx
movq %rdx, %r13
movq %rsi, %rbp
movq %rdi, %r12
leaq 0x8(%rdi), %rax
movq %rax, 0x18(%rsp)
leaq 0x20(%rdi), %rax
movq %rax, 0x10(%rsp)
leaq 0x38(%rdi), %r15
xorps %xmm0, %xmm0
movups %xmm0, 0x38(%rdi)
movups %xmm0, 0x28(%rdi)
movups %xmm0, 0x18(%rdi)
movups %xmm0, 0x8(%rdi)
andq $0x0, 0x48(%rdi)
leaq 0x470(%rsp), %rdi
callq 0x2180
leaq 0x60(%rsp), %rdi
callq 0x2180
leaq 0x268(%rsp), %rdi
callq 0x2180
leaq 0x470(%rsp), %rdi
pushq $0x8
popq %rdx
movq %r13, %rsi
callq 0x2120
leaq 0x60(%rsp), %rdi
pushq $0x8
popq %rdx
movq %rbp, %rsi
callq 0x2120
leaq 0x268(%rsp), %rdi
pushq $0x8
popq %rdx
movq %rbx, %rsi
callq 0x2120
movq 0x470(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x490(%rsp,%rax)
jne 0x2751
movq 0x60(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x80(%rsp,%rax)
jne 0x2751
movq 0x268(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x288(%rsp,%rax)
jne 0x2751
leaq 0x2ccc(%rip), %rsi      # 0x527b
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0x329e
leaq 0x30(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x60(%rsp), %rbx
leaq 0x20(%rsp), %r14
pushq $0xa
popq %rbp
leaq 0x8(%rsp), %r13
movq 0x60(%rsp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0x80(%rsp,%rax)
jne 0x2620
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0x2240
movq 0x20(%rsp), %rdi
callq 0x21a0
movsd %xmm0, 0x8(%rsp)
movq 0x18(%rsp), %rdi
movq %r13, %rsi
callq 0x32da
jmp 0x25e1
leaq 0x470(%rsp), %r13
leaq 0x40(%rsp), %rbp
pushq $0xa
popq %rbx
leaq 0x8(%rsp), %r14
movq %r13, %rdi
movq %rbp, %rsi
callq 0x21b0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x266d
movq %rbp, %rdi
xorl %esi, %esi
movl %ebx, %edx
callq 0x32fc
movl %eax, 0x8(%rsp)
movq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x3318
jmp 0x2635
leaq 0x268(%rsp), %r13
leaq 0x40(%rsp), %rbp
pushq $0xa
popq %rbx
leaq 0x8(%rsp), %r14
movq %r13, %rdi
movq %rbp, %rsi
callq 0x21b0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x26b8
movq %rbp, %rdi
xorl %esi, %esi
movl %ebx, %edx
callq 0x32fc
movl %eax, 0x8(%rsp)
movq %r15, %rdi
movq %r14, %rsi
callq 0x3318
jmp 0x2682
movq 0x28(%r12), %rcx
subq 0x20(%r12), %rcx
movq 0x38(%r12), %rax
shrq $0x2, %rcx
decl %ecx
movl %ecx, (%r12)
andl $0x0, 0x4(%r12)
movq 0x40(%r12), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
xorl %edx, %edx
xorl %esi, %esi
movl %esi, %esi
cmpq %rsi, %rcx
jbe 0x2700
movl (%rax,%rsi,4), %edi
cmpl %edx, %edi
jle 0x26fc
movl %edi, 0x4(%r12)
movl %edi, %edx
incl %esi
jmp 0x26e7
incl %edx
movl %edx, 0x4(%r12)
leaq 0x20(%rsp), %rdi
callq 0x20a0
leaq 0x40(%rsp), %rdi
callq 0x20a0
leaq 0x268(%rsp), %rdi
callq 0x2050
leaq 0x60(%rsp), %rdi
callq 0x2050
leaq 0x470(%rsp), %rdi
callq 0x2050
addq $0x678, %rsp            # imm = 0x678
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x5878(%rip), %rdi      # 0x7fd0
leaq 0x28d1(%rip), %rsi      # 0x5030
callq 0x2140
movq %rax, %rdi
callq 0x20b0
pushq $0x1
popq %rdi
callq 0x2190
jmp 0x2785
movq %rax, %r12
jmp 0x27b8
movq %rax, %r12
jmp 0x27c2
movq %rax, %r12
jmp 0x27cf
movq %rax, %r12
jmp 0x27ab
jmp 0x2794
jmp 0x2794
jmp 0x2794
jmp 0x2794
jmp 0x2794
movq %rax, %r12
leaq 0x20(%rsp), %rdi
callq 0x20a0
leaq 0x40(%rsp), %rdi
callq 0x20a0
leaq 0x268(%rsp), %rdi
callq 0x2050
leaq 0x60(%rsp), %rdi
callq 0x2050
leaq 0x470(%rsp), %rdi
callq 0x2050
movq %r15, %rdi
callq 0x35f2
movq 0x10(%rsp), %rdi
callq 0x35f2
movq 0x18(%rsp), %rdi
callq 0x3692
movq %r12, %rdi
callq 0x2220
nop