// File: /workspace/github_cpp_makefile_star2_O2/mateuz[P]MTS-LS1/source/Benchmarks.cpp
// Function: Benchmarks::readOvectorVec()
double** Benchmarks::readOvectorVec()
{
  // read O vector from file in csv format, seperated by s_size groups
  double** d = (double**) malloc(s_size*sizeof(double*));
  stringstream ss;
  ss<< "cdatafiles/" << "F" << ID << "-xopt.txt";
  ifstream file (ss.str());
  string value;
  string line;
  int c = 0;                      // index over 1 to dim
  int i = -1;                      // index over 1 to s_size
  int up = 0;                   // current upper bound for one group
  
  if (file.is_open())
    {
      stringstream iss;
      while ( getline(file, line) )
        {
          if (c==up)             // out (start) of one group
            {
              // printf("=\n");
              i++;
              d[i] =  (double*) malloc(s[i]*sizeof(double));
              up += s[i];
            }
          iss<<line;
          while (getline(iss, value, ','))
            {
              // printf("c=%d\ts=%d\ti=%d\tup=%d\tindex=%d\n",c,s[i],i,up,c-(up-s[i]));
              d[i][c-(up-s[i])] = stod(value);
              // printf("1\n");
              c++;
            }
          iss.clear();
          // printf("2\n");
        }
      file.close();
    }
  else
    {
      cout<<"Cannot open datafiles"<<endl;
    }
  return d;  
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x568, %rsp            # imm = 0x568
movq %rdi, %r14
movslq 0x3c(%rdi), %rdi
shlq $0x3, %rdi
callq 0x3220
movq %rax, -0x38(%rbp)
leaq -0x388(%rbp), %rdi
callq 0x3140
leaq -0x378(%rbp), %rdi
leaq 0x63da(%rip), %rsi      # 0xa0d0
callq 0x31d0
leaq 0x63da(%rip), %rsi      # 0xa0dc
movq %rax, %rdi
callq 0x31d0
movl 0x8(%r14), %esi
movq %rax, %rdi
callq 0x3130
leaq 0x63c1(%rip), %rsi      # 0xa0de
movq %rax, %rdi
callq 0x31d0
leaq -0x370(%rbp), %rsi
leaq -0x200(%rbp), %rdi
callq 0x3260
leaq -0x590(%rbp), %rdi
leaq -0x200(%rbp), %rsi
pushq $0x8
popq %rdx
callq 0x3270
leaq -0x200(%rbp), %rdi
callq 0x30e0
leaq -0x68(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
leaq -0x48(%rbp), %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
xorl %edx, %edx
movb %dl, (%rax)
movb %dl, (%rcx)
leaq -0x518(%rbp), %rdi
callq 0x3090
testb %al, %al
je 0x3e92
leaq -0x200(%rbp), %rdi
callq 0x3140
pushq $-0x1
popq %rax
movl %eax, -0x2c(%rbp)
xorl %ebx, %ebx
leaq -0x78(%rbp), %r13
movl $0x0, -0x30(%rbp)
leaq -0x590(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x3060
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x3eaf
cmpl -0x30(%rbp), %ebx
jne 0x3e07
movq 0xf0(%r14), %rax
movl -0x2c(%rbp), %ecx
movslq %ecx, %r15
incl %ecx
movl %ecx, -0x2c(%rbp)
movslq 0x4(%rax,%r15,4), %r12
movq %r12, %rdi
shlq $0x3, %rdi
callq 0x3220
movq -0x38(%rbp), %rcx
movq %rax, 0x8(%rcx,%r15,8)
leal (%r12,%rbx), %eax
movl %eax, -0x30(%rbp)
leaq -0x1f0(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x31b0
movslq -0x2c(%rbp), %r15
movl -0x30(%rbp), %eax
movl %eax, %r12d
negl %r12d
leaq -0x200(%rbp), %rdi
movq %r13, %rsi
pushq $0x2c
popq %rdx
callq 0x32f0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x3e71
movq %r13, %rdi
xorl %esi, %esi
callq 0x5a35
movq 0xf0(%r14), %rax
leal (%r12,%rbx), %ecx
addl (%rax,%r15,4), %ecx
movq -0x38(%rbp), %rax
movq (%rax,%r15,8), %rax
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
incl %ebx
jmp 0x3e24
movq -0x200(%rbp), %rax
movq -0x18(%rax), %rdi
leaq -0x200(%rbp), %rax
addq %rax, %rdi
xorl %esi, %esi
callq 0x32a0
jmp 0x3dad
movq 0xb137(%rip), %rdi      # 0xefd0
leaq 0x6248(%rip), %rsi      # 0xa0e8
callq 0x31d0
movq %rax, %rdi
callq 0x30f0
jmp 0x3ec7
leaq -0x590(%rbp), %rdi
callq 0x3070
leaq -0x200(%rbp), %rdi
callq 0x3160
leaq -0x58(%rbp), %rdi
callq 0x30e0
leaq -0x78(%rbp), %rdi
callq 0x30e0
leaq -0x590(%rbp), %rdi
callq 0x30a0
leaq -0x388(%rbp), %rdi
callq 0x3160
movq -0x38(%rbp), %rax
addq $0x568, %rsp            # imm = 0x568
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3f2a
jmp 0x3f0b
movq %rax, %rbx
jmp 0x3f39
movq %rax, %rbx
leaq -0x200(%rbp), %rdi
callq 0x30e0
jmp 0x3f57
jmp 0x3f23
movq %rax, %rbx
jmp 0x3f57
jmp 0x3f2a
movq %rax, %rbx
leaq -0x200(%rbp), %rdi
callq 0x3160
leaq -0x58(%rbp), %rdi
callq 0x30e0
leaq -0x78(%rbp), %rdi
callq 0x30e0
leaq -0x590(%rbp), %rdi
callq 0x30a0
leaq -0x388(%rbp), %rdi
callq 0x3160
movq %rbx, %rdi
callq 0x32d0
nop