// File: Luthaf[P]zeopp/net.cc
// Function: loop_is_unique(int, int, int, std::vector<int, std::allocator<int>>*, std::vector<int, std::allocator<int>>*, std::vector<int, std::allocator<int>>*)
bool loop_is_unique(int a, int b, int c, vector<int> *loops_a, vector<int> *loops_b, vector<int> *loops_c) {
  bool verbose = false;
  bool unique = true; //unique until proven otherwise
  int num_loops = loops_a->size();
if(verbose) printf("DEBUG: testing new loop uniqueness versus %d existing loops\n", num_loops);
  for(int i=0; i<num_loops && unique; i++) {
if(verbose) printf("DEBUG: checking against existing loop %d: (%d %d %d)\n", i, loops_a->at(i), loops_b->at(i), loops_c->at(i));
    //first, test for plain equivalence
    if(a==loops_a->at(i) && b==loops_b->at(i) && c==loops_c->at(i)) {
      unique = false;
if(verbose) printf("DEBUG: trivial equivalence\n");
    } else {
      //second, we are definitely unique if there are any zero-nonzero pairings
      vector<double> ratios;
      bool zero_nonzero_pairing = false;
      if((a==0 && loops_a->at(i)!=0) || (a!=0 && loops_a->at(i)==0)) zero_nonzero_pairing = true; else if(a!=0 && loops_a->at(i)!=0) ratios.push_back(((double)(a))/loops_a->at(i));
      if((b==0 && loops_b->at(i)!=0) || (b!=0 && loops_b->at(i)==0)) zero_nonzero_pairing = true; else if(b!=0 && loops_b->at(i)!=0) ratios.push_back(((double)(b))/loops_b->at(i));
      if((c==0 && loops_c->at(i)!=0) || (c!=0 && loops_c->at(i)==0)) zero_nonzero_pairing = true; else if(c!=0 && loops_c->at(i)!=0) ratios.push_back(((double)(c))/loops_c->at(i));
      if(!zero_nonzero_pairing) {
        //third, given that there was no zero-nonzero pairing, check the ratios to see if one is a multiple of the other
        int num_ratios = ratios.size();
        if(num_ratios==0) {
          printf("ERROR: passed trivial equivalence filter but both loops are completely zero (no ratios between elements could be found)\n");
          exit(EXIT_FAILURE);
        }
        double ratio = ratios.at(0); //there should always be at least one ratio, otherwise we would have been caught by the trivial equivalence filter
        unique = false; //here we assume not unique, and it becomes unique if any ratios are different
        for(int j=1; j<num_ratios && !unique; j++) {
          if(ratio!=ratios.at(j)) unique = true;
        }
if(verbose && !unique) printf("DEBUG: equivalence by ratio (%.3f)\n", ratio);
      }
    }
  }
  return unique;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
movq %rcx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movb $0x0, -0x29(%rbp)
movb $0x1, -0x2a(%rbp)
movq -0x18(%rbp), %rdi
callq 0x10090
movl %eax, -0x30(%rbp)
testb $0x1, -0x29(%rbp)
je 0x112c8b
movl -0x30(%rbp), %esi
leaq 0xea75f(%rip), %rdi     # 0x1fd3e3
movb $0x0, %al
callq 0x5070
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %ecx
xorl %eax, %eax
cmpl -0x30(%rbp), %ecx
movb %al, -0x95(%rbp)
jge 0x112cab
movb -0x2a(%rbp), %al
movb %al, -0x95(%rbp)
movb -0x95(%rbp), %al
testb $0x1, %al
jne 0x112cba
jmp 0x113180
testb $0x1, -0x29(%rbp)
je 0x112d23
movl -0x34(%rbp), %eax
movl %eax, -0xa4(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x101d0
movl (%rax), %eax
movl %eax, -0xa0(%rbp)
movq -0x20(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x101d0
movl (%rax), %eax
movl %eax, -0x9c(%rbp)
movq -0x28(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x101d0
movl -0xa4(%rbp), %esi
movl -0xa0(%rbp), %edx
movl -0x9c(%rbp), %ecx
movl (%rax), %r8d
leaq 0xea704(%rip), %rdi     # 0x1fd420
movb $0x0, %al
callq 0x5070
movl -0x4(%rbp), %eax
movl %eax, -0xa8(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x101d0
movq %rax, %rcx
movl -0xa8(%rbp), %eax
cmpl (%rcx), %eax
jne 0x112da9
movl -0x8(%rbp), %eax
movl %eax, -0xac(%rbp)
movq -0x20(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x101d0
movq %rax, %rcx
movl -0xac(%rbp), %eax
cmpl (%rcx), %eax
jne 0x112da9
movl -0xc(%rbp), %eax
movl %eax, -0xb0(%rbp)
movq -0x28(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x101d0
movq %rax, %rcx
movl -0xb0(%rbp), %eax
cmpl (%rcx), %eax
jne 0x112da9
movb $0x0, -0x2a(%rbp)
testb $0x1, -0x29(%rbp)
je 0x112da4
leaq 0xea6b9(%rip), %rdi     # 0x1fd456
movb $0x0, %al
callq 0x5070
jmp 0x113170
leaq -0x50(%rbp), %rdi
callq 0xf650
movb $0x0, -0x51(%rbp)
cmpl $0x0, -0x4(%rbp)
jne 0x112dde
movq -0x18(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x101d0
movq %rax, -0xb8(%rbp)
jmp 0x112dd2
movq -0xb8(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x112e06
cmpl $0x0, -0x4(%rbp)
je 0x112e29
movq -0x18(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x101d0
movq %rax, -0xc0(%rbp)
jmp 0x112dfa
movq -0xc0(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x112e29
movb $0x1, -0x51(%rbp)
jmp 0x112ea3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x50(%rbp), %rdi
callq 0xf9d0
jmp 0x11318e
cmpl $0x0, -0x4(%rbp)
je 0x112ea1
movq -0x18(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x101d0
movq %rax, -0xc8(%rbp)
jmp 0x112e45
movq -0xc8(%rbp), %rax
cmpl $0x0, (%rax)
je 0x112ea1
cvtsi2sdl -0x4(%rbp), %xmm0
movsd %xmm0, -0xd8(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x101d0
movq %rax, -0xd0(%rbp)
jmp 0x112e74
movsd -0xd8(%rbp), %xmm0
movq -0xd0(%rbp), %rax
cvtsi2sdl (%rax), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x70(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0xf6d0
jmp 0x112e9f
jmp 0x112ea1
jmp 0x112ea3
cmpl $0x0, -0x8(%rbp)
jne 0x112ecb
movq -0x20(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x101d0
movq %rax, -0xe0(%rbp)
jmp 0x112ebf
movq -0xe0(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x112ef3
cmpl $0x0, -0x8(%rbp)
je 0x112ef9
movq -0x20(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x101d0
movq %rax, -0xe8(%rbp)
jmp 0x112ee7
movq -0xe8(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x112ef9
movb $0x1, -0x51(%rbp)
jmp 0x112f73
cmpl $0x0, -0x8(%rbp)
je 0x112f71
movq -0x20(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x101d0
movq %rax, -0xf0(%rbp)
jmp 0x112f15
movq -0xf0(%rbp), %rax
cmpl $0x0, (%rax)
je 0x112f71
cvtsi2sdl -0x8(%rbp), %xmm0
movsd %xmm0, -0x100(%rbp)
movq -0x20(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x101d0
movq %rax, -0xf8(%rbp)
jmp 0x112f44
movsd -0x100(%rbp), %xmm0
movq -0xf8(%rbp), %rax
cvtsi2sdl (%rax), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x78(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0xf6d0
jmp 0x112f6f
jmp 0x112f71
jmp 0x112f73
cmpl $0x0, -0xc(%rbp)
jne 0x112f9b
movq -0x28(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x101d0
movq %rax, -0x108(%rbp)
jmp 0x112f8f
movq -0x108(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x112fc3
cmpl $0x0, -0xc(%rbp)
je 0x112fc9
movq -0x28(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x101d0
movq %rax, -0x110(%rbp)
jmp 0x112fb7
movq -0x110(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x112fc9
movb $0x1, -0x51(%rbp)
jmp 0x113043
cmpl $0x0, -0xc(%rbp)
je 0x113041
movq -0x28(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x101d0
movq %rax, -0x118(%rbp)
jmp 0x112fe5
movq -0x118(%rbp), %rax
cmpl $0x0, (%rax)
je 0x113041
cvtsi2sdl -0xc(%rbp), %xmm0
movsd %xmm0, -0x128(%rbp)
movq -0x28(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x101d0
movq %rax, -0x120(%rbp)
jmp 0x113014
movsd -0x128(%rbp), %xmm0
movq -0x120(%rbp), %rax
cvtsi2sdl (%rax), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x80(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0xf6d0
jmp 0x11303f
jmp 0x113041
jmp 0x113043
testb $0x1, -0x51(%rbp)
jne 0x113167
leaq -0x50(%rbp), %rdi
callq 0xf990
movl %eax, -0x84(%rbp)
cmpl $0x0, -0x84(%rbp)
jne 0x11307f
leaq 0xea406(%rip), %rdi     # 0x1fd472
xorl %eax, %eax
callq 0x5070
jmp 0x113075
movl $0x1, %edi
callq 0x67c0
xorl %eax, %eax
movl %eax, %esi
leaq -0x50(%rbp), %rdi
callq 0xfc80
movq %rax, -0x130(%rbp)
jmp 0x113095
movq -0x130(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x90(%rbp)
movb $0x0, -0x2a(%rbp)
movl $0x1, -0x94(%rbp)
movl -0x94(%rbp), %ecx
xorl %eax, %eax
cmpl -0x84(%rbp), %ecx
movb %al, -0x131(%rbp)
jge 0x1130d7
movb -0x2a(%rbp), %al
xorb $-0x1, %al
movb %al, -0x131(%rbp)
movb -0x131(%rbp), %al
testb $0x1, %al
jne 0x1130e3
jmp 0x11313f
movsd -0x90(%rbp), %xmm0
movsd %xmm0, -0x148(%rbp)
movslq -0x94(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0xfc80
movq %rax, -0x140(%rbp)
jmp 0x11310c
movsd -0x148(%rbp), %xmm0
movq -0x140(%rbp), %rax
ucomisd (%rax), %xmm0
jne 0x113125
jp 0x113125
jmp 0x113129
movb $0x1, -0x2a(%rbp)
jmp 0x11312b
movl -0x94(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x94(%rbp)
jmp 0x1130b6
testb $0x1, -0x29(%rbp)
je 0x113165
testb $0x1, -0x2a(%rbp)
jne 0x113165
movsd -0x90(%rbp), %xmm0
leaq 0xea391(%rip), %rdi     # 0x1fd4eb
movb $0x1, %al
callq 0x5070
jmp 0x113163
jmp 0x113165
jmp 0x113167
leaq -0x50(%rbp), %rdi
callq 0xf9d0
jmp 0x113172
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x112c92
movb -0x2a(%rbp), %al
andb $0x1, %al
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
movq -0x60(%rbp), %rdi
callq 0x58f0
nopw (%rax,%rax)