// File: /workspace/github_cpp_makefile_star2_O3/atfrank[P]PCASA/lib/Trajectory.cpp
// Function: Trajectory::writeFrame(std::basic_ofstream<char, std::char_traits<char>>&, Trajectory*)
void Trajectory::writeFrame(std::ofstream &trjout, Trajectory *ftrjin){
  double *dbuffer;
  float *xbuffer;
  float *ybuffer;
  float *zbuffer;
  unsigned int i;
  int length;
  Molecule *mol;

  //crystal
  if (this->getQCrystal() > 0){
    double pbc[ftrjin->pb.size()];
    for(i=0; i< ftrjin->pb.size(); i++){
      pbc[i]=ftrjin->pb.at(i);
    }
    dbuffer=&pbc[0];
    length=sizeof(double)*ftrjin->pb.size();
    writeFortran(trjout, dbuffer, length);
  }

  if (this->getMolecule() == NULL){
    float x[ftrjin->x.size()];
    float y[ftrjin->y.size()];
    float z[ftrjin->z.size()];

    for(i=0; i< ftrjin->x.size(); i++){
      x[i]=ftrjin->x.at(i);
      y[i]=ftrjin->y.at(i);
      z[i]=ftrjin->z.at(i);
    } 

    length=sizeof(float)*ftrjin->x.size();

    xbuffer=&x[0];
    ybuffer=&y[0];
    zbuffer=&z[0];

    writeFortran(trjout, xbuffer, length);
    writeFortran(trjout, ybuffer, length);
    writeFortran(trjout, zbuffer, length);
  
  }
  else{
    mol=this->getMolecule();
    float x[mol->getNAtom()];
    float y[mol->getNAtom()];
    float z[mol->getNAtom()];

    for(i=0; i< mol->getNAtom(); i++){
      x[i]=mol->getAtom(i)->getX();
      y[i]=mol->getAtom(i)->getY();
      z[i]=mol->getAtom(i)->getZ();
    }

    length=sizeof(float)*mol->getNAtom();

    xbuffer=&x[0];
    ybuffer=&y[0];
    zbuffer=&z[0];

    writeFortran(trjout, xbuffer, length);
    writeFortran(trjout, ybuffer, length);
    writeFortran(trjout, zbuffer, length);

  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
cmpl $0x0, 0x9c(%rdi)
jle 0x39433
movq %rsp, %rbx
movq 0xf0(%r14), %rax
subq 0xe8(%r14), %rax
addq $0xf, %rax
andq $-0x10, %rax
movq %rsp, %rdx
subq %rax, %rdx
movq %rdx, %rsp
movq 0xe8(%r14), %rcx
movq 0xf0(%r14), %rsi
movq %rsi, %rax
subq %rcx, %rax
sarq $0x3, %rax
cmpq %rcx, %rsi
je 0x3941c
xorl %esi, %esi
movsd (%rcx,%rsi,8), %xmm0
movsd %xmm0, (%rdx,%rsi,8)
incq %rsi
movl %esi, %edi
cmpq %rdi, %rax
ja 0x39408
shll $0x3, %eax
leaq -0x30(%rbp), %rcx
movl %eax, (%rcx)
movq %r12, %rdi
movq %r15, %rsi
callq 0x39cb0
movq %rbx, %rsp
movq %r12, -0x50(%rbp)
movq 0x28(%r12), %rbx
testq %rbx, %rbx
je 0x3956f
movq %r15, -0x48(%rbp)
movq %rbx, %rdi
callq 0x2557c
movq %rsp, -0x40(%rbp)
movl %eax, %eax
movq %rsp, %r15
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
subq %rax, %r15
movq %r15, %rsp
movq %rbx, %rdi
callq 0x2557c
movl %eax, %eax
movq %rsp, %r13
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
subq %rax, %r13
movq %r13, %rsp
movq %rbx, %rdi
callq 0x2557c
movl %eax, %eax
movq %rsp, %r12
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
subq %rax, %r12
movq %r12, %rsp
movl $0x0, -0x2c(%rbp)
movq %rbx, %rdi
callq 0x2557c
testl %eax, %eax
je 0x3955a
movq %rbx, %rdi
leaq -0x2c(%rbp), %r14
movq %r14, %rsi
callq 0x24578
movq %rax, %rdi
callq 0x14bd6
xorps %xmm0, %xmm0
cvtsd2ss (%rax), %xmm0
movl -0x2c(%rbp), %eax
movss %xmm0, (%r15,%rax,4)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x24578
movq %rax, %rdi
callq 0x14bde
xorps %xmm0, %xmm0
cvtsd2ss (%rax), %xmm0
movl -0x2c(%rbp), %eax
movss %xmm0, (%r13,%rax,4)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x24578
movq %rax, %rdi
callq 0x14be6
xorps %xmm0, %xmm0
cvtsd2ss (%rax), %xmm0
movl -0x2c(%rbp), %eax
movss %xmm0, (%r12,%rax,4)
movq %r12, %r14
movq %r13, %r12
movq %r15, %r13
leal 0x1(%rax), %r15d
movl %r15d, -0x2c(%rbp)
movq %rbx, %rdi
callq 0x2557c
cmpl %eax, %r15d
movq %r13, %r15
movq %r12, %r13
movq %r14, %r12
jb 0x394c1
movq %r15, -0x38(%rbp)
movq %rbx, %rdi
callq 0x2557c
movq -0x48(%rbp), %r15
jmp 0x3964d
movq %r15, %rbx
movq %rsp, %r11
movq 0x138(%r14), %rax
subq 0x130(%r14), %rax
addq $0xf, %rax
andq $-0x10, %rax
movq %rsp, %r15
subq %rax, %r15
movq %r15, %rsp
movq 0x148(%r14), %rdi
movq 0x150(%r14), %rdx
subq %rdi, %rdx
movq %rsp, %r13
leaq 0xf(%rdx), %rax
andq $-0x10, %rax
subq %rax, %r13
movq %r13, %rsp
movq 0x160(%r14), %r8
movq 0x168(%r14), %rcx
subq %r8, %rcx
movq %rsp, %r12
leaq 0xf(%rcx), %rax
andq $-0x10, %rax
subq %rax, %r12
movq %r12, %rsp
movq 0x130(%r14), %r9
movq 0x138(%r14), %rsi
movq %rsi, %rax
subq %r9, %rax
sarq $0x2, %rax
cmpq %r9, %rsi
je 0x39642
sarq $0x2, %rdx
sarq $0x2, %rcx
movl $0x1, %r10d
xorl %esi, %esi
movss (%r9,%rsi,4), %xmm0
movss %xmm0, (%r15,%rsi,4)
cmpq %rsi, %rdx
jbe 0x396ad
movss (%rdi,%rsi,4), %xmm0
movss %xmm0, (%r13,%rsi,4)
cmpq %rsi, %rcx
jbe 0x396a1
movss (%r8,%rsi,4), %xmm0
movss %xmm0, (%r12,%rsi,4)
movl %r10d, %esi
incl %r10d
cmpq %rsi, %rax
ja 0x39605
movq %r15, -0x38(%rbp)
movq %r11, -0x40(%rbp)
movq %rbx, %r15
shll $0x2, %eax
leaq -0x30(%rbp), %rbx
movl %eax, (%rbx)
movq -0x50(%rbp), %r14
movq %r14, %rdi
movq %r15, %rsi
movq -0x38(%rbp), %rdx
movq %rbx, %rcx
callq 0x39cf2
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x39cf2
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x39cf2
movq -0x40(%rbp), %rsp
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1c81(%rip), %rdi      # 0x3b329
movq %rcx, %rdx
jmp 0x396b4
leaq 0x1c75(%rip), %rdi      # 0x3b329
xorl %eax, %eax
callq 0x4440
nop