// File: /workspace/github_cpp_makefile_star2_O3/j-faria[P]kima/src/Data.cpp
// Function: Data::load(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, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>> const&)
void Data::load(const std::string filename, const std::string units, 
                int skip, const vector<string>& indicators)
{

  data_t data;

  // Empty the vectors
  t.clear();
  y.clear();
  sig.clear();
  
  // check for indicator correlations and store stuff
  int nempty = count(indicators.begin(), indicators.end(), "");
  number_indicators = indicators.size() - nempty;
  indicator_correlations = number_indicators > 0;
  indicator_names = indicators;
  indicator_names.erase(
    std::remove( indicator_names.begin(), indicator_names.end(), "" ), 
    indicator_names.end() );


  // Empty the indicator vectors as well
  actind.clear();
  actind.resize(number_indicators);
  for (int n = 0; n < number_indicators; n++)
    actind[n].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 = false;
  number_instruments = 1;


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

  for (size_t n = 0; 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 (indicator_correlations)
      {
        j = 0;
        for (size_t i = 0; i < number_indicators + nempty; i++)
        {
          if (indicators[i] == "")
            continue; // skip column
          else
          {
            actind[j].push_back(data[n][3+i] * factor);
            j++;
          }
        }
      }
  
    }
  
  // epoch for the mean anomaly, by default the time of the first observation
  M0_epoch = t[0];


  // subtract means from activity indicators
  if (indicator_correlations)
  {
    double mean;
    for (auto& i: actind){ // use auto& instead of auto to modify i
      mean = std::accumulate(i.begin(), i.end(), 0.0) / y.size();
      std::for_each(i.begin(), i.end(), [mean](double& d) { d -= mean;});
    }
  }

  // How many points did we read?
  printf("# Loaded %zu data points from file %s\n", t.size(), filename.c_str());
  // Did we read activity indicators? how many?
  if(indicator_correlations){
    printf("# Loaded %zu observations of %zu activity indicators: ", 
           actind[0].size(), actind.size());
    for (const auto i: indicators){
      if (i != ""){
        printf("'%s'", i.c_str());
        (i != indicators.back()) ? cout << ", " : cout << " ";
      }
    }
    cout << endl;
  }
  // What are the units?
  if(units == "kms")
    printf("# Multiplied all RVs by 1000; units are now m/s.\n");

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x298, %rsp            # imm = 0x298
movq %r8, %r13
movl %ecx, %r15d
movq %rsi, %r12
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq (%rdi), %rax
cmpq %rax, 0x8(%rdi)
je 0x934c
movq %rax, 0x8(%rdi)
movq 0x18(%rdi), %rax
cmpq %rax, 0x20(%rdi)
je 0x935a
movq %rax, 0x20(%rdi)
movq %rdx, 0x30(%rsp)
movq 0x30(%rdi), %rax
cmpq %rax, 0x38(%rdi)
je 0x936d
movq %rax, 0x38(%rdi)
movq %rdi, (%rsp)
movq (%r13), %rbx
movq 0x8(%r13), %r14
cmpq %r14, %rbx
je 0x93bc
movl %r15d, 0x8(%rsp)
movq %r12, %r15
xorl %ebp, %ebp
leaq 0x3474e(%rip), %r12     # 0x3dadd
movq %rbx, %rdi
movq %r12, %rsi
callq 0x6100
cmpl $0x1, %eax
adcq $0x0, %rbp
addq $0x20, %rbx
cmpq %r14, %rbx
jne 0x938f
movq (%r13), %rbx
movq 0x8(%r13), %rax
movq %r15, %r12
movl 0x8(%rsp), %r15d
jmp 0x93c1
xorl %ebp, %ebp
movq %rbx, %rax
subq %rbx, %rax
shrq $0x5, %rax
subl %ebp, %eax
movq (%rsp), %r14
movl %eax, 0x7c(%r14)
testl %eax, %eax
setg 0x78(%r14)
leaq 0x80(%r14), %rbx
movq %rbx, %rdi
movq %r13, %rsi
callq 0xb9b6
movq 0x80(%r14), %rdi
movq 0x88(%r14), %rsi
leaq 0x346dd(%rip), %rdx     # 0x3dadd
callq 0xc52d
movq 0x88(%r14), %rdx
movq %rbx, %rdi
movq %rax, %rsi
callq 0xc682
leaq 0x60(%r14), %rbx
movq 0x60(%r14), %rsi
movq %rbx, %rdi
callq 0xc750
movslq 0x7c(%r14), %rsi
movq %rbx, 0x68(%rsp)
movq %rbx, %rdi
callq 0xbb4c
movslq 0x7c(%r14), %rcx
testq %rcx, %rcx
movq %r14, %rbx
movq 0x30(%rsp), %r14
jle 0x9474
movq 0x68(%rsp), %rax
movq (%rax), %rax
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rcx
xorl %edx, %edx
movq (%rax,%rdx), %rsi
cmpq %rsi, 0x8(%rax,%rdx)
je 0x946b
movq %rsi, 0x8(%rax,%rdx)
addq $0x18, %rdx
cmpq %rdx, %rcx
jne 0x945b
leaq 0x90(%rsp), %rdi
movq %r12, %rsi
movl $0x8, %edx
callq 0x6640
movq %r13, 0x8(%rsp)
leaq 0x90(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x9287
movq 0x90(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0xb0(%rsp,%rax)
je 0x996f
leaq 0x90(%rsp), %rdi
callq 0x60a0
leaq 0x98(%rbx), %rdi
movq %r12, %rsi
callq 0x6210
leaq 0xd0(%rbx), %rdi
movq %r14, %rsi
callq 0x6210
movq %r12, 0x70(%rsp)
movl %r15d, 0xf0(%rbx)
movb $0x0, 0xf4(%rbx)
movl $0x1, 0xf8(%rbx)
leaq 0x34007(%rip), %rsi     # 0x3d510
movq %r14, %rdi
callq 0x6100
xorl %ecx, %ecx
testl %eax, %eax
sete %dl
movq 0x10(%rsp), %rax
cmpq %rax, 0x18(%rsp)
je 0x9708
movq (%rsp), %rsi
leaq 0x18(%rsi), %rdi
movq %rdi, 0x80(%rsp)
addq $0x30, %rsi
movq %rsi, 0x78(%rsp)
movb %dl, %cl
leaq 0x33f56(%rip), %rdx     # 0x3d4a0
movsd (%rdx,%rcx,8), %xmm0
movsd %xmm0, 0x38(%rsp)
movslq %r15d, %rcx
movq %rcx, 0x88(%rsp)
movl %ebp, %ecx
negl %ecx
movl %ecx, 0x64(%rsp)
xorl %r12d, %r12d
cmpq 0x88(%rsp), %r12
jb 0x96dd
leaq (%r12,%r12,2), %r14
movq (%rax,%r14,8), %rdx
movq (%rsp), %rbx
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x95a1
movsd (%rdx), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x95b2
movq %rbx, %rdi
callq 0xc042
movq 0x10(%rsp), %rax
movq (%rax,%r14,8), %rdx
movsd 0x8(%rdx), %xmm0
mulsd 0x38(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
movq 0x20(%rbx), %rsi
cmpq 0x28(%rbx), %rsi
je 0x95db
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x20(%rbx)
jmp 0x95f2
movq 0x80(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x7488
movq 0x10(%rsp), %rax
movq (%rax,%r14,8), %rax
movsd 0x10(%rax), %xmm0
mulsd 0x38(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
movq 0x38(%rbx), %rsi
cmpq 0x40(%rbx), %rsi
je 0x961f
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x38(%rbx)
jmp 0x962e
movq 0x78(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x7488
cmpb $0x1, 0x78(%rbx)
jne 0x96dd
movq (%rsp), %rax
movl 0x64(%rsp), %ecx
cmpl %ecx, 0x7c(%rax)
je 0x96dd
xorl %r13d, %r13d
xorl %ebx, %ebx
xorl %r15d, %r15d
movq 0x8(%rsp), %rax
movq (%rax), %rdi
addq %r13, %rdi
leaq 0x3447a(%rip), %rsi     # 0x3dadd
callq 0x6100
testl %eax, %eax
je 0x96bf
movslq %ebx, %rax
movq 0x68(%rsp), %rcx
movq (%rcx), %rcx
leaq (%rax,%rax,2), %rax
leaq (%rcx,%rax,8), %rdi
movq 0x10(%rsp), %rax
movq (%rax,%r14,8), %rax
movsd 0x18(%rax,%r15,8), %xmm0
mulsd 0x38(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x96b3
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x96bd
leaq 0x40(%rsp), %rdx
callq 0x7488
incl %ebx
incq %r15
movq (%rsp), %rax
movslq 0x7c(%rax), %rax
movslq %ebp, %rcx
addq %rax, %rcx
addq $0x20, %r13
cmpq %rcx, %r15
jb 0x9651
incq %r12
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdx, %rcx
cmpq %rcx, %r12
jb 0x956b
movq (%rsp), %rcx
movq (%rcx), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x100(%rcx)
cmpb $0x0, 0x78(%rcx)
movq 0x30(%rsp), %rbx
movq 0x8(%rsp), %r15
movq 0x70(%rsp), %r9
je 0x97b9
movq (%rsp), %rdx
movq 0x60(%rdx), %rcx
movq 0x68(%rdx), %rdx
cmpq %rdx, %rcx
je 0x97b9
movq (%rsp), %rdi
movq 0x20(%rdi), %rsi
subq 0x18(%rdi), %rsi
sarq $0x3, %rsi
movq %rsi, %xmm1
punpckldq 0x338ae(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x338b6(%rip), %xmm1    # 0x3d020
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movq (%rcx), %rsi
movq 0x8(%rcx), %rdi
cmpq %rdi, %rsi
je 0x97b0
xorpd %xmm1, %xmm1
movq %rsi, %r8
addsd (%r8), %xmm1
addq $0x8, %r8
cmpq %rdi, %r8
jne 0x9789
divsd %xmm0, %xmm1
movsd (%rsi), %xmm2
subsd %xmm1, %xmm2
movsd %xmm2, (%rsi)
addq $0x8, %rsi
cmpq %rdi, %rsi
jne 0x979b
addq $0x18, %rcx
cmpq %rdx, %rcx
jne 0x9776
movq (%rsp), %r14
movq 0x8(%r14), %rsi
subq %rax, %rsi
sarq $0x3, %rsi
movq (%r9), %rdx
leaq 0x33d42(%rip), %rdi     # 0x3d514
xorl %eax, %eax
callq 0x6050
cmpb $0x1, 0x78(%r14)
jne 0x9927
movq 0x60(%r14), %rax
movq 0x68(%r14), %rdx
movq 0x8(%rax), %rsi
subq (%rax), %rsi
sarq $0x3, %rsi
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rdx
leaq 0x33d28(%rip), %rdi     # 0x3d53b
xorl %eax, %eax
callq 0x6050
movq (%r15), %r14
movq 0x8(%r15), %r13
cmpq %r13, %r14
je 0x98f3
leaq 0x50(%rsp), %r12
leaq 0x40(%rsp), %rbx
leaq 0x342a2(%rip), %r15     # 0x3dadd
movq %r12, 0x40(%rsp)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0xbf78
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6100
testl %eax, %eax
je 0x98cf
movq 0x40(%rsp), %rsi
leaq 0x33d05(%rip), %rdi     # 0x3d572
xorl %eax, %eax
callq 0x6050
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x48(%rsp), %rdx
movl $0x2, %ebp
cmpq -0x18(%rax), %rdx
jne 0x98b9
testq %rdx, %rdx
je 0x98ab
movq -0x20(%rax), %rsi
movq 0x40(%rsp), %rdi
callq 0x6470
leaq 0x3bd04(%rip), %rsi     # 0x455ab
testl %eax, %eax
jne 0x98c0
movl $0x1, %ebp
leaq 0x33d14(%rip), %rsi     # 0x3d5cb
jmp 0x98c0
leaq 0x3bceb(%rip), %rsi     # 0x455ab
movq 0x466d1(%rip), %rdi     # 0x4ff98
movq %rbp, %rdx
callq 0x64a0
movq 0x40(%rsp), %rdi
cmpq %r12, %rdi
je 0x98e6
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x6460
addq $0x20, %r14
cmpq %r13, %r14
jne 0x983b
movq 0x4669e(%rip), %rdi     # 0x4ff98
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x6430
movq 0x30(%rsp), %rbx
movsbl %al, %esi
movq 0x4667e(%rip), %rdi     # 0x4ff98
callq 0x6030
movq %rax, %rdi
callq 0x6300
leaq 0x33be2(%rip), %rsi     # 0x3d510
movq %rbx, %rdi
callq 0x6100
testl %eax, %eax
jne 0x9946
leaq 0x33d3a(%rip), %rdi     # 0x3d67b
callq 0x65f0
leaq 0x90(%rsp), %rdi
callq 0x60e0
leaq 0x10(%rsp), %rdi
callq 0xbb88
addq $0x298, %rsp            # imm = 0x298
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r12), %rsi
leaq 0x33b76(%rip), %rdi     # 0x3d4f0
xorl %eax, %eax
callq 0x6050
movl $0x1, %edi
callq 0x64e0
jmp 0x9993
jmp 0x9993
jmp 0x9993
jmp 0x99be
movq %rax, %rbx
jmp 0x99ce
jmp 0x99be
jmp 0x99be
jmp 0x99be
jmp 0x99be
movq %rax, %rbx
movq 0x40(%rsp), %rdi
cmpq %r12, %rdi
je 0x99c1
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x6460
jmp 0x99c1
jmp 0x99be
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x60e0
leaq 0x10(%rsp), %rdi
callq 0xbb88
movq %rbx, %rdi
callq 0x6710