// File: /workspace/github_cpp_makefile_star2_O3/chrislarson1[P]MVEE/include/utils.hpp
// Function: readCSV(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, char)
Eigen::MatrixXd readCSV(std::string file, char delim) 
{
	// Get dimensions for Eigen::MatrixXd constructor
	int rows = 0;
	int cols = 0;
	std::ifstream in;
	in.open(file);
	if (in.is_open())
	{
		std::string s;
		while(!in.eof()) 
		{
			getline(in, s);
			if (s != "")
			{
				rows++;
				if (!cols)
				{
					cols = count(s.begin(), s.end(), delim) + 1;
				} 
			}
		}
	}
	else
	{
		throw std::runtime_error("Error: Cannot open " + file + ".");
	}
	in.close();
	

	// Stream file into Eigen::MatrixXd container
	std::string line;
	Eigen::MatrixXd X = Eigen::MatrixXd(rows, cols);
	int row = 0;
	int col = 0;
	in.open(file);
	while (getline(in, line)) 
	{
		char* ptr = (char*) line.c_str();
		int len = line.length();
		col = 0;
		char* start = ptr;
		for (int i=0; i<len; i++) 
		{
			if (ptr[i] == delim) 
			{
				X(row, col++) = atof(start);
				start = ptr + i + 1;
			}
		}
		X(row, col) = atof(start);
		row++;
	}
	in.close();
	
	return X;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x268, %rsp            # imm = 0x268
movl %edx, %r12d
movq %rsi, %rbx
movq %rdi, %rbp
leaq 0x60(%rsp), %r15
movq %r15, %rdi
callq 0x12b90
movq %r15, %rdi
movq %rbx, %rsi
movl $0x8, %edx
callq 0x128a0
leaq 0xd8(%rsp), %rdi
callq 0x12200
testb %al, %al
je 0x13a45
leaq 0x20(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x60(%rsp), %rax
movq -0x18(%rax), %rax
xorl %r14d, %r14d
testb $0x2, 0x80(%rsp,%rax)
movl $0x0, %r15d
movl %r12d, 0xc(%rsp)
jne 0x13843
leaq (%rsp,%rax), %rdi
addq $0x60, %rdi
xorl %r14d, %r14d
leaq 0x10(%rsp), %r12
leaq 0x22b3c(%rip), %r13     # 0x362db
xorl %r15d, %r15d
movl $0xa, %esi
callq 0x12990
movsbl %al, %edx
leaq 0x60(%rsp), %rdi
movq %r12, %rsi
callq 0x13300
movq %r12, %rdi
movq %r13, %rsi
callq 0x12290
testl %eax, %eax
je 0x1380b
incl %r15d
testl %r14d, %r14d
jne 0x1380b
movq 0x18(%rsp), %rax
testq %rax, %rax
je 0x13805
movq 0x10(%rsp), %rcx
xorl %edx, %edx
xorl %r14d, %r14d
movl 0xc(%rsp), %edi
xorl %esi, %esi
cmpb %dil, (%rcx,%rdx)
sete %sil
addl %esi, %r14d
incq %rdx
cmpq %rdx, %rax
jne 0x137eb
incl %r14d
jmp 0x1380b
movl $0x1, %r14d
movq 0x60(%rsp), %rax
movq -0x18(%rax), %rax
leaq (%rsp,%rax), %rdi
addq $0x60, %rdi
testb $0x2, 0x20(%rdi)
je 0x137a2
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x1383e
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x12a60
movl 0xc(%rsp), %r12d
leaq 0x60(%rsp), %rdi
callq 0x121c0
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
xorl %eax, %eax
movq %rax, 0x18(%rsp)
movb $0x0, 0x20(%rsp)
movq %rax, 0x10(%rbp)
xorps %xmm0, %xmm0
movups %xmm0, (%rbp)
movslq %r15d, %r8
movslq %r14d, %rcx
movq %rcx, %rax
orq %r8, %rax
js 0x13a98
testl %r15d, %r15d
je 0x138a2
testl %r14d, %r14d
je 0x138a2
movabsq $0x7fffffffffffffff, %rax # imm = 0x7FFFFFFFFFFFFFFF
xorl %edx, %edx
idivq %rcx
cmpq %r8, %rax
jl 0x13ab7
movq %rcx, %rsi
imulq %r8, %rsi
movq %rbp, %rdi
movq %r8, %rdx
callq 0x12170
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movl $0x8, %edx
callq 0x128a0
movq $0x0, 0x30(%rsp)
movq %rbp, 0x38(%rsp)
movq 0x60(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x12990
movsbl %al, %edx
movq %r14, %rdi
leaq 0x10(%rsp), %rsi
callq 0x13300
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x139e1
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %r15
movq 0x8(%rbp), %r13
testl %r15d, %r15d
jle 0x13991
movq 0x30(%rsp), %rax
leaq (,%rax,8), %rbx
addq (%rbp), %rbx
andl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
leaq 0x1(%rdi), %rbp
xorl %r14d, %r14d
cmpb %r12b, -0x1(%rbp)
jne 0x13987
testl %r14d, %r14d
js 0x13a26
cmpq 0x30(%rsp), %r13
jle 0x13a26
movslq %r14d, %r12
movq 0x38(%rsp), %rax
cmpq %r12, 0x10(%rax)
jle 0x13a26
callq 0x12c80
imulq %r13, %r12
incl %r14d
movsd %xmm0, (%rbx,%r12,8)
movq %rbp, %rdi
movl 0xc(%rsp), %r12d
incq %rbp
decq %r15
jne 0x13941
jmp 0x13994
xorl %r14d, %r14d
testl %r14d, %r14d
movq 0x38(%rsp), %rbp
js 0x13a26
cmpq 0x30(%rsp), %r13
jle 0x13a26
movslq %r14d, %rbx
cmpq %rbx, 0x10(%rbp)
jle 0x13a26
callq 0x12c80
imulq %rbx, %r13
shlq $0x3, %r13
addq (%rbp), %r13
movq 0x30(%rsp), %rax
movsd %xmm0, (%r13,%rax,8)
incq %rax
movq %rax, 0x30(%rsp)
leaq 0x60(%rsp), %r14
jmp 0x138d7
leaq 0x60(%rsp), %rdi
callq 0x121c0
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x13a07
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x12a60
leaq 0x60(%rsp), %rdi
callq 0x12230
movq %rbp, %rax
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x229e5(%rip), %rdi     # 0x36412
leaq 0x228f1(%rip), %rsi     # 0x36325
leaq 0x22a0c(%rip), %rcx     # 0x36447
movl $0x16f, %edx            # imm = 0x16F
callq 0x126a0
movl $0x10, %edi
callq 0x124f0
movq %rbx, %rdx
movq %rax, %rbx
leaq 0x2286c(%rip), %rsi     # 0x362c8
leaq 0x40(%rsp), %rdi
callq 0x128f0
leaq 0x2286f(%rip), %rsi     # 0x362dc
leaq 0x40(%rsp), %rdi
callq 0x13390
leaq 0x20(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x13ae5
movups (%rcx), %xmm0
movups %xmm0, (%r15)
jmp 0x13af2
leaq 0x22a38(%rip), %rdi     # 0x364d7
leaq 0x22bc0(%rip), %rsi     # 0x36666
leaq 0x22bee(%rip), %rcx     # 0x3669b
movl $0x115, %edx            # imm = 0x115
callq 0x126a0
movl $0x8, %edi
callq 0x124f0
movq 0x444f0(%rip), %rcx     # 0x57fb8
addq $0x10, %rcx
movq %rcx, (%rax)
movq 0x444fa(%rip), %rsi     # 0x57fd0
movq 0x444cb(%rip), %rdx     # 0x57fa8
movq %rax, %rdi
callq 0x13140
movq %rdx, 0x10(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x20(%rsp)
movq 0x8(%rax), %rdx
leaq 0x10(%rsp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movb $0x1, %bpl
movq %rbx, %rdi
callq 0x13050
xorl %ebp, %ebp
movq 0x444ce(%rip), %rsi     # 0x57ff0
movq 0x44497(%rip), %rdx     # 0x57fc0
movq %rbx, %rdi
callq 0x13140
movq %rax, %r14
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x13b4b
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x12a60
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x13b66
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x12a60
testb %bpl, %bpl
jne 0x13b90
jmp 0x13bd0
movq %rax, %r14
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x13b90
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x12a60
jmp 0x13b90
movq %rax, %r14
movq %rbx, %rdi
callq 0x12740
jmp 0x13bd0
jmp 0x13ba8
jmp 0x13ba8
movq %rax, %r14
jmp 0x13bd0
movq %rax, %r14
jmp 0x13bb4
movq %rax, %r14
movq (%rbp), %rdi
callq 0x12c20
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x13bd0
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x12a60
leaq 0x60(%rsp), %rdi
callq 0x12230
movq %r14, %rdi
callq 0x131e0