// File: WeiqiangZhou[P]BIRD/source/create_library_function.cpp
// Function: ReadMatrix_d(char*, double**)
int ReadMatrix_d(char *file, double **data)
{
	std::ifstream infile(file);
	std::string line_temp;
	std::string line_token;
	int m, k;
	m = 0;
	if (infile.is_open())
	{
		std::cout << "Reading " << file << "..." << std::endl;
		while (!infile.eof())
		{
			std::getline(infile, line_temp);
			if (line_temp.empty()){ break; }
			std::stringstream each_line(line_temp);
			k = 0;
			while (std::getline(each_line, line_token, '\t'))
			{
				data[k][m] = atof(line_token.c_str());
				k++;
			}
			m++;
		}

		infile.close();
	}
	else
	{
		std::cout << "Error! File " << file << " not found!" << std::endl;
		return 1;
	}

	return 0;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x460, %rsp            # imm = 0x460
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x220(%rbp), %rdi
movq %rdi, -0x410(%rbp)
movl $0x8, %edx
callq 0x2200
leaq -0x240(%rbp), %rdi
callq 0x2160
leaq -0x260(%rbp), %rdi
callq 0x2160
movq -0x410(%rbp), %rdi
movl $0x0, -0x264(%rbp)
callq 0x21c0
movb %al, -0x405(%rbp)
jmp 0x48b5
movb -0x405(%rbp), %al
testb $0x1, %al
jne 0x48c4
jmp 0x4abd
movq 0x370d(%rip), %rdi      # 0x7fd8
leaq 0x1ab9(%rip), %rsi      # 0x638b
callq 0x20f0
movq %rax, -0x418(%rbp)
jmp 0x48e0
movq -0x418(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x20f0
movq %rax, -0x420(%rbp)
jmp 0x48f9
movq -0x420(%rbp), %rdi
leaq 0x1a46(%rip), %rsi      # 0x634d
callq 0x20f0
movq %rax, -0x428(%rbp)
jmp 0x4915
movq -0x428(%rbp), %rdi
movq 0x36a5(%rip), %rsi      # 0x7fc8
callq 0x2110
jmp 0x492a
jmp 0x492c
movq -0x220(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x220(%rbp,%rax), %rdi
callq 0x2220
movb %al, -0x429(%rbp)
jmp 0x494c
movb -0x429(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x495d
jmp 0x4aad
leaq -0x220(%rbp), %rdi
leaq -0x240(%rbp), %rsi
callq 0x2040
jmp 0x4972
leaq -0x240(%rbp), %rdi
callq 0x21d0
testb $0x1, %al
jne 0x4984
jmp 0x49a0
jmp 0x4aad
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x270(%rbp)
movl %eax, -0x274(%rbp)
jmp 0x4b77
movl $0x10, %edi
movl $0x8, %esi
callq 0x5180
movl %eax, -0x430(%rbp)
jmp 0x49b7
movl -0x430(%rbp), %edx
leaq -0x400(%rbp), %rdi
leaq -0x240(%rbp), %rsi
callq 0x21b0
jmp 0x49d2
movl $0x0, -0x268(%rbp)
leaq -0x400(%rbp), %rdi
leaq -0x260(%rbp), %rsi
movl $0x9, %edx
callq 0x2230
movq %rax, -0x438(%rbp)
jmp 0x49fd
movq -0x438(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x2140
movb %al, -0x439(%rbp)
jmp 0x4a1b
movb -0x439(%rbp), %al
testb $0x1, %al
jne 0x4a27
jmp 0x4a8d
leaq -0x260(%rbp), %rdi
callq 0x2070
movq %rax, %rdi
callq 0x2130
movq -0x18(%rbp), %rax
movslq -0x268(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x264(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x268(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x268(%rbp)
jmp 0x49dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x270(%rbp)
movl %eax, -0x274(%rbp)
leaq -0x400(%rbp), %rdi
callq 0x20b0
jmp 0x4b77
movl -0x264(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x264(%rbp)
leaq -0x400(%rbp), %rdi
callq 0x20b0
jmp 0x492c
leaq -0x220(%rbp), %rdi
callq 0x2050
jmp 0x4abb
jmp 0x4b36
movq 0x3514(%rip), %rdi      # 0x7fd8
leaq 0x1a6d(%rip), %rsi      # 0x6538
callq 0x20f0
movq %rax, -0x448(%rbp)
jmp 0x4ad9
movq -0x448(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x20f0
movq %rax, -0x450(%rbp)
jmp 0x4af2
movq -0x450(%rbp), %rdi
leaq 0x1a45(%rip), %rsi      # 0x6545
callq 0x20f0
movq %rax, -0x458(%rbp)
jmp 0x4b0e
movq -0x458(%rbp), %rdi
movq 0x34ac(%rip), %rsi      # 0x7fc8
callq 0x2110
jmp 0x4b23
movl $0x1, -0x4(%rbp)
movl $0x1, -0x404(%rbp)
jmp 0x4b47
movl $0x0, -0x4(%rbp)
movl $0x1, -0x404(%rbp)
leaq -0x260(%rbp), %rdi
callq 0x20a0
leaq -0x240(%rbp), %rdi
callq 0x20a0
leaq -0x220(%rbp), %rdi
callq 0x2060
movl -0x4(%rbp), %eax
addq $0x460, %rsp            # imm = 0x460
popq %rbp
retq
leaq -0x260(%rbp), %rdi
callq 0x20a0
leaq -0x240(%rbp), %rdi
callq 0x20a0
leaq -0x220(%rbp), %rdi
callq 0x2060
movq -0x270(%rbp), %rdi
callq 0x21f0
nopw (%rax,%rax)