// File: /workspace/github_c_makefile_star2_O2/thegenemyers[P]DAMASKER/tandem.c
// Function: Fusion
static void Fusion(Path *path1, int ap, Path *path2, Trace_Buffer *tbuf)
{ int     k, k1, k2;
  int     len, diff;
  uint16 *trace;

  k1 = 2 * ((ap/MR_tspace) - (path1->abpos/MR_tspace));
  k2 = 2 * ((ap/MR_tspace) - (path2->abpos/MR_tspace));

  len = k1+(path2->tlen-k2);

  if (tbuf->top + len >= tbuf->max)
    { tbuf->max = 1.2*(tbuf->top+len) + 1000;
      tbuf->trace = (uint16 *) Realloc(tbuf->trace,sizeof(uint16)*tbuf->max,"Allocating paths");
      if (tbuf->trace == NULL)
        Clean_Exit(1);
    }

  trace = tbuf->trace + tbuf->top;
  tbuf->top += len;

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

  path1->aepos = path2->aepos;
  path1->bepos = path2->bepos;
  path1->diffs = diff;
  path1->trace = (void *) (trace - tbuf->trace);
  path1->tlen  = len;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r15
movq %rdx, %r11
movl %esi, %eax
movl 0x1d3aa(%rip), %ecx     # 0x22200
cltd
idivl %ecx
movl %eax, %ebp
movq %rdi, (%rsp)
movl 0x10(%rdi), %eax
cltd
idivl %ecx
movl %ebp, %r13d
subl %eax, %r13d
leal (,%r13,2), %r8d
movl 0x10(%r11), %eax
cltd
idivl %ecx
subl %eax, %ebp
addl %ebp, %ebp
movl 0x8(%r11), %eax
addl %r8d, %eax
subl %ebp, %eax
movslq %eax, %r12
movq 0x8(%r15), %rax
addq %r12, %rax
cmpq (%r15), %rax
jb 0x4f23
movq %rax, %xmm0
punpckldq 0x16759(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x16761(%rip), %xmm0    # 0x1b610
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x16145(%rip), %xmm1    # 0x1b008
addsd 0x1672d(%rip), %xmm1    # 0x1b5f8
cvttsd2si %xmm1, %rax
movq %rax, %rcx
subsd 0x16715(%rip), %xmm1    # 0x1b5f0
sarq $0x3f, %rcx
cvttsd2si %xmm1, %rsi
andq %rcx, %rsi
orq %rax, %rsi
movq %rsi, (%r15)
movq 0x10(%r15), %rdi
addq %rsi, %rsi
leaq 0x16876(%rip), %rdx     # 0x1b771
movl %r8d, %r14d
movq %r11, %rbx
callq 0x13535
movq %rbx, %r11
movl %r14d, %r8d
movq %rax, 0x10(%r15)
testq %rax, %rax
jne 0x4f23
pushq $0x1
popq %rdi
callq 0x242c
movq %rbx, %r11
movl %r14d, %r8d
movq 0x8(%r15), %rax
movq 0x10(%r15), %rsi
addq %rax, %r12
movq %r12, 0x8(%r15)
testl %r13d, %r13d
jle 0x4f7a
movq (%rsp), %rbx
movq (%rbx), %rcx
leaq (%rsi,%rcx,2), %rdi
movl %r8d, %r8d
leaq (%rsi,%rax,2), %r9
addq $0x2, %r9
xorl %ecx, %ecx
xorl %edx, %edx
cmpq %r8, %rcx
jae 0x4f82
movzwl (%rdi,%rcx,2), %r10d
movw %r10w, -0x2(%r9,%rcx,2)
movzwl 0x2(%rdi,%rcx,2), %r10d
movw %r10w, (%r9,%rcx,2)
movzwl (%rdi,%rcx,2), %r10d
addq $0x2, %rcx
addl %r10d, %edx
jmp 0x4f51
xorl %edx, %edx
xorl %ecx, %ecx
movq (%rsp), %rbx
movslq 0x8(%r11), %rdi
cmpl %edi, %ebp
jge 0x4fcb
movq (%r11), %r8
leaq (%rsi,%r8,2), %r8
movl %ecx, %ecx
movslq %ebp, %r9
leaq (%rsi,%rax,2), %rsi
addq $0x2, %rsi
cmpq %rdi, %r9
jge 0x4fcb
movzwl (%r8,%r9,2), %r10d
movw %r10w, -0x2(%rsi,%rcx,2)
movzwl 0x2(%r8,%r9,2), %r10d
movw %r10w, (%rsi,%rcx,2)
addq $0x2, %rcx
movzwl (%r8,%r9,2), %r10d
addl %r10d, %edx
addq $0x2, %r9
jmp 0x4f9e
movq 0x18(%r11), %rsi
movq %rsi, 0x18(%rbx)
movl %edx, 0xc(%rbx)
movq %rax, (%rbx)
movl %ecx, 0x8(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop