// File: Luthaf[P]zeopp/networkstorage.cc
// Function: apply_symmetry_operator(MOLECULE, int, int, ATOM_NETWORK*)
MOLECULE apply_symmetry_operator(MOLECULE orig, int sym_op, int sym_ID, ATOM_NETWORK *underlying_net) {
  MOLECULE rot = orig;
  int num_atom = orig.atoms_xyz.size();
  for(int i=0; i<num_atom+1; i++) {
    XYZ pos;
    if(i<num_atom) pos = orig.atoms_xyz.at(i); else pos = orig.com; //handle the centre of mass too!
    XYZ abc_pos = underlying_net->xyz_to_abc_returning_XYZ(pos);
    XYZ new_pos = underlying_net->abc_to_xyz_returning_XYZ(GetEquivalentPositions(sym_ID, &abc_pos).at(sym_op));
    if(i<num_atom) rot.atoms_xyz.at(i) = new_pos; else rot.com = new_pos; //handle the centre of mass too!
  }
  return rot;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rsi, -0xa8(%rbp)
movq %rdi, -0xb8(%rbp)
movq %rdi, %rax
movq %rax, -0xb0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movb $0x0, -0x21(%rbp)
callq 0xaf160
movq -0xa8(%rbp), %rdi
callq 0xae590
movl %eax, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl -0x28(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jge 0xa6c10
leaq -0x48(%rbp), %rdi
xorps %xmm2, %xmm2
movaps %xmm2, %xmm0
movaps %xmm2, %xmm1
callq 0xea8e0
jmp 0xa6a89
movl -0x2c(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0xa6adb
movq -0xa8(%rbp), %rdi
movslq -0x2c(%rbp), %rsi
callq 0xae5c0
movq %rax, -0xc0(%rbp)
jmp 0xa6aaa
movq -0xc0(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0x48(%rbp)
movq 0x8(%rax), %rcx
movq %rcx, -0x40(%rbp)
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0xa6b03
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xa6c36
movq -0xa8(%rbp), %rax
movq 0x90(%rax), %rcx
movq %rcx, -0x48(%rbp)
movq 0x98(%rax), %rcx
movq %rcx, -0x40(%rbp)
movq 0xa0(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rsi
leaq -0x70(%rbp), %rdi
leaq -0x48(%rbp), %rdx
callq 0x95a40
jmp 0xa6b16
movq -0x20(%rbp), %rax
movq %rax, -0xc8(%rbp)
movl -0x18(%rbp), %esi
leaq -0xa0(%rbp), %rdi
leaq -0x70(%rbp), %rdx
callq 0x117c50
jmp 0xa6b36
movslq -0x14(%rbp), %rsi
leaq -0xa0(%rbp), %rdi
callq 0xae5c0
movq %rax, -0xd0(%rbp)
jmp 0xa6b4f
movq -0xd0(%rbp), %rdx
movq -0xc8(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0x97310
jmp 0xa6b6b
leaq -0xa0(%rbp), %rdi
callq 0x12210
movl -0x2c(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0xa6bd5
movq -0xb8(%rbp), %rdi
movslq -0x2c(%rbp), %rsi
callq 0xae5c0
movq %rax, -0xd8(%rbp)
jmp 0xa6b98
movq -0xd8(%rbp), %rax
movq -0x88(%rbp), %rcx
movq %rcx, (%rax)
movq -0x80(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x78(%rbp), %rcx
movq %rcx, 0x10(%rax)
jmp 0xa6c00
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x12210
jmp 0xa6c36
movq -0xb8(%rbp), %rax
movq -0x88(%rbp), %rcx
movq %rcx, 0x90(%rax)
movq -0x80(%rbp), %rcx
movq %rcx, 0x98(%rax)
movq -0x78(%rbp), %rcx
movq %rcx, 0xa0(%rax)
jmp 0xa6c02
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xa6a64
movb $0x1, -0x21(%rbp)
testb $0x1, -0x21(%rbp)
jne 0xa6c26
movq -0xb8(%rbp), %rdi
callq 0xaf390
movq -0xb0(%rbp), %rax
addq $0xe0, %rsp
popq %rbp
retq
movq -0xb8(%rbp), %rdi
callq 0xaf390
movq -0x50(%rbp), %rdi
callq 0x58f0
nopl (%rax,%rax)