// File: /workspace/github_c_makefile_star2_O2/thegenemyers[P]DASCRUBBER/align.c
// Function: Compute_Trace_IRR
int Compute_Trace_IRR(Alignment *align, Work_Data *ework, 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   mmax, 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 = mmax = 0;
    for (d = 0; d < tlen; d += 2)
      { if (points[d] > mmax)
          mmax = points[d];
        if (points[d+1] > nmax)
          nmax = points[d+1];
      }
    if (tlen <= 1)
      { mmax = M;
        nmax = N;
      }
    if (mmax > nmax)
      dmax = nmax;
    else
      dmax = mmax;

    s = (dmax+3)*2*((mmax+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 = mmax+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;
    bb = path->bbpos;
    for (i = 0; i < tlen; i += 2)
      { ae = ab + points[i];
        be = bb + points[i+1];
        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;
      }
  }

  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 $0x88, %rsp
movl %edx, 0x14(%rsp)
movq %rsi, %rcx
movl 0x20(%rdi), %eax
movl %eax, 0x1c(%rsp)
movl 0x24(%rdi), %eax
movl %eax, 0x18(%rsp)
movq (%rdi), %rax
movq 0x10(%rdi), %rdx
movq %rdx, 0x38(%rsp)
movq 0x18(%rdi), %rdx
movq %rdx, 0x30(%rsp)
movslq 0x8(%rax), %rbp
movl 0x18(%rax), %ebx
subl 0x10(%rax), %ebx
movq (%rax), %r12
movl 0x1c(%rax), %r15d
movq %rax, 0x20(%rsp)
subl 0x14(%rax), %r15d
cmpl %r15d, %ebx
movl %r15d, %eax
cmovgl %ebx, %eax
movslq %eax, %rsi
shlq $0x2, %rsi
movq %rcx, 0x8(%rsp)
movslq 0x30(%rcx), %rax
cmpq %rax, %rsi
jle 0x102dd
movq 0x8(%rsp), %rdi
callq 0xedbc
xorl %ecx, %ecx
xorl %eax, %eax
xorl %r14d, %r14d
cmpq %rbp, %rcx
jge 0x10306
movzwl (%r12,%rcx,2), %edx
cmpl %edx, %eax
cmovlel %edx, %eax
movzwl 0x2(%r12,%rcx,2), %edx
cmpl %edx, %r14d
cmovlel %edx, %r14d
addq $0x2, %rcx
jmp 0x102e4
cmpl $0x2, %ebp
cmovll %ebx, %eax
cmovll %r15d, %r14d
cmpl %r14d, %eax
movl %r14d, %ecx
cmovll %eax, %ecx
leal 0x3(%rcx), %r15d
movq %rcx, 0x28(%rsp)
leal 0x6(,%rcx,2), %ecx
movslq %ecx, %rcx
addl %r14d, %eax
addl $0x3, %eax
movslq %eax, %rbx
leaq 0x8(,%rbx,4), %rsi
imulq %rcx, %rsi
movq 0x8(%rsp), %r13
movslq (%r13), %rax
cmpq %rax, %rsi
jle 0x10357
movq %r13, %rdi
callq 0x3017
movq 0x8(%r13), %rcx
leaq 0x10(%rcx), %rax
movq %rax, 0x60(%rsp)
movslq %r15d, %rax
leaq (%rcx,%rax,8), %rdx
addq $0x10, %rdx
movq %rdx, 0x68(%rsp)
movslq 0x28(%rsp), %rax
leaq (%rdx,%rax,8), %rsi
movslq %r14d, %rdi
leaq 0xc(%rsi,%rdi,4), %rsi
movq %rsi, (%rcx)
pushq $-0x1
popq %rsi
shlq $0x2, %rbx
cmpq %rax, %rsi
jg 0x103a6
movq 0x8(%rcx,%rsi,8), %rdi
addq %rbx, %rdi
movq %rdi, 0x10(%rcx,%rsi,8)
incq %rsi
jmp 0x1038f
leaq (%rcx,%rax,8), %rcx
addq $0x20, %rcx
movq -0x10(%rcx), %rsi
addq %rbx, %rsi
movq %rsi, -0x10(%rdx)
pushq $-0x1
popq %rdx
movq 0x8(%rsp), %rdi
cmpq %rax, %rdx
jg 0x103d7
movq (%rcx,%rdx,8), %rsi
addq %rbx, %rsi
movq %rsi, 0x8(%rcx,%rdx,8)
incq %rdx
jmp 0x103c1
movq 0x38(%rdi), %rax
leaq 0x40(%rsp), %rcx
movq %rax, (%rcx)
movq 0x38(%rsp), %rax
movq %rax, 0x10(%rcx)
movq 0x30(%rsp), %rax
movq %rax, 0x18(%rcx)
movq 0x20(%rsp), %rax
movl 0x10(%rax), %edx
movl 0x14(%rax), %eax
xorl %r15d, %r15d
xorl %ebx, %ebx
cmpq %rbp, %r15
jge 0x10468
movzwl (%r12,%r15,2), %esi
leal (%rdx,%rsi), %r14d
cmpl 0x1c(%rsp), %r14d
jg 0x1049f
movzwl 0x2(%r12,%r15,2), %ecx
leal (%rax,%rcx), %r13d
cmpl 0x18(%rsp), %r13d
jg 0x1049f
movslq %edx, %rdi
addq 0x38(%rsp), %rdi
movslq %eax, %rdx
addq 0x30(%rsp), %rdx
movq 0x28(%rsp), %rax
movl %eax, (%rsp)
leaq 0x40(%rsp), %r8
movl 0x14(%rsp), %r9d
callq 0xee06
testl %eax, %eax
js 0x104c8
addl %eax, %ebx
addq $0x2, %r15
movl %r13d, %eax
movl %r14d, %edx
jmp 0x10405
movq 0x8(%rsp), %rax
movq 0x38(%rax), %rax
movq 0x20(%rsp), %rdx
movq %rax, (%rdx)
movq 0x40(%rsp), %rcx
subq %rax, %rcx
shrq $0x2, %rcx
movl %ecx, 0x8(%rdx)
movl %ebx, 0xc(%rdx)
xorl %eax, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xdb52(%rip), %rax      # 0x1dff8
movq (%rax), %rdi
leaq 0xde40(%rip), %rax      # 0x1e2f0
movq (%rax), %rdx
leaq 0x81a2(%rip), %rsi      # 0x1865c
leaq 0x81fe(%rip), %rcx      # 0x186bf
xorl %eax, %eax
callq 0x11a0
pushq $0x1
popq %rdi
callq 0x1280