// File: lotka[P]prologplusplus/main.cpp
// Function: query_test(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void query_test(string s)
{
	if(s == "halt.")
	{
		exit(1);
	}
	PredicateRef p(s,predicates);
	bool unified = false;

	cout << "test" << endl;
	// Basically what happens here is that we try to unify the ref with all
	// the existing predicates, if one works set the unified flag to true
	for(int i = 0; i < predicates.size(); ++i)
	{
		if(predicates[i]->unifyWith(&p))
		{
			unified = true;
		}
	}
	// If unified, print out the variables that worked, these are stored inside the atoms
	// in a list of possibilites, this is potentially a really bad way to do this
	// I think this is going to need some kind of virtual/temporary variables to make this work
	if(unified)
	{
		for(int i = 0; i < p.args.size(); ++i)
		{
			char c;
			for(int j = 0; j < p.args[i]->possibilties.size(); ++j)
			{
				cout << *p.args[i] << "=" << *p.args[i]->possibilties[j] << endl;
			}
			cin >> c;
		}
		cout << endl << "yes" << endl;
	}
	else
	{
		cout << endl << "no" << endl;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x90(%rbp)
movq %rdi, -0x8(%rbp)
leaq 0x6977(%rip), %rsi      # 0x9004
callq 0x2cb0
testb $0x1, %al
jne 0x2698
jmp 0x26a2
movl $0x1, %edi
callq 0x2220
movq -0x90(%rbp), %rsi
leaq -0x68(%rbp), %rdi
movq %rdi, -0x98(%rbp)
callq 0x20a0
movq -0x98(%rbp), %rsi
leaq 0xbb01(%rip), %rdx      # 0xe1c8
leaq -0x48(%rbp), %rdi
callq 0x4db0
jmp 0x26d2
leaq -0x68(%rbp), %rdi
callq 0x20f0
movb $0x0, -0x75(%rbp)
movq 0xb8ea(%rip), %rdi      # 0xdfd0
leaq 0x691d(%rip), %rsi      # 0x900a
callq 0x2190
movq %rax, -0xa0(%rbp)
jmp 0x26fb
movq -0xa0(%rbp), %rdi
movq 0xb8b7(%rip), %rsi      # 0xdfc0
callq 0x21c0
jmp 0x2710
movl $0x0, -0x7c(%rbp)
movslq -0x7c(%rbp), %rax
movq %rax, -0xa8(%rbp)
leaq 0xba9f(%rip), %rdi      # 0xe1c8
callq 0x2ce0
movq %rax, %rcx
movq -0xa8(%rbp), %rax
cmpq %rcx, %rax
jae 0x27b7
movslq -0x7c(%rbp), %rsi
leaq 0xba80(%rip), %rdi      # 0xe1c8
callq 0x2d00
movq (%rax), %rdi
leaq -0x48(%rbp), %rsi
callq 0x6080
movb %al, -0xa9(%rbp)
jmp 0x2761
movb -0xa9(%rbp), %al
testb $0x1, %al
jne 0x276d
jmp 0x27a7
movb $0x1, -0x75(%rbp)
jmp 0x27a7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x20f0
jmp 0x29b4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x2d90
jmp 0x29b4
jmp 0x27a9
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x2717
testb $0x1, -0x75(%rbp)
je 0x2953
movl $0x0, -0x80(%rbp)
movslq -0x80(%rbp), %rax
movq %rax, -0xb8(%rbp)
leaq -0x48(%rbp), %rdi
addq $0x20, %rdi
callq 0x2d20
movq %rax, %rcx
movq -0xb8(%rbp), %rax
cmpq %rcx, %rax
jae 0x2904
movl $0x0, -0x88(%rbp)
movslq -0x88(%rbp), %rax
movq %rax, -0xc0(%rbp)
leaq -0x48(%rbp), %rdi
addq $0x20, %rdi
movslq -0x80(%rbp), %rsi
callq 0x2d40
movq (%rax), %rdi
addq $0x28, %rdi
callq 0x2d20
movq %rax, %rcx
movq -0xc0(%rbp), %rax
cmpq %rcx, %rax
jae 0x28df
leaq -0x28(%rbp), %rdi
movslq -0x80(%rbp), %rsi
callq 0x2d40
movq (%rax), %rsi
movq 0xb77e(%rip), %rdi      # 0xdfd0
callq 0x2d60
movq %rax, -0xc8(%rbp)
jmp 0x2860
movq -0xc8(%rbp), %rdi
leaq 0x67a1(%rip), %rsi      # 0x900f
callq 0x2190
movq %rax, -0xd0(%rbp)
jmp 0x287c
leaq -0x28(%rbp), %rdi
movslq -0x80(%rbp), %rsi
callq 0x2d40
movq (%rax), %rdi
addq $0x28, %rdi
movslq -0x88(%rbp), %rsi
callq 0x2d40
movq -0xd0(%rbp), %rdi
movq (%rax), %rsi
callq 0x2d60
movq %rax, -0xd8(%rbp)
jmp 0x28b4
movq -0xd8(%rbp), %rdi
movq 0xb6fe(%rip), %rsi      # 0xdfc0
callq 0x21c0
jmp 0x28c9
jmp 0x28cb
movl -0x88(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x88(%rbp)
jmp 0x27fd
movq 0xb6fa(%rip), %rdi      # 0xdfe0
leaq -0x81(%rbp), %rsi
callq 0x2270
jmp 0x28f4
jmp 0x28f6
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0x27c8
movq 0xb6c5(%rip), %rdi      # 0xdfd0
movq 0xb6ae(%rip), %rsi      # 0xdfc0
callq 0x21c0
movq %rax, -0xe0(%rbp)
jmp 0x2920
movq -0xe0(%rbp), %rdi
leaq 0x66e3(%rip), %rsi      # 0x9011
callq 0x2190
movq %rax, -0xe8(%rbp)
jmp 0x293c
movq -0xe8(%rbp), %rdi
movq 0xb676(%rip), %rsi      # 0xdfc0
callq 0x21c0
jmp 0x2951
jmp 0x29a2
movq 0xb676(%rip), %rdi      # 0xdfd0
movq 0xb65f(%rip), %rsi      # 0xdfc0
callq 0x21c0
movq %rax, -0xf0(%rbp)
jmp 0x296f
movq -0xf0(%rbp), %rdi
leaq 0x6698(%rip), %rsi      # 0x9015
callq 0x2190
movq %rax, -0xf8(%rbp)
jmp 0x298b
movq -0xf8(%rbp), %rdi
movq 0xb627(%rip), %rsi      # 0xdfc0
callq 0x21c0
jmp 0x29a0
jmp 0x29a2
leaq -0x48(%rbp), %rdi
callq 0x2d90
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
movq -0x70(%rbp), %rdi
callq 0x22d0
nopl (%rax)