// File: /workspace/github_c_makefile_star2_O3/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 0x1dc97(%rip), %ecx     # 0x24200
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 0x6638
movq %rax, %xmm0
punpckldq 0x17056(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1705e(%rip), %xmm0    # 0x1d620
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x16a32(%rip), %xmm1    # 0x1d008
addsd 0x1707a(%rip), %xmm1    # 0x1d658
cvttsd2si %xmm1, %rax
movq %rax, %rcx
subsd 0x17062(%rip), %xmm1    # 0x1d650
sarq $0x3f, %rcx
cvttsd2si %xmm1, %rsi
andq %rcx, %rsi
orq %rax, %rsi
movq %rsi, (%r15)
movq 0x10(%r15), %rdi
addq %rsi, %rsi
leaq 0x171a3(%rip), %rdx     # 0x1d7b1
movl %r8d, %r14d
movq %r11, %rbx
callq 0x15185
movq %rbx, %r11
movl %r14d, %r8d
movq %rax, 0x10(%r15)
testq %rax, %rax
jne 0x6638
movl $0x1, %edi
callq 0x351c
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 0x668f
movq (%rsp), %rbx
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 0x6666
jmp 0x6697
xorl %ecx, %ecx
xorl %edx, %edx
movq (%rsp), %rbx
movslq 0x8(%r11), %rdi
cmpl %edi, %ebp
jge 0x66e6
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 0x66ba
movq 0x18(%r11), %rsi
movq %rsi, 0x18(%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
nop