// File: 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
subq $0x610, %rsp            # imm = 0x610
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x5b8(%rbp)
movslq 0x3c(%rax), %rdi
shlq $0x3, %rdi
callq 0x3240
movq %rax, -0x10(%rbp)
leaq -0x198(%rbp), %rdi
callq 0x3120
leaq -0x188(%rbp), %rdi
leaq 0xeefa(%rip), %rsi      # 0x130ff
callq 0x31d0
movq %rax, -0x5b0(%rbp)
jmp 0x4213
movq -0x5b0(%rbp), %rdi
leaq 0xeeea(%rip), %rsi      # 0x1310b
callq 0x31d0
movq %rax, -0x5c0(%rbp)
jmp 0x422f
movq -0x5c0(%rbp), %rdi
movq -0x5b8(%rbp), %rax
movl 0x8(%rax), %esi
callq 0x3250
movq %rax, -0x5c8(%rbp)
jmp 0x424e
movq -0x5c8(%rbp), %rdi
leaq 0xeeb1(%rip), %rsi      # 0x1310d
callq 0x31d0
jmp 0x4263
leaq -0x3d0(%rbp), %rdi
leaq -0x198(%rbp), %rsi
callq 0x31c0
jmp 0x4278
leaq -0x3b0(%rbp), %rdi
leaq -0x3d0(%rbp), %rsi
movl $0x8, %edx
callq 0x32b0
jmp 0x4292
leaq -0x3d0(%rbp), %rdi
callq 0x3110
leaq -0x3f0(%rbp), %rdi
callq 0x3260
leaq -0x410(%rbp), %rdi
callq 0x3260
movl $0x0, -0x414(%rbp)
movl $0xffffffff, -0x418(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x41c(%rbp)
leaq -0x3b0(%rbp), %rdi
callq 0x32a0
movb %al, -0x5c9(%rbp)
jmp 0x42e8
movb -0x5c9(%rbp), %al
testb $0x1, %al
jne 0x42f7
jmp 0x4551
leaq -0x5a8(%rbp), %rdi
callq 0x3120
jmp 0x4305
jmp 0x4307
leaq -0x3b0(%rbp), %rdi
leaq -0x410(%rbp), %rsi
callq 0x3060
movq %rax, -0x5d8(%rbp)
jmp 0x4323
movq -0x5d8(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x3220
movb %al, -0x5d9(%rbp)
jmp 0x4341
movb -0x5d9(%rbp), %al
testb $0x1, %al
jne 0x4350
jmp 0x4535
movl -0x414(%rbp), %eax
cmpl -0x41c(%rbp), %eax
jne 0x443f
movq -0x5b8(%rbp), %rax
movl -0x418(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x418(%rbp)
movq 0xf0(%rax), %rax
movslq -0x418(%rbp), %rcx
movslq (%rax,%rcx,4), %rdi
shlq $0x3, %rdi
callq 0x3240
movq %rax, %rsi
movq -0x5b8(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq -0x418(%rbp), %rdx
movq %rsi, (%rcx,%rdx,8)
movq 0xf0(%rax), %rax
movslq -0x418(%rbp), %rcx
movl (%rax,%rcx,4), %eax
addl -0x41c(%rbp), %eax
movl %eax, -0x41c(%rbp)
jmp 0x443f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a0(%rbp)
movl %eax, -0x1a4(%rbp)
jmp 0x45f3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a0(%rbp)
movl %eax, -0x1a4(%rbp)
leaq -0x3d0(%rbp), %rdi
callq 0x3110
jmp 0x45f3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a0(%rbp)
movl %eax, -0x1a4(%rbp)
jmp 0x45cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a0(%rbp)
movl %eax, -0x1a4(%rbp)
leaq -0x5a8(%rbp), %rdi
callq 0x3140
jmp 0x45cf
leaq -0x598(%rbp), %rdi
leaq -0x410(%rbp), %rsi
callq 0x31a0
jmp 0x4454
jmp 0x4456
leaq -0x5a8(%rbp), %rdi
leaq -0x3f0(%rbp), %rsi
movl $0x2c, %edx
callq 0x3340
movq %rax, -0x5e8(%rbp)
jmp 0x4477
movq -0x5e8(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x3220
movb %al, -0x5e9(%rbp)
jmp 0x4495
movb -0x5e9(%rbp), %al
testb $0x1, %al
jne 0x44a1
jmp 0x4514
xorl %eax, %eax
movl %eax, %esi
leaq -0x3f0(%rbp), %rdi
callq 0x7570
movsd %xmm0, -0x5f8(%rbp)
jmp 0x44bb
movsd -0x5f8(%rbp), %xmm0
movq -0x5b8(%rbp), %rsi
movq -0x10(%rbp), %rax
movslq -0x418(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x414(%rbp), %ecx
movl -0x41c(%rbp), %edx
movq 0xf0(%rsi), %rsi
movslq -0x418(%rbp), %rdi
subl (%rsi,%rdi,4), %edx
subl %edx, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x414(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x414(%rbp)
jmp 0x4456
movq -0x5a8(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x5a8(%rbp,%rax), %rdi
xorl %esi, %esi
callq 0x32f0
jmp 0x4530
jmp 0x4307
leaq -0x3b0(%rbp), %rdi
callq 0x3070
jmp 0x4543
leaq -0x5a8(%rbp), %rdi
callq 0x3140
jmp 0x4584
movq 0x15a78(%rip), %rdi     # 0x19fd0
leaq 0xebb8(%rip), %rsi      # 0x13117
callq 0x31d0
movq %rax, -0x600(%rbp)
jmp 0x456d
movq -0x600(%rbp), %rdi
movq 0x15a3d(%rip), %rsi     # 0x19fb8
callq 0x31f0
jmp 0x4582
jmp 0x4584
movq -0x10(%rbp), %rax
movq %rax, -0x608(%rbp)
leaq -0x410(%rbp), %rdi
callq 0x3110
leaq -0x3f0(%rbp), %rdi
callq 0x3110
leaq -0x3b0(%rbp), %rdi
callq 0x3090
leaq -0x198(%rbp), %rdi
callq 0x3140
movq -0x608(%rbp), %rax
addq $0x610, %rsp            # imm = 0x610
popq %rbp
retq
leaq -0x410(%rbp), %rdi
callq 0x3110
leaq -0x3f0(%rbp), %rdi
callq 0x3110
leaq -0x3b0(%rbp), %rdi
callq 0x3090
leaq -0x198(%rbp), %rdi
callq 0x3140
movq -0x1a0(%rbp), %rdi
callq 0x3320
nopl (%rax,%rax)