// File: /workspace/github_cpp_makefile_star2_O2/eryxcc[P]lois/src/relations.cpp
// Function: lois::SubRelTree::exists(lois::FormulaQ*, int, std::shared_ptr<lois::Subdomain>&, int, int)
bool exists(FormulaQ* q, int at, std::shared_ptr<Subdomain>& dom, int val, int rid) {

    if(parent.size() < val+2) parent.resize(val+2);
  
    // create a new tree
    if(val == 0) {
      parent[0] = -1;
      if(q->generateAll(at, dom, val, rid+1) != q->type) return !q->type;
      }
    
    // already created
    if(val > 0 && parent[val-1] == val) 
      return q->generateAll(at, dom, val, rid+1);
    
    // create a descendant
    for(int u=0; u<val; u++) {
      parent[val] = u;
      if(q->generateAll(at, dom, val, rid+1) != q->type) return !q->type;
      }
    
    // create an intermediate ancestor
    for(int u=0; u<val; u++) {
      parent[val] = parent[u]; parent[u] = val;
      bool b = q->generateAll(at, dom, val, rid+1);
      parent[u] = parent[val];
      if(b != q->type) return !q->type;
      }
    
    // create another child of an intermediate ancestor of u
    for(int u=0; u<val; u++) {
      dom->nextval++;
      parent[val+1] = parent[u]; parent[u] = val+1; parent[val] = val+1;
      bool b = q->generateAll(at, dom, val, rid+1);
      parent[u] = parent[val+1]; dom->nextval--;
      if(b != q->type) return !q->type;
      }
    
    return q->type;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, 0x8(%rsp)
movl %r8d, %r14d
movq %rcx, 0x10(%rsp)
movl %edx, 0x4(%rsp)
movq %rsi, %r12
leaq 0x10(%rdi), %r13
movq 0x18(%rdi), %rax
subq 0x10(%rdi), %rax
sarq $0x2, %rax
leal 0x2(%r14), %ecx
movslq %ecx, %rsi
cmpq %rsi, %rax
jae 0x27bc8
movq %r13, %rdi
callq 0x26ef6
testl %r14d, %r14d
je 0x27c07
jle 0x27c39
movq (%r13), %rax
movl %r14d, %ecx
cmpl %r14d, -0x4(%rax,%rcx,4)
jne 0x27c39
movq 0x8(%rsp), %r8
incl %r8d
movq %r12, %rdi
movl 0x4(%rsp), %esi
movq 0x10(%rsp), %rdx
movl %r14d, %ecx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x206a6
movq (%r13), %rax
orl $-0x1, (%rax)
movq 0x8(%rsp), %rax
leal 0x1(%rax), %r8d
movq %r12, %rdi
movl 0x4(%rsp), %esi
movq 0x10(%rsp), %rdx
xorl %ecx, %ecx
callq 0x206a6
movl %eax, %ecx
movb 0x10(%r12), %al
cmpb %cl, %al
jne 0x27d47
movslq %r14d, %rbp
movq 0x8(%rsp), %rax
incl %eax
movq %rax, 0x8(%rsp)
xorl %ebx, %ebx
testl %r14d, %r14d
movl $0x0, %r15d
cmovgl %r14d, %r15d
cmpl %ebx, %r15d
je 0x27c8e
movq (%r13), %rax
movl %ebx, (%rax,%rbp,4)
movq %r12, %rdi
movl 0x4(%rsp), %esi
movq 0x10(%rsp), %rdx
movl %r14d, %ecx
movq 0x8(%rsp), %r8
callq 0x206a6
movl %eax, %ecx
movb 0x10(%r12), %al
incl %ebx
cmpb %cl, %al
je 0x27c57
jmp 0x27d47
movl %r15d, %r15d
xorl %ebx, %ebx
cmpq %rbx, %r15
je 0x27cd9
movq (%r13), %rax
movl (%rax,%rbx,4), %ecx
movl %ecx, (%rax,%rbp,4)
movl %r14d, (%rax,%rbx,4)
movq %r12, %rdi
movl 0x4(%rsp), %esi
movq 0x10(%rsp), %rdx
movl %r14d, %ecx
movq 0x8(%rsp), %r8
callq 0x206a6
movl %eax, %ecx
movq (%r13), %rax
movl (%rax,%rbp,4), %edx
movl %edx, (%rax,%rbx,4)
movb 0x10(%r12), %al
incq %rbx
cmpb %cl, %al
je 0x27c93
jmp 0x27d47
movq %r15, 0x20(%rsp)
movq %r14, 0x18(%rsp)
leal 0x1(%r14), %eax
movslq %eax, %rbx
xorl %r15d, %r15d
movq 0x10(%rsp), %r14
cmpq %r15, 0x20(%rsp)
je 0x27d58
movq (%r14), %rax
incl (%rax)
movq (%r13), %rax
movl (%rax,%r15,4), %ecx
movl %ecx, (%rax,%rbx,4)
movl %ebx, (%rax,%r15,4)
movl %ebx, (%rax,%rbp,4)
movq %r12, %rdi
movl 0x4(%rsp), %esi
movq %r14, %rdx
movq 0x18(%rsp), %rcx
movq 0x8(%rsp), %r8
callq 0x206a6
movq (%r13), %rcx
movl (%rcx,%rbx,4), %edx
movl %edx, (%rcx,%r15,4)
movq (%r14), %rcx
decl (%rcx)
movl %eax, %ecx
movb 0x10(%r12), %al
incq %r15
cmpb %cl, %al
je 0x27cf2
xorb $0x1, %al
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb 0x10(%r12), %al
jmp 0x27d49
nop