// File: eryxcc[P]lois/src/env.cpp
// Function: lois::outenv(lois::rbool, bool, std::shared_ptr<lois::Context>, std::shared_ptr<lois::Context>)
rbool outenv(rbool phi, bool universal, contextptr anccontext, contextptr nowcontext) {
  auto qquery = std::make_shared<FormulaQ> (universal, phi);
  contextptr e = nowcontext;
  while(e != anccontext) {
    if(!e) throw env_exception();
    if(universal)
      qquery->right = (!e->phi) || qquery->right;
    else
      qquery->right = (e->phi) && qquery->right;
    for(auto w: e->var)
      if(qquery->right->uses(w)) qquery->var.push_back(w);
    e = e->parent;
    }
  
  qquery->setfv();
  
  // std::cout << "Simplifying qquery: " << rbool(qquery) << std::endl;
  auto q = qquery->simplify(qquery);
  // std::cout << "Qquery simplified." << std::endl;
  return q;
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x190, %rsp            # imm = 0x190
movq %r8, -0x120(%rbp)
movq %rcx, -0x138(%rbp)
movl %edx, %eax
movq %rsi, %rdx
movq %rdi, -0x130(%rbp)
movq %rdi, %rsi
movq %rsi, -0x128(%rbp)
movq %rdi, -0x8(%rbp)
movq %rdx, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x11(%rbp), %rsi
callq 0x3ec40
movq -0x120(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0x173b0
movq -0x138(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0x1af60
testb $0x1, %al
jne 0x3e1fa
jmp 0x3e594
leaq -0x48(%rbp), %rdi
callq 0x1afa0
testb $0x1, %al
jne 0x3e257
movl $0x8, %edi
callq 0x8160
movq %rax, %rdi
movq %rdi, -0x140(%rbp)
movq $0x0, (%rdi)
callq 0x1afc0
movq -0x140(%rbp), %rdi
leaq 0x65293(%rip), %rsi     # 0xa34c8
leaq -0x2323c(%rip), %rdx    # 0x1b000
callq 0x84b0
jmp 0x3e67c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x3e661
testb $0x1, -0x11(%rbp)
je 0x3e357
leaq -0x48(%rbp), %rdi
callq 0x1b020
movq %rax, %rsi
addq $0x10, %rsi
leaq -0x88(%rbp), %rdi
movq %rdi, -0x148(%rbp)
callq 0x11030
movq -0x148(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x400a0
jmp 0x3e296
leaq -0x38(%rbp), %rdi
callq 0x3ecc0
movq %rax, %rsi
addq $0x18, %rsi
leaq -0x98(%rbp), %rdi
movq %rdi, -0x150(%rbp)
callq 0x11030
movq -0x150(%rbp), %rdx
leaq -0x68(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x42550
jmp 0x3e2cf
leaq -0x38(%rbp), %rdi
callq 0x3ecc0
movq %rax, %rdi
addq $0x18, %rdi
leaq -0x68(%rbp), %rsi
callq 0x11290
leaq -0x68(%rbp), %rdi
callq 0x11060
leaq -0x98(%rbp), %rdi
callq 0x11060
leaq -0x78(%rbp), %rdi
callq 0x11060
leaq -0x88(%rbp), %rdi
callq 0x11060
jmp 0x3e424
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x3e346
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x11060
leaq -0x78(%rbp), %rdi
callq 0x11060
leaq -0x88(%rbp), %rdi
callq 0x11060
jmp 0x3e661
leaq -0x48(%rbp), %rdi
callq 0x1b020
movq %rax, %rsi
addq $0x10, %rsi
leaq -0xb8(%rbp), %rdi
movq %rdi, -0x160(%rbp)
callq 0x11030
leaq -0x38(%rbp), %rdi
callq 0x3ecc0
movq %rax, %rsi
addq $0x18, %rsi
leaq -0xc8(%rbp), %rdi
movq %rdi, -0x158(%rbp)
callq 0x11030
movq -0x160(%rbp), %rsi
movq -0x158(%rbp), %rdx
leaq -0xa8(%rbp), %rdi
callq 0x42150
jmp 0x3e3b9
leaq -0x38(%rbp), %rdi
callq 0x3ecc0
movq %rax, %rdi
addq $0x18, %rdi
leaq -0xa8(%rbp), %rsi
callq 0x11290
leaq -0xa8(%rbp), %rdi
callq 0x11060
leaq -0xc8(%rbp), %rdi
callq 0x11060
leaq -0xb8(%rbp), %rdi
callq 0x11060
jmp 0x3e424
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x11060
leaq -0xb8(%rbp), %rdi
callq 0x11060
jmp 0x3e661
leaq -0x48(%rbp), %rdi
callq 0x1b020
addq $0x20, %rax
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rdi
callq 0x1b040
movq %rax, -0xd8(%rbp)
movq -0xd0(%rbp), %rdi
callq 0x1b070
movq %rax, -0xe0(%rbp)
leaq -0xd8(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x1b0a0
testb $0x1, %al
jne 0x3e47a
jmp 0x3e57a
leaq -0xd8(%rbp), %rdi
callq 0x1b0e0
movq %rax, %rsi
leaq -0xf0(%rbp), %rdi
callq 0x1b100
leaq -0x38(%rbp), %rdi
callq 0x3ecc0
movq %rax, %rdi
addq $0x18, %rdi
callq 0x3ece0
movq %rax, -0x168(%rbp)
jmp 0x3e4b3
leaq -0x100(%rbp), %rdi
movq %rdi, -0x178(%rbp)
leaq -0xf0(%rbp), %rsi
callq 0x1b100
movq -0x168(%rbp), %rdi
movq -0x178(%rbp), %rsi
movq (%rdi), %rax
movq 0x28(%rax), %rax
callq *%rax
movb %al, -0x169(%rbp)
jmp 0x3e4ec
leaq -0x100(%rbp), %rdi
callq 0x10f20
movb -0x169(%rbp), %al
testb $0x1, %al
jne 0x3e504
jmp 0x3e54c
leaq -0x38(%rbp), %rdi
callq 0x3ecc0
movq %rax, %rdi
addq $0x28, %rdi
leaq -0xf0(%rbp), %rsi
callq 0x1b320
jmp 0x3e522
jmp 0x3e54c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x3e569
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x10f20
jmp 0x3e569
leaq -0xf0(%rbp), %rdi
callq 0x10f20
leaq -0xd8(%rbp), %rdi
callq 0x1b390
jmp 0x3e45e
leaq -0xf0(%rbp), %rdi
callq 0x10f20
jmp 0x3e661
leaq -0x48(%rbp), %rdi
callq 0x1b020
movq %rax, %rsi
leaq -0x48(%rbp), %rdi
callq 0x1ade0
jmp 0x3e1e1
leaq -0x38(%rbp), %rdi
callq 0x3ecc0
movq %rax, %rdi
callq 0x3ed00
jmp 0x3e5a7
movb $0x0, -0x101(%rbp)
leaq -0x38(%rbp), %rdi
movq %rdi, -0x190(%rbp)
callq 0x3ecc0
movq -0x190(%rbp), %rsi
movq %rax, -0x188(%rbp)
leaq -0x118(%rbp), %rdi
movq %rdi, -0x180(%rbp)
callq 0x3ed10
movq -0x130(%rbp), %rdi
movq -0x188(%rbp), %rsi
movq -0x180(%rbp), %rdx
callq 0x41240
jmp 0x3e5fb
leaq -0x118(%rbp), %rdi
callq 0x3ed40
movb $0x1, -0x101(%rbp)
testb $0x1, -0x101(%rbp)
jne 0x3e63f
jmp 0x3e633
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x3ed40
jmp 0x3e661
movq -0x130(%rbp), %rdi
callq 0x11060
leaq -0x48(%rbp), %rdi
callq 0x14b20
leaq -0x38(%rbp), %rdi
callq 0x3ed40
movq -0x128(%rbp), %rax
addq $0x190, %rsp            # imm = 0x190
popq %rbp
retq
leaq -0x48(%rbp), %rdi
callq 0x14b20
leaq -0x38(%rbp), %rdi
callq 0x3ed40
movq -0x50(%rbp), %rdi
callq 0x84d0
nopl (%rax)