// File: /workspace/github_cpp_makefile_star2_O2/Luthaf[P]zeopp/network.cc
// Function: extendUnitCell(ATOM_NETWORK*, ATOM_NETWORK*, int, int, int)
void extendUnitCell(ATOM_NETWORK *cell, ATOM_NETWORK *newCell, int xfactor, int yfactor, int zfactor){
  newCell->a = cell->a*xfactor;
  newCell->b = cell->b*yfactor;
  newCell->c = cell->c*zfactor;
  newCell->alpha = cell->alpha;
  newCell->beta = cell->beta;
  newCell->gamma = cell->gamma;
  newCell->initialize();

  int numAtoms = 0;
  newCell->atoms.clear();
  for(unsigned int i = 0; i<cell->atoms.size(); i++){
    ATOM oldAtom = cell->atoms.at(i);
    for(int j = 0; j < xfactor; j++){
      for(int k = 0; k < yfactor; k++){
	for(int m = 0; m < zfactor; m++){
	  ATOM newAtom;
	  newAtom.specialID = i;
	  newAtom.type = oldAtom.type;
	  newAtom.radius = oldAtom.radius;
	  newAtom.a_coord = oldAtom.a_coord/xfactor + j*1.0/xfactor;
	  newAtom.b_coord = oldAtom.b_coord/yfactor + k*1.0/yfactor;
	  newAtom.c_coord = oldAtom.c_coord/zfactor + m*1.0/zfactor;
	  Point newCoords = newCell->abc_to_xyz(newAtom.a_coord, newAtom.b_coord, newAtom.c_coord);
	  newAtom.x = newCoords[0];
	  newAtom.y = newCoords[1];
	  newAtom.z = newCoords[2];
	  newCell->atoms.push_back(newAtom);
	  numAtoms++;
	}
      }
    }
  }
  newCell->numAtoms = numAtoms;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1c8, %rsp            # imm = 0x1C8
movl %r8d, %r15d
movl %ecx, %ebp
movl %edx, (%rsp)
movq %rsi, %r14
movq %rdi, %rbx
movd %ecx, %xmm0
movd %edx, %xmm1
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
cvtdq2pd %xmm1, %xmm1
movapd %xmm1, 0x30(%rsp)
movupd 0x8(%rdi), %xmm0
mulpd %xmm1, %xmm0
cvtsi2sd %r8d, %xmm1
movapd %xmm1, 0x20(%rsp)
movupd %xmm0, 0x8(%rsi)
movsd 0x18(%rdi), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x18(%rsi)
movups 0x20(%rdi), %xmm0
movups %xmm0, 0x20(%rsi)
movsd 0x30(%rdi), %xmm0
movsd %xmm0, 0x30(%rsi)
movq %rsi, %rdi
callq 0x3e5a4
movl $0x2f0, %r12d           # imm = 0x2F0
movq %r14, 0x18(%rsp)
leaq (%r14,%r12), %r13
movq %r13, %rdi
callq 0xa732
movq %rbx, 0x48(%rsp)
addq %rbx, %r12
movq %r12, 0x40(%rsp)
xorl %eax, %eax
testl %r15d, %r15d
cmovlel %eax, %r15d
testl %ebp, %ebp
cmovlel %eax, %ebp
movl %r15d, %ebx
movl %ebp, 0x10(%rsp)
imull %ebp, %r15d
movl %r15d, 0x8(%rsp)
movl (%rsp), %ecx
testl %ecx, %ecx
movl $0x0, 0x4(%rsp)
cmovlel %eax, %ecx
movl %ecx, (%rsp)
movaps 0x30(%rsp), %xmm0
movhlps %xmm0, %xmm0            # xmm0 = xmm0[1,1]
movaps %xmm0, 0x50(%rsp)
movapd 0x20(%rsp), %xmm0
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
movapd %xmm0, 0x20(%rsp)
leaq 0x80(%rsp), %rbp
leaq 0x1b0(%rsp), %r12
xorl %r15d, %r15d
movl %r15d, %esi
movq 0x48(%rsp), %rcx
movq 0x2f8(%rcx), %rax
subq 0x2f0(%rcx), %rax
cqto
movl $0x98, %ecx
idivq %rcx
cmpq %rsi, %rax
jbe 0x5d63
movq 0x40(%rsp), %rdi
callq 0xa73a
leaq 0x118(%rsp), %rdi
movq %rax, %rsi
callq 0xa75c
xorl %eax, %eax
cmpl (%rsp), %eax
je 0x5d4e
movl %eax, 0xc(%rsp)
cvtsi2sd %eax, %xmm0
divsd 0x30(%rsp), %xmm0
movapd %xmm0, 0x60(%rsp)
movl 0x8(%rsp), %eax
addl %eax, 0x4(%rsp)
xorl %eax, %eax
cmpl 0x10(%rsp), %eax
je 0x5d43
movl %eax, 0x14(%rsp)
cvtsi2sd %eax, %xmm0
divsd 0x50(%rsp), %xmm0
movapd 0x60(%rsp), %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
movapd %xmm1, 0x70(%rsp)
xorl %r14d, %r14d
cmpl %r14d, %ebx
je 0x5d38
movq %rbp, %rdi
callq 0x3dc5a
movl %r15d, 0x100(%rsp)
leaq 0xc0(%rsp), %rdi
leaq 0x158(%rsp), %rsi
callq 0x4270
movsd 0x148(%rsp), %xmm0
movsd %xmm0, 0xb0(%rsp)
movupd 0x130(%rsp), %xmm0
divpd 0x30(%rsp), %xmm0
addpd 0x70(%rsp), %xmm0
cvtsi2sd %r14d, %xmm1
movhpd 0x140(%rsp), %xmm1      # xmm1 = xmm1[0],mem[0]
movupd %xmm0, 0x98(%rsp)
divpd 0x20(%rsp), %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
movsd %xmm2, 0xa8(%rsp)
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
movq %r12, %rdi
movq 0x18(%rsp), %rsi
callq 0x3f0e6
movq %r12, %rdi
xorl %esi, %esi
callq 0x63c78
movsd (%rax), %xmm0
movsd %xmm0, 0x80(%rsp)
movq %r12, %rdi
pushq $0x1
popq %rsi
callq 0x63c78
movsd (%rax), %xmm0
movsd %xmm0, 0x88(%rsp)
movq %r12, %rdi
pushq $0x2
popq %rsi
callq 0x63c78
movsd (%rax), %xmm0
movsd %xmm0, 0x90(%rsp)
movq %r13, %rdi
movq %rbp, %rsi
callq 0xa7d8
movq %rbp, %rdi
callq 0xa808
incl %r14d
jmp 0x5c3a
movl 0x14(%rsp), %eax
incl %eax
jmp 0x5c0f
movl 0xc(%rsp), %eax
incl %eax
jmp 0x5be8
leaq 0x118(%rsp), %rdi
callq 0xa808
incl %r15d
jmp 0x5ba3
movq 0x18(%rsp), %rax
movl 0x4(%rsp), %ecx
movl %ecx, 0x110(%rax)
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x5d9b
jmp 0x5d8b
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0xa808
leaq 0x118(%rsp), %rdi
callq 0xa808
movq %rbx, %rdi
callq 0x4780