// File: /workspace/github_c_makefile_star2_O1/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, 0x28(%rsp)
jle 0x102bd
movq %rdx, %rdi
callq 0x1055f
movq 0x28(%rsp), %r9
movq 0x18(%rsp), %rdx
xorl %r15d, %r15d
movl $0x0, %r14d
cmpl $0x2, %ebx
jl 0x102f7
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 0x102d6
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, 0x20(%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 0x10354
movq %rdx, %rdi
movq %r10, 0x48(%rsp)
callq 0x4252
movq 0x48(%rsp), %r10
movq 0x28(%rsp), %r9
movq 0x18(%rsp), %rdx
movq 0x8(%rdx), %rax
leaq 0x10(%rax), %rcx
movq %rcx, 0x70(%rsp)
movl %r12d, %ecx
leaq (%rax,%rcx,8), %rdx
addq $0x10, %rdx
movq %rdx, 0x78(%rsp)
movq 0x20(%rsp), %r8
movl %r8d, %ecx
leaq (%rdx,%rcx,8), %rsi
movslq %r14d, %rdi
leaq (%rsi,%rdi,4), %rsi
addq $0xc, %rsi
movq %rsi, (%rax)
movq %rcx, %rsi
shlq $0x4, %rsi
leaq (%rsi,%rdi,4), %rsi
leaq (%rsi,%r13,4), %rsi
shlq $0x2, %r13
addq %rax, %rsi
addq $0x34, %rsi
leaq 0x2(%r8), %rdi
xorl %r8d, %r8d
movq %rsi, 0x8(%rax,%r8,8)
addq %r13, %rsi
incq %r8
cmpq %r8, %rdi
jne 0x103ac
movq 0x10(%rax,%rcx,8), %rsi
addq %r13, %rsi
movq %rsi, -0x10(%rdx)
movl %r15d, %edx
addq %rdx, %r10
movq 0x18(%rax,%r10,8), %rdx
addq %r13, %rdx
leaq (%rax,%rcx,8), %rax
addq $0x20, %rax
movq 0x20(%rsp), %rcx
addq $0x2, %rcx
xorl %esi, %esi
movq %rdx, (%rax,%rsi,8)
addq %r13, %rdx
incq %rsi
cmpq %rsi, %rcx
jne 0x103e9
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 0x104c0
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 0x10555
movzwl (%rbp,%r13,2), %ecx
leal (%r8,%rcx), %r12d
cmpl 0x10(%rsp), %r12d
jg 0x10555
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 0x20(%rsp), %rax
movl %eax, (%rsp)
leaq 0x50(%rsp), %r8
movl 0xc(%rsp), %r9d
callq 0x105ab
testl %eax, %eax
js 0x1054b
addl %eax, %r15d
addq $0x2, %r13
movl %r14d, %edi
movl %r12d, %r8d
movl %r14d, %esi
cmpl %r13d, %ebx
movq 0x28(%rsp), %r9
jg 0x10448
jmp 0x104c6
movl %r8d, %r12d
movl %edi, %r14d
movq 0x40(%rsp), %rbx
movl 0x18(%rbx), %esi
cmpl 0x14(%rsp), %esi
jg 0x1055a
movl 0x1c(%rbx), %ecx
cmpl 0x10(%rsp), %ecx
jg 0x1055a
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 0x20(%rsp), %rax
movl %eax, (%rsp)
leaq 0x50(%rsp), %r8
movl 0xc(%rsp), %r9d
callq 0x105ab
testl %eax, %eax
js 0x1054b
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