// File: /workspace/github_cpp_makefile_star2_O3/biotomas[P]ipasir/app/genipaessentials/genipaessentials.cpp
// Function: main
int main(int argc, char **argv) {
	printf("Using the incremental SAT solver %s.\n", ipasir_signature());

	if (argc != 2) {
		puts("USAGE: ./genipaessentials <dimacs.cnf>");
		return 0;
	}

	puts("Given a satisfiable formula F and a variable x, we say that x is");
	puts("essential for the satisfiability of F if a truth value (True or False)");
	puts("must be assigned to x in each satisfying assignment of F. This application");
	puts("finds all the variables essential for the satisfiability of a given formula.");

	void *solver = ipasir_init();
	ipasir_set_learn(solver, NULL, 3, learnCb);
	int variables = 0;
	bool loaded = loadFormulaDualRailed(solver, argv[1], &variables);

	if (!loaded) {
		printf("The input formula \"%s\" could not be loaded.\n", argv[1]);
		return 0;
	}

	int satRes = ipasir_solve(solver);

	if (satRes == 20) {
		puts("The input formula is unsatisfiable.");
		return 0;
	}

	std::vector<int> essentialVariables;
	for (int var = 1; var <= variables; var++) {
		printf("Testing if variable %d (out of %d) is essential for satisfiability.\n", var, variables);
		ipasir_assume(solver, -getDualRailName(var));
		ipasir_assume(solver, -getDualRailName(-var));
		satRes = ipasir_solve(solver);
		if (satRes == 10) {
			printf("Variable %d IS NOT essential for satisfiability.\n", var);
		} else {
			printf("Variable %d IS essential for satisfiability.\n", var);
			essentialVariables.push_back(var);
		}
	}
	int essentials = (int)essentialVariables.size();
	printf("SUMMARY: %d of %d (%0.2f%%) of variables is essential for satisfiability.\n",
			essentials, variables, 100.0*essentials/variables);
	puts("The list of variables eseential for satisfiability:");
	for (size_t i = 0; i < essentialVariables.size(); i++) {
		printf("%d ", essentialVariables[i]);
	}
	printf("\n");
	printf("The solver shared %d unit, %d binary and %d ternary clauses.\n", lunits, lbins, lterns);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r14
movl %edi, %ebx
callq 0x1ce4
leaq 0xe70c(%rip), %rdi      # 0x10010
movq %rax, %rsi
xorl %eax, %eax
callq 0x1030
cmpl $0x2, %ebx
jne 0x1992
leaq 0xe743(%rip), %rdi      # 0x1005d
callq 0x11d0
leaq 0xe778(%rip), %rdi      # 0x1009e
callq 0x11d0
leaq 0xe7b3(%rip), %rdi      # 0x100e5
callq 0x11d0
leaq 0xe7f2(%rip), %rdi      # 0x10130
callq 0x11d0
callq 0x1cec
movq %rax, %rbx
leaq -0xa1(%rip), %rcx       # 0x18b1
movq %rax, %rdi
xorl %esi, %esi
movl $0x3, %edx
callq 0x1d91
leaq 0x34(%rsp), %rdx
movl $0x0, (%rdx)
movq 0x8(%r14), %rsi
movq %rbx, %rdi
callq 0x1740
testb %al, %al
je 0x19a3
movq %rbx, %rdi
callq 0x1d67
cmpl $0x14, %eax
jne 0x19ba
leaq 0xe81a(%rip), %rdi      # 0x101aa
jmp 0x1999
leaq 0xe69d(%rip), %rdi      # 0x10036
callq 0x11d0
jmp 0x1b74
movq 0x8(%r14), %rsi
leaq 0xe7cf(%rip), %rdi      # 0x1017d
xorl %eax, %eax
callq 0x1030
jmp 0x1b74
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movl 0x34(%rsp), %ebp
movl $0x1, 0xc(%rsp)
testl %ebp, %ebp
jle 0x1ac1
movl $0x1, %esi
leaq 0xe7e3(%rip), %r14      # 0x101ce
leaq 0xe821(%rip), %r15      # 0x10213
leaq 0xe84c(%rip), %r12      # 0x10245
leaq 0xc(%rsp), %r13
movq %r14, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0x1030
movl 0xc(%rsp), %eax
xorl %esi, %esi
testl %eax, %eax
setle %sil
leal (%rax,%rax), %ecx
negl %esi
xorl %ecx, %esi
testl %eax, %eax
cmovel %eax, %esi
negl %esi
movq %rbx, %rdi
callq 0x1d62
movl 0xc(%rsp), %eax
leal (%rax,%rax), %ecx
negl %ecx
movl %eax, %esi
notl %esi
sarl $0x1f, %esi
xorl %ecx, %esi
testl %eax, %eax
cmovel %eax, %esi
negl %esi
movq %rbx, %rdi
callq 0x1d62
movq %rbx, %rdi
callq 0x1d67
movl 0xc(%rsp), %esi
cmpl $0xa, %eax
jne 0x1a6a
movq %r15, %rdi
xorl %eax, %eax
callq 0x1030
jmp 0x1a9e
movq %r12, %rdi
xorl %eax, %eax
callq 0x1030
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x1a91
movl 0xc(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x1a9e
leaq 0x10(%rsp), %rdi
movq %r13, %rdx
callq 0x1ba8
movl 0xc(%rsp), %eax
leal 0x1(%rax), %esi
movl %esi, 0xc(%rsp)
cmpl %ebp, %eax
jl 0x19fe
movq 0x18(%rsp), %rsi
subq 0x10(%rsp), %rsi
shrq $0x2, %rsi
jmp 0x1ac3
xorl %esi, %esi
xorps %xmm0, %xmm0
cvtsi2sd %esi, %xmm0
mulsd 0xe536(%rip), %xmm0     # 0x10008
cvtsi2sd %ebp, %xmm1
divsd %xmm1, %xmm0
leaq 0xe792(%rip), %rdi      # 0x10273
movl %ebp, %edx
movb $0x1, %al
callq 0x1030
leaq 0xe7cd(%rip), %rdi      # 0x102be
callq 0x11d0
movq 0x10(%rsp), %rax
cmpq %rax, 0x18(%rsp)
je 0x1b33
leaq 0xe7e9(%rip), %rbx      # 0x102f2
xorl %r14d, %r14d
movl (%rax,%r14,4), %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1030
incq %r14
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %rcx, %r14
jb 0x1b0c
movl $0xa, %edi
callq 0x11b0
movl 0x155e9(%rip), %esi     # 0x1712c
movl 0x155e7(%rip), %edx     # 0x17130
movl 0x155e5(%rip), %ecx     # 0x17134
leaq 0xe7a0(%rip), %rdi      # 0x102f6
xorl %eax, %eax
callq 0x1030
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1b74
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x1110
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1b9f
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x1110
movq %rbx, %rdi
callq 0x1210
nop