// File: sebastienmeyer2[P]mst-clustering/src/point.cpp
// Function: Point::read_points_from_file(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int)
std::vector<Point*> Point::read_points_from_file(std::string file_path, int d) 
{
    /*!
     * @brief Builds a vector of points from a file where data is correctly
     * formatted (double spaced with " ")
     * 
     * @param file_path the path to the file to get data from
     * @param d the dimension of the points
     * 
     * @return A vector of pointers to the created points
     */

    std::vector<Point*> points;

    std::ifstream is(file_path);
    assert(("No such file", is.is_open()));

    std::string line;

	// while not at the end of the file
	while(is.peek() != EOF)
	{
		// read new points
        Point* p = new Point();

		for(int m = 0; m < d; m++)
		{
			is >> p->coords[m];
		}

        points.push_back(p);

		// new line
		is.get();
	}
    points.pop_back(); // last line makes an empty point otherwise

    return points;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x290, %rsp            # imm = 0x290
movq %rsi, -0x268(%rbp)
movq %rdi, -0x278(%rbp)
movq %rdi, %rax
movq %rax, -0x270(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movb $0x0, -0x15(%rbp)
callq 0xb970
movq -0x268(%rbp), %rsi
leaq -0x220(%rbp), %rdi
movl $0x8, %edx
callq 0xac80
jmp 0xb741
leaq -0x220(%rbp), %rdi
callq 0xac60
movb %al, -0x279(%rbp)
jmp 0xb755
movb -0x279(%rbp), %al
testb $0x1, %al
jne 0xb761
jmp 0xb763
jmp 0xb7b0
leaq 0x2b8a7(%rip), %rdi     # 0x37011
leaq 0x2b8bf(%rip), %rsi     # 0x37030
movl $0x56, %edx
leaq 0x2b8c1(%rip), %rcx     # 0x3703e
callq 0xa4a0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0xb920
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0xb8f6
leaq -0x250(%rbp), %rdi
callq 0xaad0
leaq -0x220(%rbp), %rdi
callq 0xa260
movl %eax, -0x280(%rbp)
jmp 0xb7d0
movl -0x280(%rbp), %eax
cmpl $-0x1, %eax
je 0xb8ba
movl $0x10, %edi
callq 0xa790
movq %rax, -0x288(%rbp)
jmp 0xb7f2
movq -0x288(%rbp), %rdi
callq 0xb520
jmp 0xb800
movq -0x288(%rbp), %rax
movq %rax, -0x258(%rbp)
movl $0x0, -0x25c(%rbp)
movl -0x25c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0xb892
movq -0x258(%rbp), %rax
movq (%rax), %rax
movslq -0x25c(%rbp), %rcx
leaq (%rax,%rcx,8), %rsi
leaq -0x220(%rbp), %rdi
callq 0xa650
jmp 0xb846
jmp 0xb848
movl -0x25c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x25c(%rbp)
jmp 0xb818
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0xb8ea
movq -0x288(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
movl $0x10, %esi
callq 0xa7b0
jmp 0xb8ea
movq -0x278(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0xb990
jmp 0xb8a7
leaq -0x220(%rbp), %rdi
callq 0xa920
jmp 0xb8b5
jmp 0xb7bc
movq -0x278(%rbp), %rdi
callq 0xba00
movb $0x1, -0x15(%rbp)
leaq -0x250(%rbp), %rdi
callq 0xa470
leaq -0x220(%rbp), %rdi
callq 0xa1b0
testb $0x1, -0x15(%rbp)
jne 0xb910
jmp 0xb904
leaq -0x250(%rbp), %rdi
callq 0xa470
leaq -0x220(%rbp), %rdi
callq 0xa1b0
jmp 0xb920
movq -0x278(%rbp), %rdi
callq 0xba30
movq -0x270(%rbp), %rax
addq $0x290, %rsp            # imm = 0x290
popq %rbp
retq
movq -0x278(%rbp), %rdi
callq 0xba30
movq -0x228(%rbp), %rdi
callq 0xade0
nopl (%rax,%rax)