// File: /workspace/github_cpp_makefile_star2_O2/Luthaf[P]zeopp/grid.cc
// Function: GaussianCube::loadHistogramDataPerFrame(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void GaussianCube::loadHistogramDataPerFrame(std::string listfilename){

 fstream flist;

 flist.open(listfilename.c_str());
 if(flist.is_open()==false){
   cerr << "Error: A file with frames (" << listfilename << ") failed to open. \n" ;
   }else{
   // file with a list of frames is open. proceed.

   int nfiles=0;
   cout << "Loading filenames from " << listfilename << endl;
   while(!flist.eof())
    {
    string inputfilename;

    flist >> inputfilename;
    if(flist.eof()){
      nfiles--;
      break;
      };

    nfiles++;
 
    fstream input;
    input.open(inputfilename.c_str());
    if(input.is_open()==false){
      cerr << "Error: CSSR failed to open " << inputfilename << endl;
    }else{

    // reading in datapoints (expect points in "Liverpool format" (fractional coordinates)

    int n = 0; // number of points 
    double a,b,c;
    int code;
    string ptStatus; 
    int pocketID;
    while(!input.eof())
       {
       input >> a;

       if(input.eof())
         {
         n--;
         break;
         };

       input >> b >> c >> code >> ptStatus >> pocketID;

       n++;

       // analysis of the read-in data
       a = trans_to_origuc(a);
       b = trans_to_origuc(b);
       c = trans_to_origuc(c);    

       // projecting into a grid

       int ca, cb, cc;

       ca = floor(a * na);
       cb = floor(b * nb);
       cc = floor(c * nc);

//       cube[ca][cb][cc] += 1.0; // increase count at grid point ca, cb, cc

       if(cube[ca][cb][cc]-floor(cube[ca][cb][cc]) == 0.0) cube[ca][cb][cc] += 0.5; // adding 0.5 serves as a flag

       };

    cout << "File " << inputfilename << ":  " << n << " lines read." << "\n";

    input.close();
    };

   for(int i=0; i<na; i++)
      for(int j=0; j< nb; j++)
        for(int k=0; k<nc; k++)
           cube[i][j][k] = ceil(cube[i][j][k]);

   }; // ends while loop over a file list

  cout << nfiles << " frames loaded.\n";

  };

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4a8, %rsp            # imm = 0x4A8
movq %rsi, %r14
movq %rdi, 0x10(%rsp)
leaq 0x298(%rsp), %r15
movq %r15, %rdi
callq 0x4540
movq (%r14), %rsi
pushq $0x18
popq %rdx
movq %r15, %rdi
callq 0x4410
leaq 0x318(%rsp), %rdi
callq 0x4130
testb %al, %al
je 0x67dbc
movq 0xe85bf(%rip), %rdi     # 0x14ffc0
leaq 0x9cee4(%rip), %rsi     # 0x1048ec
callq 0x4480
movq %rax, %rdi
movq %r14, %rsi
callq 0x43f0
movq %rax, %rdi
callq 0x4230
leaq 0x88(%rsp), %rbx
leaq 0x20(%rsp), %r12
leaq 0x18(%rsp), %r13
movl $0x0, 0x4(%rsp)
movq 0x298(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0x2b8(%rsp,%rax)
jne 0x67d9b
leaq 0x48(%rsp), %rax
movq %rax, 0x38(%rsp)
andq $0x0, 0x40(%rsp)
movb $0x0, 0x48(%rsp)
leaq 0x298(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x4580
movq 0x298(%rsp), %rax
movq -0x18(%rax), %rax
movl 0x2b8(%rsp,%rax), %eax
movl %eax, 0x2c(%rsp)
testb $0x2, %al
jne 0x67c3e
movq %rbx, %rdi
callq 0x4540
movq 0x38(%rsp), %rsi
movq %rbx, %rdi
pushq $0x18
popq %rdx
callq 0x4410
leaq 0x108(%rsp), %rdi
callq 0x4130
testb %al, %al
je 0x67c47
leaq 0x78(%rsp), %rax
movq %rax, 0x68(%rsp)
andq $0x0, 0x70(%rsp)
movb $0x0, 0x78(%rsp)
xorl %r15d, %r15d
movq 0x88(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0xa8(%rsp,%rax)
jne 0x67c74
movq %rbx, %rdi
movq %r12, %rsi
callq 0x42d0
movq 0x88(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0xa8(%rsp,%rax)
jne 0x67c71
movq %rbx, %rdi
movq %r13, %rsi
callq 0x42d0
movq %rax, %rdi
leaq 0x30(%rsp), %rsi
callq 0x42d0
movq %rax, %rdi
leaq 0x64(%rsp), %rsi
callq 0x42a0
movq %rax, %rdi
leaq 0x68(%rsp), %rsi
callq 0x4580
movq %rax, %rdi
leaq 0x60(%rsp), %rsi
callq 0x42a0
movsd 0x20(%rsp), %xmm0
callq 0x6377f
movsd %xmm0, 0x20(%rsp)
movsd 0x18(%rsp), %xmm0
callq 0x6377f
movsd %xmm0, 0x18(%rsp)
movsd 0x30(%rsp), %xmm0
callq 0x6377f
movsd %xmm0, 0x30(%rsp)
movq 0x10(%rsp), %r14
movsd %xmm0, 0x8(%rsp)
cvtsi2sdl 0x78(%r14), %xmm0
mulsd 0x20(%rsp), %xmm0
callq 0x4720
cvttsd2si %xmm0, %ebx
cvtsi2sdl 0x7c(%r14), %xmm0
mulsd 0x18(%rsp), %xmm0
callq 0x4720
cvttsd2si %xmm0, %ebp
cvtsi2sdl 0x80(%r14), %xmm0
mulsd 0x8(%rsp), %xmm0
callq 0x4720
cvttsd2si %xmm0, %eax
movq 0x88(%r14), %rcx
movslq %ebx, %rdx
movq (%rcx,%rdx,8), %rcx
movslq %ebp, %rdx
movq (%rcx,%rdx,8), %rbx
movslq %eax, %r14
movsd (%rbx,%r14,8), %xmm0
movsd %xmm0, 0x8(%rsp)
callq 0x4720
movsd 0x8(%rsp), %xmm2
movapd %xmm2, %xmm1
subsd %xmm0, %xmm1
ucomisd 0x986c4(%rip), %xmm1    # 0x1002e0
jne 0x67c2e
jp 0x67c2e
addsd 0x94410(%rip), %xmm2    # 0xfc038
movsd %xmm2, (%rbx,%r14,8)
incl %r15d
leaq 0x88(%rsp), %rbx
jmp 0x67adf
decl 0x4(%rsp)
jmp 0x67d86
movq 0xe83a2(%rip), %rdi     # 0x14fff0
leaq 0x95552(%rip), %rsi     # 0xfd1a7
callq 0x4480
movq %rax, %rdi
leaq 0x38(%rsp), %rsi
callq 0x43f0
movq %rax, %rdi
callq 0x4230
jmp 0x67cde
decl %r15d
movq 0xe8345(%rip), %rdi     # 0x14ffc0
leaq 0x9cc82(%rip), %rsi     # 0x104904
callq 0x4480
movq %rax, %rdi
leaq 0x38(%rsp), %rsi
callq 0x43f0
movq %rax, %rdi
leaq 0x9c237(%rip), %rsi     # 0x103ed5
callq 0x4480
movq %rax, %rdi
movl %r15d, %esi
callq 0x4760
movq %rax, %rdi
leaq 0x9cbf7(%rip), %rsi     # 0x1048af
callq 0x4480
movq %rax, %rdi
leaq 0x9a8b7(%rip), %rsi     # 0x10257e
callq 0x4480
movq %rbx, %rdi
callq 0x4080
leaq 0x68(%rsp), %rdi
callq 0x4210
incl 0x4(%rsp)
movq 0x10(%rsp), %rax
movl 0x78(%rax), %ecx
movl 0x7c(%rax), %edx
testl %edx, %edx
movl $0x0, %eax
cmovlel %eax, %edx
movq %rdx, 0x8(%rsp)
testl %ecx, %ecx
cmovlel %eax, %ecx
movq %rcx, 0x58(%rsp)
xorl %ebp, %ebp
cmpq 0x58(%rsp), %rbp
je 0x67d6c
movq 0x10(%rsp), %rax
movl 0x80(%rax), %r13d
testl %r13d, %r13d
movl $0x0, %eax
cmovlel %eax, %r13d
xorl %r14d, %r14d
cmpq 0x8(%rsp), %r14
je 0x67d67
movq 0x10(%rsp), %rax
movq 0x88(%rax), %r15
xorl %ebx, %ebx
cmpq %rbx, %r13
je 0x67d62
movq (%r15,%rbp,8), %rax
movq (%rax,%r14,8), %r12
movsd (%r12,%rbx,8), %xmm0
callq 0x40c0
movsd %xmm0, (%r12,%rbx,8)
incq %rbx
jmp 0x67d3f
incq %r14
jmp 0x67d2a
incq %rbp
jmp 0x67d08
leaq 0x88(%rsp), %rbx
movq %rbx, %rdi
callq 0x4120
leaq 0x20(%rsp), %r12
leaq 0x18(%rsp), %r13
leaq 0x38(%rsp), %rdi
callq 0x4210
testb $0x2, 0x2c(%rsp)
je 0x67a3a
movq 0xe821e(%rip), %rdi     # 0x14ffc0
movl 0x4(%rsp), %esi
callq 0x4760
leaq 0x9cb58(%rip), %rsi     # 0x10490a
movq %rax, %rdi
callq 0x4480
jmp 0x67de9
movq 0xe822d(%rip), %rdi     # 0x14fff0
leaq 0x9caf2(%rip), %rsi     # 0x1048bc
callq 0x4480
movq %rax, %rdi
movq %r14, %rsi
callq 0x43f0
leaq 0x9caf7(%rip), %rsi     # 0x1048d8
movq %rax, %rdi
callq 0x4480
leaq 0x298(%rsp), %rdi
callq 0x4120
addq $0x4a8, %rsp            # imm = 0x4A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x67e0a
movq %rax, %rbx
jmp 0x67e41
jmp 0x67e11
movq %rax, %rbx
jmp 0x67e37
movq %rax, %rbx
jmp 0x67e2a
jmp 0x67e1d
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x4210
leaq 0x88(%rsp), %rdi
callq 0x4120
leaq 0x38(%rsp), %rdi
callq 0x4210
leaq 0x298(%rsp), %rdi
callq 0x4120
movq %rbx, %rdi
callq 0x4780