// File: WeihuaZhu[P]hpc_prog2/./io.h
// Function: std::vector<double, std::allocator<double>> read_binary_file<double>(char const*)
std::vector<T> read_binary_file(const char* filename)
{
    // get file size
    std::ifstream in(filename, std::ios::binary | std::ios::ate);
    if (!(in.good() && in.is_open()))
        throw std::runtime_error(std::string("Couldn't open file ") + filename);
    std::size_t nbytes = in.tellg();
    in.close();
    // open again, this time at the beginning
    std::ifstream infile(filename, std::ios::binary);

    // create vector of the correct size
    std::size_t n = nbytes / sizeof(T);
    std::vector<T> result(n);
    // read file into vector:
    infile.read((char*) &result[0], nbytes);
    return result;
}

// Assembly:
subq $0x4f8, %rsp            # imm = 0x4F8
movq %rdi, 0x40(%rsp)
movq %rdi, %rax
movq %rax, 0x48(%rsp)
movq %rdi, 0x4f0(%rsp)
movq %rsi, 0x4e8(%rsp)
movq 0x4e8(%rsp), %rax
movq %rax, 0x50(%rsp)
movl $0x4, %edi
movl $0x2, %esi
callq 0x117e0
movq 0x50(%rsp), %rsi
movl %eax, %edx
leaq 0x2e0(%rsp), %rdi
callq 0x9d50
movq 0x2e0(%rsp), %rax
movq -0x18(%rax), %rax
leaq 0x2e0(%rsp,%rax), %rdi
callq 0x9c50
movb %al, 0x5d(%rsp)
jmp 0xbf03
movb 0x5d(%rsp), %al
testb $0x1, %al
jne 0xbf0d
jmp 0xbf2e
leaq 0x2e0(%rsp), %rdi
callq 0x9b60
movb %al, 0x3f(%rsp)
jmp 0xbf20
movb 0x3f(%rsp), %al
testb $0x1, %al
jne 0xc065
jmp 0xbf2e
movb $0x1, 0x28e(%rsp)
movl $0x10, %edi
callq 0x92c0
movq %rax, 0x28(%rsp)
leaq 0x28f(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0x9cd0
movq 0x30(%rsp), %rdx
leaq 0x83c5(%rip), %rsi      # 0x14328
leaq 0x290(%rsp), %rdi
callq 0xbd60
jmp 0xbf72
movq 0x4e8(%rsp), %rdx
leaq 0x2b0(%rsp), %rdi
leaq 0x290(%rsp), %rsi
callq 0x11800
jmp 0xbf91
movq 0x28(%rsp), %rdi
leaq 0x2b0(%rsp), %rsi
callq 0x9b80
jmp 0xbfa5
movq 0x28(%rsp), %rdi
movb $0x0, 0x28e(%rsp)
movq 0xe037(%rip), %rsi      # 0x19ff0
movq 0xdff8(%rip), %rdx      # 0x19fb8
callq 0x9c70
jmp 0xc1f3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d8(%rsp)
movl %eax, 0x2d4(%rsp)
jmp 0xc1d9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d8(%rsp)
movl %eax, 0x2d4(%rsp)
jmp 0xc03d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d8(%rsp)
movl %eax, 0x2d4(%rsp)
jmp 0xc030
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d8(%rsp)
movl %eax, 0x2d4(%rsp)
leaq 0x2b0(%rsp), %rdi
callq 0x93e0
leaq 0x290(%rsp), %rdi
callq 0x93e0
leaq 0x28f(%rsp), %rdi
callq 0x9770
testb $0x1, 0x28e(%rsp)
jne 0xc056
jmp 0xc060
movq 0x28(%rsp), %rdi
callq 0x9480
jmp 0xc1d9
leaq 0x2e0(%rsp), %rdi
callq 0x9c90
movq %rdx, 0x18(%rsp)
movq %rax, 0x20(%rsp)
jmp 0xc07e
movq 0x18(%rsp), %rax
movq 0x20(%rsp), %rcx
movq %rcx, 0x270(%rsp)
movq %rax, 0x278(%rsp)
leaq 0x270(%rsp), %rdi
callq 0x11850
movq %rax, 0x10(%rsp)
jmp 0xc0ac
movq 0x10(%rsp), %rax
movq %rax, 0x280(%rsp)
leaq 0x2e0(%rsp), %rdi
callq 0x9100
jmp 0xc0c8
movq 0x4e8(%rsp), %rsi
leaq 0x68(%rsp), %rdi
movl $0x4, %edx
callq 0x9d50
jmp 0xc0e1
movq 0x280(%rsp), %rax
shrq $0x3, %rax
movq %rax, 0x60(%rsp)
movb $0x0, 0x5f(%rsp)
movq 0x60(%rsp), %rax
movq %rax, (%rsp)
leaq 0x5e(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0xbc00
movq 0x40(%rsp), %rdi
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
callq 0xbc10
jmp 0xc124
leaq 0x5e(%rsp), %rdi
callq 0xbc90
movq 0x40(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xbca0
movq %rax, %rsi
movq 0x280(%rsp), %rdx
leaq 0x68(%rsp), %rdi
callq 0x98d0
jmp 0xc153
movb $0x1, 0x5f(%rsp)
testb $0x1, 0x5f(%rsp)
jne 0xc1ab
jmp 0xc1a1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d8(%rsp)
movl %eax, 0x2d4(%rsp)
leaq 0x5e(%rsp), %rdi
callq 0xbc90
jmp 0xc1cf
movq 0x40(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d8(%rsp)
movl %eax, 0x2d4(%rsp)
callq 0xbcc0
jmp 0xc1cf
movq 0x40(%rsp), %rdi
callq 0xbcc0
leaq 0x68(%rsp), %rdi
callq 0x9160
leaq 0x2e0(%rsp), %rdi
callq 0x9160
movq 0x48(%rsp), %rax
addq $0x4f8, %rsp            # imm = 0x4F8
retq
leaq 0x68(%rsp), %rdi
callq 0x9160
leaq 0x2e0(%rsp), %rdi
callq 0x9160
movq 0x2d8(%rsp), %rdi
callq 0x9cc0
nopw %cs:(%rax,%rax)
nopl (%rax)