// File: /workspace/github_cpp_makefile_star2_O1/Luthaf[P]zeopp/net.cc
// Function: recursive_test_dimensionality(int, int, int, int, std::vector<CONNECTION, std::allocator<CONNECTION>>*, std::vector<bool, std::allocator<bool>>*, std::vector<int, std::allocator<int>>*, std::vector<int, std::allocator<int>>*, std::vector<int, std::allocator<int>>*, std::vector<bool, std::allocator<bool>>*, std::vector<bool, std::allocator<bool>>*)
int recursive_test_dimensionality(int this_v, int a, int b, int c, vector<CONNECTION> *two_way_connections, vector<bool> *edge_traversed, vector<int> *vertex_visit_a, vector<int> *vertex_visit_b, vector<int> *vertex_visit_c, vector<bool> *vertex_visited, vector<bool> *is_periodic) {
  bool verbose = false;
  //visit this vertex
  if(vertex_visited->at(this_v)) {
    //previously visited this vertex - have we made a loop?
    int old_a = vertex_visit_a->at(this_v);
    int old_b = vertex_visit_b->at(this_v);
    int old_c = vertex_visit_c->at(this_v);
    int period_a = a-old_a;
    int period_b = b-old_b;
    int period_c = c-old_c;
    if(period_a!=0 || period_b!=0 || period_c!=0) { //it's a loop!
if(verbose) printf("DEBUG: a loop was found with periodicity (%d %d %d)\n", period_a, period_b, period_c);
      //update periodicity
      if(period_a!=0) is_periodic->at(0) = true;
      if(period_b!=0) is_periodic->at(1) = true;
      if(period_c!=0) is_periodic->at(2) = true;
      int dimensionality = 0;
      for(int i=0; i<3; i++) {
        if(is_periodic->at(i)) dimensionality++;
      }
      return dimensionality; //quit the recursive method here - we have a loop, time to try and find some other loops
    } else {
      //else do nothing - it's not a loop, so just proceed with journey from this vertex
    }
  } else {
    //haven't previously visited this vertex; visit it
    vertex_visited->at(this_v) = true;
    vertex_visit_a->at(this_v) = a;
    vertex_visit_b->at(this_v) = b;
    vertex_visit_c->at(this_v) = c;
  }
  //at this point, we have either completed a loop, or visited a vertex that did not complete a loop; only if a loop was found do we quit out - else proceed to recursively traverse other connections - if we find three-dimensionality during this run, terminate early
  int num_c = two_way_connections->size();
  int dimensionality = 0;
  for(int i=0; i<3; i++) {
    if(is_periodic->at(i)) dimensionality++;
  }
  for(int i=0; i<num_c && dimensionality<3; i++) {
    if(!edge_traversed->at(i)) {
      //only traverse new edges
      CONNECTION con = two_way_connections->at(i);
      if(con.v1==this_v) {
        //traverse this edge
        edge_traversed->at(i) = true;
        //don't visit the vertex - that will happen in next call
        int new_a = a+con.a;
        int new_b = b+con.b;
        int new_c = c+con.c;
        dimensionality = recursive_test_dimensionality(con.v2, new_a, new_b, new_c, two_way_connections, edge_traversed, vertex_visit_a, vertex_visit_b, vertex_visit_c, vertex_visited, is_periodic);
      } else if(con.v2==this_v) {
        //traverse this edge, pointing the other way
        edge_traversed->at(i) = true;
        //don't visit the vertex - that will happen in next call
        int new_a = a-con.a;
        int new_b = b-con.b;
        int new_c = c-con.c;
        dimensionality = recursive_test_dimensionality(con.v1, new_a, new_b, new_c, two_way_connections, edge_traversed, vertex_visit_a, vertex_visit_b, vertex_visit_c, vertex_visited, is_periodic);
      }
    }
  }
  return dimensionality;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, 0x28(%rsp)
movq %r8, 0x18(%rsp)
movl %ecx, 0xc(%rsp)
movl %edx, 0x8(%rsp)
movl %esi, 0x10(%rsp)
movl %edi, 0x34(%rsp)
movq 0x90(%rsp), %r12
movq 0x88(%rsp), %rbx
movq 0x70(%rsp), %r14
movslq %edi, %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0xedb6
testq %rdx, (%rax)
je 0xa219e
movq (%r14), %rax
movq 0x8(%r14), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %r15, %rdx
jbe 0xa23c4
movq 0x78(%rsp), %rdx
movq (%rdx), %rcx
movq 0x8(%rdx), %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
cmpq %r15, %rdx
jbe 0xa23c4
movq 0x80(%rsp), %rdx
movq (%rdx), %rsi
movq 0x8(%rdx), %rdx
subq %rsi, %rdx
sarq $0x2, %rdx
cmpq %r15, %rdx
jbe 0xa23c4
movl (%rax,%r15,4), %eax
movl (%rcx,%r15,4), %r14d
movl (%rsi,%r15,4), %ebx
movl %eax, %ecx
xorl 0x10(%rsp), %ecx
movl %r14d, %edx
xorl 0x8(%rsp), %edx
orl %ecx, %edx
movl %ebx, %ecx
xorl 0xc(%rsp), %ecx
orl %edx, %ecx
setne %bpl
je 0xa2194
cmpl 0x10(%rsp), %eax
je 0xa2143
movq %r12, %rdi
xorl %esi, %esi
callq 0xedb6
orq %rdx, (%rax)
cmpl 0x8(%rsp), %r14d
je 0xa215a
movl $0x1, %esi
movq %r12, %rdi
callq 0xedb6
orq %rdx, (%rax)
cmpl 0xc(%rsp), %ebx
je 0xa2170
movl $0x2, %esi
movq %r12, %rdi
callq 0xedb6
orq %rdx, (%rax)
xorl %ebx, %ebx
xorl %r15d, %r15d
movq %r12, %rdi
movq %rbx, %rsi
callq 0xedb6
andq (%rax), %rdx
cmpq $0x1, %rdx
sbbl $-0x1, %r15d
incq %rbx
cmpq $0x3, %rbx
jne 0xa2175
testb %bpl, %bpl
je 0xa2216
jmp 0xa23a6
movq %rbx, %rdi
movq %r15, %rsi
callq 0xedb6
orq %rdx, (%rax)
movq (%r14), %rax
movq 0x8(%r14), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %r15, %rdx
jbe 0xa23c4
movl 0x10(%rsp), %ecx
movl %ecx, (%rax,%r15,4)
movq 0x78(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %r15, %rdx
jbe 0xa23c4
movl 0x8(%rsp), %ecx
movl %ecx, (%rax,%r15,4)
movq 0x80(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %r15, %rdx
jbe 0xa23c4
movl 0xc(%rsp), %ecx
movl %ecx, (%rax,%r15,4)
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rcx
subq (%rax), %rcx
sarq $0x2, %rcx
movabsq $0x6db6db6db6db6db7, %rax # imm = 0x6DB6DB6DB6DB6DB7
imulq %rax, %rcx
movq %rcx, 0x20(%rsp)
xorl %ebx, %ebx
xorl %r15d, %r15d
movq %r12, %rdi
movq %rbx, %rsi
callq 0xedb6
andq (%rax), %rdx
cmpq $0x1, %rdx
sbbl $-0x1, %r15d
incq %rbx
cmpq $0x3, %rbx
jne 0xa223e
cmpl $0x0, 0x20(%rsp)
jle 0xa23a6
cmpl $0x2, %r15d
ja 0xa23a6
movq 0x20(%rsp), %rax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, 0x20(%rsp)
movl $0x18, %r13d
xorl %r12d, %r12d
movq 0x28(%rsp), %rdi
movq %r12, %rsi
callq 0xedb6
testq %rdx, (%rax)
jne 0xa238e
movq 0x18(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
movabsq $0x6db6db6db6db6db7, %rcx # imm = 0x6DB6DB6DB6DB6DB7
imulq %rcx, %rdx
cmpq %r12, %rdx
jbe 0xa23b8
movl -0x18(%rax,%r13), %ebp
movl -0x14(%rax,%r13), %edx
movl -0x8(%rax,%r13), %ebx
movl -0x4(%rax,%r13), %r14d
movl (%rax,%r13), %ecx
movl 0x34(%rsp), %eax
cmpl %eax, %ebp
jne 0xa2321
movq 0x28(%rsp), %r15
movl %edx, 0x14(%rsp)
movq %r15, %rdi
movq %r12, %rsi
movl %ecx, %ebp
callq 0xedb6
orq %rdx, (%rax)
addl 0x10(%rsp), %ebx
addl 0x8(%rsp), %r14d
addl 0xc(%rsp), %ebp
subq $0x8, %rsp
movl 0x1c(%rsp), %edi
movl %ebx, %esi
movl %r14d, %edx
movl %ebp, %ecx
jmp 0xa2357
cmpl %eax, %edx
jne 0xa238e
movq 0x28(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
movl %ecx, 0x14(%rsp)
callq 0xedb6
orq %rdx, (%rax)
movl 0x10(%rsp), %esi
subl %ebx, %esi
movl 0x8(%rsp), %edx
subl %r14d, %edx
movl 0xc(%rsp), %ecx
subl 0x14(%rsp), %ecx
subq $0x8, %rsp
movl %ebp, %edi
movq 0x20(%rsp), %r8
movq %r15, %r9
pushq 0x98(%rsp)
pushq 0x98(%rsp)
pushq 0x98(%rsp)
pushq 0x98(%rsp)
pushq 0x98(%rsp)
callq 0xa2061
addq $0x30, %rsp
movl %eax, %r15d
incq %r12
cmpq 0x20(%rsp), %r12
jae 0xa23a6
addq $0x1c, %r13
cmpl $0x3, %r15d
jl 0xa228a
movl %r15d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xad2e6(%rip), %rdi     # 0x14f6a5
movq %r12, %rsi
jmp 0xa23ce
leaq 0xad2da(%rip), %rdi     # 0x14f6a5
movq %r15, %rsi
xorl %eax, %eax
callq 0x4630