// File: /workspace/github_cpp_makefile_star2_O1/jstaursky[P]hutch/src/Sleigh/slghpatexpress.cc
// Function: TokenPattern::commonSubPattern(TokenPattern const&) const
TokenPattern TokenPattern::commonSubPattern(const TokenPattern &tokpat) const

{				// Construct pattern that matches anything
				// that matches either -this- or -tokpat-
  TokenPattern patres((Pattern *)0); // Empty shell
  int4 i;
  bool reversedirection = false;

  if (leftellipsis||tokpat.leftellipsis) {
    if (rightellipsis||tokpat.rightellipsis)
      throw SleighError("Right/left ellipsis in commonSubPattern");
    reversedirection = true;
  }

				// Find common subset of tokens and ellipses
  patres.leftellipsis = leftellipsis || tokpat.leftellipsis;
  patres.rightellipsis = rightellipsis || tokpat.rightellipsis;
  int4 minnum = toklist.size();
  int4 maxnum = tokpat.toklist.size();
  if (maxnum < minnum) {
    int4 tmp = minnum;
    minnum = maxnum;
    maxnum = tmp;
  }
  if (reversedirection) {
    for(i=0;i<minnum;++i) {
      Token *tok = toklist[toklist.size()-1-i];
      if (tok == tokpat.toklist[tokpat.toklist.size()-1-i])
	patres.toklist.insert(patres.toklist.begin(),tok);
      else
	break;
    }
    if (i<maxnum)
      patres.leftellipsis = true;
  }
  else {
    for(i=0;i<minnum;++i) {
      Token *tok = toklist[i];
      if (tok == tokpat.toklist[i])
	patres.toklist.push_back(tok);
      else
	break;
    }
    if (i<maxnum)
      patres.rightellipsis = true;
  }
  
  patres.pattern = pattern->commonSubPattern(tokpat.pattern,0);
  return patres;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r14
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rdi)
movups %xmm0, (%rdi)
movw $0x0, 0x20(%rdi)
movb 0x20(%rsi), %cl
testb %cl, %cl
movq %rdi, 0x10(%rsp)
jne 0x5c312
cmpb $0x1, 0x20(%r15)
jne 0x5c37a
cmpb $0x0, 0x21(%r12)
jne 0x5c323
movb $0x1, %al
cmpb $0x1, 0x21(%r15)
jne 0x5c37c
movl $0x20, %edi
callq 0x3fb00
movq %rax, %r14
leaq 0x38(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x243e0(%rip), %rsi     # 0x80721
leaq 0x24400(%rip), %rdx     # 0x80748
leaq 0x28(%rsp), %rdi
callq 0x3f8a0
movb $0x1, %bpl
leaq 0x28(%rsp), %rsi
movq %r14, %rdi
callq 0x3f890
xorl %ebp, %ebp
movq 0x46b25(%rip), %rsi     # 0xa2e90
movq 0x468c6(%rip), %rdx     # 0xa2c38
movq %r14, %rdi
callq 0x41d60
xorl %eax, %eax
movl $0x1, %edx
movl $0x1, %esi
testb %cl, %cl
jne 0x5c38e
movl 0x20(%r15), %esi
leaq 0x8(%r14), %rcx
movq %rcx, 0x20(%rsp)
movb %sil, 0x20(%r14)
cmpb $0x0, 0x21(%r12)
movzbl 0x21(%r15), %ecx
cmovnel %edx, %ecx
movb %cl, 0x21(%r14)
movq 0x10(%r12), %rcx
subq 0x8(%r12), %rcx
shrq $0x3, %rcx
movq 0x10(%r15), %rbx
subq 0x8(%r15), %rbx
shrq $0x3, %rbx
cmpl %ecx, %ebx
movl %ecx, %edx
cmovll %ebx, %edx
movl %ecx, %edi
cmovgl %ebx, %edi
testb %al, %al
je 0x5c475
testl %edx, %edx
jle 0x5c4f8
movl %edi, 0xc(%rsp)
cmpl %ebx, %ecx
cmovll %ecx, %ebx
movq %rbx, 0x18(%rsp)
movabsq $-0x100000000, %rbp     # imm = 0xFFFFFFFF00000000
xorl %r13d, %r13d
movq %r12, %rbx
movq 0x10(%r12), %rax
movq %rbp, %rcx
sarq $0x1d, %rcx
movq (%rax,%rcx), %r14
movq %r14, 0x28(%rsp)
movq %r15, %r12
movq 0x10(%r15), %rax
movq (%rax,%rcx), %r15
cmpq %r15, %r14
jne 0x5c4e7
movq 0x20(%rsp), %rdi
movq (%rdi), %rsi
leaq 0x28(%rsp), %rdx
callq 0x41ae0
cmpq %r15, %r14
jne 0x5c4e7
incq %r13
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
addq %rax, %rbp
cmpq %r13, 0x18(%rsp)
movq %r12, %r15
movq %rbx, %r12
jne 0x5c3fe
movq 0x10(%rsp), %r14
movl 0xc(%rsp), %edi
movq 0x18(%rsp), %r13
jmp 0x5c4fb
testl %edx, %edx
jle 0x5c507
movl %edi, 0xc(%rsp)
cmpl %ebx, %ecx
cmovll %ecx, %ebx
xorl %ebp, %ebp
movq 0x8(%r12), %rax
movq (%rax,%rbp,8), %r13
movq %r13, 0x28(%rsp)
movq 0x8(%r15), %rax
movq (%rax,%rbp,8), %r14
cmpq %r14, %r13
jne 0x5c4da
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rsi
cmpq 0x18(%rax), %rsi
je 0x5c4bc
movq %r13, (%rsi)
addq $0x8, 0x10(%rax)
jmp 0x5c4cb
movq 0x20(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x409a0
cmpq %r14, %r13
jne 0x5c4da
incq %rbp
cmpq %rbp, %rbx
jne 0x5c488
jmp 0x5c4dc
movl %ebp, %ebx
movq 0x10(%rsp), %r14
movl 0xc(%rsp), %edi
jmp 0x5c509
movq 0x10(%rsp), %r14
movq %r12, %r15
movq %rbx, %r12
movl 0xc(%rsp), %edi
jmp 0x5c4fb
xorl %r13d, %r13d
cmpl %edi, %r13d
jge 0x5c512
movb $0x1, 0x20(%r14)
jmp 0x5c512
xorl %ebx, %ebx
cmpl %edi, %ebx
jge 0x5c512
movb $0x1, 0x21(%r14)
movq (%r12), %rdi
movq (%r15), %rsi
movq (%rdi), %rax
xorl %edx, %edx
callq *0x30(%rax)
movq %rax, (%r14)
movq %r14, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r15
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0x5c558
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x40870
jmp 0x5c558
movq %rax, %r15
movb $0x1, %bpl
testb %bpl, %bpl
je 0x5c56e
movq %r14, %rdi
callq 0x40080
jmp 0x5c56e
jmp 0x5c56b
jmp 0x5c56b
movq %rax, %r15
movq 0x10(%rsp), %rdi
callq 0x3fa70
movq %r15, %rdi
callq 0x41f00