// File: 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
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdx, -0x48(%rbp)
movb %r9b, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
andb $0x1, %al
movb %al, -0x21(%rbp)
movb $0x0, -0x22(%rbp)
movq -0x10(%rbp), %rdi
callq 0xae590
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x48, %rdi
callq 0x10090
movl %eax, -0x30(%rbp)
testb $0x1, -0x21(%rbp)
jne 0x114fd1
movl -0x30(%rbp), %ecx
movl -0x2c(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x2c(%rbp)
movq -0x48(%rbp), %rdi
movq -0x8(%rbp), %rax
movq %rax, -0x58(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x4c(%rbp)
callq 0x5200
movq -0x58(%rbp), %rdi
movl -0x4c(%rbp), %edx
movq %rax, %rcx
leaq 0xe5d4c(%rip), %rsi     # 0x1fad45
movb $0x0, %al
callq 0x5750
cmpl $-0x1, -0x1c(%rbp)
jne 0x115020
cmpl $-0x1, -0x20(%rbp)
jne 0x115020
movq -0x8(%rbp), %rdi
leaq 0xe460e(%rip), %rsi     # 0x1f9625
movb $0x0, %al
callq 0x5750
jmp 0x115038
movq -0x8(%rbp), %rdi
movl -0x1c(%rbp), %edx
movl -0x20(%rbp), %ecx
leaq 0xe8a19(%rip), %rsi     # 0x1fda4a
movb $0x0, %al
callq 0x5750
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x11518d
movb $0x1, -0x35(%rbp)
testb $0x1, -0x21(%rbp)
jne 0x1150ac
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %ecx
xorl %eax, %eax
cmpl -0x30(%rbp), %ecx
movb %al, -0x59(%rbp)
jge 0x11506f
movb -0x35(%rbp), %al
movb %al, -0x59(%rbp)
movb -0x59(%rbp), %al
testb $0x1, %al
jne 0x115078
jmp 0x1150aa
movl -0x34(%rbp), %eax
movl %eax, -0x60(%rbp)
movq -0x10(%rbp), %rdi
addq $0x48, %rdi
movslq -0x3c(%rbp), %rsi
callq 0x101d0
movq %rax, %rcx
movl -0x60(%rbp), %eax
cmpl (%rcx), %eax
jne 0x11509d
movb $0x0, -0x35(%rbp)
jmp 0x11509f
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x11505c
jmp 0x1150ac
testb $0x1, -0x35(%rbp)
je 0x11513c
movq -0x8(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movslq -0x34(%rbp), %rsi
callq 0xaf450
movq %rax, %rdi
callq 0x5200
movq %rax, -0x78(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0xae5c0
movsd (%rax), %xmm0
movsd %xmm0, -0x70(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0xae5c0
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x68(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0xae5c0
movq -0x80(%rbp), %rdi
movq -0x78(%rbp), %rdx
movsd -0x70(%rbp), %xmm0
movsd -0x68(%rbp), %xmm1
movsd 0x10(%rax), %xmm2
leaq 0xe1e91(%rip), %rsi     # 0x1f6fc4
movb $0x3, %al
callq 0x5750
jmp 0x11517d
testb $0x1, -0x22(%rbp)
je 0x11517b
movl -0x34(%rbp), %eax
movl %eax, -0x84(%rbp)
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movslq -0x34(%rbp), %rsi
callq 0xaf450
movq %rax, %rdi
callq 0x5200
movl -0x84(%rbp), %esi
movq %rax, %rdx
leaq 0xe8925(%rip), %rdi     # 0x1fda99
movb $0x0, %al
callq 0x5070
jmp 0x11517d
jmp 0x11517f
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x11503f
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)