// File: shisharka[P]interactive_deduction/naturaldeduction.cpp
// Function: applyImpE(std::pair<std::vector<std::shared_ptr<BaseFormula>, std::allocator<std::shared_ptr<BaseFormula>>>, std::shared_ptr<BaseFormula>> const&, std::vector<std::pair<std::vector<std::shared_ptr<BaseFormula>, std::allocator<std::shared_ptr<BaseFormula>>>, std::shared_ptr<BaseFormula>>, std::allocator<std::pair<std::vector<std::shared_ptr<BaseFormula>, std::allocator<std::shared_ptr<BaseFormula>>>, std::shared_ptr<BaseFormula>>>>&)
void applyImpE(const Goal & g, vector<Goal> & subgoals) {
  Formula a, b;
  vector<Formula> ass1, ass2;
  bool applied = false;

  for(vector<Formula>::const_iterator i = g.first.begin(); i != g.first.end(); i++) {
    if((*i)->getType() == T_IMP && !applied) {
      a = ((Imp *)(*i).get())->getOperand1();
      b = ((Imp *)(*i).get())->getOperand2();
      applied = true;
    }
    else {
      addAssumption(ass1, *i);
      addAssumption(ass2, *i);
    };
  };

  if(applied) {
    addAssumption(ass2, b);
    subgoals.push_back(make_pair(ass1, a));
    subgoals.push_back(make_pair(ass2, g.second));
  }
  else
    cerr << "Failed to apply ImpE" << endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x7240
leaq -0x30(%rbp), %rdi
callq 0x7240
leaq -0x48(%rbp), %rdi
callq 0x7430
leaq -0x60(%rbp), %rdi
callq 0x7430
movb $0x0, -0x61(%rbp)
movq -0x8(%rbp), %rdi
callq 0xe7a0
movq %rax, -0x70(%rbp)
movq -0x8(%rbp), %rdi
callq 0xe7d0
movq %rax, -0x78(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0xeb70
testb $0x1, %al
jne 0x13bcb
jmp 0x13ccb
leaq -0x70(%rbp), %rdi
callq 0xebe0
movq %rax, %rdi
callq 0x120d0
movq %rax, %rdi
movq (%rdi), %rax
movq (%rax), %rax
callq *%rax
movl %eax, -0xe4(%rbp)
jmp 0x13bef
movl -0xe4(%rbp), %eax
cmpl $0x6, %eax
jne 0x13c82
testb $0x1, -0x61(%rbp)
jne 0x13c82
leaq -0x70(%rbp), %rdi
callq 0xebe0
movq %rax, %rdi
callq 0x120f0
movq %rax, %rdi
callq 0x11a70
movq %rax, -0xf0(%rbp)
jmp 0x13c26
movq -0xf0(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x6b30
leaq -0x70(%rbp), %rdi
callq 0xebe0
movq %rax, %rdi
callq 0x120f0
movq %rax, %rdi
callq 0x11a90
movq %rax, -0xf8(%rbp)
jmp 0x13c58
movq -0xf8(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x6b30
movb $0x1, -0x61(%rbp)
jmp 0x13cb2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x13e08
leaq -0x70(%rbp), %rdi
callq 0xebe0
movq %rax, %rsi
leaq -0x48(%rbp), %rdi
callq 0x12cf0
jmp 0x13c99
leaq -0x70(%rbp), %rdi
callq 0xebe0
movq %rax, %rsi
leaq -0x60(%rbp), %rdi
callq 0x12cf0
jmp 0x13cb0
jmp 0x13cb2
jmp 0x13cb4
leaq -0x70(%rbp), %rdi
xorl %esi, %esi
callq 0x14a70
movq %rax, -0x90(%rbp)
jmp 0x13ba8
testb $0x1, -0x61(%rbp)
je 0x13da8
leaq -0x60(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x12cf0
jmp 0x13ce4
movq -0x10(%rbp), %rax
movq %rax, -0x100(%rbp)
leaq -0xb8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
leaq -0x20(%rbp), %rdx
callq 0x14b20
jmp 0x13d05
movq -0x100(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x14ab0
jmp 0x13d1a
leaq -0xb8(%rbp), %rdi
callq 0x7450
movq -0x10(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0x8(%rbp), %rdx
addq $0x18, %rdx
leaq -0xe0(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x14ae0
jmp 0x13d4b
movq -0x108(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x14ab0
jmp 0x13d60
leaq -0xe0(%rbp), %rdi
callq 0x7450
jmp 0x13ddb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x7450
jmp 0x13e08
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x7450
jmp 0x13e08
movq 0x10239(%rip), %rdi     # 0x23fe8
leaq 0x437c(%rip), %rsi      # 0x18132
callq 0x41d0
movq %rax, -0x110(%rbp)
jmp 0x13dc4
movq -0x110(%rbp), %rdi
movq 0x101ae(%rip), %rsi     # 0x23f80
callq 0x4200
jmp 0x13dd9
jmp 0x13ddb
leaq -0x60(%rbp), %rdi
callq 0x7480
leaq -0x48(%rbp), %rdi
callq 0x7480
leaq -0x30(%rbp), %rdi
callq 0x7260
leaq -0x20(%rbp), %rdi
callq 0x7260
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
leaq -0x60(%rbp), %rdi
callq 0x7480
leaq -0x48(%rbp), %rdi
callq 0x7480
leaq -0x30(%rbp), %rdi
callq 0x7260
leaq -0x20(%rbp), %rdi
callq 0x7260
movq -0x80(%rbp), %rdi
callq 0x4370
nopw %cs:(%rax,%rax)