// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
cmpq $0x0, 0x294c5(%rip)     # 0x2c560
jne 0x30d1
movslq 0x290e4(%rip), %rax     # 0x2c188
imulq $0x30, %rax, %rdi
leaq 0x2418d(%rip), %rsi     # 0x2723c
callq 0x1b7c0
movq %rax, 0x294a5(%rip)     # 0x2c560
cmpq $0x0, 0x2949d(%rip)     # 0x2c560
jne 0x30cf
movl $0x1, %edi
callq 0x2280
jmp 0x30d1
cmpl $0x0, -0x14(%rbp)
je 0x3114
cmpq $0x0, 0x29489(%rip)     # 0x2c568
jne 0x3114
movslq 0x290a4(%rip), %rdi     # 0x2c18c
shlq %rdi
leaq 0x24164(%rip), %rsi     # 0x27256
callq 0x1b7c0
movq %rax, 0x2946a(%rip)     # 0x2c568
cmpq $0x0, 0x29462(%rip)     # 0x2c568
jne 0x3112
movl $0x1, %edi
callq 0x2280
jmp 0x3114
movq -0x8(%rbp), %rdi
callq 0x2100
movq -0x8(%rbp), %rcx
leaq -0x30(%rbp), %rdi
movl $0x8, %esi
movl $0x1, %edx
callq 0x20a0
movq -0x8(%rbp), %rcx
leaq 0x292d9(%rip), %rdi     # 0x2c418
movl $0x4, %esi
movl $0x1, %edx
callq 0x20a0
cmpl $0x7d, 0x292c3(%rip)    # 0x2c418
jg 0x316d
movl $0x1, 0x2940f(%rip)     # 0x2c570
movl $0x1, 0x29409(%rip)     # 0x2c574
jmp 0x3181
movl $0x2, 0x293f9(%rip)     # 0x2c570
movl $0x0, 0x293f3(%rip)     # 0x2c574
movq -0x8(%rbp), %rdi
movq 0x293d4(%rip), %rsi     # 0x2c560
callq 0xe650
cmpl $0x0, %eax
je 0x31a9
movq 0x293c3(%rip), %rax     # 0x2c560
movl $0x7fffffff, 0x24(%rax) # imm = 0x7FFFFFFF
jmp 0x329b
cmpl $0x0, -0x14(%rbp)
je 0x3277
movq 0x293a6(%rip), %rax     # 0x2c560
movl 0x8(%rax), %eax
cmpl 0x28fc9(%rip), %eax     # 0x2c18c
jle 0x322d
movq 0x29394(%rip), %rax     # 0x2c560
cvtsi2sdl 0x8(%rax), %xmm0
movsd 0x23e2f(%rip), %xmm1    # 0x27008
mulsd %xmm1, %xmm0
movsd 0x23e2b(%rip), %xmm1    # 0x27010
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x28f99(%rip)     # 0x2c18c
movq 0x2936e(%rip), %rdi     # 0x2c568
movslq 0x28f8b(%rip), %rsi     # 0x2c18c
shlq %rsi
leaq 0x24062(%rip), %rdx     # 0x2726d
callq 0x1b840
movq %rax, 0x29351(%rip)     # 0x2c568
cmpq $0x0, 0x29349(%rip)     # 0x2c568
jne 0x322b
movl $0x1, %edi
callq 0x2280
jmp 0x322d
movq 0x29334(%rip), %rdi     # 0x2c568
movslq 0x29335(%rip), %rsi     # 0x2c570
movq 0x2931e(%rip), %rax     # 0x2c560
movslq 0x8(%rax), %rdx
movq -0x8(%rbp), %rcx
callq 0x20a0
cmpl $0x1, 0x2931a(%rip)     # 0x2c570
jne 0x3275
movq 0x29309(%rip), %rcx     # 0x2c568
movq 0x292fa(%rip), %rax     # 0x2c560
movq %rcx, (%rax)
movq 0x292f0(%rip), %rdi     # 0x2c560
callq 0xe880
jmp 0x3299
movq -0x8(%rbp), %rdi
movl 0x292ef(%rip), %eax     # 0x2c570
movq 0x292d8(%rip), %rcx     # 0x2c560
imull 0x8(%rcx), %eax
movslq %eax, %rsi
movl $0x1, %edx
callq 0x2210
jmp 0x329b
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x40(%rbp)
movl $0x0, -0x34(%rbp)
movq 0x292a9(%rip), %rax     # 0x2c560
movslq 0x24(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movslq 0x2917a(%rip), %rcx     # 0x2c444
cmpq %rcx, %rax
jge 0x364d
movq 0x29286(%rip), %rdi     # 0x2c560
movq 0x2927f(%rip), %rsi     # 0x2c560
movslq -0x34(%rbp), %rax
imulq $0x30, %rax, %rax
addq %rax, %rsi
movl $0x30, %edx
callq 0x21c0
movq 0x29263(%rip), %rax     # 0x2c560
movl 0x24(%rax), %eax
movl %eax, -0x38(%rbp)
movslq -0x38(%rbp), %rax
cmpq -0x28(%rbp), %rax
je 0x3319
movl $0x0, -0x34(%rbp)
jmp 0x3614
cmpl $0x0, -0x14(%rbp)
je 0x334a
movq 0x29242(%rip), %rdi     # 0x2c568
movq 0x2923b(%rip), %rsi     # 0x2c568
movslq -0x3c(%rbp), %rax
shlq %rax
addq %rax, %rsi
movq 0x29222(%rip), %rax     # 0x2c560
movslq 0x8(%rax), %rdx
shlq %rdx
callq 0x2230
movl $0x1, -0x34(%rbp)
movq 0x29208(%rip), %rax     # 0x2c560
movl 0x8(%rax), %eax
movl %eax, -0x3c(%rbp)
movq -0x8(%rbp), %rdi
movq 0x291f7(%rip), %rsi     # 0x2c560
movslq -0x34(%rbp), %rax
imulq $0x30, %rax, %rax
addq %rax, %rsi
callq 0xe650
cmpl $0x0, %eax
je 0x339c
movq 0x291db(%rip), %rax     # 0x2c560
movslq -0x34(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl $0x7fffffff, 0x24(%rax) # imm = 0x7FFFFFFF
jmp 0x359f
cmpl $0x0, -0x14(%rbp)
je 0x34bd
movl -0x3c(%rbp), %eax
movq 0x291b0(%rip), %rcx     # 0x2c560
movslq -0x34(%rbp), %rdx
imulq $0x30, %rdx, %rdx
addq %rdx, %rcx
addl 0x8(%rcx), %eax
cmpl 0x28dc8(%rip), %eax     # 0x2c18c
jle 0x343e
movl -0x3c(%rbp), %eax
movq 0x29190(%rip), %rcx     # 0x2c560
movslq -0x34(%rbp), %rdx
imulq $0x30, %rdx, %rdx
addq %rdx, %rcx
addl 0x8(%rcx), %eax
cvtsi2sd %eax, %xmm0
movsd 0x23c1e(%rip), %xmm1    # 0x27008
mulsd %xmm1, %xmm0
movsd 0x23c1a(%rip), %xmm1    # 0x27010
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x28d88(%rip)     # 0x2c18c
movq 0x2915d(%rip), %rdi     # 0x2c568
movslq 0x28d7a(%rip), %rsi     # 0x2c18c
shlq %rsi
leaq 0x23e51(%rip), %rdx     # 0x2726d
callq 0x1b840
movq %rax, 0x29140(%rip)     # 0x2c568
cmpq $0x0, 0x29138(%rip)     # 0x2c568
jne 0x343c
movl $0x1, %edi
callq 0x2280
jmp 0x343e
movq 0x29123(%rip), %rdi     # 0x2c568
movslq -0x3c(%rbp), %rax
shlq %rax
addq %rax, %rdi
movslq 0x2911a(%rip), %rsi     # 0x2c570
movq 0x29103(%rip), %rax     # 0x2c560
movslq -0x34(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movslq 0x8(%rax), %rdx
movq -0x8(%rbp), %rcx
callq 0x20a0
cmpl $0x1, 0x290f4(%rip)     # 0x2c570
jne 0x34bb
movq 0x290e3(%rip), %rcx     # 0x2c568
movslq -0x3c(%rbp), %rax
shlq %rax
addq %rax, %rcx
movq 0x290ca(%rip), %rax     # 0x2c560
movslq -0x34(%rbp), %rdx
imulq $0x30, %rdx, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movq 0x290b5(%rip), %rdi     # 0x2c560
movslq -0x34(%rbp), %rax
imulq $0x30, %rax, %rax
addq %rax, %rdi
callq 0xe880
jmp 0x34ea
movq -0x8(%rbp), %rdi
movl 0x290a9(%rip), %eax     # 0x2c570
movq 0x29092(%rip), %rcx     # 0x2c560
movslq -0x34(%rbp), %rdx
imulq $0x30, %rdx, %rdx
addq %rdx, %rcx
imull 0x8(%rcx), %eax
movslq %eax, %rsi
movl $0x1, %edx
callq 0x2210
movq 0x2906f(%rip), %rax     # 0x2c560
movslq -0x34(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl 0x24(%rax), %eax
cmpl -0x38(%rbp), %eax
je 0x3509
jmp 0x359f
movq 0x29050(%rip), %rax     # 0x2c560
movslq -0x34(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
addl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl 0x28c52(%rip), %eax     # 0x2c188
jl 0x359a
cvtsi2sdl -0x34(%rbp), %xmm0
movsd 0x23ac3(%rip), %xmm1    # 0x27008
mulsd %xmm1, %xmm0
movsd 0x23ac7(%rip), %xmm1    # 0x27018
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x28c29(%rip)     # 0x2c188
movq 0x28ffa(%rip), %rdi     # 0x2c560
movslq 0x28c1b(%rip), %rax     # 0x2c188
imulq $0x30, %rax, %rsi
leaq 0x23d0b(%rip), %rdx     # 0x27283
callq 0x1b840
movq %rax, 0x28fdc(%rip)     # 0x2c560
cmpq $0x0, 0x28fd4(%rip)     # 0x2c560
jne 0x3598
movl $0x1, %edi
callq 0x2280
jmp 0x359a
jmp 0x335e
movl -0x34(%rbp), %eax
cmpl -0x40(%rbp), %eax
jl 0x35ad
movl -0x34(%rbp), %eax
movl %eax, -0x40(%rbp)
movl $0x0, -0x3c(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x20(%rbp), %rax
movslq -0x34(%rbp), %rcx
cmpq %rcx, %rax
jge 0x3612
movq 0x28f98(%rip), %rcx     # 0x2c568
movslq -0x3c(%rbp), %rax
shlq %rax
addq %rax, %rcx
movq 0x28f7f(%rip), %rax     # 0x2c560
imulq $0x30, -0x20(%rbp), %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movq 0x28f6d(%rip), %rax     # 0x2c560
imulq $0x30, -0x20(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
addl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x35bc
jmp 0x3614
movq -0x28(%rbp), %rax
movslq 0x28e21(%rip), %rcx     # 0x2c440
cmpq %rcx, %rax
jl 0x363a
movq -0x10(%rbp), %rax
movq -0x28(%rbp), %rcx
movl %ecx, %edi
movq 0x28f2b(%rip), %rsi     # 0x2c560
movl -0x34(%rbp), %edx
callq *%rax
jmp 0x363c
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x32bf
movq 0x28f0c(%rip), %rax     # 0x2c560
movslq -0x34(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
cmpl $0x7fffffff, 0x24(%rax) # imm = 0x7FFFFFFF
jge 0x369e
movq 0x28989(%rip), %rax     # 0x2bff8
movq (%rax), %rdi
leaq 0x28fe7(%rip), %rax     # 0x2c660
movq (%rax), %rdx
movq 0x28af5(%rip), %rax     # 0x2c178
movl 0x38(%rax), %ecx
leaq 0x23c0f(%rip), %rsi     # 0x2729c
movb $0x0, %al
callq 0x2190
movl $0x1, %edi
callq 0x2280
movl -0x40(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)