// File: mateuz[P]MTS-LS1/source/Benchmarks.cpp
// Function: Benchmarks::readR(int)
double** Benchmarks::readR(int sub_dim)
{
  double** m;

  m = new double*[sub_dim];
  for (int i = 0; i< sub_dim; i++)
    {
      m[i] = new double[sub_dim];
    }

  stringstream ss;
  ss<< "cdatafiles/" << "F" << ID << "-R"<<sub_dim<<".txt";
  // cout<<ss.str()<<endl;

  ifstream file (ss.str());
  string value;
  string line;
  int i=0;
  int j;

  if (file.is_open())
    {
      stringstream iss;
      while ( getline(file, line) )
        {
          j=0;
          iss<<line;
          while (getline(iss, value, ','))
            {
              // printf("%d,%d\t%f\n", i,j, stod(value));
              m[i][j] = stod(value);
              // printf("done\n");
              j++;
            }
          iss.clear();
          i++;
        }
      file.close();
    }
  else
    {
      cout<<"Cannot open datafiles"<<endl;
    }
  return m;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x620, %rsp            # imm = 0x620
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x5b8(%rbp)
movslq -0xc(%rbp), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x3030
movq %rax, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x5274
movslq -0xc(%rbp), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x3030
movq %rax, %rdx
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x522d
leaq -0x1a8(%rbp), %rdi
callq 0x3120
leaq -0x198(%rbp), %rdi
leaq 0xde71(%rip), %rsi      # 0x130ff
callq 0x31d0
movq %rax, -0x5c0(%rbp)
jmp 0x529c
movq -0x5c0(%rbp), %rdi
leaq 0xde61(%rip), %rsi      # 0x1310b
callq 0x31d0
movq %rax, -0x5c8(%rbp)
jmp 0x52b8
movq -0x5c8(%rbp), %rdi
movq -0x5b8(%rbp), %rax
movl 0x8(%rax), %esi
callq 0x3250
movq %rax, -0x5d0(%rbp)
jmp 0x52d7
movq -0x5d0(%rbp), %rdi
leaq 0xde4f(%rip), %rsi      # 0x13134
callq 0x31d0
movq %rax, -0x5d8(%rbp)
jmp 0x52f3
movq -0x5d8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x3300
movq %rax, -0x5e0(%rbp)
jmp 0x530b
movq -0x5e0(%rbp), %rdi
leaq 0xde16(%rip), %rsi      # 0x1312f
callq 0x31d0
jmp 0x5320
leaq -0x3e0(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x31c0
jmp 0x5335
leaq -0x3c0(%rbp), %rdi
leaq -0x3e0(%rbp), %rsi
movl $0x8, %edx
callq 0x32b0
jmp 0x534f
leaq -0x3e0(%rbp), %rdi
callq 0x3110
leaq -0x400(%rbp), %rdi
callq 0x3260
leaq -0x420(%rbp), %rdi
callq 0x3260
movl $0x0, -0x424(%rbp)
leaq -0x3c0(%rbp), %rdi
callq 0x32a0
movb %al, -0x5e1(%rbp)
jmp 0x5391
movb -0x5e1(%rbp), %al
testb $0x1, %al
jne 0x53a0
jmp 0x5579
leaq -0x5b0(%rbp), %rdi
callq 0x3120
jmp 0x53ae
jmp 0x53b0
leaq -0x3c0(%rbp), %rdi
leaq -0x420(%rbp), %rsi
callq 0x3060
movq %rax, -0x5f0(%rbp)
jmp 0x53cc
movq -0x5f0(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x3220
movb %al, -0x5f1(%rbp)
jmp 0x53ea
movb -0x5f1(%rbp), %al
testb $0x1, %al
jne 0x53f9
jmp 0x555d
movl $0x0, -0x428(%rbp)
leaq -0x5a0(%rbp), %rdi
leaq -0x420(%rbp), %rsi
callq 0x31a0
jmp 0x5418
jmp 0x541a
leaq -0x5b0(%rbp), %rdi
leaq -0x400(%rbp), %rsi
movl $0x2c, %edx
callq 0x3340
movq %rax, -0x600(%rbp)
jmp 0x543b
movq -0x600(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x3220
movb %al, -0x601(%rbp)
jmp 0x5459
movb -0x601(%rbp), %al
testb $0x1, %al
jne 0x5468
jmp 0x552d
xorl %eax, %eax
movl %eax, %esi
leaq -0x400(%rbp), %rdi
callq 0x7570
movsd %xmm0, -0x610(%rbp)
jmp 0x5482
movsd -0x610(%rbp), %xmm0
movq -0x18(%rbp), %rax
movslq -0x424(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x428(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x428(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x428(%rbp)
jmp 0x541a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1b0(%rbp)
movl %eax, -0x1b4(%rbp)
jmp 0x561b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1b0(%rbp)
movl %eax, -0x1b4(%rbp)
leaq -0x3e0(%rbp), %rdi
callq 0x3110
jmp 0x561b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1b0(%rbp)
movl %eax, -0x1b4(%rbp)
jmp 0x55f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1b0(%rbp)
movl %eax, -0x1b4(%rbp)
leaq -0x5b0(%rbp), %rdi
callq 0x3140
jmp 0x55f7
movq -0x5b0(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x5b0(%rbp,%rax), %rdi
xorl %esi, %esi
callq 0x32f0
jmp 0x5549
movl -0x424(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x424(%rbp)
jmp 0x53b0
leaq -0x3c0(%rbp), %rdi
callq 0x3070
jmp 0x556b
leaq -0x5b0(%rbp), %rdi
callq 0x3140
jmp 0x55ac
movq 0x14a50(%rip), %rdi     # 0x19fd0
leaq 0xdb90(%rip), %rsi      # 0x13117
callq 0x31d0
movq %rax, -0x618(%rbp)
jmp 0x5595
movq -0x618(%rbp), %rdi
movq 0x14a15(%rip), %rsi     # 0x19fb8
callq 0x31f0
jmp 0x55aa
jmp 0x55ac
movq -0x18(%rbp), %rax
movq %rax, -0x620(%rbp)
leaq -0x420(%rbp), %rdi
callq 0x3110
leaq -0x400(%rbp), %rdi
callq 0x3110
leaq -0x3c0(%rbp), %rdi
callq 0x3090
leaq -0x1a8(%rbp), %rdi
callq 0x3140
movq -0x620(%rbp), %rax
addq $0x620, %rsp            # imm = 0x620
popq %rbp
retq
leaq -0x420(%rbp), %rdi
callq 0x3110
leaq -0x400(%rbp), %rdi
callq 0x3110
leaq -0x3c0(%rbp), %rdi
callq 0x3090
leaq -0x1a8(%rbp), %rdi
callq 0x3140
movq -0x1b0(%rbp), %rdi
callq 0x3320
nopw %cs:(%rax,%rax)