// File: /workspace/github_c_makefile_star2_O1/thegenemyers[P]DASCRUBBER/DASrealign.c
// Function: make_a_pass
static int make_a_pass(FILE *input, void (*ACTION)(int, Overlap *, int), int trace)
{ static Overlap *ovls  = NULL;
  static int      omax  = 500;
  static uint16  *paths = NULL;
  static int      pmax  = 100000;

  int64 i, j, novl;
  int   n, a;
  int   pcur;
  int   max;

  if (ovls == NULL)
    { ovls = (Overlap *) Malloc(sizeof(Overlap)*omax,"Allocating overlap buffer");
      if (ovls == NULL)
        exit (1);
    }
  if (trace && paths == NULL)
    { paths = (uint16 *) Malloc(sizeof(uint16)*pmax,"Allocating path buffer");
      if (paths == NULL)
        exit (1);
    }

  rewind(input);
  fread(&novl,sizeof(int64),1,input);
  fread(&TRACE_SPACING,sizeof(int),1,input);
  if (TRACE_SPACING <= TRACE_XOVR)
    { TBYTES = sizeof(uint8);
      SMALL  = 1;
    }
  else
    { TBYTES = sizeof(uint16);
      SMALL  = 0;
    }

  if (Read_Overlap(input,ovls) != 0)
    ovls[0].aread = INT32_MAX;
  else if (trace)
    { if (ovls[0].path.tlen > pmax)
        { pmax = 1.2*(ovls[0].path.tlen)+10000;
          paths = (uint16 *) Realloc(paths,sizeof(uint16)*pmax,"Expanding path buffer");
          if (paths == NULL) exit (1);
        }
      fread(paths,TBYTES,ovls[0].path.tlen,input);
      if (TBYTES == 1)
        { ovls[0].path.trace = paths;
          Decompress_TraceTo16(ovls);
        }
    }
  else
    fseek(input,TBYTES*ovls[0].path.tlen,SEEK_CUR);

  pcur = 0;
  n = max = 0;
  for (j = ovls[0].aread; j < ADB_olast; j++)
    { ovls[0] = ovls[n];
      a = ovls[0].aread;
      if (a != j)
        n = 0;
      else
        { if (trace)
            memmove(paths,paths+pcur,sizeof(uint16)*ovls[0].path.tlen);
          n = 1;
          pcur = ovls[0].path.tlen;
          while (1)
            { if (Read_Overlap(input,ovls+n) != 0)
                { ovls[n].aread = INT32_MAX;
                  break;
                }
              if (trace)
                { if (pcur + ovls[n].path.tlen > pmax)
                    { pmax = 1.2*(pcur+ovls[n].path.tlen)+10000;
                      paths = (uint16 *) Realloc(paths,sizeof(uint16)*pmax,"Expanding path buffer");
                      if (paths == NULL) exit (1);
                    }
                  fread(paths+pcur,TBYTES,ovls[n].path.tlen,input);
                  if (TBYTES == 1)
                    { ovls[n].path.trace = paths+pcur;
                      Decompress_TraceTo16(ovls+n);
                    }
                }
              else
                fseek(input,TBYTES*ovls[n].path.tlen,SEEK_CUR);
              if (ovls[n].aread != a)
                break;
              pcur += ovls[n].path.tlen;
              n    += 1;
              if (n >= omax)
                { omax = 1.2*n + 100;
                  ovls = (Overlap *) Realloc(ovls,sizeof(Overlap)*omax,"Expanding overlap buffer");
                  if (ovls == NULL) exit (1);
                }
            }

          if (n >= max)
            max = n;
          pcur = 0;
          for (i = 0; i < n; i++)
            { ovls[i].path.trace = paths+pcur;
              pcur += ovls[i].path.tlen;
            }
        }

      if (j >= ADB_ofirst)
        ACTION(j,ovls,n);
    }

  if (ovls[n].aread < INT32_MAX)
    { fprintf(stderr,"%s: .las file overlaps don't correspond to reads in block %d of DB\n",
                     Prog_Name,ADB->part);
      exit (1);
    }

  return (max);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, 0x8(%rsp)
cmpq $0x0, 0x1e5c1(%rip)     # 0x212d8
jne 0x2d44
movslq 0x1e450(%rip), %rax     # 0x21170
shlq $0x4, %rax
leaq (%rax,%rax,2), %rdi
leaq 0x18505(%rip), %rsi     # 0x1b234
callq 0x1312d
movq %rax, 0x1e59d(%rip)     # 0x212d8
testq %rax, %rax
je 0x3143
cmpq $0x0, 0x1e594(%rip)     # 0x212e0
jne 0x2d74
movslq 0x1e41f(%rip), %rdi     # 0x21174
addq %rdi, %rdi
leaq 0x184ef(%rip), %rsi     # 0x1b24e
callq 0x1312d
movq %rax, 0x1e575(%rip)     # 0x212e0
testq %rax, %rax
je 0x3143
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x1110
leaq 0x20(%rsp), %rdi
movl $0x8, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x10b0
leaq 0x1e3f9(%rip), %rdi     # 0x21198
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x10b0
xorl %eax, %eax
cmpl $0x7e, 0x1e3de(%rip)    # 0x21198
setge %al
incl %eax
movl %eax, 0x1e523(%rip)     # 0x212e8
movq 0x1e50c(%rip), %rsi     # 0x212d8
movq %rbx, %rdi
callq 0xa590
movq 0x1e4fd(%rip), %rcx     # 0x212d8
testl %eax, %eax
je 0x2deb
movl $0x7fffffff, 0x24(%rcx) # imm = 0x7FFFFFFF
jmp 0x2e7e
movl 0x8(%rcx), %eax
cmpl 0x1e380(%rip), %eax     # 0x21174
jle 0x2e3d
cvtsi2sd %eax, %xmm0
mulsd 0x18206(%rip), %xmm0    # 0x1b008
addsd 0x18206(%rip), %xmm0    # 0x1b010
cvttsd2si %xmm0, %eax
movl %eax, 0x1e360(%rip)     # 0x21174
movq 0x1e4c5(%rip), %rdi     # 0x212e0
movslq %eax, %rsi
addq %rsi, %rsi
leaq 0x1843d(%rip), %rdx     # 0x1b265
callq 0x13185
movq %rax, 0x1e4ac(%rip)     # 0x212e0
testq %rax, %rax
je 0x3143
movq 0x1e49c(%rip), %rdi     # 0x212e0
movl 0x1e49e(%rip), %esi     # 0x212e8
movq 0x1e487(%rip), %rax     # 0x212d8
movslq 0x8(%rax), %rdx
movq 0x8(%rsp), %rcx
callq 0x10b0
cmpl $0x1, 0x1e482(%rip)     # 0x212e8
jne 0x2e7e
movq 0x1e471(%rip), %rax     # 0x212e0
movq 0x1e462(%rip), %rdi     # 0x212d8
movq %rax, (%rdi)
callq 0xa69b
movq 0x1e453(%rip), %rax     # 0x212d8
movslq 0x24(%rax), %r14
xorl %r15d, %r15d
cmpl 0x1e329(%rip), %r14d    # 0x211bc
jge 0x311b
xorl %ebx, %ebx
xorl %ebp, %ebp
movq 0x1e434(%rip), %r12     # 0x212d8
movslq %ebp, %rax
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
movupd (%r12,%rax), %xmm0
movups 0x10(%r12,%rax), %xmm1
movups 0x20(%r12,%rax), %xmm2
movups %xmm2, 0x20(%r12)
movups %xmm1, 0x10(%r12)
movupd %xmm0, (%r12)
movslq 0x24(%r12), %rcx
xorl %ebp, %ebp
movq %rcx, 0x18(%rsp)
cmpq %rcx, %r14
jne 0x30dc
movq 0x1e3f1(%rip), %rdi     # 0x212e0
movslq %ebx, %rax
leaq (%rdi,%rax,2), %rsi
movslq 0x8(%r12), %rdx
addq %rdx, %rdx
callq 0x1220
movl 0x8(%r12), %ebp
movq 0x1e3c9(%rip), %rsi     # 0x212d8
addq $0x30, %rsi
movq 0x8(%rsp), %rdi
callq 0xa590
testl %eax, %eax
je 0x2f31
movl $0x1, %r12d
movl $0x1, %ebp
jmp 0x3094
movq %r15, 0x10(%rsp)
movl $0x1, %r12d
movl $0x2, %r13d
xorl %ebx, %ebx
movq 0x1e38d(%rip), %rax     # 0x212d8
movl 0x38(%rax,%rbx), %eax
addl %ebp, %eax
cmpl 0x1e21d(%rip), %eax     # 0x21174
jle 0x2fa3
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x180a0(%rip), %xmm0    # 0x1b008
addsd 0x180a0(%rip), %xmm0    # 0x1b010
cvttsd2si %xmm0, %eax
movl %eax, 0x1e1fa(%rip)     # 0x21174
movq 0x1e35f(%rip), %rdi     # 0x212e0
movslq %eax, %rsi
addq %rsi, %rsi
leaq 0x182d7(%rip), %rdx     # 0x1b265
callq 0x13185
movq %rax, 0x1e346(%rip)     # 0x212e0
testq %rax, %rax
je 0x3143
movslq %ebp, %r15
addq %r15, %r15
movq 0x1e330(%rip), %rdi     # 0x212e0
addq %r15, %rdi
movl 0x1e32f(%rip), %esi     # 0x212e8
movq 0x1e318(%rip), %rax     # 0x212d8
movslq 0x38(%rax,%rbx), %rdx
movq 0x8(%rsp), %rcx
callq 0x10b0
cmpl $0x1, 0x1e312(%rip)     # 0x212e8
jne 0x2ff6
addq 0x1e301(%rip), %r15     # 0x212e0
movq 0x1e2f2(%rip), %rax     # 0x212d8
leaq (%rax,%rbx), %rdi
addq $0x30, %rdi
movq %r15, (%rdi)
callq 0xa69b
movq 0x1e2db(%rip), %rdi     # 0x212d8
movq 0x18(%rsp), %rax
cmpl %eax, 0x54(%rdi,%rbx)
jne 0x310e
addl 0x38(%rdi,%rbx), %ebp
cmpl %r13d, 0x1e159(%rip)    # 0x21170
jg 0x3061
xorps %xmm0, %xmm0
cvtsi2sd %r13d, %xmm0
mulsd 0x17fdf(%rip), %xmm0    # 0x1b008
addsd 0x17fe7(%rip), %xmm0    # 0x1b018
cvttsd2si %xmm0, %eax
movl %eax, 0x1e135(%rip)     # 0x21170
cltq
shlq $0x4, %rax
leaq (%rax,%rax,2), %rsi
leaq 0x1822f(%rip), %rdx     # 0x1b27b
callq 0x13185
movq %rax, 0x1e280(%rip)     # 0x212d8
testq %rax, %rax
je 0x3143
movq 0x1e270(%rip), %rax     # 0x212d8
leaq (%rax,%rbx), %rsi
addq $0x60, %rsi
movq 0x8(%rsp), %rdi
callq 0xa590
addq $0x30, %rbx
incl %r13d
incq %r12
testl %eax, %eax
je 0x2f44
movl %r12d, %ebp
movq 0x10(%rsp), %r15
movq 0x1e23d(%rip), %rax     # 0x212d8
leaq (%r12,%r12,2), %rcx
shlq $0x4, %rcx
movl $0x7fffffff, 0x24(%rax,%rcx) # imm = 0x7FFFFFFF
movq 0x1e22e(%rip), %rax     # 0x212e0
movq 0x1e21f(%rip), %rcx     # 0x212d8
addq $0x8, %rcx
xorl %ebx, %ebx
movslq %ebx, %rbx
leaq (%rax,%rbx,2), %rdx
movq %rdx, -0x8(%rcx)
addl (%rcx), %ebx
addq $0x30, %rcx
decq %r12
jne 0x30bf
cmpl %r15d, %ebp
cmovgl %ebp, %r15d
movslq 0x1e0d5(%rip), %rax     # 0x211b8
cmpq %rax, %r14
jl 0x30f9
movq 0x1e1e9(%rip), %rsi     # 0x212d8
movl %r14d, %edi
movl %ebp, %edx
callq 0x3152
incq %r14
movslq 0x1e0b9(%rip), %rax     # 0x211bc
cmpq %rax, %r14
jl 0x2e9d
jmp 0x3118
movl %r12d, %ebp
movq 0x10(%rsp), %r15
jmp 0x30ab
movslq %ebp, %r15
movq 0x1e1b6(%rip), %rax     # 0x212d8
leaq (%r15,%r15,2), %rcx
shlq $0x4, %rcx
cmpl $0x7fffffff, 0x24(%rax,%rcx) # imm = 0x7FFFFFFF
jne 0x314d
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %edi
callq 0x1270
callq 0x12c0