// File: jstaursky[P]hutch/src/Sleigh/slghpattern.cc
// Function: InstructionPattern::commonSubPattern(Pattern const*, int) const
Pattern *InstructionPattern::commonSubPattern(const Pattern *b,int4 sa) const

{
  if (b->numDisjoint()>0)
    return b->commonSubPattern(this,-sa);

  const CombinePattern *b2 = dynamic_cast<const CombinePattern *>(b);
  if (b2 != (const CombinePattern *)0)
    return b->commonSubPattern(this,-sa);

  const ContextPattern *b3 = dynamic_cast<const ContextPattern *>(b);
  if (b3 != (const ContextPattern *)0) {
    InstructionPattern *res = new InstructionPattern(true);
    return res;
  }
  const InstructionPattern *b4 = (const InstructionPattern *)b;
  
  PatternBlock *respattern;
  if (sa < 0) {
    PatternBlock *a = maskvalue->clone();
    a->shift(-sa);
    respattern = a->commonSubPattern(b4->maskvalue);
    delete a;
  }
  else {
    PatternBlock *c = b4->maskvalue->clone();
    c->shift(sa);
    respattern = maskvalue->commonSubPattern(c);
    delete c;
  }
  return new InstructionPattern(respattern);
}

// Assembly:
subq $0xb8, %rsp
movq %rdi, 0xa8(%rsp)
movq %rsi, 0xa0(%rsp)
movl %edx, 0x9c(%rsp)
movq 0xa8(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0xa0(%rsp), %rdi
movq (%rdi), %rax
callq *0x40(%rax)
cmpl $0x0, %eax
jle 0x1378e7
movq 0x48(%rsp), %rsi
movq 0xa0(%rsp), %rdi
xorl %edx, %edx
subl 0x9c(%rsp), %edx
movq (%rdi), %rax
callq *0x30(%rax)
movq %rax, 0xb0(%rsp)
jmp 0x137b59
movq 0xa0(%rsp), %rax
movq %rax, 0x40(%rsp)
cmpq $0x0, %rax
je 0x13791d
movq 0x40(%rsp), %rdi
movq 0x903a2(%rip), %rsi     # 0x1c7ca8
movq 0x90413(%rip), %rdx     # 0x1c7d20
xorl %eax, %eax
movl %eax, %ecx
callq 0xd99a0
movq %rax, 0x38(%rsp)
jmp 0x137926
xorl %eax, %eax
movq %rax, 0x38(%rsp)
jmp 0x137926
movq 0x38(%rsp), %rax
movq %rax, 0x90(%rsp)
cmpq $0x0, 0x90(%rsp)
je 0x137967
movq 0x48(%rsp), %rsi
movq 0xa0(%rsp), %rdi
xorl %edx, %edx
subl 0x9c(%rsp), %edx
movq (%rdi), %rax
callq *0x30(%rax)
movq %rax, 0xb0(%rsp)
jmp 0x137b59
movq 0xa0(%rsp), %rax
movq %rax, 0x30(%rsp)
cmpq $0x0, %rax
je 0x13799d
movq 0x30(%rsp), %rdi
movq 0x90322(%rip), %rsi     # 0x1c7ca8
movq 0x901d3(%rip), %rdx     # 0x1c7b60
xorl %eax, %eax
movl %eax, %ecx
callq 0xd99a0
movq %rax, 0x28(%rsp)
jmp 0x1379a6
xorl %eax, %eax
movq %rax, 0x28(%rsp)
jmp 0x1379a6
movq 0x28(%rsp), %rax
movq %rax, 0x88(%rsp)
cmpq $0x0, 0x88(%rsp)
je 0x137a23
movl $0x10, %edi
callq 0xd8380
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x20(%rsp)
movl $0x1, %esi
callq 0xdbad0
jmp 0x1379df
movq 0x20(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0x80(%rsp), %rax
movq %rax, 0xb0(%rsp)
jmp 0x137b59
movq 0x20(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x78(%rsp)
movl %eax, 0x74(%rsp)
movl $0x10, %esi
callq 0xd8620
jmp 0x137b69
movq 0xa0(%rsp), %rax
movq %rax, 0x68(%rsp)
cmpl $0x0, 0x9c(%rsp)
jge 0x137aa3
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0xd1ee0
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rdi
xorl %esi, %esi
subl 0x9c(%rsp), %esi
callq 0xdd720
movq 0x58(%rsp), %rdi
movq 0x68(%rsp), %rax
movq 0x8(%rax), %rsi
callq 0xd0960
movq %rax, 0x60(%rsp)
movq 0x58(%rsp), %rax
movq %rax, 0x18(%rsp)
cmpq $0x0, %rax
je 0x137aa1
movq 0x18(%rsp), %rdi
callq 0xd2d60
movq 0x18(%rsp), %rdi
movl $0x38, %esi
callq 0xd8620
jmp 0x137b0a
movq 0x68(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0xd1ee0
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rdi
movl 0x9c(%rsp), %esi
callq 0xdd720
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x50(%rsp), %rsi
callq 0xd0960
movq %rax, 0x60(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x10(%rsp)
cmpq $0x0, %rax
je 0x137b08
movq 0x10(%rsp), %rdi
callq 0xd2d60
movq 0x10(%rsp), %rdi
movl $0x38, %esi
callq 0xd8620
jmp 0x137b0a
movl $0x10, %edi
callq 0xd8380
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x8(%rsp)
movq 0x60(%rsp), %rsi
callq 0xd6d10
jmp 0x137b2b
movq 0x8(%rsp), %rax
movq %rax, 0xb0(%rsp)
jmp 0x137b59
movq 0x8(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x78(%rsp)
movl %eax, 0x74(%rsp)
movl $0x10, %esi
callq 0xd8620
jmp 0x137b69
movq 0xb0(%rsp), %rax
addq $0xb8, %rsp
retq
movq 0x78(%rsp), %rdi
callq 0xe0be0
nopw %cs:(%rax,%rax)