// File: /workspace/github_cpp_makefile_star2_O3/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 $0x38, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rdi)
movups %xmm0, (%rdi)
movw $0x0, 0x20(%rdi)
movb 0x20(%rsi), %al
testb %al, %al
jne 0x5c069
movb 0x20(%r14), %sil
testb %sil, %sil
je 0x5c088
cmpb $0x0, 0x21(%r15)
jne 0x5c20f
movb 0x21(%r14), %dl
testb %dl, %dl
jne 0x5c20f
movb 0x20(%r14), %sil
movb $0x1, %cl
jmp 0x5c09c
movzbl 0x21(%r14), %ecx
testb $0x1, 0x21(%r15)
movl $0x1, %edx
cmovel %ecx, %edx
xorl %ecx, %ecx
leaq 0x8(%rbx), %r12
movzbl %sil, %esi
testb %al, %al
movl $0x1, %eax
cmovel %esi, %eax
movb %al, 0x20(%rbx)
movb %dl, 0x21(%rbx)
movq 0x10(%r15), %rax
subq 0x8(%r15), %rax
shrq $0x3, %rax
movq 0x10(%r14), %rbp
subq 0x8(%r14), %rbp
shrq $0x3, %rbp
cmpl %eax, %ebp
movl %eax, %esi
cmovll %ebp, %esi
movl %eax, %edx
cmovgl %ebp, %edx
testb %cl, %cl
je 0x5c161
testl %esi, %esi
jle 0x5c1bf
movl %esi, 0xc(%rsp)
movl %edx, 0x8(%rsp)
movq %rbx, 0x10(%rsp)
cmpl %ebp, %eax
cmovll %eax, %ebp
movabsq $-0x100000000, %rbx     # imm = 0xFFFFFFFF00000000
xorl %r13d, %r13d
movq 0x10(%r15), %rax
movq %rbx, %rcx
sarq $0x1d, %rcx
movq (%rax,%rcx), %rax
movq %rax, 0x18(%rsp)
movq 0x10(%r14), %rdx
cmpq (%rdx,%rcx), %rax
jne 0x5c1d8
movq (%r12), %rsi
movq %r12, %rdi
leaq 0x18(%rsp), %rdx
callq 0x41af0
incq %r13
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
addq %rax, %rbx
cmpq %r13, %rbp
jne 0x5c107
movq 0x10(%rsp), %rbx
movl 0x8(%rsp), %edx
movl 0xc(%rsp), %eax
jmp 0x5c1e4
testl %esi, %esi
jle 0x5c1c3
movl %esi, 0xc(%rsp)
movl %edx, 0x8(%rsp)
cmpl %ebp, %eax
cmovll %eax, %ebp
xorl %r13d, %r13d
movq 0x8(%r15), %rax
movq (%rax,%r13,8), %rax
movq %rax, 0x18(%rsp)
movq 0x8(%r14), %rcx
cmpq (%rcx,%r13,8), %rax
jne 0x5c1c7
movq 0x10(%rbx), %rsi
cmpq 0x18(%rbx), %rsi
je 0x5c1a0
movq %rax, (%rsi)
addq $0x8, 0x10(%rbx)
jmp 0x5c1ad
movq %r12, %rdi
leaq 0x18(%rsp), %rdx
callq 0x409b0
incq %r13
cmpq %r13, %rbp
jne 0x5c175
movl 0x8(%rsp), %edx
movl 0xc(%rsp), %eax
jmp 0x5c1ce
xorl %eax, %eax
jmp 0x5c1e4
xorl %eax, %eax
jmp 0x5c1ce
movl %r13d, %eax
movl 0x8(%rsp), %edx
cmpl %edx, %eax
jge 0x5c1ec
movb $0x1, 0x21(%rbx)
jmp 0x5c1ec
movl %r13d, %eax
movq 0x10(%rsp), %rbx
movl 0x8(%rsp), %edx
cmpl %edx, %eax
jge 0x5c1ec
movb $0x1, 0x20(%rbx)
movq (%r15), %rdi
movq (%r14), %rsi
movq (%rdi), %rax
xorl %edx, %edx
callq *0x30(%rax)
movq %rax, (%rbx)
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, 0x10(%rsp)
movl $0x20, %edi
callq 0x3fb00
movq %rax, %r14
leaq 0x28(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x244ef(%rip), %rsi     # 0x80721
leaq 0x2450f(%rip), %rdx     # 0x80748
leaq 0x18(%rsp), %rdi
callq 0x3f8a0
movb $0x1, %bpl
leaq 0x18(%rsp), %rsi
movq %r14, %rdi
callq 0x3f890
xorl %ebp, %ebp
movq 0x46c34(%rip), %rsi     # 0xa2e90
movq 0x469d5(%rip), %rdx     # 0xa2c38
movq %r14, %rdi
callq 0x41d70
movq %rax, %r15
movq 0x18(%rsp), %rdi
cmpq %r12, %rdi
je 0x5c285
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x40880
testb %bpl, %bpl
jne 0x5c28f
jmp 0x5c2a5
movq %rax, %r15
movq %r14, %rdi
callq 0x40090
jmp 0x5c2a5
jmp 0x5c29b
movq %rbx, 0x10(%rsp)
jmp 0x5c2a2
movq %rax, %r15
movq 0x10(%rsp), %rdi
callq 0x3fa70
movq %r15, %rdi
callq 0x41f10
nop