// File: /workspace/github_cpp_makefile_star2_O3/j-faria[P]kima/src/Data.cpp
// Function: Data::load_multi(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int)
void Data::load_multi(const std::string filename, const std::string units, int skip)
  {

  data_t data;

  // Empty the vectors
  t.clear();
  y.clear();
  sig.clear();
  obsi.clear();

  // Read the file into the data container
  ifstream infile( filename );
  infile >> data;

  // Complain if something went wrong.
  if (!infile.eof())
  {
    printf("Could not read data file (%s)!\n", filename.c_str());
    exit(1);
  }

  infile.close();

  datafile = filename;
  dataunits = units;
  dataskip = skip;
  datamulti = true;

  double factor = 1.;
  if(units == "kms") factor = 1E3;

  // the 4th column of the file identifies the instrument; can have "0"s
  // this is to make sure the obsi vector always starts at 1, to avoid
  // segmentation faults later
  vector<int> inst_id;
  int id = 0;

  inst_id.push_back(data[skip][3]);

  for (size_t n = skip+1; n < data.size(); n++)
  {
    if (data[n][3] != inst_id.back())
      inst_id.push_back(data[n][3]);
  }

  for (unsigned n = skip; n < data.size(); n++)
  {
    // if (n < skip) continue;
    t.push_back(data[n][0]);
    y.push_back(data[n][1] * factor);
    sig.push_back(data[n][2] * factor);

    if (data[n][3] != inst_id[id])
      id++;
    obsi.push_back(id+1);
  }

  // How many points did we read?
  printf("# Loaded %zu data points from file %s\n", t.size(), filename.c_str());

  // Of how many instruments?
  std::set<int> s( obsi.begin(), obsi.end() );
  printf("# RVs come from %zu different instruments.\n", s.size());
  number_instruments = s.size();
  
  if(units == "kms") 
    cout << "# Multiplied all RVs by 1000; units are now m/s." << endl;

  // epoch for the mean anomaly, by default the time of the first observation
  M0_epoch = t[0];

  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x298, %rsp            # imm = 0x298
movl %ecx, %ebp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
xorpd %xmm0, %xmm0
movapd %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movq (%rdi), %rax
cmpq %rax, 0x8(%rdi)
je 0x9a1b
movq %rax, 0x8(%rbx)
movq 0x18(%rbx), %rax
cmpq %rax, 0x20(%rbx)
je 0x9a29
movq %rax, 0x20(%rbx)
movq 0x30(%rbx), %rax
cmpq %rax, 0x38(%rbx)
je 0x9a37
movq %rax, 0x38(%rbx)
movq 0x48(%rbx), %rax
cmpq %rax, 0x50(%rbx)
je 0x9a45
movq %rax, 0x50(%rbx)
leaq 0x90(%rsp), %rdi
movq %r15, %rsi
movl $0x8, %edx
callq 0x6640
leaq 0x90(%rsp), %rdi
movq %rsp, %rsi
callq 0x9287
movq 0x90(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0xb0(%rsp,%rax)
je 0x9e29
leaq 0x90(%rsp), %rdi
callq 0x60a0
leaq 0x98(%rbx), %rdi
movq %r15, %rsi
callq 0x6210
leaq 0xd0(%rbx), %rdi
movq %r14, %rsi
callq 0x6210
movl %ebp, 0xf0(%rbx)
movb $0x1, 0xf4(%rbx)
leaq 0x33a4d(%rip), %rsi     # 0x3d510
movq %r14, %rdi
callq 0x6100
xorpd %xmm0, %xmm0
leaq 0x20(%rsp), %rdi
movapd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movslq %ebp, %rcx
movq (%rsp), %rdx
leaq (%rcx,%rcx,2), %rcx
movq (%rdx,%rcx,8), %rcx
cvttsd2si 0x18(%rcx), %ecx
testl %eax, %eax
sete %r12b
leaq 0x60(%rsp), %rdx
movl %ecx, (%rdx)
xorl %esi, %esi
callq 0xc8d4
movb %r12b, 0x18(%rsp)
movq %r15, 0x40(%rsp)
movq %r14, 0x38(%rsp)
movq (%rsp), %rax
movq 0x8(%rsp), %rcx
leal 0x1(%rbp), %r15d
movslq %r15d, %r14
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %r12 # imm = 0xAAAAAAAAAAAAAAAB
imulq %r12, %rdx
cmpq %r14, %rdx
jbe 0x9bbc
leaq (,%r14,8), %rdx
leaq (%rdx,%rdx,2), %r13
movq (%rax,%r13), %rdx
movsd 0x18(%rdx), %xmm0
movq 0x28(%rsp), %rsi
xorps %xmm1, %xmm1
cvtsi2sdl -0x4(%rsi), %xmm1
ucomisd %xmm1, %xmm0
jne 0x9b6e
jnp 0x9ba2
cvttsd2si %xmm0, %edx
movl %edx, 0x60(%rsp)
cmpq 0x30(%rsp), %rsi
je 0x9b8a
movl %edx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x28(%rsp)
jmp 0x9ba2
leaq 0x20(%rsp), %rdi
leaq 0x60(%rsp), %rdx
callq 0xc8d4
movq (%rsp), %rax
movq 0x8(%rsp), %rcx
incq %r14
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r12, %rdx
addq $0x18, %r13
cmpq %rdx, %r14
jb 0x9b50
movl %ebp, %ecx
cmpq %rcx, %rdx
jbe 0x9d21
leaq 0x18(%rbx), %rdx
movq %rdx, 0x58(%rsp)
leaq 0x30(%rbx), %rdx
movq %rdx, 0x50(%rsp)
leaq 0x48(%rbx), %rdx
movq %rdx, 0x48(%rsp)
xorl %esi, %esi
movb 0x18(%rsp), %dl
movb %dl, %sil
leaq 0x338ae(%rip), %rdx     # 0x3d4a0
movsd (%rdx,%rsi,8), %xmm0
movsd %xmm0, 0x18(%rsp)
xorl %r13d, %r13d
leaq 0x60(%rsp), %r14
leaq (%rcx,%rcx,2), %rbp
movq (%rax,%rbp,8), %rdx
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x9c29
movsd (%rdx), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x9c39
movq %rbx, %rdi
callq 0xc042
movq (%rsp), %rax
movq (%rax,%rbp,8), %rdx
movsd 0x8(%rdx), %xmm0
mulsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x60(%rsp)
movq 0x20(%rbx), %rsi
cmpq 0x28(%rbx), %rsi
je 0x9c62
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x20(%rbx)
jmp 0x9c73
movq 0x58(%rsp), %rdi
movq %r14, %rdx
callq 0x7488
movq (%rsp), %rax
movq (%rax,%rbp,8), %rcx
movsd 0x10(%rcx), %xmm0
mulsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x60(%rsp)
movq 0x38(%rbx), %rsi
cmpq 0x40(%rbx), %rsi
je 0x9ca0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x38(%rbx)
jmp 0x9cb1
movq 0x50(%rsp), %rdi
movq %r14, %rdx
callq 0x7488
movq (%rsp), %rax
movq (%rax,%rbp,8), %rcx
movl %r13d, %edx
movq 0x20(%rsp), %rsi
xorps %xmm0, %xmm0
cvtsi2sdl (%rsi,%rdx,4), %xmm0
cmpneqsd 0x18(%rcx), %xmm0
movq %xmm0, %rcx
subl %ecx, %r13d
leal 0x1(%r13), %ecx
movl %ecx, 0x60(%rsp)
movq 0x50(%rbx), %rsi
cmpq 0x58(%rbx), %rsi
je 0x9cf1
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x50(%rbx)
jmp 0x9d02
movq 0x48(%rsp), %rdi
movq %r14, %rdx
callq 0xc8d4
movq (%rsp), %rax
movl %r15d, %ecx
movq 0x8(%rsp), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r12, %rdx
incl %r15d
cmpq %rcx, %rdx
ja 0x9c05
movq 0x8(%rbx), %rsi
subq (%rbx), %rsi
sarq $0x3, %rsi
movq 0x40(%rsp), %rax
movq (%rax), %rdx
leaq 0x337d9(%rip), %rdi     # 0x3d514
xorl %eax, %eax
callq 0x6050
movq 0x48(%rbx), %rsi
movq 0x50(%rbx), %rdx
leaq 0x60(%rsp), %rdi
callq 0xbbdc
movq 0x88(%rsp), %rsi
leaq 0x33814(%rip), %rdi     # 0x3d577
xorl %eax, %eax
callq 0x6050
movl 0x88(%rsp), %eax
movl %eax, 0xf8(%rbx)
leaq 0x33792(%rip), %rsi     # 0x3d510
movq 0x38(%rsp), %rdi
callq 0x6100
testl %eax, %eax
jne 0x9dd2
movq 0x46205(%rip), %r14     # 0x4ff98
leaq 0x338e1(%rip), %rsi     # 0x3d67b
movl $0x30, %edx
movq %r14, %rdi
callq 0x64a0
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x6430
movsbl %al, %esi
movq 0x461d3(%rip), %rdi     # 0x4ff98
callq 0x6030
movq %rax, %rdi
callq 0x6300
movq (%rbx), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x100(%rbx)
leaq 0x60(%rsp), %rdi
callq 0xbf28
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x9e02
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x6460
leaq 0x90(%rsp), %rdi
callq 0x60e0
movq %rsp, %rdi
callq 0xbb88
addq $0x298, %rsp            # imm = 0x298
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r15), %rsi
leaq 0x336bd(%rip), %rdi     # 0x3d4f0
xorl %eax, %eax
callq 0x6050
movl $0x1, %edi
callq 0x64e0
jmp 0x9e69
jmp 0x9e69
movq %rax, %rbx
jmp 0x9e90
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0xbf28
jmp 0x9e6c
jmp 0x9e69
movq %rax, %rbx
jmp 0x9e83
jmp 0x9e69
jmp 0x9e69
jmp 0x9e69
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x9e83
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x6460
leaq 0x90(%rsp), %rdi
callq 0x60e0
movq %rsp, %rdi
callq 0xbb88
movq %rbx, %rdi
callq 0x6710