// File: 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
movq %rsp, %rbp
subq $0x1b0, %rsp            # imm = 0x1B0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movsd 0x8(%rax), %xmm0
cvtsi2sdl -0x14(%rbp), %xmm1
mulsd %xmm1, %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, 0x8(%rax)
movq -0x8(%rbp), %rax
movsd 0x10(%rax), %xmm0
cvtsi2sdl -0x18(%rbp), %xmm1
mulsd %xmm1, %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, 0x10(%rax)
movq -0x8(%rbp), %rax
movsd 0x18(%rax), %xmm0
cvtsi2sdl -0x1c(%rbp), %xmm1
mulsd %xmm1, %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, 0x18(%rax)
movq -0x8(%rbp), %rax
movsd 0x20(%rax), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, 0x20(%rax)
movq -0x8(%rbp), %rax
movsd 0x28(%rax), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, 0x28(%rax)
movq -0x8(%rbp), %rax
movsd 0x30(%rax), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, 0x30(%rax)
movq -0x10(%rbp), %rdi
callq 0x96250
movl $0x0, -0x20(%rbp)
movq -0x10(%rbp), %rdi
addq $0x2f0, %rdi            # imm = 0x2F0
callq 0xf040
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq %rax, -0x198(%rbp)
movq -0x8(%rbp), %rdi
addq $0x2f0, %rdi            # imm = 0x2F0
callq 0xf060
movq %rax, %rcx
movq -0x198(%rbp), %rax
cmpq %rcx, %rax
jae 0x7a53
movq -0x8(%rbp), %rdi
addq $0x2f0, %rdi            # imm = 0x2F0
movl -0x24(%rbp), %eax
movl %eax, %esi
callq 0xf090
movq %rax, %rsi
leaq -0xc0(%rbp), %rdi
callq 0xf0d0
movl $0x0, -0xc4(%rbp)
movl -0xc4(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x7a2b
movl $0x0, -0xc8(%rbp)
movl -0xc8(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x7a15
movl $0x0, -0xcc(%rbp)
movl -0xcc(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x79ff
leaq -0x168(%rbp), %rdi
callq 0x954b0
jmp 0x7835
movl -0x24(%rbp), %eax
movl %eax, -0xe8(%rbp)
leaq -0x80(%rbp), %rsi
leaq -0x128(%rbp), %rdi
callq 0x5060
jmp 0x7850
movsd -0x90(%rbp), %xmm0
movsd %xmm0, -0x138(%rbp)
movsd -0xa8(%rbp), %xmm0
cvtsi2sdl -0x14(%rbp), %xmm2
divsd %xmm2, %xmm0
cvtsi2sdl -0xc4(%rbp), %xmm1
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, -0x150(%rbp)
movsd -0xa0(%rbp), %xmm0
cvtsi2sdl -0x18(%rbp), %xmm2
divsd %xmm2, %xmm0
cvtsi2sdl -0xc8(%rbp), %xmm1
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, -0x148(%rbp)
movsd -0x98(%rbp), %xmm0
cvtsi2sdl -0x1c(%rbp), %xmm2
divsd %xmm2, %xmm0
cvtsi2sdl -0xcc(%rbp), %xmm1
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, -0x140(%rbp)
movq -0x10(%rbp), %rsi
movsd -0x150(%rbp), %xmm0
movsd -0x148(%rbp), %xmm1
movsd -0x140(%rbp), %xmm2
leaq -0x190(%rbp), %rdi
callq 0x97170
jmp 0x7905
leaq -0x190(%rbp), %rdi
xorl %esi, %esi
callq 0xe9d70
movq %rax, -0x1a0(%rbp)
jmp 0x791c
movq -0x1a0(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x168(%rbp)
leaq -0x190(%rbp), %rdi
movl $0x1, %esi
callq 0xe9d70
movq %rax, -0x1a8(%rbp)
jmp 0x7949
movq -0x1a8(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x160(%rbp)
leaq -0x190(%rbp), %rdi
movl $0x2, %esi
callq 0xe9d70
movq %rax, -0x1b0(%rbp)
jmp 0x7976
movq -0x1b0(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x158(%rbp)
movq -0x10(%rbp), %rdi
addq $0x2f0, %rdi            # imm = 0x2F0
leaq -0x168(%rbp), %rsi
callq 0xf190
jmp 0x79a2
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
leaq -0x168(%rbp), %rdi
callq 0xf200
movl -0xcc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xcc(%rbp)
jmp 0x7818
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x170(%rbp)
movl %eax, -0x174(%rbp)
jmp 0x7a45
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x170(%rbp)
movl %eax, -0x174(%rbp)
leaq -0x168(%rbp), %rdi
callq 0xf200
jmp 0x7a45
jmp 0x7a01
movl -0xc8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc8(%rbp)
jmp 0x77ff
jmp 0x7a17
movl -0xc4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc4(%rbp)
jmp 0x77e6
leaq -0xc0(%rbp), %rdi
callq 0xf200
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x778b
leaq -0xc0(%rbp), %rdi
callq 0xf200
jmp 0x7a69
movl -0x20(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x110(%rax)
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbp
retq
movq -0x170(%rbp), %rdi
callq 0x58f0
nopw %cs:(%rax,%rax)