// File: /workspace/github_cpp_makefile_star2_O2/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
pushq $0x1
popq %rdx
movq %r14, %rdi
movl %edx, %esi
callq 0x31d8
movq %r14, %rdi
xorl %esi, %esi
callq 0x3238
cmpb $0x6e, %r13b
je 0x30a8
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 0x2c80
movq %rax, %r14
pushq $0x1
popq %rsi
movq %r15, %rdi
callq 0x3280
testq %r14, %r14
je 0x30a2
movq %rbx, 0x8(%r14)
movq %r14, (%rbx)
cmpb $0x73, %r13b
je 0x30e5
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 0x2c80
movq %rax, %r14
pushq $0x1
popq %rsi
movq %r15, %rdi
callq 0x3280
testq %r14, %r14
je 0x30df
movq %rbx, (%r14)
movq %r14, 0x8(%rbx)
cmpb $0x65, %r13b
je 0x311e
leal 0x1(%r12), %esi
movq %rbx, %rdi
movq -0x30(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq %r15, %r8
callq 0x2c80
movq %rax, %r14
pushq $0x1
popq %rsi
movq %r15, %rdi
callq 0x3280
testq %r14, %r14
je 0x3118
movq %rbx, 0x18(%r14)
movq %r14, 0x10(%rbx)
cmpb $0x6f, %r13b
je 0x3152
decl %r12d
movq %rbx, %rdi
movl %r12d, %esi
movq -0x30(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq %r15, %r8
callq 0x2c80
movq %rax, %r14
pushq $0x1
popq %rsi
movq %r15, %rdi
callq 0x3280
testq %r14, %r14
je 0x3152
movq %rbx, 0x10(%r14)
movq %r14, 0x18(%rbx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)