// File: 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
movq %rsp, %rbp
subq $0x730, %rsp            # imm = 0x730
movq %rsi, -0x6e0(%rbp)
movq %rdx, -0x6d8(%rbp)
movq %rcx, -0x6d0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x6b8(%rbp)
addq $0x8, %rdi
movq %rdi, -0x6c8(%rbp)
callq 0x41a0
movq -0x6b8(%rbp), %rdi
addq $0x20, %rdi
movq %rdi, -0x6c0(%rbp)
callq 0x41c0
movq -0x6b8(%rbp), %rdi
addq $0x38, %rdi
movq %rdi, -0x6b0(%rbp)
callq 0x41c0
leaq -0x228(%rbp), %rdi
callq 0x2200
jmp 0x2767
leaq -0x440(%rbp), %rdi
callq 0x2200
jmp 0x2775
leaq -0x648(%rbp), %rdi
callq 0x2200
jmp 0x2783
movq -0x6d8(%rbp), %rsi
leaq -0x228(%rbp), %rdi
movl $0x8, %edx
callq 0x2150
jmp 0x279d
movq -0x6e0(%rbp), %rsi
leaq -0x440(%rbp), %rdi
movl $0x8, %edx
callq 0x2150
jmp 0x27b7
movq -0x6d0(%rbp), %rsi
leaq -0x648(%rbp), %rdi
movl $0x8, %edx
callq 0x2150
jmp 0x27d1
movq -0x228(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x228(%rbp,%rax), %rdi
callq 0x20b0
movb %al, -0x6e1(%rbp)
jmp 0x27f1
movb -0x6e1(%rbp), %al
testb $0x1, %al
jne 0x2858
jmp 0x27fd
movq -0x440(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x440(%rbp,%rax), %rdi
callq 0x20b0
movb %al, -0x6e2(%rbp)
jmp 0x281d
movb -0x6e2(%rbp), %al
testb $0x1, %al
jne 0x2858
jmp 0x2829
movq -0x648(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x648(%rbp,%rax), %rdi
callq 0x20b0
movb %al, -0x6e3(%rbp)
jmp 0x2849
movb -0x6e3(%rbp), %al
testb $0x1, %al
jne 0x2858
jmp 0x28ef
movq 0xe771(%rip), %rdi      # 0x10fd0
leaq 0x97c2(%rip), %rsi      # 0xc028
callq 0x2170
movq %rax, -0x6f0(%rbp)
jmp 0x2874
movq -0x6f0(%rbp), %rdi
movq 0xe736(%rip), %rsi      # 0x10fb8
callq 0x21a0
jmp 0x2889
movl $0x1, %edi
callq 0x2210
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x2c5f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x2c53
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x2c47
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x2c3b
leaq -0x669(%rbp), %rdi
movq %rdi, -0x6f8(%rbp)
callq 0x2320
movq -0x6f8(%rbp), %rdx
leaq 0x9945(%rip), %rsi      # 0xc255
leaq -0x668(%rbp), %rdi
callq 0x4780
jmp 0x291e
leaq -0x669(%rbp), %rdi
callq 0x21c0
leaq -0x690(%rbp), %rdi
callq 0x2260
movq -0x440(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x440(%rbp,%rax), %rdi
callq 0x22f0
movb %al, -0x6f9(%rbp)
jmp 0x2956
movb -0x6f9(%rbp), %al
testb $0x1, %al
jne 0x2965
jmp 0x2a08
leaq -0x440(%rbp), %rdi
leaq -0x690(%rbp), %rsi
movl $0xa, %edx
callq 0x2340
jmp 0x297f
leaq -0x690(%rbp), %rdi
callq 0x2090
movq %rax, %rdi
callq 0x2230
movq -0x6b8(%rbp), %rdi
movsd %xmm0, -0x698(%rbp)
addq $0x8, %rdi
leaq -0x698(%rbp), %rsi
callq 0x4830
jmp 0x29b4
jmp 0x2936
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
leaq -0x669(%rbp), %rdi
callq 0x21c0
jmp 0x2c3b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
leaq -0x690(%rbp), %rdi
callq 0x20e0
leaq -0x668(%rbp), %rdi
callq 0x20e0
jmp 0x2c3b
jmp 0x2a0a
leaq -0x228(%rbp), %rdi
leaq -0x668(%rbp), %rsi
callq 0x2250
movq %rax, -0x708(%rbp)
jmp 0x2a26
movq -0x708(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x2240
movb %al, -0x709(%rbp)
jmp 0x2a44
movb -0x709(%rbp), %al
testb $0x1, %al
jne 0x2a50
jmp 0x2a97
xorl %eax, %eax
movl %eax, %esi
leaq -0x668(%rbp), %rdi
movl $0xa, %edx
callq 0x48a0
movl %eax, -0x710(%rbp)
jmp 0x2a6d
movq -0x6b8(%rbp), %rdi
movl -0x710(%rbp), %eax
movl %eax, -0x69c(%rbp)
addq $0x20, %rdi
leaq -0x69c(%rbp), %rsi
callq 0x48e0
jmp 0x2a92
jmp 0x2a0a
jmp 0x2a99
leaq -0x648(%rbp), %rdi
leaq -0x668(%rbp), %rsi
callq 0x2250
movq %rax, -0x718(%rbp)
jmp 0x2ab5
movq -0x718(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x2240
movb %al, -0x719(%rbp)
jmp 0x2ad3
movb -0x719(%rbp), %al
testb $0x1, %al
jne 0x2adf
jmp 0x2b26
xorl %eax, %eax
movl %eax, %esi
leaq -0x668(%rbp), %rdi
movl $0xa, %edx
callq 0x48a0
movl %eax, -0x720(%rbp)
jmp 0x2afc
movq -0x6b8(%rbp), %rdi
movl -0x720(%rbp), %eax
movl %eax, -0x6a0(%rbp)
addq $0x38, %rdi
leaq -0x6a0(%rbp), %rsi
callq 0x48e0
jmp 0x2b21
jmp 0x2a99
movq -0x6b8(%rbp), %rdi
addq $0x20, %rdi
callq 0x4680
movq %rax, %rcx
movq -0x6b8(%rbp), %rax
subq $0x1, %rcx
movl %ecx, (%rax)
movl $0x0, 0x4(%rax)
movl $0x0, -0x6a4(%rbp)
movq -0x6b8(%rbp), %rdi
movl -0x6a4(%rbp), %eax
movq %rax, -0x728(%rbp)
addq $0x38, %rdi
callq 0x4680
movq %rax, %rcx
movq -0x728(%rbp), %rax
cmpq %rcx, %rax
jae 0x2be6
movq -0x6b8(%rbp), %rdi
addq $0x38, %rdi
movl -0x6a4(%rbp), %eax
movl %eax, %esi
callq 0x46a0
movq -0x6b8(%rbp), %rcx
movl (%rax), %eax
cmpl 0x4(%rcx), %eax
jle 0x2bd0
movq -0x6b8(%rbp), %rdi
addq $0x38, %rdi
movl -0x6a4(%rbp), %eax
movl %eax, %esi
callq 0x46a0
movq %rax, %rcx
movq -0x6b8(%rbp), %rax
movl (%rcx), %ecx
movl %ecx, 0x4(%rax)
jmp 0x2bd2
movl -0x6a4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6a4(%rbp)
jmp 0x2b57
movq -0x6b8(%rbp), %rax
movl 0x4(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x4(%rax)
leaq -0x690(%rbp), %rdi
callq 0x20e0
leaq -0x668(%rbp), %rdi
callq 0x20e0
leaq -0x648(%rbp), %rdi
callq 0x2050
leaq -0x440(%rbp), %rdi
callq 0x2050
leaq -0x228(%rbp), %rdi
callq 0x2050
addq $0x730, %rsp            # imm = 0x730
popq %rbp
retq
leaq -0x648(%rbp), %rdi
callq 0x2050
leaq -0x440(%rbp), %rdi
callq 0x2050
leaq -0x228(%rbp), %rdi
callq 0x2050
movq -0x6b0(%rbp), %rdi
callq 0x46c0
movq -0x6c0(%rbp), %rdi
callq 0x46c0
movq -0x6c8(%rbp), %rdi
callq 0x4720
movq -0x230(%rbp), %rdi
callq 0x2310
nop