// File: giovifazi[P]knossos-bloodbath/Node.cpp
// Function: Node::link_adjacent(char, Node*, Node&)
void Node::link_adjacent(char exclude, Node* current, Node& origin)
{
   Node* found;
   int xx = current->get_x();
   int yy = current->get_y();

	Map search_map(1,1);    // mappa di ricerca
	search_map.init(0);

   // Cerco nodo adiacente a nord
   if (exclude != 'n')
   {
      found = current->search_node(xx, yy+1, origin, search_map);
      search_map.delete_map(true);

      if (found != NULL)
      {
         // Collegamento nodi
         found->set_cardinal('s', *(current));
         current->set_cardinal('n', *(found));
      }
   }

   // Cerco nodo adiacente a sud
   if (exclude != 's')
   {
      found = current->search_node(xx, yy-1, origin, search_map);
      search_map.delete_map(true);

      if (found != NULL)
      {
         // Collegamento nodi
         found->set_cardinal('n', *(current));
         current->set_cardinal('s', *(found));
      }
   }

   // Cerco nodo adiacente a est
   if (exclude != 'e')
   {
      found = current->search_node(xx+1, yy, origin, search_map);
      search_map.delete_map(true);

      if (found != NULL)
      {
         // Collegamento nodi
         found->set_cardinal('o', *(current));
         current->set_cardinal('e', *(found));
      }
   }

   // Cerco nodo adiacente a ovest
   if (exclude != 'o')
   {
      found = current->search_node(xx-1, yy, origin, search_map);
      search_map.delete_map(true);

      if (found != NULL)
      {
         // Collegamento nodi
         found->set_cardinal('e', *(current));
         current->set_cardinal('o', *(found));
      }
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movb %sil, %al
movq %rdi, -0x8(%rbp)
movb %al, -0x9(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x18(%rbp), %rdi
callq 0x3510
movl %eax, -0x2c(%rbp)
movq -0x18(%rbp), %rdi
callq 0x3530
movl %eax, -0x30(%rbp)
leaq -0x48(%rbp), %rdi
movl $0x1, %edx
movl %edx, %esi
callq 0x4280
leaq -0x48(%rbp), %rdi
xorl %esi, %esi
callq 0x4390
movsbl -0x9(%rbp), %eax
cmpl $0x6e, %eax
je 0x409f
movq -0x18(%rbp), %rdi
movl -0x2c(%rbp), %esi
movl -0x30(%rbp), %edx
addl $0x1, %edx
movq -0x20(%rbp), %rcx
leaq -0x48(%rbp), %r8
callq 0x3690
movq %rax, -0x28(%rbp)
leaq -0x48(%rbp), %rdi
movl $0x1, %esi
callq 0x4450
cmpq $0x0, -0x28(%rbp)
je 0x409d
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rdx
movl $0x73, %esi
callq 0x3610
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rdx
movl $0x6e, %esi
callq 0x3610
jmp 0x409f
movsbl -0x9(%rbp), %eax
cmpl $0x73, %eax
je 0x4101
movq -0x18(%rbp), %rdi
movl -0x2c(%rbp), %esi
movl -0x30(%rbp), %edx
subl $0x1, %edx
movq -0x20(%rbp), %rcx
leaq -0x48(%rbp), %r8
callq 0x3690
movq %rax, -0x28(%rbp)
leaq -0x48(%rbp), %rdi
movl $0x1, %esi
callq 0x4450
cmpq $0x0, -0x28(%rbp)
je 0x40ff
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rdx
movl $0x6e, %esi
callq 0x3610
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rdx
movl $0x73, %esi
callq 0x3610
jmp 0x4101
movsbl -0x9(%rbp), %eax
cmpl $0x65, %eax
je 0x4163
movq -0x18(%rbp), %rdi
movl -0x2c(%rbp), %esi
addl $0x1, %esi
movl -0x30(%rbp), %edx
movq -0x20(%rbp), %rcx
leaq -0x48(%rbp), %r8
callq 0x3690
movq %rax, -0x28(%rbp)
leaq -0x48(%rbp), %rdi
movl $0x1, %esi
callq 0x4450
cmpq $0x0, -0x28(%rbp)
je 0x4161
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rdx
movl $0x6f, %esi
callq 0x3610
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rdx
movl $0x65, %esi
callq 0x3610
jmp 0x4163
movsbl -0x9(%rbp), %eax
cmpl $0x6f, %eax
je 0x41c5
movq -0x18(%rbp), %rdi
movl -0x2c(%rbp), %esi
subl $0x1, %esi
movl -0x30(%rbp), %edx
movq -0x20(%rbp), %rcx
leaq -0x48(%rbp), %r8
callq 0x3690
movq %rax, -0x28(%rbp)
leaq -0x48(%rbp), %rdi
movl $0x1, %esi
callq 0x4450
cmpq $0x0, -0x28(%rbp)
je 0x41c3
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rdx
movl $0x65, %esi
callq 0x3610
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rdx
movl $0x6f, %esi
callq 0x3610
jmp 0x41c5
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)