// File: /workspace/github_cpp_makefile_star2_O3/Luthaf[P]zeopp/net.cc
// Function: write_molecule(_IO_FILE*, MOLECULE*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, int, bool)
void write_molecule(FILE *rotmol, MOLECULE *rotated, string name, int vertex_ID, int sym_op, bool write_out_sites) {
  bool verbose = false;
  int num_atom = rotated->atoms_xyz.size();
  int num_atom_to_write = num_atom;
  int num_sites = rotated->sites.size();
  if(!write_out_sites) num_atom_to_write-=num_sites;
  fprintf(rotmol, "%d\n%s", num_atom_to_write, name.c_str());
  if(vertex_ID==-1 && sym_op==-1) { //obviously not a symmetry operation ...
    fprintf(rotmol,"\n");
  } else {
    fprintf(rotmol," - molecule rotated to align with basic vertex ID %d and symmetry operator %d\n", vertex_ID, sym_op);
  }
  for(int i=0; i<num_atom; i++) {
    bool write_this_one = true;
    if(!write_out_sites) {
      for(int j=0; j<num_sites && write_this_one; j++) {
        if(i==rotated->sites.at(j)) write_this_one = false;
      }
    }
    if(write_this_one) {
      fprintf(rotmol, "%s %.3f %.3f %.3f\n", rotated->atoms_type.at(i).c_str(), rotated->atoms_xyz.at(i).x, rotated->atoms_xyz.at(i).y, rotated->atoms_xyz.at(i).z);
    } else {
if(verbose) printf("DEBUG: not writing atom ID %d (%s) because it is a site\n", i, rotated->atoms_type.at(i).c_str());
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r8d, %ebp
movl %ecx, %r12d
movq %rsi, %rbx
movq 0x8(%rsi), %r13
subq (%rsi), %r13
movq 0x50(%rsi), %r15
sarq $0x3, %r13
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %r13
subq 0x48(%rsi), %r15
shrq $0x2, %r15
xorl %eax, %eax
movl %r9d, 0x4(%rsp)
testl %r9d, %r9d
movl %r15d, %ecx
cmovnel %eax, %ecx
movq %rdi, %r14
movl %r13d, %eax
subl %ecx, %eax
movq (%rdx), %rcx
leaq 0xb29d1(%rip), %rsi     # 0x153d86
movl %eax, %edx
xorl %eax, %eax
callq 0x45f0
movl %ebp, %eax
andl %r12d, %eax
cmpl $-0x1, %eax
je 0xa13e0
leaq 0xb52c1(%rip), %rsi     # 0x156690
movq %r14, %rdi
movl %r12d, %edx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x45f0
jmp 0xa13ed
movl $0xa, %edi
movq %r14, %rsi
callq 0x4550
testl %r13d, %r13d
jle 0xa14c4
testl %r15d, %r15d
setle %bpl
movslq %r15d, %r12
andl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
orb 0x4(%rsp), %bpl
xorl %r15d, %r15d
testb %bpl, %bpl
jne 0xa1452
movq 0x48(%rbx), %rax
movq 0x50(%rbx), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
movq %rdx, %rcx
negq %rcx
movl $0x1, %esi
leaq (%rcx,%rsi), %rdi
cmpq $0x1, %rdi
je 0xa14d3
movl -0x4(%rax,%rsi,4), %edi
cmpq %r12, %rsi
jge 0xa144d
incq %rsi
cmpq %rdi, %r15
jne 0xa142e
cmpq %rdi, %r15
je 0xa14b8
movq 0x18(%rbx), %rax
movq 0x20(%rbx), %rdx
subq %rax, %rdx
sarq $0x5, %rdx
cmpq %r15, %rdx
jbe 0xa14e4
movq (%rbx), %rcx
movq 0x8(%rbx), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rsi # imm = 0xAAAAAAAAAAAAAAAB
imulq %rsi, %rdx
cmpq %r15, %rdx
jbe 0xa14e4
movq %r15, %rdx
shlq $0x5, %rdx
movq (%rax,%rdx), %rdx
leaq (%r15,%r15,2), %rax
movsd (%rcx,%rax,8), %xmm0
movsd 0x8(%rcx,%rax,8), %xmm1
movsd 0x10(%rcx,%rax,8), %xmm2
movq %r14, %rdi
leaq 0xb0b17(%rip), %rsi     # 0x151fc8
movb $0x3, %al
callq 0x45f0
incq %r15
cmpq %r13, %r15
jne 0xa140f
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xac21b(%rip), %rdi     # 0x14d6f5
movq %rdx, %rsi
xorl %eax, %eax
callq 0x4630
leaq 0xac20a(%rip), %rdi     # 0x14d6f5
movq %r15, %rsi
jmp 0xa14dd