// File: /workspace/github_c_makefile_star2_O0/thegenemyers[P]DASCRUBBER/align.c
// Function: Compute_Trace_MID
int Compute_Trace_MID(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)*4*((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;
    int as, bs;
    int af, bf;

    diffs = 0;
    ab = as = af = path->abpos;
    ae = (ab/trace_spacing)*trace_spacing;
    bb = bs = bf = 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);
          }
        if (middle_np(aseq+ab,ae-ab,bseq+bb,be-bb,&wave,mode,dmax))
          EXIT(1);
        af = wave.mida;
        bf = wave.midb;
        d  = iter_np(aseq+as,af-as,bseq+bs,bf-bs,&wave,mode,dmax);
        if (d < 0)
          EXIT(1);
        diffs += d;
        ab = ae;
        bb = be;
        as = af;
        bs = bf;
      }

    ae = path->aepos;
    be = path->bepos;

    if (ae > alen || be > blen)
      { EPRINTF(EPLACE,"%s: %s\n",Prog_Name,TP_Error);
        EXIT(1);
      }
    if (middle_np(aseq+ab,ae-ab,bseq+bb,be-bb,&wave,mode,dmax))
      EXIT(1);
    af = wave.mida;
    bf = wave.midb;
    d  = iter_np(aseq+as,af-as,bseq+bs,bf-bs,&wave,mode,dmax);
    if (d < 0)
      EXIT(1);
    diffs += d;
    as = af;
    bs = bf;
    
    d += iter_np(aseq+af,ae-as,bseq+bf,be-bs,&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 $0x100, %rsp            # imm = 0x100
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 0x180c3
movslq -0xc4(%rbp), %rax
shlq $0x2, %rax
movq %rax, -0xb8(%rbp)
jmp 0x180d5
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 0x1810c
movq -0x20(%rbp), %rdi
movq -0xb8(%rbp), %rax
movl %eax, %esi
callq 0x16de0
cmpl $0x0, %eax
je 0x1810a
movl $0x1, %edi
callq 0x2290
jmp 0x1810c
movl $0x0, -0xc8(%rbp)
movl $0x0, -0xac(%rbp)
movl $0x1, -0xbc(%rbp)
movl -0xbc(%rbp), %eax
cmpl -0x94(%rbp), %eax
jge 0x181c0
movq -0x90(%rbp), %rax
movl -0xbc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
cmpl -0xac(%rbp), %eax
jle 0x18178
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 0x181aa
movq -0x90(%rbp), %rax
movslq -0xbc(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
movl %eax, -0xc8(%rbp)
jmp 0x181ac
movl -0xbc(%rbp), %eax
addl $0x2, %eax
movl %eax, -0xbc(%rbp)
jmp 0x1812a
cmpl $0x1, -0x94(%rbp)
jg 0x181d5
movl -0xc4(%rbp), %eax
movl %eax, -0xc8(%rbp)
movl -0xac(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x181f2
movl -0xac(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xac(%rbp)
movl -0xac(%rbp), %eax
addl $0x3, %eax
shll $0x2, %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 0x18258
movq -0x20(%rbp), %rdi
movq -0xb8(%rbp), %rax
movl %eax, %esi
callq 0x5220
cmpl $0x0, %eax
je 0x18256
movl $0x1, %edi
callq 0x2290
jmp 0x18258
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 0x1833f
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 0x182e9
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 0x183ca
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 0x18374
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, -0xec(%rbp)
movl %eax, -0xe4(%rbp)
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, -0xf0(%rbp)
movl %eax, -0xe8(%rbp)
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 0x18603
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 0x184ac
movl -0xa4(%rbp), %eax
cmpl -0x88(%rbp), %eax
jle 0x184df
movq 0x12b45(%rip), %rax     # 0x2aff8
movq (%rax), %rdi
leaq 0x13093(%rip), %rax     # 0x2b550
movq (%rax), %rdx
movq 0x12d51(%rip), %rcx     # 0x2b218
leaq 0xe178(%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 0x18830
cmpl $0x0, %eax
je 0x18538
movl $0x1, %edi
callq 0x2290
movl -0x38(%rbp), %eax
movl %eax, -0xec(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0xf0(%rbp)
movq -0x78(%rbp), %rdi
movslq -0xe4(%rbp), %rax
addq %rax, %rdi
movl -0xec(%rbp), %esi
subl -0xe4(%rbp), %esi
movq -0x80(%rbp), %rdx
movslq -0xe8(%rbp), %rax
addq %rax, %rdx
movl -0xf0(%rbp), %ecx
subl -0xe8(%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 0x185ad
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 -0xec(%rbp), %eax
movl %eax, -0xe4(%rbp)
movl -0xf0(%rbp), %eax
movl %eax, -0xe8(%rbp)
movl -0xdc(%rbp), %eax
addl $0x2, %eax
movl %eax, -0xdc(%rbp)
jmp 0x1844f
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 0x18639
movl -0xa4(%rbp), %eax
cmpl -0x88(%rbp), %eax
jle 0x1866c
movq 0x129b8(%rip), %rax     # 0x2aff8
movq (%rax), %rdi
leaq 0x12f06(%rip), %rax     # 0x2b550
movq (%rax), %rdx
movq 0x12bc4(%rip), %rcx     # 0x2b218
leaq 0xdfeb(%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 0x18830
cmpl $0x0, %eax
je 0x186c5
movl $0x1, %edi
callq 0x2290
movl -0x38(%rbp), %eax
movl %eax, -0xec(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0xf0(%rbp)
movq -0x78(%rbp), %rdi
movslq -0xe4(%rbp), %rax
addq %rax, %rdi
movl -0xec(%rbp), %esi
subl -0xe4(%rbp), %esi
movq -0x80(%rbp), %rdx
movslq -0xe8(%rbp), %rax
addq %rax, %rdx
movl -0xf0(%rbp), %ecx
subl -0xe8(%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 0x1873a
movl $0x1, %edi
callq 0x2290
movl -0xe0(%rbp), %eax
addl -0xa8(%rbp), %eax
movl %eax, -0xa8(%rbp)
movl -0xec(%rbp), %eax
movl %eax, -0xe4(%rbp)
movl -0xf0(%rbp), %eax
movl %eax, -0xe8(%rbp)
movq -0x78(%rbp), %rdi
movslq -0xec(%rbp), %rax
addq %rax, %rdi
movl -0xa0(%rbp), %esi
subl -0xe4(%rbp), %esi
movq -0x80(%rbp), %rdx
movslq -0xf0(%rbp), %rax
addq %rax, %rdx
movl -0xa4(%rbp), %ecx
subl -0xe8(%rbp), %ecx
movl -0x18(%rbp), %r9d
movl -0xac(%rbp), %eax
leaq -0x68(%rbp), %r8
movl %eax, (%rsp)
callq 0x16e60
addl -0xe0(%rbp), %eax
movl %eax, -0xe0(%rbp)
cmpl $0x0, -0xe0(%rbp)
jge 0x187cd
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 $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nopw %cs:(%rax,%rax)