// File: tlestang[P]IW_gene/topo.cpp
// Function: Topography::Topography(int const*, int, double***, VelSite**, VelSite**)
Topography::Topography(const int d[2], int h, double ***u,
		       VelSite **sites, VelSite **_sites)
{
  nbNodes = d[0];
  double u0[2] = {0.0, 0.0};
  int x,y;
  lbl = new int[nbNodes];
  nodes = new int*[nbNodes];
  for (int i=0;i<nbNodes;i++)
    {nodes[i] = new int[2];}

  double a;
  int cc = 0;
  for (int xx=0;xx<d[0];xx++)
    {
      nodes[cc][0] = xx;
      a = 2.*M_PI / d[0];
      nodes[cc][1] = floor(h*sin(a*xx)) + h;
      for(int yy=0;yy<nodes[cc][1];yy++)
	{
	  sites[xx][yy].init(LatticeSite::Solid, 1.0, u0, 0);
	  _sites[xx][yy].init(LatticeSite::Solid, 1.0, u0, 0);
	}
            
      cc += 1;
    }

  for(int i=1;i<nbNodes-1;i++)
    {
      x = nodes[i][0]; y = nodes[i][1];
      if(nodes[i-1][1] == (y-1) && nodes[i+1][1] == (y+1)){lbl[i]=2; } //3 pts aligned along y
      else if(nodes[i-1][1] == nodes[i+1][1]){lbl[i]=1;}
      else if((nodes[i-1][1] == (y-1) && nodes[i+1][1] == y) || (nodes[i-1][1] == y && nodes[i+1][1] == y-1) ){lbl[i] = 2;}
      else{lbl[i] = 0;}
    }

  
  x = nodes[0][0]; y = nodes[0][1];
  if(nodes[nbNodes-1][0] == nodes[1][0]){lbl[0]=2;}
  else if(nodes[nbNodes-1][1] == nodes[1][1]){lbl[0]=1;}
  else if((nodes[nbNodes-1][1] == (y-1) && nodes[1][1] == y) || (nodes[nbNodes-1][1] == y && nodes[1][1] == y-1) ){lbl[0] = 2;}
  else{lbl[0] = 0;}
  
  x = nodes[nbNodes-1][0]; y = nodes[nbNodes-1][1];
  if(nodes[nbNodes-2][0] == nodes[0][0]){lbl[nbNodes-1]=2;}
  else if(nodes[nbNodes-2][1] == nodes[0][1]){lbl[nbNodes-1]=1;}
  else if((nodes[nbNodes-2][1] == (y-1) && nodes[0][1] == y) || (nodes[nbNodes-2][1] == y && nodes[0][1] == y-1) ){lbl[nbNodes-1] = 2;}
  else{lbl[nbNodes-1] = 0;}


  
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x70(%rbp)
callq 0x3e20
movq -0x70(%rbp), %rax
leaq 0x7296(%rip), %rcx      # 0xbd80
addq $0x10, %rcx
movq %rcx, (%rax)
movq -0x10(%rbp), %rcx
movl (%rcx), %ecx
movl %ecx, 0x8(%rax)
leaq -0x40(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x3100
movq -0x70(%rbp), %rax
movslq 0x8(%rax), %rax
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x3030
movq %rax, %rcx
movq -0x70(%rbp), %rax
movq %rcx, 0x18(%rax)
movslq 0x8(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x3030
movq %rax, %rcx
movq -0x70(%rbp), %rax
movq %rcx, 0x10(%rax)
movl $0x0, -0x4c(%rbp)
movq -0x70(%rbp), %rcx
movl -0x4c(%rbp), %eax
cmpl 0x8(%rcx), %eax
jge 0x4ba9
movl $0x8, %edi
callq 0x3030
movq %rax, %rdx
movq -0x70(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x4c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x4b75
movl $0x0, -0x5c(%rbp)
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x4cee
movq -0x70(%rbp), %rax
movl -0x60(%rbp), %ecx
movq 0x10(%rax), %rax
movslq -0x5c(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
cvtsi2sdl (%rax), %xmm1
movsd 0x45e5(%rip), %xmm0     # 0x91d0
divsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rbp)
cvtsi2sdl -0x14(%rbp), %xmm0
movsd %xmm0, -0x78(%rbp)
movsd -0x58(%rbp), %xmm0
cvtsi2sdl -0x60(%rbp), %xmm1
mulsd %xmm1, %xmm0
callq 0x3090
movaps %xmm0, %xmm1
movsd -0x78(%rbp), %xmm0
mulsd %xmm1, %xmm0
callq 0x3340
movq -0x70(%rbp), %rax
cvtsi2sdl -0x14(%rbp), %xmm1
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
movq 0x10(%rax), %rax
movslq -0x5c(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movl %ecx, 0x4(%rax)
movl $0x0, -0x64(%rbp)
movq -0x70(%rbp), %rcx
movl -0x64(%rbp), %eax
movq 0x10(%rcx), %rcx
movslq -0x5c(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
cmpl 0x4(%rcx), %eax
jge 0x4cd7
movq -0x28(%rbp), %rax
movslq -0x60(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movslq -0x64(%rbp), %rax
imulq $0x88, %rax, %rax
addq %rax, %rdi
leaq -0x40(%rbp), %rdx
movq (%rdi), %rax
movl $0x62, %esi
movsd 0x4399(%rip), %xmm0     # 0x9028
xorps %xmm1, %xmm1
callq *0x18(%rax)
movq -0x30(%rbp), %rax
movslq -0x60(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movslq -0x64(%rbp), %rax
imulq $0x88, %rax, %rax
addq %rax, %rdi
leaq -0x40(%rbp), %rdx
movq (%rdi), %rax
movl $0x62, %esi
movsd 0x4365(%rip), %xmm0     # 0x9028
xorps %xmm1, %xmm1
callq *0x18(%rax)
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x4c49
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x4bb7
movl $0x1, -0x68(%rbp)
movq -0x70(%rbp), %rcx
movl -0x68(%rbp), %eax
movl 0x8(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x4e89
movq -0x70(%rbp), %rax
movq 0x10(%rax), %rcx
movslq -0x68(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movl (%rcx), %ecx
movl %ecx, -0x44(%rbp)
movq 0x10(%rax), %rcx
movslq -0x68(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movl 0x4(%rcx), %ecx
movl %ecx, -0x48(%rbp)
movq 0x10(%rax), %rax
movl -0x68(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movl 0x4(%rax), %eax
movl -0x48(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x4d89
movq -0x70(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x68(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movl 0x4(%rax), %eax
movl -0x48(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0x4d89
movq -0x70(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x68(%rbp), %rcx
movl $0x2, (%rax,%rcx,4)
jmp 0x4e79
movq -0x70(%rbp), %rcx
movq 0x10(%rcx), %rax
movl -0x68(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
movq (%rax,%rdx,8), %rax
movl 0x4(%rax), %eax
movq 0x10(%rcx), %rcx
movl -0x68(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
movq (%rcx,%rdx,8), %rcx
cmpl 0x4(%rcx), %eax
jne 0x4dcf
movq -0x70(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x68(%rbp), %rcx
movl $0x1, (%rax,%rcx,4)
jmp 0x4e77
movq -0x70(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x68(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movl 0x4(%rax), %eax
movl -0x48(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x4e0e
movq -0x70(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x68(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movl 0x4(%rax), %eax
cmpl -0x48(%rbp), %eax
je 0x4e4d
movq -0x70(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x68(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movl 0x4(%rax), %eax
cmpl -0x48(%rbp), %eax
jne 0x4e62
movq -0x70(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x68(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movl 0x4(%rax), %eax
movl -0x48(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x4e62
movq -0x70(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x68(%rbp), %rcx
movl $0x2, (%rax,%rcx,4)
jmp 0x4e75
movq -0x70(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x68(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
jmp 0x4e77
jmp 0x4e79
jmp 0x4e7b
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0x4cf5
movq -0x70(%rbp), %rcx
movq 0x10(%rcx), %rax
movq (%rax), %rax
movl (%rax), %eax
movl %eax, -0x44(%rbp)
movq 0x10(%rcx), %rax
movq (%rax), %rax
movl 0x4(%rax), %eax
movl %eax, -0x48(%rbp)
movq 0x10(%rcx), %rax
movl 0x8(%rcx), %edx
subl $0x1, %edx
movslq %edx, %rdx
movq (%rax,%rdx,8), %rax
movl (%rax), %eax
movq 0x10(%rcx), %rcx
movq 0x8(%rcx), %rcx
cmpl (%rcx), %eax
jne 0x4ed8
movq -0x70(%rbp), %rax
movq 0x18(%rax), %rax
movl $0x2, (%rax)
jmp 0x4f9e
movq -0x70(%rbp), %rcx
movq 0x10(%rcx), %rax
movl 0x8(%rcx), %edx
subl $0x1, %edx
movslq %edx, %rdx
movq (%rax,%rdx,8), %rax
movl 0x4(%rax), %eax
movq 0x10(%rcx), %rcx
movq 0x8(%rcx), %rcx
cmpl 0x4(%rcx), %eax
jne 0x4f10
movq -0x70(%rbp), %rax
movq 0x18(%rax), %rax
movl $0x1, (%rax)
jmp 0x4f9c
movq -0x70(%rbp), %rcx
movq 0x10(%rcx), %rax
movl 0x8(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movl 0x4(%rax), %eax
movl -0x48(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x4f46
movq -0x70(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
movl 0x4(%rax), %eax
cmpl -0x48(%rbp), %eax
je 0x4f7c
movq -0x70(%rbp), %rcx
movq 0x10(%rcx), %rax
movl 0x8(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movl 0x4(%rax), %eax
cmpl -0x48(%rbp), %eax
jne 0x4f8c
movq -0x70(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
movl 0x4(%rax), %eax
movl -0x48(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x4f8c
movq -0x70(%rbp), %rax
movq 0x18(%rax), %rax
movl $0x2, (%rax)
jmp 0x4f9a
movq -0x70(%rbp), %rax
movq 0x18(%rax), %rax
movl $0x0, (%rax)
jmp 0x4f9c
jmp 0x4f9e
movq -0x70(%rbp), %rcx
movq 0x10(%rcx), %rax
movl 0x8(%rcx), %edx
subl $0x1, %edx
movslq %edx, %rdx
movq (%rax,%rdx,8), %rax
movl (%rax), %eax
movl %eax, -0x44(%rbp)
movq 0x10(%rcx), %rax
movl 0x8(%rcx), %edx
subl $0x1, %edx
movslq %edx, %rdx
movq (%rax,%rdx,8), %rax
movl 0x4(%rax), %eax
movl %eax, -0x48(%rbp)
movq 0x10(%rcx), %rax
movl 0x8(%rcx), %edx
subl $0x2, %edx
movslq %edx, %rdx
movq (%rax,%rdx,8), %rax
movl (%rax), %eax
movq 0x10(%rcx), %rcx
movq (%rcx), %rcx
cmpl (%rcx), %eax
jne 0x500a
movq -0x70(%rbp), %rcx
movq 0x18(%rcx), %rax
movl 0x8(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl $0x2, (%rax,%rcx,4)
jmp 0x50eb
movq -0x70(%rbp), %rcx
movq 0x10(%rcx), %rax
movl 0x8(%rcx), %edx
subl $0x2, %edx
movslq %edx, %rdx
movq (%rax,%rdx,8), %rax
movl 0x4(%rax), %eax
movq 0x10(%rcx), %rcx
movq (%rcx), %rcx
cmpl 0x4(%rcx), %eax
jne 0x504b
movq -0x70(%rbp), %rcx
movq 0x18(%rcx), %rax
movl 0x8(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl $0x1, (%rax,%rcx,4)
jmp 0x50e9
movq -0x70(%rbp), %rcx
movq 0x10(%rcx), %rax
movl 0x8(%rcx), %ecx
subl $0x2, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movl 0x4(%rax), %eax
movl -0x48(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x5080
movq -0x70(%rbp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movl 0x4(%rax), %eax
cmpl -0x48(%rbp), %eax
je 0x50b5
movq -0x70(%rbp), %rcx
movq 0x10(%rcx), %rax
movl 0x8(%rcx), %ecx
subl $0x2, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movl 0x4(%rax), %eax
cmpl -0x48(%rbp), %eax
jne 0x50cf
movq -0x70(%rbp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movl 0x4(%rax), %eax
movl -0x48(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x50cf
movq -0x70(%rbp), %rcx
movq 0x18(%rcx), %rax
movl 0x8(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl $0x2, (%rax,%rcx,4)
jmp 0x50e7
movq -0x70(%rbp), %rcx
movq 0x18(%rcx), %rax
movl 0x8(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl $0x0, (%rax,%rcx,4)
jmp 0x50e9
jmp 0x50eb
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)