// File: /workspace/github_cpp_makefile_star2_O3/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, %r12d
movq 0x90(%rsp), %r15
movq 0x88(%rsp), %rbx
movq 0x70(%rsp), %r13
movslq %edi, %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0xee36
testq %rdx, (%rax)
je 0xa04c9
movq (%r13), %rax
movq 0x8(%r13), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %r14, %rdx
jbe 0xa06f2
movq 0x78(%rsp), %rdx
movq (%rdx), %rcx
movq 0x8(%rdx), %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
cmpq %r14, %rdx
jbe 0xa06f2
movq 0x80(%rsp), %rdx
movq (%rdx), %rsi
movq 0x8(%rdx), %rdx
subq %rsi, %rdx
sarq $0x2, %rdx
cmpq %r14, %rdx
jbe 0xa06f2
movl (%rax,%r14,4), %eax
movl (%rcx,%r14,4), %ebp
movl (%rsi,%r14,4), %ebx
movl %eax, %ecx
xorl 0x10(%rsp), %ecx
movl %ebp, %edx
xorl 0x8(%rsp), %edx
orl %ecx, %edx
movl %ebx, %ecx
xorl 0xc(%rsp), %ecx
orl %edx, %ecx
je 0xa0542
cmpl 0x10(%rsp), %eax
je 0xa0474
movq %r15, %rdi
xorl %esi, %esi
callq 0xee36
orq %rdx, (%rax)
cmpl 0x8(%rsp), %ebp
je 0xa048a
movl $0x1, %esi
movq %r15, %rdi
callq 0xee36
orq %rdx, (%rax)
cmpl 0xc(%rsp), %ebx
je 0xa04a0
movl $0x2, %esi
movq %r15, %rdi
callq 0xee36
orq %rdx, (%rax)
xorl %ebx, %ebx
xorl %r13d, %r13d
movq %r15, %rdi
movq %rbx, %rsi
callq 0xee36
andq (%rax), %rdx
cmpq $0x1, %rdx
sbbl $-0x1, %r13d
incq %rbx
cmpq $0x3, %rbx
jne 0xa04a5
jmp 0xa06e0
movq %rbx, %rdi
movq %r14, %rsi
callq 0xee36
orq %rdx, (%rax)
movq (%r13), %rax
movq 0x8(%r13), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %r14, %rdx
jbe 0xa06f2
movl 0x10(%rsp), %ecx
movl %ecx, (%rax,%r14,4)
movq 0x78(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %r14, %rdx
jbe 0xa06f2
movl 0x8(%rsp), %ecx
movl %ecx, (%rax,%r14,4)
movq 0x80(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %r14, %rdx
jbe 0xa06f2
movl 0xc(%rsp), %ecx
movl %ecx, (%rax,%r14,4)
movl %r12d, 0x34(%rsp)
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 %r13d, %r13d
movq %r15, %rdi
movq %rbx, %rsi
callq 0xee36
andq (%rax), %rdx
cmpq $0x1, %rdx
sbbl $-0x1, %r13d
incq %rbx
cmpq $0x3, %rbx
jne 0xa056f
cmpl $0x0, 0x20(%rsp)
jle 0xa06e0
cmpl $0x2, %r13d
ja 0xa06e0
movq 0x20(%rsp), %rax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, 0x20(%rsp)
movl $0x18, %ebp
xorl %r14d, %r14d
movq 0x28(%rsp), %rdi
movq %r14, %rsi
callq 0xee36
testq %rdx, (%rax)
jne 0xa06c8
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 %r14, %rdx
jbe 0xa06f2
movl -0x18(%rax,%rbp), %r15d
movl -0x14(%rax,%rbp), %edx
movl -0x8(%rax,%rbp), %ebx
movl -0x4(%rax,%rbp), %r12d
movl (%rax,%rbp), %ecx
movl 0x34(%rsp), %eax
cmpl %eax, %r15d
jne 0xa065a
movq 0x28(%rsp), %r15
movl %edx, 0x14(%rsp)
movq %r15, %rdi
movq %r14, %rsi
movl %ecx, %r13d
callq 0xee36
orq %rdx, (%rax)
addl 0x10(%rsp), %ebx
addl 0x8(%rsp), %r12d
addl 0xc(%rsp), %r13d
subq $0x8, %rsp
movl 0x1c(%rsp), %edi
movl %ebx, %esi
movl %r12d, %edx
movl %r13d, %ecx
movq 0x20(%rsp), %r8
movq %r15, %r9
jmp 0xa0699
cmpl %eax, %edx
jne 0xa06c8
movq 0x28(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
movl %ecx, 0x14(%rsp)
callq 0xee36
orq %rdx, (%rax)
movl 0x10(%rsp), %esi
subl %ebx, %esi
movl 0x8(%rsp), %edx
subl %r12d, %edx
movl 0xc(%rsp), %ecx
subl 0x14(%rsp), %ecx
subq $0x8, %rsp
movl %r15d, %edi
movq 0x20(%rsp), %r8
movq %r13, %r9
pushq 0x98(%rsp)
pushq 0x98(%rsp)
pushq 0x98(%rsp)
pushq 0x98(%rsp)
pushq 0x98(%rsp)
callq 0xa0393
addq $0x30, %rsp
movl %eax, %r13d
incq %r14
cmpq 0x20(%rsp), %r14
jae 0xa06e0
addq $0x1c, %rbp
cmpl $0x3, %r13d
jl 0xa05ba
movl %r13d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xacffc(%rip), %rdi     # 0x14d6f5
movq %r14, %rsi
xorl %eax, %eax
callq 0x4630