// File: /workspace/github_cpp_makefile_star2_O3/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 0xe5e8(%rip), %rdi      # 0x10004
callq 0x11f0
cmpl $0x2, %ebp
jne 0x1c86
xorps %xmm0, %xmm0
leaq 0xe0(%rsp), %rsi
movaps %xmm0, 0x20(%rsi)
movaps %xmm0, 0x10(%rsi)
movaps %xmm0, (%rsi)
xorl %eax, %eax
movq %rax, 0x30(%rsi)
leaq 0xa0(%rsp), %rdx
movq %rax, 0x30(%rdx)
movaps %xmm0, 0x20(%rdx)
movaps %xmm0, 0x10(%rdx)
movaps %xmm0, (%rdx)
leaq 0x60(%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 0x17eb
movl 0xe0(%rsp), %esi
movl 0xa0(%rsp), %edx
movl 0x20(%rsp), %ecx
movl 0x60(%rsp), %r8d
leaq 0xe5a7(%rip), %rdi      # 0x10056
xorl %eax, %eax
callq 0x1030
movq 0xf0(%rsp), %rsi
subq 0xe8(%rsp), %rsi
sarq $0x3, %rsi
movabsq $-0x5555555555555555, %rbx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rbx, %rsi
movq 0xb0(%rsp), %rdx
subq 0xa8(%rsp), %rdx
sarq $0x3, %rdx
movq 0x30(%rsp), %rcx
subq 0x28(%rsp), %rcx
imulq %rbx, %rdx
sarq $0x3, %rcx
imulq %rbx, %rcx
movq 0x70(%rsp), %r8
subq 0x68(%rsp), %r8
sarq $0x3, %r8
imulq %rbx, %r8
leaq 0xe579(%rip), %rdi      # 0x10094
xorl %eax, %eax
callq 0x1030
callq 0x22b8
leaq 0xe8(%rsp), %r14
leaq 0xa8(%rsp), %r15
leaq 0xe596(%rip), %rdi      # 0x100d4
movq %rax, %rsi
xorl %eax, %eax
callq 0x1030
movl -0x8(%r14), %ebp
cmpl %ebp, -0x8(%r15)
jne 0x1c99
cmpl %ebp, 0x20(%rsp)
jne 0x1c99
leal (,%rbp,2), %eax
cmpl %eax, 0x60(%rsp)
jne 0x1c99
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movq 0x28(%rsp), %rax
movq 0x30(%rsp), %rcx
cmpq %rax, %rcx
je 0x1c01
movl $0x8, %r15d
xorl %r13d, %r13d
movq %rsp, %r12
movq -0x8(%rax,%r15), %rdx
movq (%rax,%r15), %rsi
movq %rsi, %rdi
subq %rdx, %rdi
cmpq $0x5, %rdi
jae 0x1d7c
cmpq %rdx, %rsi
je 0x1be7
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x1bd5
movl (%rdx), %edx
movl %edx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rsp)
jmp 0x1be7
movq %r12, %rdi
callq 0x2198
movq 0x28(%rsp), %rax
movq 0x30(%rsp), %rcx
incq %r13
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %rbx, %rdx
addq $0x18, %r15
cmpq %rdx, %r13
jb 0x1b9c
callq 0x22c0
movq %rax, %r12
movq %rax, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x18f8
movl %ebp, %r14d
negl %r14d
movq %rsp, %rbx
xorl %r15d, %r15d
xorl %r13d, %r13d
leaq 0xe4d0(%rip), %rdi      # 0x100fc
movl %r13d, %esi
xorl %eax, %eax
callq 0x1030
movq %r12, %rdi
leaq 0xa8(%rsp), %rsi
movl %r15d, %edx
callq 0x18f8
testl %r13d, %r13d
je 0x1c5f
leal (%r14,%r15), %edx
movq %r12, %rdi
leaq 0x68(%rsp), %rsi
callq 0x18f8
movq %r12, %rdi
movq %rbx, %rsi
movl %r15d, %edx
callq 0x19ab
movq %r12, %rdi
callq 0x233b
cmpl $0xa, %eax
je 0x1d57
incl %r13d
addl %ebp, %r15d
jmp 0x1c25
leaq 0xe3a3(%rip), %rdi      # 0x10030
callq 0x11f0
xorl %ebp, %ebp
jmp 0x1d43
leaq 0xe4f0(%rip), %rdi      # 0x10190
callq 0x11f0
movl $0x1, %ebp
leaq 0x28(%rsp), %rbx
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x1cc5
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x1130
movq %rbx, %rdi
callq 0x2144
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x1cea
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x1130
leaq 0x68(%rsp), %rdi
callq 0x2144
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x1d11
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x1130
leaq 0xa8(%rsp), %rdi
callq 0x2144
movq 0x100(%rsp), %rdi
testq %rdi, %rdi
je 0x1d3b
movq 0x110(%rsp), %rsi
subq %rdi, %rsi
callq 0x1130
movq %r14, %rdi
callq 0x2144
movl %ebp, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xe3b5(%rip), %rdi      # 0x10113
xorl %ebp, %ebp
movl %r13d, %esi
xorl %eax, %eax
callq 0x1030
movq %r12, %rdi
callq 0x231f
leaq 0xe8(%rsp), %r14
jmp 0x1d8d
leaq 0xe3c3(%rip), %rdi      # 0x10146
callq 0x11f0
movl $0x1, %ebp
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x1caa
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x1130
jmp 0x1caa
jmp 0x1db7
jmp 0x1db7
movq %rax, %rbx
jmp 0x1dd0
jmp 0x1db7
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x1dd0
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x1130
leaq 0x20(%rsp), %rdi
callq 0x1e66
leaq 0x60(%rsp), %rdi
callq 0x1e66
leaq 0xa0(%rsp), %rdi
callq 0x1e66
leaq 0xe0(%rsp), %rdi
callq 0x1e66
movq %rbx, %rdi
callq 0x1240