// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, -0x84(%rbp)
movq -0x8(%rbp), %rax
movl 0x24(%rax), %eax
movl %eax, -0x88(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x80(%rbp)
movq -0x70(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x94(%rbp)
movq -0x70(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x90(%rbp)
movq -0x70(%rbp), %rax
movl 0x18(%rax), %eax
movq -0x70(%rbp), %rcx
subl 0x10(%rcx), %eax
movl %eax, -0xc0(%rbp)
movq -0x70(%rbp), %rax
movl 0x1c(%rax), %eax
movq -0x70(%rbp), %rcx
subl 0x14(%rcx), %eax
movl %eax, -0xc4(%rbp)
movl -0xc0(%rbp), %eax
cmpl -0xc4(%rbp), %eax
jge 0x16813
movslq -0xc4(%rbp), %rax
shlq $0x2, %rax
movq %rax, -0xb8(%rbp)
jmp 0x16825
movslq -0xc0(%rbp), %rax
shlq $0x2, %rax
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq 0x30(%rcx), %rcx
cmpq %rcx, %rax
jle 0x1685c
movq -0x20(%rbp), %rdi
movq -0xb8(%rbp), %rax
movl %eax, %esi
callq 0x16de0
cmpl $0x0, %eax
je 0x1685a
movl $0x1, %edi
callq 0x2290
jmp 0x1685c
movl $0x0, -0xc8(%rbp)
movl $0x0, -0xac(%rbp)
movl $0x1, -0xbc(%rbp)
movl -0xbc(%rbp), %eax
cmpl -0x94(%rbp), %eax
jge 0x16910
movq -0x90(%rbp), %rax
movl -0xbc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
cmpl -0xac(%rbp), %eax
jle 0x168c8
movq -0x90(%rbp), %rax
movl -0xbc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
movl %eax, -0xac(%rbp)
movq -0x90(%rbp), %rax
movslq -0xbc(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
cmpl -0xc8(%rbp), %eax
jle 0x168fa
movq -0x90(%rbp), %rax
movslq -0xbc(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
movl %eax, -0xc8(%rbp)
jmp 0x168fc
movl -0xbc(%rbp), %eax
addl $0x2, %eax
movl %eax, -0xbc(%rbp)
jmp 0x1687a
cmpl $0x1, -0x94(%rbp)
jg 0x16925
movl -0xc4(%rbp), %eax
movl %eax, -0xc8(%rbp)
movl -0xac(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x16942
movl -0xac(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xac(%rbp)
movl -0xac(%rbp), %eax
addl $0x3, %eax
shll %eax
cltq
movl -0x14(%rbp), %ecx
addl -0xc8(%rbp), %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq $0x8, %rcx
imulq %rcx, %rax
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
cmpq %rcx, %rax
jle 0x169a7
movq -0x20(%rbp), %rdi
movq -0xb8(%rbp), %rax
movl %eax, %esi
callq 0x5220
cmpl $0x0, %eax
je 0x169a5
movl $0x1, %edi
callq 0x2290
jmp 0x169a7
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
addq $0x10, %rax
movq %rax, -0xd0(%rbp)
movq %rax, -0x48(%rbp)
movq -0xd0(%rbp), %rax
movl -0xac(%rbp), %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0xd8(%rbp)
movq %rax, -0x40(%rbp)
movl -0x14(%rbp), %eax
addl -0xc8(%rbp), %eax
addl $0x3, %eax
cltq
movq %rax, -0xb8(%rbp)
movq -0xd8(%rbp), %rcx
movl -0xac(%rbp), %eax
addl $0x1, %eax
cltq
shlq $0x3, %rax
addq %rax, %rcx
movl -0xc8(%rbp), %eax
addl $0x1, %eax
cltq
shlq $0x2, %rax
addq %rax, %rcx
movq -0xd0(%rbp), %rax
movq %rcx, -0x10(%rax)
movl $0xffffffff, -0xbc(%rbp) # imm = 0xFFFFFFFF
movl -0xbc(%rbp), %eax
cmpl -0xac(%rbp), %eax
jg 0x16a8e
movq -0xd0(%rbp), %rax
movl -0xbc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdx
movq -0xb8(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rdx
movq -0xd0(%rbp), %rax
movslq -0xbc(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0xbc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xbc(%rbp)
jmp 0x16a38
movq -0xd0(%rbp), %rax
movslq -0xac(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
movq -0xb8(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rcx
movq -0xd8(%rbp), %rax
movq %rcx, -0x10(%rax)
movl $0xffffffff, -0xbc(%rbp) # imm = 0xFFFFFFFF
movl -0xbc(%rbp), %eax
cmpl -0xac(%rbp), %eax
jg 0x16b19
movq -0xd8(%rbp), %rax
movl -0xbc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdx
movq -0xb8(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rdx
movq -0xd8(%rbp), %rax
movslq -0xbc(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0xbc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xbc(%rbp)
jmp 0x16ac3
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x50(%rbp)
movl $0x0, -0xa8(%rbp)
movq -0x70(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x98(%rbp)
movl -0x98(%rbp), %eax
cltd
idivl -0x14(%rbp)
imull -0x14(%rbp), %eax
movl %eax, -0xa0(%rbp)
movq -0x70(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x9c(%rbp)
movl -0x94(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x94(%rbp)
movl $0x1, -0xdc(%rbp)
movl -0xdc(%rbp), %eax
cmpl -0x94(%rbp), %eax
jge 0x16cb7
movl -0xa0(%rbp), %eax
addl -0x14(%rbp), %eax
movl %eax, -0xa0(%rbp)
movl -0x9c(%rbp), %eax
movq -0x90(%rbp), %rcx
movslq -0xdc(%rbp), %rdx
movzwl (%rcx,%rdx,2), %ecx
addl %ecx, %eax
movl %eax, -0xa4(%rbp)
movl -0xa0(%rbp), %eax
cmpl -0x84(%rbp), %eax
jg 0x16be3
movl -0xa4(%rbp), %eax
cmpl -0x88(%rbp), %eax
jle 0x16c16
movq 0x1440e(%rip), %rax     # 0x2aff8
movq (%rax), %rdi
leaq 0x1495c(%rip), %rax     # 0x2b550
movq (%rax), %rdx
movq 0x1461a(%rip), %rcx     # 0x2b218
leaq 0xfa41(%rip), %rsi      # 0x26646
movb $0x0, %al
callq 0x2190
movl $0x1, %edi
callq 0x2290
movq -0x78(%rbp), %rdi
movslq -0x98(%rbp), %rax
addq %rax, %rdi
movl -0xa0(%rbp), %esi
subl -0x98(%rbp), %esi
movq -0x80(%rbp), %rdx
movslq -0x9c(%rbp), %rax
addq %rax, %rdx
movl -0xa4(%rbp), %ecx
subl -0x9c(%rbp), %ecx
movl -0x18(%rbp), %r9d
movl -0xac(%rbp), %eax
leaq -0x68(%rbp), %r8
movl %eax, (%rsp)
callq 0x16e60
movl %eax, -0xe0(%rbp)
cmpl $0x0, -0xe0(%rbp)
jge 0x16c79
movl $0x1, %edi
callq 0x2290
movl -0xe0(%rbp), %eax
addl -0xa8(%rbp), %eax
movl %eax, -0xa8(%rbp)
movl -0xa0(%rbp), %eax
movl %eax, -0x98(%rbp)
movl -0xa4(%rbp), %eax
movl %eax, -0x9c(%rbp)
movl -0xdc(%rbp), %eax
addl $0x2, %eax
movl %eax, -0xdc(%rbp)
jmp 0x16b86
movq -0x70(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0xa0(%rbp)
movq -0x70(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0xa4(%rbp)
movl -0xa0(%rbp), %eax
cmpl -0x84(%rbp), %eax
jg 0x16ced
movl -0xa4(%rbp), %eax
cmpl -0x88(%rbp), %eax
jle 0x16d20
movq 0x14304(%rip), %rax     # 0x2aff8
movq (%rax), %rdi
leaq 0x14852(%rip), %rax     # 0x2b550
movq (%rax), %rdx
movq 0x14510(%rip), %rcx     # 0x2b218
leaq 0xf937(%rip), %rsi      # 0x26646
movb $0x0, %al
callq 0x2190
movl $0x1, %edi
callq 0x2290
movq -0x78(%rbp), %rdi
movslq -0x98(%rbp), %rax
addq %rax, %rdi
movl -0xa0(%rbp), %esi
subl -0x98(%rbp), %esi
movq -0x80(%rbp), %rdx
movslq -0x9c(%rbp), %rax
addq %rax, %rdx
movl -0xa4(%rbp), %ecx
subl -0x9c(%rbp), %ecx
movl -0x18(%rbp), %r9d
movl -0xac(%rbp), %eax
leaq -0x68(%rbp), %r8
movl %eax, (%rsp)
callq 0x16e60
movl %eax, -0xe0(%rbp)
cmpl $0x0, -0xe0(%rbp)
jge 0x16d83
movl $0x1, %edi
callq 0x2290
movl -0xe0(%rbp), %eax
addl -0xa8(%rbp), %eax
movl %eax, -0xa8(%rbp)
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rcx
movq -0x70(%rbp), %rax
movq %rcx, (%rax)
movq -0x68(%rbp), %rax
movq -0x70(%rbp), %rcx
movq (%rcx), %rcx
subq %rcx, %rax
sarq $0x2, %rax
movl %eax, %ecx
movq -0x70(%rbp), %rax
movl %ecx, 0x8(%rax)
movl -0xa8(%rbp), %ecx
movq -0x70(%rbp), %rax
movl %ecx, 0xc(%rax)
xorl %eax, %eax
addq $0xf0, %rsp
popq %rbp
retq
nopw (%rax,%rax)