// File: /workspace/github_cpp_makefile_star2_O2/Myyura[P]MyyuraSat/./source/../include/util/dimacs.hpp
// Function: MyyuraSat::parse_dimacs(_IO_FILE*, MyyuraSat::Solver&)
void parse_dimacs(FILE* in, Solver& s) {
    UnitParser p(in);
    Vector<Literal> lits;
    int vars = 0;
    int clauses = 0;
    int count = 0;

    for (; p.read_line();) {
        p.skip_whitespace();
        if (p.current_char() == '\0') {
            continue;
        }

        if (p.current_char() == 'p') {
            if (p.match("p cnf")) {
                vars = p.parse_integer();
                clauses = p.parse_integer();
            } else {
                fprintf(stderr, "PARSE ERROR! Unexpected char: %c\n", p.current_char());
                exit(3);
            }
        } else if (p.current_char() == 'c' || p.current_char() == 'p') {
            continue;
        } else {
            count++;

            // Read clause
            int parsed_lit, var;
            lits.clear();
            for (; ;) {
                parsed_lit = p.parse_integer();
                if (parsed_lit == 0) {
                    break;
                }
                var = std::abs(parsed_lit) - 1;

                for (; var >= s.n_variables();) {
                    // std::cout << var << std::endl;
                    s.new_variable();
                }

                lits.push((parsed_lit > 0) ? Literal(var) : ~Literal(var));
            }

            s.add_clause(lits);
        }
    }

    if (count != clauses) {
        fprintf(stderr, "PARSE ERROR! DIMACS header mismatch: wrong number ofclauses\n");
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %rbx
movq %rdi, -0x48(%rbp)
movabsq $0x40000000000, %rax    # imm = 0x40000000000
movq %rax, -0x38(%rbp)
movl $0x400, %edi            # imm = 0x400
callq 0x2190
movq %rax, -0x40(%rbp)
testq %rax, %rax
je 0x2579
movq %rax, %r13
xorps %xmm0, %xmm0
leaq -0x70(%rbp), %r14
movaps %xmm0, (%r14)
movq $0x0, -0x58(%rbp)
leaq -0x48(%rbp), %r15
movl $0x0, -0x2c(%rbp)
movl -0x34(%rbp), %esi
movq -0x48(%rbp), %rdx
movq %r13, %rdi
callq 0x21f0
testq %rax, %rax
je 0x2532
andl $0x0, -0x38(%rbp)
movq %r15, %rdi
callq 0x25f2
movq -0x40(%rbp), %r13
movslq -0x38(%rbp), %rax
movzbl (%r13,%rax), %ecx
testl %ecx, %ecx
je 0x243a
cmpl $0x63, %ecx
je 0x243a
cmpl $0x70, %ecx
jne 0x249e
movl %eax, %ecx
leaq (%rax,%r13), %rsi
xorl %edx, %edx
leaq 0x5b7b(%rip), %rdi      # 0x8004
movb (%rdx,%rdi), %dil
cmpq $0x5, %rdx
je 0x24fa
cmpb (%rsi,%rdx), %dil
jne 0x24fa
incq %rdx
jmp 0x2482
cmpq $0x0, -0x70(%rbp)
je 0x24a9
andl $0x0, -0x68(%rbp)
incl -0x2c(%rbp)
movq %r15, %rdi
callq 0x2626
testl %eax, %eax
je 0x251e
movl %eax, %r13d
movl %eax, %r12d
negl %r12d
cmovsl %eax, %r12d
cmpl 0xf0(%rbx), %r12d
jle 0x24da
movq %rbx, %rdi
xorl %edx, %edx
callq 0x26ba
jmp 0x24c5
xorl %eax, %eax
testl %r13d, %r13d
setle %al
leal (%rax,%r12,2), %eax
addl $-0x2, %eax
movl %eax, -0x4c(%rbp)
movq %r14, %rdi
leaq -0x4c(%rbp), %rsi
callq 0x49e6
jmp 0x24ac
addl %edx, %eax
movl %eax, -0x38(%rbp)
testb %dil, %dil
jne 0x25a5
movq %r15, %rdi
callq 0x2626
movq %r15, %rdi
callq 0x2626
movq %rax, -0x58(%rbp)
jmp 0x2529
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4a20
movq -0x40(%rbp), %r13
jmp 0x243a
movq -0x58(%rbp), %rax
cmpl %eax, -0x2c(%rbp)
jne 0x255b
leaq -0x70(%rbp), %rdi
callq 0x4a4c
movq %r13, %rdi
callq 0x2160
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xaa46(%rip), %rax      # 0xcfa8
movq (%rax), %rcx
leaq 0x5ac0(%rip), %rdi      # 0x802c
pushq $0x3c
popq %rsi
pushq $0x1
popq %rdx
callq 0x2270
jmp 0x253b
pushq $0x8
popq %rdi
callq 0x20a0
movq 0xa9f8(%rip), %rcx      # 0xcf80
addq $0x10, %rcx
movq %rcx, (%rax)
movq 0xaa0a(%rip), %rsi      # 0xcfa0
movq 0xa9d3(%rip), %rdx      # 0xcf70
movq %rax, %rdi
callq 0x2230
movq 0xa9fc(%rip), %rax      # 0xcfa8
movq (%rax), %rdi
addl %edx, %ecx
movslq %ecx, %rax
movsbl (%r13,%rax), %edx
leaq 0x5a49(%rip), %rsi      # 0x800a
xorl %eax, %eax
callq 0x21a0
pushq $0x3
popq %rdi
callq 0x2170
jmp 0x25d4
jmp 0x25d4
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x4a4c
movq -0x40(%rbp), %rdi
callq 0x2160
movq %rbx, %rdi
callq 0x2250
nop