// File: /workspace/github_cpp_makefile_star2_O2/tlestang[P]IW_gene/topo.cpp
// Function: Topography::HalfWayFreeSlipBC(VelSite**, VelSite**)
void Topography::HalfWayFreeSlipBC(VelSite **sites, VelSite **_sites)
{  int x,y, xm, xp;
  int op[9] = {0, 1, 4, 3, 2, 6, 5, 8, 7};
  double dd; int cc= 0;

  // ofstream bb, lns, rns, ts;
  // bb.open("bb.dat");lns.open("lns.dat");rns.open("rns.dat");ts.open("ts.dat");
  for (int i=0;i<nbNodes;i++)
    {
      x = nodes[i][0]; y = nodes[i][1];
      xp = (x + 1 + nbNodes)%nbNodes; 
      xm = (x - 1 + nbNodes)%nbNodes; 
      //flat wall
      if(lbl[i] == 1)
	{
	  _sites[x][y].f[6] = sites[xm][y].f[7];
	  _sites[x][y].f[2] = sites[x][y].f[4];
	  _sites[x][y].f[5] = sites[xp][y].f[8];
	}

      //External corner
       else if(lbl[i] == 2)
	{
	  if(nodes[i][0] == 0 || nodes[i][0] == nbNodes-1){dd = +1;}
	  else{dd = (nodes[i+1][1]-nodes[i-1][1])/2.;}

	  if(dd > 0.) // if mur gauche
	    {
	      _sites[x][y].f[6] = sites[x][y].f[8];
	    }
	  else
	    {
	      _sites[x][y].f[5] = sites[x][y].f[7];
	    }
	}
      
      // internal corner
       else{
	 if(nodes[i][0] == 0 || nodes[i][0] == nbNodes-1){dd = +1;}
	 else{dd = (nodes[i+1][1]-nodes[i-1][1])/2.;}
	 if(dd > 0.)
	   {
	     _sites[x][y].f[2] = sites[x][y].f[4];
	     _sites[x][y].f[3] = sites[x][y].f[1];
	     _sites[x][y].f[6] = sites[x][y].f[8];
	     _sites[x][y].f[5] = sites[xm][y].f[8];
	   }
	 else
	   {
	     _sites[x][y].f[2] = sites[x][y].f[4];
	     _sites[x][y].f[1] = sites[x][y].f[3];
	     _sites[x][y].f[5] = sites[x][y].f[7];
	     _sites[x][y].f[6] = sites[xp][y].f[7];
	   }
       }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdx, %rcx
movslq 0x8(%rdi), %r8
movq 0x10(%rdi), %r9
movq 0x18(%rdi), %r10
leal 0x1(%r8), %r11d
leal -0x1(%r8), %ebx
xorl %r14d, %r14d
movsd 0x1e76(%rip), %xmm0     # 0x5188
xorpd %xmm1, %xmm1
cmpq %r8, %r14
jge 0x34ce
movq (%r9,%r14,8), %rax
movslq (%rax), %r15
movslq 0x4(%rax), %r12
leal (%r11,%r15), %eax
cltd
idivl %r8d
movl %edx, %edi
leal (%rbx,%r15), %eax
cltd
idivl %r8d
movl (%r10,%r14,4), %ebp
cmpl $0x2, %ebp
je 0x3395
movslq %edx, %rdx
movslq %edi, %rax
cmpl $0x1, %ebp
jne 0x33e7
movq (%rsi,%rdx,8), %rdx
imulq $0x88, %r12, %rdi
movsd 0x40(%rdx,%rdi), %xmm2
movq (%rcx,%r15,8), %rdx
movsd %xmm2, 0x38(%rdx,%rdi)
movq (%rsi,%r15,8), %r15
movsd 0x28(%r15,%rdi), %xmm2
movsd %xmm2, 0x18(%rdx,%rdi)
movq (%rsi,%rax,8), %rax
movsd 0x48(%rax,%rdi), %xmm2
movsd %xmm2, 0x30(%rdx,%rdi)
jmp 0x34c6
testl %r15d, %r15d
sete %al
cmpl %ebx, %r15d
sete %dl
orb %al, %dl
jne 0x33c7
movq -0x8(%r9,%r14,8), %rax
movq 0x8(%r9,%r14,8), %rdx
movl 0x4(%rdx), %edx
subl 0x4(%rax), %edx
cvtsi2sd %edx, %xmm2
mulsd %xmm0, %xmm2
ucomisd %xmm1, %xmm2
jbe 0x3462
movq (%rsi,%r15,8), %rax
imulq $0x88, %r12, %rdx
movsd 0x48(%rax,%rdx), %xmm2
movq (%rcx,%r15,8), %rax
movsd %xmm2, 0x38(%rax,%rdx)
jmp 0x34c6
testl %r15d, %r15d
sete %dil
cmpl %ebx, %r15d
sete %bpl
orb %dil, %bpl
jne 0x3419
movq -0x8(%r9,%r14,8), %rdi
movq 0x8(%r9,%r14,8), %r13
movl 0x4(%r13), %ebp
subl 0x4(%rdi), %ebp
cvtsi2sd %ebp, %xmm2
mulsd %xmm0, %xmm2
ucomisd %xmm1, %xmm2
jbe 0x347f
movq (%rsi,%r15,8), %rax
imulq $0x88, %r12, %rdi
movsd 0x28(%rax,%rdi), %xmm2
movq (%rcx,%r15,8), %r15
movsd %xmm2, 0x18(%r15,%rdi)
movsd 0x10(%rax,%rdi), %xmm2
movsd %xmm2, 0x20(%r15,%rdi)
movsd 0x48(%rax,%rdi), %xmm2
movsd %xmm2, 0x38(%r15,%rdi)
movq (%rsi,%rdx,8), %rax
movsd 0x48(%rax,%rdi), %xmm2
movsd %xmm2, 0x30(%r15,%rdi)
jmp 0x34c6
movq (%rsi,%r15,8), %rax
imulq $0x88, %r12, %rdx
movsd 0x40(%rax,%rdx), %xmm2
movq (%rcx,%r15,8), %rax
movsd %xmm2, 0x30(%rax,%rdx)
jmp 0x34c6
movq (%rsi,%r15,8), %rdx
imulq $0x88, %r12, %rdi
movsd 0x28(%rdx,%rdi), %xmm2
movq (%rcx,%r15,8), %r15
movsd %xmm2, 0x18(%r15,%rdi)
movsd 0x20(%rdx,%rdi), %xmm2
movsd %xmm2, 0x10(%r15,%rdi)
movsd 0x40(%rdx,%rdi), %xmm2
movsd %xmm2, 0x30(%r15,%rdi)
movq (%rsi,%rax,8), %rax
movsd 0x40(%rax,%rdi), %xmm2
movsd %xmm2, 0x38(%r15,%rdi)
incq %r14
jmp 0x3316
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop