// File: /workspace/github_cpp_makefile_star2_O1/biotomas[P]ipasir/app/genipabones/genipabones.cpp
// Function: loadFormula(void*, char const*, std::vector<int, std::allocator<int>>&, int&)
bool loadFormula(void* solver, const char* filename, vector<int>& boundary, int& maxVar) {
	FILE* f = fopen(filename, "r");
	if (f == NULL) {
		return false;
	}
	maxVar = 0;
	int c = 0;
	bool neg = false;
	while (c != EOF) {
		c = fgetc(f);

		// comment or problem definition line
		if (c == 'c' || c == 'p') {
			c = fgetc(f);
			if (c == 'v' && fgetc(f) == 'i' && fgetc(f) == 'p' && fgetc(f) == ' ') {
				// boundary variables
				printf("c back-bone candidates specified in input file.\n");
				int num = 0;
				while(c != '\n') {
					c = fgetc(f);
					while (isdigit(c)) {
						num = num*10 + (c-'0');
						c = fgetc(f);
					}
					boundary.push_back(num);
					num = 0;
				}
			}
			// skip this line
			while(c != '\n') {
				c = fgetc(f);
			}
			continue;
		}
		// whitespace
		if (isspace(c)) {
			continue;
		}
		// negative
		if (c == '-') {
			neg = true;
			continue;
		}

		// number
		if (isdigit(c)) {
			int num = c - '0';
			c = fgetc(f);
			while (isdigit(c)) {
				num = num*10 + (c-'0');
				c = fgetc(f);
			}
			if (neg) {
				num *= -1;
			}
			neg = false;

			if (abs(num) > maxVar) {
				maxVar = abs(num);
			}
			// add to the solver
			ipasir_add(solver, num);
		}
	}
	fclose(f);
	return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %rax
movq %rdi, %r15
leaq 0x114c0(%rip), %rsi     # 0x12c2d
movq %rax, %rdi
callq 0x1150
movq %rax, %r12
testq %rax, %rax
je 0x1942
movq %r15, 0x10(%rsp)
movl $0x0, (%rbx)
movl $0x0, 0xc(%rsp)
leaq 0x8(%rsp), %rbp
movq %r12, %rdi
callq 0x11f0
cmpl $0x70, %eax
je 0x17b2
movl %eax, %r13d
cmpl $0x63, %eax
jne 0x189d
movq %r12, %rdi
callq 0x11f0
movl %eax, %r15d
cmpl $0x76, %eax
jne 0x1882
movq %r12, %rdi
callq 0x11f0
movl $0x76, %r15d
cmpl $0x69, %eax
jne 0x1882
movq %r12, %rdi
callq 0x11f0
cmpl $0x70, %eax
jne 0x1882
movq %r12, %rdi
callq 0x11f0
cmpl $0x20, %eax
jne 0x1882
leaq 0xe96c(%rip), %rdi      # 0x10172
callq 0x11d0
movl $0x0, 0x8(%rsp)
movq %r12, %rdi
callq 0x11f0
movl %eax, %r13d
leal -0x30(%r13), %eax
cmpl $0x9, %eax
ja 0x1849
movl 0x8(%rsp), %ecx
leal (%rcx,%rcx,4), %ecx
leal (%rax,%rcx,2), %eax
movl %eax, 0x8(%rsp)
movq %r12, %rdi
callq 0x11f0
movl %eax, %r13d
leal -0x30(%r13), %eax
cmpl $0xa, %eax
jb 0x1827
movq 0x8(%r14), %rsi
cmpq 0x10(%r14), %rsi
je 0x1863
movl 0x8(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%r14)
jmp 0x186e
movq %r14, %rdi
movq %rbp, %rdx
callq 0x1c30
movl $0x0, 0x8(%rsp)
cmpl $0xa, %r13d
jne 0x1813
movl $0xa, %r15d
movl $0xa, %r13d
cmpl $0xa, %r15d
je 0x18a9
movq %r12, %rdi
callq 0x11f0
cmpl $0xa, %eax
jne 0x188e
jmp 0x18a9
movl %r13d, %edi
callq 0x1040
testl %eax, %eax
je 0x18b8
cmpl $-0x1, %r13d
jne 0x1799
jmp 0x193a
cmpl $0x2d, %r13d
jne 0x18cc
movb $0x1, %al
movl %eax, 0xc(%rsp)
movl $0x2d, %r13d
jmp 0x18a9
movl %r13d, %r15d
addl $-0x30, %r15d
cmpl $0x9, %r15d
ja 0x18a9
movq %r12, %rdi
callq 0x11f0
movl %eax, %r13d
leal -0x30(%r13), %eax
cmpl $0x9, %eax
ja 0x1909
leal (%r15,%r15,4), %ecx
leal (%rax,%rcx,2), %r15d
movq %r12, %rdi
callq 0x11f0
movl %eax, %r13d
leal -0x30(%r13), %eax
cmpl $0xa, %eax
jb 0x18ed
movl %r15d, %esi
negl %esi
movl %r15d, %eax
cmovnsl %esi, %eax
testb $0x1, 0xc(%rsp)
cmovel %r15d, %esi
cmpl (%rbx), %eax
jle 0x1923
movl %eax, (%rbx)
movq 0x10(%rsp), %rdi
callq 0x1de5
movl $0x0, 0xc(%rsp)
jmp 0x18a9
movq %r12, %rdi
callq 0x10f0
testq %r12, %r12
setne %al
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq