// File: /workspace/github_cpp_makefile_star2_O1/iu-vail[P]iprimal/Assignment.cpp
// Function: Assignment::ImportMatrix(std::basic_ifstream<char, std::char_traits<char>>&, std::vector<std::vector<double, std::allocator<double>>, std::allocator<std::vector<double, std::allocator<double>>>>&)
void
Assignment::ImportMatrix(ifstream& input_file, mat& matrix){

  string line;
  vector<double> numstream;

  uint num_rows = 0;
  uint num_cols = 0;

  if (input_file.is_open())
  {
    while (!input_file.eof() )
    {
      getline (input_file,line);

      uint local_num_cols=0;
      vector<double> local_numstream;
      string word;

      stringstream parse(line);
      while(parse >> word){
	//if comment line, ignore it
	if(word[0] == '#')
	  break;
	//numstream.push_back(atoi(word.c_str()));  //if not number, then convert to zero
	numstream.push_back(atof(word.c_str()));  //if not number, then convert to zero
	//local_numstream.push_back(atoi(word.c_str()));
	local_numstream.push_back(atof(word.c_str()));

	//matrix(num_rows, num_cols)= atoi(word.c_str()); 	
	local_num_cols++;
      } //end inner while

      //double check if the matrix format is correct or not
      if(num_cols && local_num_cols && num_cols!=local_num_cols){
	cerr<<endl<<"Please input a correct matrix format!"<<endl<<endl;
	exit(0);
      }
      //update column number if everything looks normal
      if(local_num_cols)
	num_cols = local_num_cols;
      //update row number if everything looks normal
      if(line.length()&&local_numstream.size())
        num_rows++;

    } //end out layer while

    input_file.close();

    matrix.clear();
    //put elements into matrix
    //matrix.resize(num_rows, num_cols);
    matrix.resize(num_rows);
    for(uint i=0; i<num_rows; i++)
      matrix[i].resize(num_cols);

    vector<double>::iterator itr = numstream.begin();
    for(uint i=0; i<num_rows; i++)
      for(uint j=0; j<num_cols; j++)
	matrix[i][j] = *itr++;
  } //end outmost if
  else{ 
    cerr <<endl<<"Error: Unable to open file! Stopped."<<endl<<endl; 
    exit(0);
  }

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
movq %rdx, 0x28(%rsp)
movq %rsi, %r14
leaq 0x80(%rsp), %rax
movq %rax, -0x10(%rax)
xorl %ecx, %ecx
movq %rcx, -0x8(%rax)
movb $0x0, (%rax)
movq $0x0, 0x8(%rsp)
movq %rcx, 0x40(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
leaq 0x78(%rsi), %rdi
callq 0x3080
testb %al, %al
je 0x3b25
movq (%r14), %rax
movq -0x18(%rax), %rdi
testb $0x2, 0x20(%r14,%rdi)
movl $0x0, 0x4(%rsp)
jne 0x39fa
addq %r14, %rdi
leaq 0x70(%rsp), %rbx
leaq 0x90(%rsp), %r13
leaq 0x48(%rsp), %rbp
leaq 0x68(%rsp), %r12
movl $0x0, 0x4(%rsp)
movq $0x0, 0x8(%rsp)
movl $0xa, %esi
callq 0x3230
movsbl %al, %edx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3400
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
xorl %ecx, %ecx
movq %rcx, 0x20(%rsp)
leaq 0x58(%rsp), %rax
movq %rax, 0x48(%rsp)
movq %rcx, 0x50(%rsp)
movb $0x0, 0x58(%rsp)
movq %r13, %rdi
movq %rbx, %r15
movq %rbx, %rsi
movl $0x18, %edx
callq 0x3360
xorl %ebx, %ebx
movq %r13, %rdi
movq %rbp, %rsi
callq 0x32d0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x3948
movq 0x48(%rsp), %rdi
cmpb $0x23, (%rdi)
je 0x3948
callq 0x32c0
movsd %xmm0, 0x68(%rsp)
movq 0x38(%rsp), %rsi
cmpq 0x40(%rsp), %rsi
je 0x38fc
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x38(%rsp)
jmp 0x3909
leaq 0x30(%rsp), %rdi
movq %r12, %rdx
callq 0x42c6
movq 0x48(%rsp), %rdi
callq 0x32c0
movsd %xmm0, 0x68(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x3934
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x3941
leaq 0x10(%rsp), %rdi
movq %r12, %rdx
callq 0x42c6
incl %ebx
jmp 0x38b3
movl 0x4(%rsp), %edx
testl %edx, %edx
sete %al
testl %ebx, %ebx
sete %cl
orb %al, %cl
cmpl %ebx, %edx
sete %al
orb %cl, %al
je 0x3aeb
testl %ebx, %ebx
cmovnel %ebx, %edx
movl %edx, 0x4(%rsp)
cmpq $0x0, 0x78(%rsp)
je 0x3991
movq 0x18(%rsp), %rax
xorl %ecx, %ecx
cmpq 0x10(%rsp), %rax
setne %cl
movq 0x8(%rsp), %rax
addl %ecx, %eax
movq %rax, 0x8(%rsp)
movq %r15, %rbx
movq %r13, %rdi
movq 0xb602(%rip), %rsi      # 0xefa0
callq 0x31b0
leaq 0x110(%rsp), %rdi
callq 0x30d0
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x39cc
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3260
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x39e3
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3260
movq (%r14), %rax
movq -0x18(%rax), %rax
leaq (%r14,%rax), %rdi
testb $0x2, 0x20(%r14,%rax)
je 0x3863
movq %r14, %rdi
callq 0x3060
movq 0x8(%rsp), %rbp
movq 0x28(%rsp), %r14
movq (%r14), %rsi
movq %r14, %rdi
callq 0x3f5a
movl %ebp, %ebx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3eec
movl 0x4(%rsp), %r14d
testl %ebp, %ebp
je 0x3a58
leaq (,%rbx,8), %rax
leaq (%rax,%rax,2), %r12
xorl %r13d, %r13d
movq 0x28(%rsp), %rax
movq (%rax), %rdi
addq %r13, %rdi
movq %r14, %rsi
callq 0x3f28
addq $0x18, %r13
cmpq %r13, %r12
jne 0x3a3c
movq 0x30(%rsp), %rdi
testl %ebp, %ebp
movl 0x4(%rsp), %r9d
je 0x3aa5
movq 0x28(%rsp), %rax
movq (%rax), %rax
shlq $0x3, %r14
xorl %ecx, %ecx
movq %rdi, %rdx
testl %r9d, %r9d
je 0x3a9d
leaq (%rcx,%rcx,2), %rsi
movq (%rax,%rsi,8), %r8
xorl %esi, %esi
movsd (%rdx,%rsi), %xmm0
movsd %xmm0, (%r8,%rsi)
addq $0x8, %rsi
cmpq %rsi, %r14
jne 0x3a86
addq %rsi, %rdx
incq %rcx
cmpq %rbx, %rcx
jne 0x3a77
testq %rdi, %rdi
je 0x3ab7
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x3260
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x3ad9
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x3260
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xb4fe(%rip), %rdi      # 0xeff0
callq 0x3110
movq %rax, %rbx
leaq 0x752f(%rip), %rsi      # 0xb030
movl $0x25, %edx
movq %rax, %rdi
callq 0x32a0
movq %rbx, %rdi
callq 0x3110
movq %rax, %rdi
callq 0x3110
xorl %edi, %edi
callq 0x32b0
movq 0xb4c4(%rip), %rdi      # 0xeff0
callq 0x3110
movq %rax, %rbx
leaq 0x751b(%rip), %rsi      # 0xb056
movl $0x24, %edx
movq %rax, %rdi
callq 0x32a0
movq %rbx, %rdi
callq 0x3110
movq %rax, %rdi
callq 0x3110
jmp 0x3b1e
jmp 0x3b65
jmp 0x3b6e
movq %rax, %rbx
jmp 0x3b92
jmp 0x3b65
movq %rax, %rbx
jmp 0x3bc5
jmp 0x3b6e
jmp 0x3b6e
movq %rax, %rbx
movq 0xb428(%rip), %rsi      # 0xefa0
leaq 0x90(%rsp), %rdi
callq 0x31b0
leaq 0x110(%rsp), %rdi
callq 0x30d0
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x3bae
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3260
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3bc5
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3260
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x3bdc
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x3260
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x3bfe
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x3260
movq %rbx, %rdi
callq 0x33d0