// File: /workspace/github_c_makefile_star2_O0/thegenemyers[P]DAMASKER/tandem.c
// Function: Handle_Redundancies
static int Handle_Redundancies(Path *amatch, int novls, Trace_Buffer *tbuf)
{ Path *jpath, *kpath;
  int   j, k, no;
  int   dist, awhen = 0;

#ifdef TEST_CONTAIN
  for (j = 0; j < novls; j++)
    printf("  %3d: [%5d,%5d] x [%5d,%5d]\n",j,amatch[j].abpos,amatch[j].aepos,
                                              amatch[j].bbpos,amatch[j].bepos);
#endif

  for (j = 1; j < novls; j++)
    { jpath = amatch+j;
      for (k = j-1; k >= 0; k--)
        { kpath = amatch+k;

          if (kpath->abpos < 0)
            continue;

          if (jpath->abpos < kpath->abpos)

            { if (kpath->abpos <= jpath->aepos && kpath->bbpos <= jpath->bepos)
                { dist = Entwine(jpath,kpath,tbuf,&awhen);
                  if (dist == 0)
                    { if (kpath->aepos > jpath->aepos)
                        { Fusion(jpath,awhen,kpath,tbuf);
#ifdef TEST_CONTAIN
                          printf("  Really 3");
#endif
                          k = j;
                        }
                      kpath->abpos = -1;
#ifdef TEST_CONTAIN
                      printf("  Fuse! A %d %d\n",j,k);
#endif
                    }
                }
            }

          else // kpath->abpos <= jpath->abpos

            { if (jpath->abpos <= kpath->aepos && jpath->bbpos <= kpath->bepos)
                { dist = Entwine(kpath,jpath,tbuf,&awhen);
                  if (dist == 0)
                    { if (kpath->abpos == jpath->abpos)
                        { if (kpath->aepos > jpath->aepos)
                            *jpath = *kpath;
                        }
                      else if (jpath->aepos > kpath->aepos)
                        { Fusion(kpath,awhen,jpath,tbuf);
                          *jpath = *kpath;
#ifdef TEST_CONTAIN
                          printf("  Really 6");
#endif
                          k = j;
                        }
                      else
                        *jpath = *kpath;
                      kpath->abpos = -1;
#ifdef TEST_CONTAIN
                      printf("  Fuse! B %d %d\n",j,k);
#endif
                    }
                }
            }
        }
    }

  no = 0;
  for (j = 0; j < novls; j++)
    if (amatch[j].abpos >= 0)
      amatch[no++] = amatch[j];
  novls = no;

#ifdef TEST_CONTAIN
  for (j = 0; j < novls; j++)
    printf("  %3d: [%5d,%5d] x [%5d,%5d]\n",j,amatch[j].abpos,amatch[j].aepos,
                                              amatch[j].bbpos,amatch[j].bepos);
#endif

  return (novls);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x1, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x6b1a
movq -0x8(%rbp), %rax
movslq -0x2c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movl -0x2c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
jl 0x6b0a
movq -0x8(%rbp), %rax
movslq -0x30(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jge 0x6955
jmp 0x6afc
movq -0x20(%rbp), %rax
movl 0x10(%rax), %eax
movq -0x28(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jge 0x69df
movq -0x28(%rbp), %rax
movl 0x10(%rax), %eax
movq -0x20(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jg 0x69da
movq -0x28(%rbp), %rax
movl 0x14(%rax), %eax
movq -0x20(%rbp), %rcx
cmpl 0x1c(%rcx), %eax
jg 0x69da
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0x3c(%rbp), %rcx
callq 0x6bb0
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
jne 0x69d8
movq -0x28(%rbp), %rax
movl 0x18(%rax), %eax
movq -0x20(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jle 0x69cd
movq -0x20(%rbp), %rdi
movl -0x3c(%rbp), %esi
movq -0x28(%rbp), %rdx
movq -0x18(%rbp), %rcx
callq 0x6e40
movl -0x2c(%rbp), %eax
movl %eax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movl $0xffffffff, 0x10(%rax) # imm = 0xFFFFFFFF
jmp 0x69da
jmp 0x6afa
movq -0x20(%rbp), %rax
movl 0x10(%rax), %eax
movq -0x28(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jg 0x6af8
movq -0x20(%rbp), %rax
movl 0x14(%rax), %eax
movq -0x28(%rbp), %rcx
cmpl 0x1c(%rcx), %eax
jg 0x6af8
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0x3c(%rbp), %rcx
callq 0x6bb0
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
jne 0x6af6
movq -0x28(%rbp), %rax
movl 0x10(%rax), %eax
movq -0x20(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jne 0x6a71
movq -0x28(%rbp), %rax
movl 0x18(%rax), %eax
movq -0x20(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jle 0x6a6f
movq -0x20(%rbp), %rax
movq -0x28(%rbp), %rcx
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x10(%rcx), %rdx
movq %rdx, 0x10(%rax)
movq 0x18(%rcx), %rcx
movq %rcx, 0x18(%rax)
jmp 0x6aeb
movq -0x20(%rbp), %rax
movl 0x18(%rax), %eax
movq -0x28(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jle 0x6ac3
movq -0x28(%rbp), %rdi
movl -0x3c(%rbp), %esi
movq -0x20(%rbp), %rdx
movq -0x18(%rbp), %rcx
callq 0x6e40
movq -0x20(%rbp), %rax
movq -0x28(%rbp), %rcx
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x10(%rcx), %rdx
movq %rdx, 0x10(%rax)
movq 0x18(%rcx), %rcx
movq %rcx, 0x18(%rax)
movl -0x2c(%rbp), %eax
movl %eax, -0x30(%rbp)
jmp 0x6ae9
movq -0x20(%rbp), %rax
movq -0x28(%rbp), %rcx
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x10(%rcx), %rdx
movq %rdx, 0x10(%rax)
movq 0x18(%rcx), %rcx
movq %rcx, 0x18(%rax)
jmp 0x6aeb
movq -0x28(%rbp), %rax
movl $0xffffffff, 0x10(%rax) # imm = 0xFFFFFFFF
jmp 0x6af8
jmp 0x6afa
jmp 0x6afc
movl -0x30(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x6929
jmp 0x6b0c
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x6901
movl $0x0, -0x34(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x6b98
movq -0x8(%rbp), %rax
movslq -0x2c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $0x0, 0x10(%rax)
jl 0x6b8b
movq -0x8(%rbp), %rax
movl -0x34(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x34(%rbp)
movslq %ecx, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq -0x8(%rbp), %rcx
movslq -0x2c(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x10(%rcx), %rdx
movq %rdx, 0x10(%rax)
movq 0x18(%rcx), %rcx
movq %rcx, 0x18(%rax)
jmp 0x6b8d
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x6b28
movl -0x34(%rbp), %eax
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)