// File: /workspace/github_c_makefile_star2_O2/thegenemyers[P]DASCRUBBER/DASrealign.c
// Function: fusion
static void fusion(Path *path1, Path *path2, int wch)
{ static uint16  *paths = NULL;
  static int      pmax  = 0;
  static int      ptop  = 0;

  int     k;
  int     len;
  uint16 *trace;

  if (path1 == NULL)
    { ptop = 0;
      return;
    }

  len = path1->tlen + path2->tlen;

  if (ptop + len >= pmax)
    { pmax = 1.2*(ptop+len) + 1000;
      paths = (uint16 *) Realloc(paths,sizeof(uint16)*pmax,"Allocating paths");
      if (paths == NULL)
        exit (1);
    }
  trace = paths+ptop;
  ptop += len;

  len  = 0;
  if (path1->tlen > 0)
    { uint16 *t = (uint16 *) (path1->trace);
      for (k = 0; k < path1->tlen; k += 2)
        { trace[len++] = t[k];
          trace[len++] = t[k+1];
        }
    }
  if (path2->tlen > 0)
    { uint16 *t = (uint16 *) (path2->trace);
      for (k = 0; k < path2->tlen; k += 2)
        { trace[len++] = t[k];
          trace[len++] = t[k+1];
        }
    }

  if (wch == 1)
    { path1->aepos  = path2->aepos;
      path1->bepos  = path2->bepos;
      path1->diffs += path2->diffs;
      path1->trace  = trace;
      path1->tlen   = len;
    }
  else
    { path2->abpos  = path1->abpos;
      path2->bbpos  = path1->bbpos;
      path2->diffs += path1->diffs;
      path2->trace  = trace;
      path2->tlen   = len;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x2cab
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r14
movl 0x8(%rdi), %ecx
movl 0x8(%rsi), %r15d
addl %ecx, %r15d
movl 0x1c7cc(%rip), %edx     # 0x1f3d4
leal (%rdx,%r15), %esi
movq 0x1c7b5(%rip), %rax     # 0x1f3c8
cmpl 0x1c7b7(%rip), %esi     # 0x1f3d0
jl 0x2c6e
cvtsi2sd %esi, %xmm0
mulsd 0x163e1(%rip), %xmm0    # 0x19008
addsd 0x16401(%rip), %xmm0    # 0x19030
cvttsd2si %xmm0, %ecx
movl %ecx, 0x1c797(%rip)     # 0x1f3d0
movslq %ecx, %rsi
addq %rsi, %rsi
leaq 0x166ab(%rip), %rdx     # 0x192f1
movq %rax, %rdi
callq 0x11521
movq %rax, 0x1c773(%rip)     # 0x1f3c8
testq %rax, %rax
je 0x2d3c
movl 0x1c770(%rip), %edx     # 0x1f3d4
movl 0x8(%r14), %ecx
addl %edx, %r15d
movl %r15d, %esi
movslq %edx, %rdx
movl %esi, 0x1c75d(%rip)     # 0x1f3d4
testl %ecx, %ecx
jle 0x2cb4
movq (%r14), %rsi
movl %ecx, %edi
leaq (%rax,%rdx,2), %r8
addq $0x2, %r8
xorl %ecx, %ecx
cmpq %rdi, %rcx
jae 0x2cb6
movzwl (%rsi,%rcx,2), %r9d
movw %r9w, -0x2(%r8,%rcx,2)
movzwl 0x2(%rsi,%rcx,2), %r9d
movw %r9w, (%r8,%rcx,2)
addq $0x2, %rcx
jmp 0x2c8a
andl $0x0, 0x1c722(%rip)     # 0x1f3d4
jmp 0x2d31
xorl %ecx, %ecx
movslq 0x8(%rbx), %rsi
testq %rsi, %rsi
jle 0x2cfb
movq (%rbx), %rdi
movl %ecx, %ecx
leaq (%rcx,%rcx), %r8
leaq (%r8,%rdx,2), %r8
leaq (%rax,%r8), %r9
addq $0x2, %r9
xorl %r8d, %r8d
cmpq %rsi, %r8
jae 0x2cf8
movzwl (%rdi,%r8,2), %r10d
movw %r10w, -0x2(%r9,%r8,2)
movzwl 0x2(%rdi,%r8,2), %r10d
movw %r10w, (%r9,%r8,2)
addq $0x2, %r8
jmp 0x2cd7
addl %r8d, %ecx
leaq (%rax,%rdx,2), %rax
cmpl $0x1, %ebp
jne 0x2d1c
movq 0x18(%rbx), %rdx
movq %rdx, 0x18(%r14)
movl 0xc(%rbx), %edx
addl %edx, 0xc(%r14)
movq %rax, (%r14)
movl %ecx, 0x8(%r14)
jmp 0x2d31
movq 0x10(%r14), %rdx
movq %rdx, 0x10(%rbx)
movl 0xc(%r14), %edx
addl %edx, 0xc(%rbx)
movq %rax, (%rbx)
movl %ecx, 0x8(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
pushq $0x1
popq %rdi
callq 0x1270