// File: /workspace/github_c_makefile_star2_O2/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, 0x1c(%rsp)
movq %rdx, 0x40(%rsp)
movq %rsi, %rcx
movl 0x20(%rdi), %eax
movl %eax, 0x24(%rsp)
movl 0x24(%rdi), %eax
movl %eax, 0x20(%rsp)
movq (%rdi), %r13
movq 0x10(%rdi), %rax
movq %rax, 0x30(%rsp)
movq 0x18(%rdi), %rax
movq %rax, 0x38(%rsp)
movl 0x18(%r13), %eax
subl 0x10(%r13), %eax
movslq 0x8(%r13), %r15
movl 0x1c(%r13), %ebx
subl 0x14(%r13), %ebx
movq (%r13), %rbp
cmpl %ebx, %eax
cmovlel %ebx, %eax
movslq %eax, %rsi
shlq $0x2, %rsi
movq %rcx, 0x10(%rsp)
movslq 0x30(%rcx), %rax
cmpq %rax, %rsi
jle 0xeb5c
movq 0x10(%rsp), %rdi
callq 0xedbc
xorl %eax, %eax
pushq $0x1
popq %rcx
xorl %r12d, %r12d
cmpq %r15, %rcx
jge 0xeb85
movzwl -0x2(%rbp,%rcx,2), %edx
cmpl %edx, %eax
cmovlel %edx, %eax
movzwl (%rbp,%rcx,2), %edx
cmpl %edx, %r12d
cmovlel %edx, %r12d
addq $0x2, %rcx
jmp 0xeb64
cmpl $0x2, %r15d
cmovll %ebx, %r12d
movl %eax, %ecx
andl $0x1, %ecx
leal (%rcx,%rax), %edx
leal (%rcx,%rax), %r14d
addl $0x3, %r14d
movq %rdx, 0x28(%rsp)
leal 0x6(%rdx,%rdx), %eax
movq 0x40(%rsp), %rcx
addl %r12d, %ecx
addl $0x3, %ecx
movslq %ecx, %rbx
leaq 0x8(,%rbx,4), %rsi
imulq %rax, %rsi
movq 0x10(%rsp), %rdi
movslq (%rdi), %rax
cmpq %rax, %rsi
jle 0xebd7
callq 0x3017
movq 0x10(%rsp), %rdi
movq 0x8(%rdi), %rcx
leaq 0x10(%rcx), %rax
movq %rax, 0x70(%rsp)
movl %r14d, %edx
leaq (%rcx,%rdx,8), %rsi
addq $0x10, %rsi
movq %rsi, 0x78(%rsp)
movl 0x28(%rsp), %eax
leaq (%rsi,%rax,8), %rsi
movslq %r12d, %rdi
leaq 0xc(%rsi,%rdi,4), %rsi
movq %rsi, (%rcx)
pushq $-0x1
popq %rsi
shlq $0x2, %rbx
cmpq %rax, %rsi
jg 0xec25
movq 0x8(%rcx,%rsi,8), %rdi
addq %rbx, %rdi
movq %rdi, 0x10(%rcx,%rsi,8)
incq %rsi
jmp 0xec0e
movq 0x10(%rcx,%rax,8), %rsi
addq %rbx, %rsi
leaq (%rcx,%rdx,8), %rcx
addq $0x8, %rcx
movq %rsi, -0x8(%rcx)
pushq $-0x1
popq %rdx
cmpq %rax, %rdx
jg 0xec52
movq (%rcx,%rdx,8), %rsi
addq %rbx, %rsi
movq %rsi, 0x8(%rcx,%rdx,8)
incq %rdx
jmp 0xec3c
movq 0x10(%rsp), %rax
movq 0x38(%rax), %rax
leaq 0x50(%rsp), %rcx
movq %rax, (%rcx)
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rcx)
movq 0x38(%rsp), %rax
movq %rax, 0x18(%rcx)
movl 0x10(%r13), %ebx
movq %r13, 0x48(%rsp)
movl 0x14(%r13), %r12d
movl %ebx, %eax
cltd
movq 0x40(%rsp), %rsi
idivl %esi
addl $-0x2, %r15d
movslq %r15d, %r13
movl %ebx, %ecx
addl %esi, %ecx
subl %edx, %ecx
xorl %r15d, %r15d
pushq $0x1
popq %r14
movslq %ebx, %rax
movslq %r12d, %rdx
cmpq %r13, %r14
jge 0xed0d
movl %ecx, %ebx
cmpl 0x24(%rsp), %ecx
jg 0xed8b
movzwl (%rbp,%r14,2), %ecx
addl %ecx, %r12d
cmpl 0x20(%rsp), %r12d
jg 0xed8b
movq 0x30(%rsp), %rsi
leaq (%rsi,%rax), %rdi
movl %ebx, %esi
subl %eax, %esi
addq 0x38(%rsp), %rdx
movq 0x28(%rsp), %rax
movl %eax, (%rsp)
leaq 0x50(%rsp), %r8
movl 0x1c(%rsp), %r9d
callq 0xee06
testl %eax, %eax
js 0xedb4
addl %eax, %r15d
addq $0x2, %r14
movq 0x40(%rsp), %rax
leal (%rbx,%rax), %ecx
jmp 0xeca0
movq 0x48(%rsp), %rbx
movl 0x18(%rbx), %esi
cmpl 0x24(%rsp), %esi
jg 0xed8b
movl 0x1c(%rbx), %ecx
cmpl 0x20(%rsp), %ecx
jg 0xed8b
movq 0x30(%rsp), %rdi
addq %rax, %rdi
subl %eax, %esi
movq 0x38(%rsp), %rax
addq %rdx, %rax
subl %edx, %ecx
movq 0x28(%rsp), %rdx
movl %edx, (%rsp)
leaq 0x50(%rsp), %r8
movq %rax, %rdx
movl 0x1c(%rsp), %r9d
callq 0xee06
testl %eax, %eax
js 0xedb4
addl %r15d, %eax
movq 0x10(%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
movq 0xf266(%rip), %rax      # 0x1dff8
movq (%rax), %rdi
leaq 0xf554(%rip), %rax      # 0x1e2f0
movq (%rax), %rdx
leaq 0x98b6(%rip), %rsi      # 0x1865c
leaq 0x9912(%rip), %rcx      # 0x186bf
xorl %eax, %eax
callq 0x11a0
pushq $0x1
popq %rdi
callq 0x1280