// File: /workspace/github_c_makefile_star2_O3/thegenemyers[P]DASCRUBBER/align.c
// Function: Compute_Trace_PTS
int Compute_Trace_PTS(Alignment *align, Work_Data *ework, int trace_spacing, int mode)
{ _Work_Data *work = (_Work_Data *) ework;
  Trace_Waves wave;

  Path   *path;
  char   *aseq, *bseq;
  int     alen, blen;
  uint16 *points;
  int     tlen;
  int     ab, bb;
  int     ae, be;
  int     diffs, dmax;

  alen   = align->alen;
  blen   = align->blen;
  path   = align->path;
  aseq   = align->aseq;
  bseq   = align->bseq;
  tlen   = path->tlen;
  points = (uint16 *) path->trace;

  { int64 s;
    int   d;
    int   M, N;
    int   nmax;
    int   **PVF, **PHF;

    M = path->aepos-path->abpos;
    N = path->bepos-path->bbpos;
    if (M < N)
      s = N*sizeof(int);
    else
      s = M*sizeof(int);
    if (s > work->tramax)
      if (enlarge_trace(work,s))
        EXIT(1);

    nmax = 0;
    dmax = 0;
    for (d = 1; d < tlen; d += 2)
      { if (points[d-1] > dmax)
          dmax = points[d-1];
        if (points[d] > nmax)
          nmax = points[d];
      }
    if (tlen <= 1)
      nmax = N;
    if (dmax & 0x1)
      dmax += 1;

    s = (dmax+3)*2*((trace_spacing+nmax+3)*sizeof(int) + sizeof(int *));

    if (s > work->vecmax)
      if (enlarge_vector(work,s))
        EXIT(1);

    wave.PVF = PVF = ((int **) (work->vector)) + 2;
    wave.PHF = PHF = PVF + (dmax+3);

    s = trace_spacing+nmax+3;
    PVF[-2] = ((int *) (PHF + (dmax+1))) + (nmax+1);
    for (d = -1; d <= dmax; d++)
      PVF[d] = PVF[d-1] + s;
    PHF[-2] = PVF[dmax] + s;
    for (d = -1; d <= dmax; d++)
      PHF[d] = PHF[d-1] + s;
  }

  wave.Stop = (int *) (work->trace);
  wave.Aabs = aseq;
  wave.Babs = bseq;

  { int i, d;

    diffs = 0;
    ab = path->abpos;
    ae = (ab/trace_spacing)*trace_spacing;
    bb = path->bbpos;
    tlen -= 2;
    for (i = 1; i < tlen; i += 2)
      { ae = ae + trace_spacing;
        be = bb + points[i];
        if (ae > alen || be > blen)
          { EPRINTF(EPLACE,"%s: %s\n",Prog_Name,TP_Error);
            EXIT(1);
          }
        d  = iter_np(aseq+ab,ae-ab,bseq+bb,be-bb,&wave,mode,dmax);
        if (d < 0)
          EXIT(1);
        diffs += d;
        ab = ae;
        bb = be;
      }
    ae = path->aepos;
    be = path->bepos;
    if (ae > alen || be > blen)
      { EPRINTF(EPLACE,"%s: %s\n",Prog_Name,TP_Error);
        EXIT(1);
      }
    d  = iter_np(aseq+ab,ae-ab,bseq+bb,be-bb,&wave,mode,dmax);
    if (d < 0)
      EXIT(1);
    diffs += d;
  }

  path->trace = work->trace;
  path->tlen  = wave.Stop - ((int *) path->trace);
  path->diffs = diffs;

  return (0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movl %ecx, 0xc(%rsp)
movl %edx, %r9d
movq %rsi, %rdx
movl 0x20(%rdi), %eax
movl %eax, 0x14(%rsp)
movl 0x24(%rdi), %eax
movl %eax, 0x10(%rsp)
movq (%rdi), %rcx
movq 0x10(%rdi), %rax
movq %rax, 0x30(%rsp)
movq 0x18(%rdi), %rax
movq %rax, 0x38(%rsp)
movl 0x18(%rcx), %eax
subl 0x10(%rcx), %eax
movl 0x8(%rcx), %ebx
movl 0x1c(%rcx), %r12d
subl 0x14(%rcx), %r12d
movq %rcx, 0x40(%rsp)
movq (%rcx), %rbp
cmpl %r12d, %eax
cmovlel %r12d, %eax
movslq %eax, %rsi
shlq $0x2, %rsi
movslq 0x30(%rdx), %rax
cmpq %rax, %rsi
movq %rdx, 0x18(%rsp)
movq %r9, 0x20(%rsp)
jle 0x1009a
movq %rdx, %rdi
callq 0x10333
movq 0x20(%rsp), %r9
movq 0x18(%rsp), %rdx
xorl %r15d, %r15d
movl $0x0, %r14d
cmpl $0x2, %ebx
jl 0x100d4
xorl %r14d, %r14d
movl $0x1, %eax
xorl %r15d, %r15d
movzwl -0x2(%rbp,%rax,2), %ecx
cmpl %ecx, %r15d
cmovlel %ecx, %r15d
movzwl (%rbp,%rax,2), %ecx
cmpl %ecx, %r14d
cmovlel %ecx, %r14d
addq $0x2, %rax
cmpq %rbx, %rax
jb 0x100b3
cmpl $0x2, %ebx
cmovll %r12d, %r14d
movl %r15d, %r10d
andl $0x1, %r10d
leal (%r10,%r15), %eax
leal (%r10,%r15), %r12d
addl $0x3, %r12d
movq %rax, 0x28(%rsp)
leal 0x6(%rax,%rax), %eax
leal (%r9,%r14), %ecx
addl $0x3, %ecx
movslq %ecx, %r13
leaq 0x8(,%r13,4), %rsi
imulq %rax, %rsi
movslq (%rdx), %rax
cmpq %rax, %rsi
jle 0x10131
movq %rdx, %rdi
movq %r10, 0x48(%rsp)
callq 0x4220
movq 0x48(%rsp), %r10
movq 0x20(%rsp), %r9
movq 0x18(%rsp), %rdx
movq 0x8(%rdx), %rcx
leaq 0x10(%rcx), %rax
movq %rax, 0x70(%rsp)
movl %r12d, %eax
leaq (%rcx,%rax,8), %rdx
addq $0x10, %rdx
movq %rdx, 0x78(%rsp)
movl 0x28(%rsp), %eax
leaq (%rdx,%rax,8), %rsi
movslq %r14d, %rdi
leaq (%rsi,%rdi,4), %rsi
addq $0xc, %rsi
movq %rsi, (%rcx)
movq %rax, %rsi
shlq $0x4, %rsi
leaq (%rsi,%rdi,4), %rsi
leaq (%rsi,%r13,4), %rsi
shlq $0x2, %r13
addq %rcx, %rsi
addq $0x34, %rsi
leaq 0x2(%rax), %rdi
xorl %r8d, %r8d
movq %rsi, 0x8(%rcx,%r8,8)
addq %r13, %rsi
incq %r8
cmpq %r8, %rdi
jne 0x10185
movq 0x10(%rcx,%rax,8), %rsi
addq %r13, %rsi
movq %rsi, -0x10(%rdx)
movl %r15d, %edx
addq %rdx, %r10
movq 0x18(%rcx,%r10,8), %rdx
addq %r13, %rdx
leaq (%rcx,%rax,8), %rcx
addq $0x20, %rcx
addq $0x2, %rax
xorl %esi, %esi
movq %rdx, (%rcx,%rsi,8)
addq %r13, %rdx
incq %rsi
cmpq %rsi, %rax
jne 0x101bd
movq 0x18(%rsp), %rax
movq 0x38(%rax), %rax
movq %rax, 0x50(%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x38(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x40(%rsp), %rax
movl 0x10(%rax), %edi
movl 0x14(%rax), %r8d
xorl %r15d, %r15d
cmpl $0x4, %ebx
jl 0x10294
addl $-0x2, %ebx
movl %edi, %eax
cltd
idivl %r9d
movl %edi, %esi
subl %edx, %esi
xorl %r15d, %r15d
movl $0x1, %r13d
leal (%rsi,%r9), %r14d
cmpl 0x14(%rsp), %r14d
jg 0x10329
movzwl (%rbp,%r13,2), %ecx
leal (%r8,%rcx), %r12d
cmpl 0x10(%rsp), %r12d
jg 0x10329
movslq %edi, %rax
movq 0x30(%rsp), %rdx
leaq (%rdx,%rax), %rdi
addl %r9d, %esi
subl %eax, %esi
movslq %r8d, %rdx
addq 0x38(%rsp), %rdx
movq 0x28(%rsp), %rax
movl %eax, (%rsp)
leaq 0x50(%rsp), %r8
movl 0xc(%rsp), %r9d
callq 0x1037f
testl %eax, %eax
js 0x1031f
addl %eax, %r15d
addq $0x2, %r13
movl %r14d, %edi
movl %r12d, %r8d
movl %r14d, %esi
cmpl %r13d, %ebx
movq 0x20(%rsp), %r9
jg 0x1021c
jmp 0x1029a
movl %r8d, %r12d
movl %edi, %r14d
movq 0x40(%rsp), %rbx
movl 0x18(%rbx), %esi
cmpl 0x14(%rsp), %esi
jg 0x1032e
movl 0x1c(%rbx), %ecx
cmpl 0x10(%rsp), %ecx
jg 0x1032e
movslq %r14d, %rax
movq 0x30(%rsp), %rdi
addq %rax, %rdi
subl %eax, %esi
movslq %r12d, %rax
movq 0x38(%rsp), %rdx
addq %rax, %rdx
subl %eax, %ecx
movq 0x28(%rsp), %rax
movl %eax, (%rsp)
leaq 0x50(%rsp), %r8
movl 0xc(%rsp), %r9d
callq 0x1037f
testl %eax, %eax
js 0x1031f
addl %r15d, %eax
movq 0x18(%rsp), %rcx
movq 0x38(%rcx), %rcx
movq %rcx, (%rbx)
movq 0x50(%rsp), %rdx
subq %rcx, %rdx
shrq $0x2, %rdx
movl %edx, 0x8(%rbx)
movl %eax, 0xc(%rbx)
xorl %eax, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %edi
callq 0x1280
callq 0x135c
callq 0x132a