// File: /workspace/github_cpp_makefile_star2_O3/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 $0x228, %rsp            # imm = 0x228
movq %rdx, 0x30(%rsp)
movq %rsi, %rbx
leaq 0x90(%rsp), %rax
movq %rax, -0x10(%rax)
xorl %ecx, %ecx
movq %rcx, -0x8(%rax)
movb $0x0, (%rax)
movq $0x0, 0x8(%rsp)
movq %rcx, 0x50(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
leaq 0x78(%rsi), %rdi
callq 0x3080
testb %al, %al
je 0x3b3d
movq (%rbx), %rax
movq -0x18(%rax), %rdi
testb $0x2, 0x20(%rbx,%rdi)
movl $0x0, %r14d
jne 0x3a0a
addq %rbx, %rdi
leaq 0x80(%rsp), %r12
leaq 0xa0(%rsp), %r13
leaq 0x58(%rsp), %rbp
xorl %r14d, %r14d
movq $0x0, 0x8(%rsp)
movq %rbx, 0x78(%rsp)
movl $0xa, %esi
callq 0x3230
movsbl %al, %edx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3400
movq %r12, %rsi
movl %r14d, %r15d
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
xorl %ecx, %ecx
movq %rcx, 0x20(%rsp)
leaq 0x68(%rsp), %rax
movq %rax, 0x58(%rsp)
movq %rcx, 0x60(%rsp)
movb $0x0, 0x68(%rsp)
movq %r13, %rdi
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 0x3956
movq 0x58(%rsp), %r14
cmpb $0x23, (%r14)
je 0x3956
movq %r14, %rdi
callq 0x32c0
movsd %xmm0, 0x38(%rsp)
movq 0x48(%rsp), %rsi
cmpq 0x50(%rsp), %rsi
je 0x3903
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x48(%rsp)
jmp 0x3917
leaq 0x40(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x42e2
movq 0x58(%rsp), %r14
movq %r14, %rdi
callq 0x32c0
movsd %xmm0, 0x38(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x3940
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x394f
leaq 0x10(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x42e2
incl %ebx
jmp 0x38b2
testl %r15d, %r15d
sete %al
testl %ebx, %ebx
sete %cl
orb %al, %cl
cmpl %ebx, %r15d
sete %al
orb %cl, %al
je 0x3b03
movl %r15d, %r14d
testl %ebx, %ebx
cmovnel %ebx, %r14d
cmpq $0x0, 0x88(%rsp)
je 0x39a0
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 0x78(%rsp), %rbx
movq %r13, %rdi
movq 0xb5f1(%rip), %rsi      # 0xefa0
callq 0x31b0
leaq 0x120(%rsp), %rdi
callq 0x30d0
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x39dd
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x3260
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x39f4
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3260
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
testb $0x2, 0x20(%rbx,%rax)
je 0x3862
movq %rbx, %rdi
callq 0x3060
movq 0x8(%rsp), %r13
movq 0x30(%rsp), %rbx
movq (%rbx), %rsi
movq %rbx, %rdi
callq 0x3f78
movl %r13d, %r15d
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3f0a
testl %r13d, %r13d
je 0x3ab5
movl %r14d, %ebp
movl %r14d, %r14d
leaq (,%r15,8), %rax
leaq (%rax,%rax,2), %rbx
xorl %r12d, %r12d
movq 0x30(%rsp), %rax
movq (%rax), %rdi
addq %r12, %rdi
movq %r14, %rsi
callq 0x3f46
addq $0x18, %r12
cmpq %r12, %rbx
jne 0x3a4f
movq 0x40(%rsp), %rdi
testl %r13d, %r13d
je 0x3aba
movq 0x30(%rsp), %rax
movq (%rax), %rax
shlq $0x3, %r14
xorl %ecx, %ecx
movq %rdi, %rdx
testl %ebp, %ebp
je 0x3aab
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 0x3a94
addq %rsi, %rdx
incq %rcx
cmpq %r15, %rcx
jne 0x3a86
jmp 0x3aba
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x3acc
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x3260
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x3af1
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x3260
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xb4e6(%rip), %rdi      # 0xeff0
callq 0x3110
movq %rax, %rbx
leaq 0x7517(%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 0xb4ac(%rip), %rdi      # 0xeff0
callq 0x3110
movq %rax, %rbx
leaq 0x7503(%rip), %rsi      # 0xb056
movl $0x24, %edx
movq %rax, %rdi
callq 0x32a0
movq %rbx, %rdi
callq 0x3110
movq %rax, %rdi
callq 0x3110
jmp 0x3b36
jmp 0x3b7d
jmp 0x3b86
movq %rax, %rbx
jmp 0x3baa
jmp 0x3b7d
movq %rax, %rbx
jmp 0x3bdd
jmp 0x3b86
jmp 0x3b86
movq %rax, %rbx
movq 0xb410(%rip), %rsi      # 0xefa0
leaq 0xa0(%rsp), %rdi
callq 0x31b0
leaq 0x120(%rsp), %rdi
callq 0x30d0
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x3bc6
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x3260
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3bdd
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3260
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x3bf4
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x3260
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x3c19
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x3260
movq %rbx, %rdi
callq 0x33d0
nop