// File: /workspace/github_c_makefile_star2_O3/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 $0x18, %rsp
movq %rdi, (%rsp)
cmpq $0x0, 0x1e668(%rip)     # 0x212d8
jne 0x2c9d
movslq 0x1e4f7(%rip), %rax     # 0x21170
shlq $0x4, %rax
leaq (%rax,%rax,2), %rdi
leaq 0x185ac(%rip), %rsi     # 0x1b234
callq 0x13119
movq %rax, 0x1e644(%rip)     # 0x212d8
testq %rax, %rax
je 0x3066
cmpq $0x0, 0x1e63b(%rip)     # 0x212e0
jne 0x2ccd
movslq 0x1e4c6(%rip), %rdi     # 0x21174
addq %rdi, %rdi
leaq 0x18596(%rip), %rsi     # 0x1b24e
callq 0x13119
movq %rax, 0x1e61c(%rip)     # 0x212e0
testq %rax, %rax
je 0x3066
movq (%rsp), %rbx
movq %rbx, %rdi
callq 0x1110
leaq 0x10(%rsp), %rdi
movl $0x8, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x10b0
leaq 0x1e4a1(%rip), %rdi     # 0x21198
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x10b0
xorl %eax, %eax
cmpl $0x7e, 0x1e486(%rip)    # 0x21198
setge %al
incl %eax
movl %eax, 0x1e5cb(%rip)     # 0x212e8
movq 0x1e5b4(%rip), %rsi     # 0x212d8
movq %rbx, %rdi
callq 0xa4eb
movq 0x1e5a5(%rip), %r13     # 0x212d8
testl %eax, %eax
je 0x2d44
movl $0x7fffffff, 0x24(%r13) # imm = 0x7FFFFFFF
jmp 0x2de0
movl 0x8(%r13), %eax
movq 0x1e591(%rip), %rdi     # 0x212e0
cmpl 0x1e41f(%rip), %eax     # 0x21174
jle 0x2da4
cvtsi2sd %eax, %xmm0
mulsd 0x182a5(%rip), %xmm0    # 0x1b008
addsd 0x182a5(%rip), %xmm0    # 0x1b010
cvttsd2si %xmm0, %eax
movl %eax, 0x1e3ff(%rip)     # 0x21174
movslq %eax, %rsi
addq %rsi, %rsi
leaq 0x184e3(%rip), %rdx     # 0x1b265
callq 0x13171
movq %rax, 0x1e552(%rip)     # 0x212e0
testq %rax, %rax
je 0x3066
movq %rax, %rdi
movq 0x1e537(%rip), %rax     # 0x212d8
movl 0x8(%rax), %eax
movl 0x1e53e(%rip), %esi     # 0x212e8
movslq %eax, %rdx
movq (%rsp), %rcx
callq 0x10b0
cmpl $0x1, 0x1e52b(%rip)     # 0x212e8
movq 0x1e514(%rip), %r13     # 0x212d8
jne 0x2de0
movq 0x1e513(%rip), %rax     # 0x212e0
movq %rax, (%r13)
movq %r13, %rdi
callq 0xa5f6
movq 0x1e4f8(%rip), %r13     # 0x212d8
movslq 0x24(%r13), %r14
xorl %r15d, %r15d
cmpl 0x1e3ce(%rip), %r14d    # 0x211bc
jge 0x3044
xorl %ebx, %ebx
xorl %ebp, %ebp
movslq %ebp, %rax
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
movupd (%r13,%rax), %xmm0
movups 0x10(%r13,%rax), %xmm1
movups 0x20(%r13,%rax), %xmm2
movups %xmm2, 0x20(%r13)
movups %xmm1, 0x10(%r13)
movupd %xmm0, (%r13)
movslq 0x24(%r13), %r12
xorl %ebp, %ebp
cmpq %r12, %r14
jne 0x3007
movq %r15, 0x8(%rsp)
movq 0x1e49f(%rip), %rdi     # 0x212e0
movslq %ebx, %rax
leaq (%rdi,%rax,2), %rsi
movslq 0x8(%r13), %rdx
addq %rdx, %rdx
callq 0x1220
movl 0x8(%r13), %ebp
addq $0x30, %r13
movq (%rsp), %rdi
movq %r13, %rsi
callq 0xa4eb
movl $0x1, %r15d
testl %eax, %eax
je 0x2e7c
movl $0x1, %ebp
jmp 0x2fc0
xorl %ebx, %ebx
movq 0x1e453(%rip), %rax     # 0x212d8
movl 0x38(%rax,%rbx), %ecx
leal (%rcx,%rbp), %edx
movq 0x1e44d(%rip), %rax     # 0x212e0
cmpl 0x1e2db(%rip), %edx     # 0x21174
jle 0x2eec
xorps %xmm0, %xmm0
cvtsi2sd %edx, %xmm0
mulsd 0x1815e(%rip), %xmm0    # 0x1b008
addsd 0x1815e(%rip), %xmm0    # 0x1b010
cvttsd2si %xmm0, %ecx
movl %ecx, 0x1e2b8(%rip)     # 0x21174
movslq %ecx, %rsi
addq %rsi, %rsi
movq %rax, %rdi
leaq 0x18399(%rip), %rdx     # 0x1b265
callq 0x13171
movq %rax, 0x1e408(%rip)     # 0x212e0
testq %rax, %rax
je 0x3066
movq 0x1e3f0(%rip), %rcx     # 0x212d8
movl 0x38(%rcx,%rbx), %ecx
movslq %ebp, %r13
leaq (%rax,%r13,2), %rdi
movl 0x1e3ef(%rip), %esi     # 0x212e8
movslq %ecx, %rdx
movq (%rsp), %rcx
callq 0x10b0
cmpl $0x1, 0x1e3dc(%rip)     # 0x212e8
jne 0x2f2f
addq %r13, %r13
addq 0x1e3c8(%rip), %r13     # 0x212e0
movq 0x1e3b9(%rip), %rax     # 0x212d8
leaq (%rax,%rbx), %rdi
addq $0x30, %rdi
movq %r13, (%rdi)
callq 0xa5f6
movq 0x1e3a2(%rip), %r13     # 0x212d8
cmpl %r12d, 0x54(%r13,%rbx)
jne 0x303c
addl 0x38(%r13,%rbx), %ebp
incq %r15
cmpl %r15d, 0x1e220(%rip)    # 0x21170
jg 0x2fa0
xorps %xmm0, %xmm0
cvtsi2sd %r15d, %xmm0
mulsd 0x180a6(%rip), %xmm0    # 0x1b008
addsd 0x180ae(%rip), %xmm0    # 0x1b018
cvttsd2si %xmm0, %eax
movl %eax, 0x1e1fc(%rip)     # 0x21170
cltq
shlq $0x4, %rax
leaq (%rax,%rax,2), %rsi
movq %r13, %rdi
leaq 0x182f3(%rip), %rdx     # 0x1b27b
callq 0x13171
movq %rax, %r13
movq %rax, 0x1e341(%rip)     # 0x212d8
testq %rax, %rax
je 0x3066
leaq (%rbx,%r13), %rsi
addq $0x60, %rsi
movq (%rsp), %rdi
callq 0xa4eb
addq $0x30, %rbx
testl %eax, %eax
je 0x2e7e
movl %r15d, %ebp
movq 0x1e311(%rip), %r13     # 0x212d8
leaq (%r15,%r15,2), %rax
shlq $0x4, %rax
movl $0x7fffffff, 0x24(%r13,%rax) # imm = 0x7FFFFFFF
movq 0x1e301(%rip), %rax     # 0x212e0
leaq 0x8(%r13), %rcx
xorl %ebx, %ebx
movslq %ebx, %rbx
leaq (%rax,%rbx,2), %rdx
movq %rdx, -0x8(%rcx)
addl (%rcx), %ebx
addq $0x30, %rcx
decq %r15
jne 0x2fe5
movq 0x8(%rsp), %r15
cmpl %r15d, %ebp
cmovgl %ebp, %r15d
movslq 0x1e1aa(%rip), %rax     # 0x211b8
cmpq %rax, %r14
jl 0x3027
movl %r14d, %edi
movq %r13, %rsi
movl %ebp, %edx
callq 0x3075
movq 0x1e2b1(%rip), %r13     # 0x212d8
incq %r14
movslq 0x1e18b(%rip), %rax     # 0x211bc
cmpq %rax, %r14
jl 0x2df8
jmp 0x3041
movl %r15d, %ebp
jmp 0x2fd8
movslq %ebp, %r15
leaq (%r15,%r15,2), %rax
shlq $0x4, %rax
cmpl $0x7fffffff, 0x24(%r13,%rax) # imm = 0x7FFFFFFF
jne 0x3070
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %edi
callq 0x1270
callq 0x12c0