// File: /workspace/github_cpp_makefile_star2_O1/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, 0x8(%rsp)
leaq 0x298(%rsp), %r15
movq %r15, %rdi
callq 0x4520
movq (%r14), %rsi
movq %r15, %rdi
movl $0x18, %edx
callq 0x43d0
leaq 0x318(%rsp), %rdi
callq 0x4120
testb %al, %al
je 0x8aa62
movq 0x10c9d1(%rip), %rdi    # 0x196fc0
leaq 0xcd256(%rip), %rsi     # 0x15784c
movl $0x17, %edx
callq 0x44e0
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq 0x10c9b2(%rip), %rdi    # 0x196fc0
callq 0x44e0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4420
movsbl %al, %esi
movq %r14, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x42c0
leaq 0x38(%rsp), %r15
xorl %ebx, %ebx
leaq 0x88(%rsp), %r14
movq 0x298(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0x2b8(%rsp,%rax)
jne 0x8aa3e
movq %r15, 0x28(%rsp)
movq $0x0, 0x30(%rsp)
movb $0x0, 0x38(%rsp)
leaq 0x298(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x4560
movq 0x298(%rsp), %rax
movq -0x18(%rax), %rax
movl 0x2b8(%rsp,%rax), %eax
movl %eax, 0x24(%rsp)
testb $0x2, %al
jne 0x8a926
movq %rbx, 0x70(%rsp)
movq %r14, %rdi
callq 0x4520
movq 0x28(%rsp), %rsi
movq %r14, %rdi
movl $0x18, %edx
callq 0x43d0
leaq 0x108(%rsp), %rdi
callq 0x4120
testb %al, %al
je 0x8a92d
leaq 0x60(%rsp), %rax
movq %rax, 0x50(%rsp)
movq $0x0, 0x58(%rsp)
movb $0x0, 0x60(%rsp)
movq 0x88(%rsp), %rax
movq -0x18(%rax), %rax
xorl %r13d, %r13d
testb $0x2, 0xa8(%rsp,%rax)
jne 0x8a885
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movq %r14, %rdi
leaq 0x18(%rsp), %rsi
callq 0x42a0
movq 0x88(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0xa8(%rsp,%rax)
jne 0x8a885
movq %r14, %rdi
leaq 0x10(%rsp), %rsi
callq 0x42a0
movq %rax, %rdi
leaq 0x48(%rsp), %rsi
callq 0x42a0
movq %rax, %rdi
leaq 0x84(%rsp), %rsi
callq 0x4270
movq %rax, %rdi
leaq 0x50(%rsp), %rsi
callq 0x4560
movq %rax, %rdi
leaq 0x80(%rsp), %rsi
callq 0x4270
movsd 0x18(%rsp), %xmm0
callq 0x84e6b
movsd %xmm0, 0x18(%rsp)
movsd 0x10(%rsp), %xmm0
callq 0x84e6b
movsd %xmm0, 0x10(%rsp)
movsd 0x48(%rsp), %xmm0
callq 0x84e6b
movsd %xmm0, 0x48(%rsp)
movq 0x8(%rsp), %r14
movsd %xmm0, (%rsp)
xorps %xmm0, %xmm0
cvtsi2sdl 0x78(%r14), %xmm0
mulsd 0x18(%rsp), %xmm0
callq 0x4700
cvttsd2si %xmm0, %ebx
xorps %xmm0, %xmm0
cvtsi2sdl 0x7c(%r14), %xmm0
mulsd 0x10(%rsp), %xmm0
callq 0x4700
cvttsd2si %xmm0, %ebp
xorps %xmm0, %xmm0
cvtsi2sdl 0x80(%r14), %xmm0
mulsd (%rsp), %xmm0
callq 0x4700
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, (%rsp)
callq 0x4700
movsd (%rsp), %xmm2
movapd %xmm2, %xmm1
subsd %xmm0, %xmm1
ucomisd 0xc8a75(%rip), %xmm1    # 0x1532c0
jne 0x8a85d
jp 0x8a85d
addsd 0xc47e1(%rip), %xmm2    # 0x14f038
movsd %xmm2, (%rbx,%r14,8)
movq 0x88(%rsp), %rax
movq -0x18(%rax), %rax
incl %r13d
testb $0x2, 0xa8(%rsp,%rax)
leaq 0x88(%rsp), %r14
je 0x8a719
incl %r13d
movl $0x5, %edx
movq 0x10c72f(%rip), %rdi    # 0x196fc0
leaq 0xccfcc(%rip), %rsi     # 0x157864
callq 0x44e0
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq 0x10c712(%rip), %rdi    # 0x196fc0
callq 0x44e0
movq %rax, %r12
movl $0x3, %edx
movq %rax, %rdi
leaq 0xcc5a0(%rip), %rsi     # 0x156e65
callq 0x44e0
movq %r12, %rdi
movl %r13d, %esi
callq 0x4750
movq %rax, %r13
movl $0xc, %edx
movq %rax, %rdi
leaq 0xccf28(%rip), %rsi     # 0x15780f
callq 0x44e0
movl $0x1, %edx
movq %r13, %rdi
leaq 0xcac33(%rip), %rsi     # 0x15552e
callq 0x44e0
movq %r14, %rdi
callq 0x4090
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x8a985
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x4470
jmp 0x8a985
decl %ebx
jmp 0x8aa1c
movl $0x1b, %edx
movq 0x10c6b7(%rip), %rdi    # 0x196ff0
leaq 0xc57f7(%rip), %rsi     # 0x150137
callq 0x44e0
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq 0x10c69a(%rip), %rdi    # 0x196ff0
callq 0x44e0
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x4420
movsbl %al, %esi
movq %r13, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x42c0
movq 0x8(%rsp), %rax
movslq 0x78(%rax), %rax
movq %rax, 0x78(%rsp)
testq %rax, %rax
jle 0x8aa00
movq 0x8(%rsp), %rax
movl 0x7c(%rax), %r13d
movl 0x80(%rax), %r14d
xorl %ebp, %ebp
testl %r13d, %r13d
jle 0x8a9f6
movq 0x8(%rsp), %rax
movq 0x88(%rax), %rax
movq %rax, (%rsp)
xorl %ebx, %ebx
testl %r14d, %r14d
jle 0x8a9ee
movq (%rsp), %rax
movq (%rax,%rbp,8), %rax
movq (%rax,%rbx,8), %r12
xorl %r15d, %r15d
movsd (%r12,%r15,8), %xmm0
callq 0x40d0
movsd %xmm0, (%r12,%r15,8)
incq %r15
cmpq %r15, %r14
jne 0x8a9d5
incq %rbx
cmpq %r13, %rbx
jne 0x8a9c1
incq %rbp
cmpq 0x78(%rsp), %rbp
jne 0x8a9aa
movq 0x70(%rsp), %rbx
incl %ebx
leaq 0x88(%rsp), %r14
movq %r14, %rdi
callq 0x4110
leaq 0x38(%rsp), %r15
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x8aa33
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x4470
testb $0x2, 0x24(%rsp)
je 0x8a64c
movq 0x10c57b(%rip), %rdi    # 0x196fc0
movl %ebx, %esi
callq 0x4750
leaq 0xcce17(%rip), %rsi     # 0x15786a
movl $0x10, %edx
movq %rax, %rdi
callq 0x44e0
jmp 0x8aaa1
movq 0x10c587(%rip), %rdi    # 0x196ff0
leaq 0xccdac(%rip), %rsi     # 0x15781c
movl $0x1b, %edx
callq 0x44e0
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq 0x10c568(%rip), %rdi    # 0x196ff0
callq 0x44e0
leaq 0xccda4(%rip), %rsi     # 0x157838
movl $0x13, %edx
movq %rax, %rdi
callq 0x44e0
leaq 0x298(%rsp), %rdi
callq 0x4110
addq $0x4a8, %rsp            # imm = 0x4A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x8aac2
movq %rax, %rbx
jmp 0x8ab18
jmp 0x8aac9
movq %rax, %rbx
jmp 0x8ab01
jmp 0x8aad5
movq %rax, %rbx
jmp 0x8aaf4
movq %rax, %rbx
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x8aaf4
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x4470
leaq 0x88(%rsp), %rdi
callq 0x4110
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x8ab18
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x4470
leaq 0x298(%rsp), %rdi
callq 0x4110
movq %rbx, %rdi
callq 0x4780
nop