// File: /workspace/github_c_makefile_star2_O1/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
movq %rdi, %rbx
movl 0x1e00d(%rip), %ecx     # 0x24200
cltd
idivl %ecx
movl %eax, %ebp
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 0x62c4
movq %rax, %xmm0
punpckldq 0x173c0(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x173c8(%rip), %xmm0    # 0x1d610
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x16dac(%rip), %xmm1    # 0x1d008
addsd 0x17394(%rip), %xmm1    # 0x1d5f8
cvttsd2si %xmm1, %rax
movq %rax, %rcx
subsd 0x1737c(%rip), %xmm1    # 0x1d5f0
sarq $0x3f, %rcx
cvttsd2si %xmm1, %rsi
andq %rcx, %rsi
orq %rax, %rsi
movq %rsi, (%r15)
movq 0x10(%r15), %rdi
addq %rsi, %rsi
leaq 0x174dd(%rip), %rdx     # 0x1d771
movl %r8d, 0x4(%rsp)
movq %r11, %r14
callq 0x14dd1
movq %r14, %r11
movl 0x4(%rsp), %r8d
movq %rax, 0x10(%r15)
testq %rax, %rax
jne 0x62c4
movl $0x1, %edi
callq 0x359c
movq %r14, %r11
movl 0x4(%rsp), %r8d
movq 0x8(%r15), %rax
movq 0x10(%r15), %rsi
addq %rax, %r12
movq %r12, 0x8(%r15)
testl %r13d, %r13d
jle 0x6317
movq (%rbx), %rcx
leaq (%rsi,%rcx,2), %rdi
movl %r8d, %r8d
leaq (%rsi,%rax,2), %r9
addq $0x2, %r9
xorl %edx, %edx
xorl %ecx, %ecx
movzwl (%rdi,%rdx,2), %r10d
movw %r10w, -0x2(%r9,%rdx,2)
movzwl 0x2(%rdi,%rdx,2), %r10d
movw %r10w, (%r9,%rdx,2)
movzwl (%rdi,%rdx,2), %r10d
addq $0x2, %rdx
addl %r10d, %ecx
cmpq %r8, %rdx
jb 0x62ee
jmp 0x631b
xorl %ecx, %ecx
xorl %edx, %edx
movslq 0x8(%r11), %rdi
cmpl %edi, %ebp
jge 0x636a
movq (%r11), %r8
leaq (%rsi,%r8,2), %r8
movslq %ebp, %r9
movl %edx, %r10d
addq %r10, %r10
leaq (%r10,%rax,2), %r10
addq %r10, %rsi
addq $0x2, %rsi
movzwl (%r8,%r9,2), %r10d
movw %r10w, -0x2(%rsi)
movzwl 0x2(%r8,%r9,2), %r10d
movw %r10w, (%rsi)
movzwl (%r8,%r9,2), %r10d
addl %r10d, %ecx
addq $0x2, %r9
addq $0x4, %rsi
addl $0x2, %edx
cmpq %rdi, %r9
jl 0x633e
movl 0x18(%r11), %esi
movl %esi, 0x18(%rbx)
movl 0x1c(%r11), %esi
movl %esi, 0x1c(%rbx)
movl %ecx, 0xc(%rbx)
movq %rax, (%rbx)
movl %edx, 0x8(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq