// File: /workspace/github_cpp_makefile_star2_O1/biotomas[P]ipasir/app/genipareach/genipareach.cpp
// Function: main
int main(int argc, char **argv) {
	puts("c this is a trivial DIMSPEC formula solver.");

	if (argc != 2) {
		puts("c USAGE: ./reachability <dimspec.srt>");
		return 0;
	}

	Formula init,univ,trans, goal;
	loadReachabilityProblem(argv[1], &init, &univ, &goal, &trans);
	printf("c variables in initial %d universal %d goal %d transition %d\n", init.variables, univ.variables, goal.variables, trans.variables);
	printf("c clauses in initial %lu universal %lu goal %lu transition %lu\n", init.clauses.size(), univ.clauses.size(), goal.clauses.size(), trans.clauses.size());
	printf("c Using the incremental SAT solver %s.\n", ipasir_signature());

	int baseVariables = init.variables;
	if (univ.variables != baseVariables || goal.variables != baseVariables || trans.variables != 2*baseVariables) {
		printf("Error: Variable number inconsistency in the input formula.\n");
		return 1;
	}
	vector<int> goalLiterals;
	for (size_t cid = 0; cid < goal.clauses.size(); cid++) {
		if (goal.clauses[cid].size() > 1) {
			printf("Error: only unit goal clauses supported, encode your problem accordingly.\n");
			return 1;
		} else if (goal.clauses[cid].size() > 0) {
			goalLiterals.push_back(goal.clauses[cid][0]);
		}
	}

	void* solver = ipasir_init();
	// Add the initial conditions
	addClauses(solver, init.clauses, 0);

	for (int step = 0;;step++) {
		printf("c running step nr. %d\n", step);
		addClauses(solver, univ.clauses, step*baseVariables);
		if (step > 0) {
			addClauses(solver, trans.clauses, (step-1)*baseVariables);
		}
		assumeLits(solver, goalLiterals, step*baseVariables);
		int res = ipasir_solve(solver);
		if (res == 10) {
			printf("c solved at step nr. %d\n", step);
			break;
		}
	}
	ipasir_release(solver);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rsi, %rbx
movl %edi, %ebp
leaq 0xe5e5(%rip), %rdi      # 0x10004
callq 0x11f0
cmpl $0x2, %ebp
jne 0x1c2f
xorps %xmm0, %xmm0
leaq 0x60(%rsp), %rsi
movaps %xmm0, 0x20(%rsi)
movaps %xmm0, 0x10(%rsi)
movaps %xmm0, (%rsi)
xorl %eax, %eax
movq %rax, 0x30(%rsi)
leaq 0xe0(%rsp), %rdx
movq %rax, 0x30(%rdx)
movaps %xmm0, 0x20(%rdx)
movaps %xmm0, 0x10(%rdx)
movaps %xmm0, (%rdx)
leaq 0xa0(%rsp), %r8
movq %rax, 0x30(%r8)
movaps %xmm0, 0x20(%r8)
movaps %xmm0, 0x10(%r8)
movaps %xmm0, (%r8)
leaq 0x20(%rsp), %rcx
movq %rax, 0x30(%rcx)
movaps %xmm0, 0x20(%rcx)
movaps %xmm0, 0x10(%rcx)
movaps %xmm0, (%rcx)
movq 0x8(%rbx), %rdi
callq 0x17d3
movl 0x60(%rsp), %esi
movl 0xe0(%rsp), %edx
movl 0x20(%rsp), %ecx
movl 0xa0(%rsp), %r8d
leaq 0xe5a4(%rip), %rdi      # 0x10056
xorl %eax, %eax
callq 0x1030
movq 0x70(%rsp), %rsi
subq 0x68(%rsp), %rsi
sarq $0x3, %rsi
movabsq $-0x5555555555555555, %r15 # imm = 0xAAAAAAAAAAAAAAAB
imulq %r15, %rsi
movq 0xf0(%rsp), %rdx
subq 0xe8(%rsp), %rdx
sarq $0x3, %rdx
movq 0x30(%rsp), %rcx
subq 0x28(%rsp), %rcx
imulq %r15, %rdx
sarq $0x3, %rcx
imulq %r15, %rcx
movq 0xb0(%rsp), %r8
subq 0xa8(%rsp), %r8
sarq $0x3, %r8
imulq %r15, %r8
leaq 0xe576(%rip), %rdi      # 0x10094
xorl %eax, %eax
callq 0x1030
callq 0x2300
leaq 0x68(%rsp), %r13
leaq 0xe8(%rsp), %r14
leaq 0xe596(%rip), %rdi      # 0x100d4
movq %rax, %rsi
xorl %eax, %eax
callq 0x1030
movl -0x8(%r13), %ebx
cmpl %ebx, -0x8(%r14)
jne 0x1c42
cmpl %ebx, 0x20(%rsp)
jne 0x1c42
leal (%rbx,%rbx), %eax
cmpl %eax, 0xa0(%rsp)
jne 0x1c42
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movq 0x28(%rsp), %rax
cmpq %rax, 0x30(%rsp)
setne %r14b
je 0x1d03
movq (%rax), %rdx
movq 0x8(%rax), %rax
movq %rax, %rcx
subq %rdx, %rcx
cmpq $0x4, %rcx
ja 0x1c19
movl $0x20, %r13d
xorl %r12d, %r12d
movq %rsp, %rbp
cmpq %rdx, %rax
je 0x1bdb
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x1bd3
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rsp)
jmp 0x1bdb
movq %rbp, %rdi
callq 0x21de
incq %r12
movq 0x28(%rsp), %rax
movq 0x30(%rsp), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
imulq %r15, %rcx
cmpq %rcx, %r12
setb %r14b
jae 0x1d07
movq -0x8(%rax,%r13), %rdx
movq (%rax,%r13), %rax
addq $0x18, %r13
movq %rax, %rcx
subq %rdx, %rcx
cmpq $0x5, %rcx
jb 0x1bb3
leaq 0xe526(%rip), %rdi      # 0x10146
callq 0x11f0
movl $0x1, %ebp
jmp 0x1d09
leaq 0xe3fa(%rip), %rdi      # 0x10030
callq 0x11f0
xorl %ebp, %ebp
jmp 0x1cef
leaq 0xe547(%rip), %rdi      # 0x10190
callq 0x11f0
movl $0x1, %ebp
leaq 0x28(%rsp), %rbx
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x1c6e
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x1130
movq %rbx, %rdi
callq 0x2190
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x1c93
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x1130
leaq 0xa8(%rsp), %rdi
callq 0x2190
movq 0x100(%rsp), %rdi
testq %rdi, %rdi
je 0x1cbd
movq 0x110(%rsp), %rsi
subq %rdi, %rsi
callq 0x1130
leaq 0xe8(%rsp), %rdi
callq 0x2190
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x1ce7
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x1130
movq %r13, %rdi
callq 0x2190
movl %ebp, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ebp, %ebp
jmp 0x1d0e
xorl %ebp, %ebp
leaq 0x68(%rsp), %r13
testb %r14b, %r14b
jne 0x1dbb
callq 0x2308
movq %rax, %r12
movq %rax, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x18ef
movl %ebx, %r14d
negl %r14d
movq %rsp, %rbp
xorl %r15d, %r15d
xorl %r13d, %r13d
leaq 0xe3ba(%rip), %rdi      # 0x100fc
movl %r13d, %esi
xorl %eax, %eax
callq 0x1030
movq %r12, %rdi
leaq 0xe8(%rsp), %rsi
movl %r15d, %edx
callq 0x18ef
testl %r13d, %r13d
je 0x1d78
leal (%r14,%r15), %edx
movq %r12, %rdi
leaq 0xa8(%rsp), %rsi
callq 0x18ef
movq %r12, %rdi
movq %rbp, %rsi
movl %r15d, %edx
callq 0x19ae
movq %r12, %rdi
callq 0x2383
cmpl $0xa, %eax
je 0x1d9b
incl %r13d
addl %ebx, %r15d
jmp 0x1d3b
leaq 0xe371(%rip), %rdi      # 0x10113
xorl %ebp, %ebp
movl %r13d, %esi
xorl %eax, %eax
callq 0x1030
movq %r12, %rdi
callq 0x2367
leaq 0x68(%rsp), %r13
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x1c53
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x1130
jmp 0x1c53
jmp 0x1de5
jmp 0x1de5
movq %rax, %rbx
jmp 0x1dfe
jmp 0x1de5
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x1dfe
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x1130
leaq 0x20(%rsp), %rdi
callq 0x1e94
leaq 0xa0(%rsp), %rdi
callq 0x1e94
leaq 0xe0(%rsp), %rdi
callq 0x1e94
leaq 0x60(%rsp), %rdi
callq 0x1e94
movq %rbx, %rdi
callq 0x1240