// File: 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
movq %rsp, %rbp
subq $0x5c0, %rsp            # imm = 0x5C0
movq %rsi, -0x4e0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x4e8(%rbp)
leaq -0x220(%rbp), %rdi
callq 0x5660
movq -0x4e0(%rbp), %rdi
callq 0x5200
movq %rax, -0x4d8(%rbp)
movl $0x8, %edi
movl $0x10, %esi
callq 0x47640
movl %eax, -0x4d0(%rbp)
jmp 0xf234b
movl -0x4d0(%rbp), %edx
movq -0x4d8(%rbp), %rsi
leaq -0x220(%rbp), %rdi
callq 0x54b0
jmp 0xf2366
leaq -0x220(%rbp), %rdi
callq 0x58b0
movb %al, -0x4e9(%rbp)
jmp 0xf237a
movb -0x4e9(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0xf23f3
movq 0x180c5f(%rip), %rdi    # 0x272ff0
leaq 0x10a27d(%rip), %rsi    # 0x1fc615
callq 0x5540
movq %rax, -0x4f8(%rbp)
jmp 0xf23a6
movq -0x4e0(%rbp), %rsi
movq -0x4f8(%rbp), %rdi
callq 0x5480
movq %rax, -0x500(%rbp)
jmp 0xf23c2
movq -0x500(%rbp), %rdi
leaq 0x10a261(%rip), %rsi    # 0x1fc631
callq 0x5540
jmp 0xf23d7
jmp 0xf2b34
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0xf2b49
movl $0x0, -0x230(%rbp)
movq 0x180bbc(%rip), %rdi    # 0x272fc0
leaq 0x10a23a(%rip), %rsi    # 0x1fc645
callq 0x5540
movq %rax, -0x508(%rbp)
jmp 0xf2419
movq -0x4e0(%rbp), %rsi
movq -0x508(%rbp), %rdi
callq 0x5480
movq %rax, -0x510(%rbp)
jmp 0xf2435
movq -0x510(%rbp), %rdi
movq 0x180b55(%rip), %rsi    # 0x272f98
callq 0x55b0
jmp 0xf244a
jmp 0xf244c
movq -0x220(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x220(%rbp,%rax), %rdi
callq 0x5960
movb %al, -0x511(%rbp)
jmp 0xf246c
movb -0x511(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0xf247d
jmp 0xf2b02
leaq -0x250(%rbp), %rdi
movq %rdi, -0x520(%rbp)
callq 0x5720
movq -0x520(%rbp), %rsi
leaq -0x220(%rbp), %rdi
callq 0x56a0
jmp 0xf24a5
movq -0x220(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x220(%rbp,%rax), %rdi
callq 0x5960
movb %al, -0x521(%rbp)
jmp 0xf24c5
movb -0x521(%rbp), %al
testb $0x1, %al
jne 0xf24d1
jmp 0xf2506
movl -0x230(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x230(%rbp)
movl $0x3, -0x254(%rbp)
jmp 0xf2ac9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0xf2af4
movl -0x230(%rbp), %eax
incl %eax
movl %eax, -0x230(%rbp)
leaq -0x468(%rbp), %rdi
callq 0x5660
jmp 0xf2522
leaq -0x250(%rbp), %rdi
callq 0x5200
movq %rax, -0x530(%rbp)
movl $0x8, %edi
movl $0x10, %esi
callq 0x47640
movl %eax, -0x528(%rbp)
jmp 0xf254c
movl -0x528(%rbp), %edx
movq -0x530(%rbp), %rsi
leaq -0x468(%rbp), %rdi
callq 0x54b0
jmp 0xf2567
leaq -0x468(%rbp), %rdi
callq 0x58b0
movb %al, -0x531(%rbp)
jmp 0xf257b
movb -0x531(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0xf25f4
movq 0x180a5e(%rip), %rdi    # 0x272ff0
leaq 0x100de7(%rip), %rsi    # 0x1f3380
callq 0x5540
movq %rax, -0x540(%rbp)
jmp 0xf25a7
movq -0x540(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0x5480
movq %rax, -0x548(%rbp)
jmp 0xf25c3
movq -0x548(%rbp), %rdi
movq 0x1809c7(%rip), %rsi    # 0x272f98
callq 0x55b0
jmp 0xf25d8
jmp 0xf29af
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0xf2ae8
movl $0x0, -0x46c(%rbp)
leaq -0x4b0(%rbp), %rdi
callq 0x5720
movq -0x468(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x468(%rbp,%rax), %rdi
callq 0x5960
movb %al, -0x549(%rbp)
jmp 0xf262a
movb -0x549(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0xf263b
jmp 0xf28f5
leaq -0x468(%rbp), %rdi
leaq -0x478(%rbp), %rsi
callq 0x5420
jmp 0xf2650
movq -0x468(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x468(%rbp,%rax), %rdi
callq 0x5960
movb %al, -0x54a(%rbp)
jmp 0xf2670
movb -0x54a(%rbp), %al
testb $0x1, %al
jne 0xf267c
jmp 0xf26b3
movl -0x46c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x46c(%rbp)
jmp 0xf28f5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
leaq -0x4b0(%rbp), %rdi
callq 0x5300
jmp 0xf2ae8
leaq -0x468(%rbp), %rdi
leaq -0x480(%rbp), %rsi
callq 0x5420
movq %rax, -0x558(%rbp)
jmp 0xf26cf
movq -0x558(%rbp), %rdi
leaq -0x488(%rbp), %rsi
callq 0x5420
movq %rax, -0x560(%rbp)
jmp 0xf26eb
movq -0x560(%rbp), %rdi
leaq -0x48c(%rbp), %rsi
callq 0x52f0
movq %rax, -0x568(%rbp)
jmp 0xf2707
movq -0x568(%rbp), %rdi
leaq -0x4b0(%rbp), %rsi
callq 0x56a0
movq %rax, -0x570(%rbp)
jmp 0xf2723
movq -0x570(%rbp), %rdi
leaq -0x4b4(%rbp), %rsi
callq 0x52f0
jmp 0xf2738
movl -0x46c(%rbp), %eax
incl %eax
movl %eax, -0x46c(%rbp)
movsd -0x478(%rbp), %xmm0
callq 0xe9290
movsd %xmm0, -0x578(%rbp)
jmp 0xf275d
movsd -0x578(%rbp), %xmm0
movsd %xmm0, -0x478(%rbp)
movsd -0x480(%rbp), %xmm0
callq 0xe9290
movsd %xmm0, -0x580(%rbp)
jmp 0xf2784
movsd -0x580(%rbp), %xmm0
movsd %xmm0, -0x480(%rbp)
movsd -0x488(%rbp), %xmm0
callq 0xe9290
movsd %xmm0, -0x588(%rbp)
jmp 0xf27ab
movq -0x4e8(%rbp), %rax
movsd -0x588(%rbp), %xmm0
movsd %xmm0, -0x488(%rbp)
movsd -0x478(%rbp), %xmm0
cvtsi2sdl 0x78(%rax), %xmm1
mulsd %xmm1, %xmm0
callq 0x5870
movq -0x4e8(%rbp), %rax
cvttsd2si %xmm0, %ecx
movl %ecx, -0x4b8(%rbp)
movsd -0x480(%rbp), %xmm0
cvtsi2sdl 0x7c(%rax), %xmm1
mulsd %xmm1, %xmm0
callq 0x5870
movq -0x4e8(%rbp), %rax
cvttsd2si %xmm0, %ecx
movl %ecx, -0x4bc(%rbp)
movsd -0x488(%rbp), %xmm0
cvtsi2sdl 0x80(%rax), %xmm1
mulsd %xmm1, %xmm0
callq 0x5870
movq -0x4e8(%rbp), %rax
cvttsd2si %xmm0, %ecx
movl %ecx, -0x4c0(%rbp)
movq 0x88(%rax), %rcx
movslq -0x4b8(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x4bc(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x4c0(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movsd %xmm0, -0x590(%rbp)
movq 0x88(%rax), %rax
movslq -0x4b8(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x4bc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x4c0(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
callq 0x5870
movaps %xmm0, %xmm1
movsd -0x590(%rbp), %xmm0
subsd %xmm1, %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xf28f0
jp 0xf28f0
movq -0x4e8(%rbp), %rax
movq 0x88(%rax), %rax
movslq -0x4b8(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x4bc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x4c0(%rbp), %rcx
movsd 0xff792(%rip), %xmm0    # 0x1f2078
addsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0xf260a
movq 0x1806c4(%rip), %rdi    # 0x272fc0
leaq 0x109d5a(%rip), %rsi    # 0x1fc65d
callq 0x5540
movq %rax, -0x598(%rbp)
jmp 0xf2911
movq -0x598(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0x5480
movq %rax, -0x5a0(%rbp)
jmp 0xf292d
movq -0x5a0(%rbp), %rdi
leaq 0x109292(%rip), %rsi    # 0x1fbbcd
callq 0x5540
movq %rax, -0x5a8(%rbp)
jmp 0xf2949
movq -0x5a8(%rbp), %rdi
movl -0x46c(%rbp), %esi
callq 0x58d0
movq %rax, -0x5b0(%rbp)
jmp 0xf2964
movq -0x5b0(%rbp), %rdi
leaq 0x109c96(%rip), %rsi    # 0x1fc608
callq 0x5540
movq %rax, -0x5b8(%rbp)
jmp 0xf2980
movq -0x5b8(%rbp), %rdi
leaq 0x106c97(%rip), %rsi    # 0x1f9625
callq 0x5540
jmp 0xf2995
leaq -0x468(%rbp), %rdi
callq 0x50a0
jmp 0xf29a3
leaq -0x4b0(%rbp), %rdi
callq 0x5300
movl $0x0, -0x4c4(%rbp)
movq -0x4e8(%rbp), %rcx
movl -0x4c4(%rbp), %eax
cmpl 0x78(%rcx), %eax
jge 0xf2ab3
movl $0x0, -0x4c8(%rbp)
movq -0x4e8(%rbp), %rcx
movl -0x4c8(%rbp), %eax
cmpl 0x7c(%rcx), %eax
jge 0xf2a9d
movl $0x0, -0x4cc(%rbp)
movq -0x4e8(%rbp), %rcx
movl -0x4cc(%rbp), %eax
cmpl 0x80(%rcx), %eax
jge 0xf2a87
movq -0x4e8(%rbp), %rax
movq 0x88(%rax), %rax
movslq -0x4c4(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x4c8(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x4cc(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
callq 0x50e0
movq -0x4e8(%rbp), %rax
movq 0x88(%rax), %rax
movslq -0x4c4(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x4c8(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x4cc(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x4cc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4cc(%rbp)
jmp 0xf29f9
jmp 0xf2a89
movl -0x4c8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c8(%rbp)
jmp 0xf29d9
jmp 0xf2a9f
movl -0x4c4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c4(%rbp)
jmp 0xf29b9
leaq -0x468(%rbp), %rdi
callq 0x5150
movl $0x0, -0x254(%rbp)
leaq -0x250(%rbp), %rdi
callq 0x5300
movl -0x254(%rbp), %eax
testl %eax, %eax
je 0xf2ae3
jmp 0xf2ae1
jmp 0xf2b02
jmp 0xf244c
leaq -0x468(%rbp), %rdi
callq 0x5150
leaq -0x250(%rbp), %rdi
callq 0x5300
jmp 0xf2b49
movl -0x230(%rbp), %esi
movq 0x1804b1(%rip), %rdi    # 0x272fc0
callq 0x58d0
movq %rax, -0x5c0(%rbp)
jmp 0xf2b1d
movq -0x5c0(%rbp), %rdi
leaq 0x109b38(%rip), %rsi    # 0x1fc663
callq 0x5540
jmp 0xf2b32
jmp 0xf2b34
leaq -0x220(%rbp), %rdi
callq 0x5150
addq $0x5c0, %rsp            # imm = 0x5C0
popq %rbp
retq
leaq -0x220(%rbp), %rdi
callq 0x5150
movq -0x228(%rbp), %rdi
callq 0x58f0
nopw %cs:(%rax,%rax)