// File: WolfgangLechner[P]StructureAnalysis/molecular_system.cpp
// Function: CMolecularSystem::createHCP()
void CMolecularSystem::createHCP()
{
  double a,c,h;
  int bu,t;
  bu = this->parameter->baseunit;

  a = this->parameter->boxx/(double(bu));
  c = a*sqrt(3.0)/2.0;
  h = a*sqrt(2.0)/sqrt(3.0);
  if (bu != -1)
  {
    if (parameter->nop != -1) {cerr << "how comes that numberofparticles is already set in createHCP?\n";}
    this->parameter->nop = bu*bu*bu;
    this->initializeMolecules(bu*bu*bu);


    int jz = 0;
    for (int tz=0; tz < bu/2 ; tz++)
    {
      for (int jy=0; jy < bu ; jy++)
      {
        for (int jx=0; jx < bu ; jx++)
        {
          t  = bu*bu*jz + bu*jy + jx;
          this->molecules[t].posx = double(jx)*a + a/2.0*(jy % 2);
          this->molecules[t].posy = double(jy)*c;
          this->molecules[t].posz = double(jz)*h;
        }
      }
      jz += 1;

      for (int jy=0; jy < bu ; jy++)
      {
        for (int jx=0; jx < bu ; jx++)
        {
          t  = bu*bu*jz + bu*jy + jx;
          this->molecules[t].posx = double(jx)*a + a/2.0*((jy+1) % 2);
          this->molecules[t].posy = double(jy)*c + c/3.0;;
          this->molecules[t].posz = double(jz)*h;
        }
      }
      jz += 1;
    }
  }
  setNumberOfCells();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x60(%rbp)
movq 0xb4e8c0(%rax), %rcx
movl 0x320c(%rcx), %ecx
movl %ecx, -0x24(%rbp)
movq 0xb4e8c0(%rax), %rax
movsd 0x3218(%rax), %xmm0
cvtsi2sdl -0x24(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x10(%rbp)
movsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movsd 0x6e2d(%rip), %xmm0     # 0xc150
callq 0x31a0
movaps %xmm0, %xmm1
movsd -0x58(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd 0x6e1c(%rip), %xmm1     # 0xc158
divsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
movsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movsd 0x6e01(%rip), %xmm0     # 0xc158
callq 0x31a0
movaps %xmm0, %xmm1
movsd -0x50(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movsd 0x6ddb(%rip), %xmm0     # 0xc150
callq 0x31a0
movaps %xmm0, %xmm1
movsd -0x48(%rbp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
cmpl $-0x1, -0x24(%rbp)
je 0x5646
movq -0x60(%rbp), %rax
movq 0xb4e8c0(%rax), %rax
cmpl $-0x1, 0x3208(%rax)
je 0x53bc
movq 0x9c40(%rip), %rdi      # 0xeff0
leaq 0x6fa8(%rip), %rsi      # 0xc35f
callq 0x3200
movq -0x60(%rbp), %rdi
movl -0x24(%rbp), %ecx
imull -0x24(%rbp), %ecx
imull -0x24(%rbp), %ecx
movq 0xb4e8c0(%rdi), %rax
movl %ecx, 0x3208(%rax)
movl -0x24(%rbp), %esi
imull -0x24(%rbp), %esi
imull -0x24(%rbp), %esi
callq 0x4a00
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movl %eax, -0x64(%rbp)
movl -0x24(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x64(%rbp), %eax
cmpl %ecx, %eax
jge 0x5644
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x550e
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x54fe
movl -0x24(%rbp), %eax
imull -0x24(%rbp), %eax
imull -0x2c(%rbp), %eax
movl -0x24(%rbp), %ecx
imull -0x34(%rbp), %ecx
addl %ecx, %eax
addl -0x38(%rbp), %eax
movl %eax, -0x28(%rbp)
cvtsi2sdl -0x38(%rbp), %xmm0
movsd -0x10(%rbp), %xmm2
movsd -0x10(%rbp), %xmm1
movsd 0x6ced(%rip), %xmm3     # 0xc158
divsd %xmm3, %xmm1
movl -0x34(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movq -0x60(%rbp), %rax
cvtsi2sd %edx, %xmm3
mulsd %xmm3, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0xb4e8b8(%rax), %rcx
movslq -0x28(%rbp), %rdx
imulq $0x870, %rdx, %rdx      # imm = 0x870
addq %rdx, %rcx
movsd %xmm0, 0x8(%rcx)
cvtsi2sdl -0x34(%rbp), %xmm0
mulsd -0x18(%rbp), %xmm0
movq 0xb4e8b8(%rax), %rcx
movslq -0x28(%rbp), %rdx
imulq $0x870, %rdx, %rdx      # imm = 0x870
addq %rdx, %rcx
movsd %xmm0, 0x10(%rcx)
cvtsi2sdl -0x2c(%rbp), %xmm0
mulsd -0x20(%rbp), %xmm0
movq 0xb4e8b8(%rax), %rax
movslq -0x28(%rbp), %rcx
imulq $0x870, %rcx, %rcx      # imm = 0x870
addq %rcx, %rax
movsd %xmm0, 0x18(%rax)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x542e
jmp 0x5500
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x541b
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x562d
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x561d
movl -0x24(%rbp), %eax
imull -0x24(%rbp), %eax
imull -0x2c(%rbp), %eax
movl -0x24(%rbp), %ecx
imull -0x3c(%rbp), %ecx
addl %ecx, %eax
addl -0x40(%rbp), %eax
movl %eax, -0x28(%rbp)
cvtsi2sdl -0x40(%rbp), %xmm0
movsd -0x10(%rbp), %xmm2
movsd -0x10(%rbp), %xmm1
movsd 0x6bea(%rip), %xmm3     # 0xc158
divsd %xmm3, %xmm1
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movq -0x60(%rbp), %rax
cvtsi2sd %edx, %xmm3
mulsd %xmm3, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0xb4e8b8(%rax), %rcx
movslq -0x28(%rbp), %rdx
imulq $0x870, %rdx, %rdx      # imm = 0x870
addq %rdx, %rcx
movsd %xmm0, 0x8(%rcx)
cvtsi2sdl -0x3c(%rbp), %xmm0
movsd -0x18(%rbp), %xmm2
movsd -0x18(%rbp), %xmm1
movsd 0x6b8b(%rip), %xmm3     # 0xc150
divsd %xmm3, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0xb4e8b8(%rax), %rcx
movslq -0x28(%rbp), %rdx
imulq $0x870, %rdx, %rdx      # imm = 0x870
addq %rdx, %rcx
movsd %xmm0, 0x10(%rcx)
cvtsi2sdl -0x2c(%rbp), %xmm0
mulsd -0x20(%rbp), %xmm0
movq 0xb4e8b8(%rax), %rax
movslq -0x28(%rbp), %rcx
imulq $0x870, %rcx, %rcx      # imm = 0x870
addq %rcx, %rax
movsd %xmm0, 0x18(%rax)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x5531
jmp 0x561f
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x551e
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x53f6
jmp 0x5646
movq -0x60(%rbp), %rdi
callq 0x5af0
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)