// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, -0x38(%rbp)
movq %rdx, %rbx
movl %esi, %r13d
movl 0x20(%rdx), %r12d
movl 0x24(%rdx), %eax
movq %rax, -0x30(%rbp)
leaq -0x50(%rbp), %r14
movq %r14, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0x33ee
movq %r14, %rdi
xorl %esi, %esi
callq 0x344e
cmpb $0x6e, %r13b
je 0x3293
movq -0x30(%rbp), %rax
leal 0x1(%rax), %edx
leaq -0x50(%rbp), %r15
movq %rbx, %rdi
movl %r12d, %esi
movq -0x38(%rbp), %rcx
movq %r15, %r8
callq 0x2e30
movq %rax, %r14
movq %r15, %rdi
movl $0x1, %esi
callq 0x349a
testq %r14, %r14
je 0x328d
movq %rbx, 0x8(%r14)
movq %r14, (%rbx)
cmpb $0x73, %r13b
je 0x32d2
movq -0x30(%rbp), %rax
leal -0x1(%rax), %edx
leaq -0x50(%rbp), %r15
movq %rbx, %rdi
movl %r12d, %esi
movq -0x38(%rbp), %rcx
movq %r15, %r8
callq 0x2e30
movq %rax, %r14
movq %r15, %rdi
movl $0x1, %esi
callq 0x349a
testq %r14, %r14
je 0x32cc
movq %rbx, (%r14)
movq %r14, 0x8(%rbx)
cmpb $0x65, %r13b
je 0x330d
leal 0x1(%r12), %esi
movq %rbx, %rdi
movq -0x30(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq %r15, %r8
callq 0x2e30
movq %rax, %r14
movq %r15, %rdi
movl $0x1, %esi
callq 0x349a
testq %r14, %r14
je 0x3307
movq %rbx, 0x18(%r14)
movq %r14, 0x10(%rbx)
cmpb $0x6f, %r13b
je 0x3343
decl %r12d
movq %rbx, %rdi
movl %r12d, %esi
movq -0x30(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq %r15, %r8
callq 0x2e30
movq %rax, %r14
movq %r15, %rdi
movl $0x1, %esi
callq 0x349a
testq %r14, %r14
je 0x3343
movq %rbx, 0x10(%r14)
movq %r14, 0x18(%rbx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop