// File: /workspace/github_cpp_makefile_star2_O1/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, -0x58(%rbp)
movabsq $0x40000000000, %rax    # imm = 0x40000000000
movq %rax, -0x48(%rbp)
movl $0x400, %edi            # imm = 0x400
callq 0x21b0
movq %rax, -0x50(%rbp)
testq %rax, %rax
je 0x2746
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
movq -0x58(%rbp), %r14
movq -0x50(%rbp), %r15
movl -0x44(%rbp), %r13d
movl -0x48(%rbp), %r12d
movq %r15, %rdi
movl %r13d, %esi
movq %r14, %rdx
callq 0x2210
testq %rax, %rax
je 0x26ef
leaq 0x2b0(%rbx), %rax
movq %rax, -0x70(%rbp)
movq $0x0, -0x60(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x5, %ecx
xorl %edx, %edx
movq %rdx, %r12
movzbl (%r15,%rdx), %eax
leal -0x9(%rax), %edx
cmpl $0x5, %edx
jae 0x2582
incq %r12
incl %ecx
movq %r12, %rdx
jmp 0x2568
cmpl $0x20, %eax
je 0x2578
movslq %r12d, %rax
movzbl (%r15,%rax), %edx
testl %edx, %edx
je 0x2598
cmpl $0x63, %edx
jne 0x25ba
movq %r15, %rdi
movl %r13d, %esi
movq %r14, %rdx
callq 0x2210
movl $0x5, %ecx
movl $0x0, %edx
testq %rax, %rax
jne 0x2568
jmp 0x26fe
cmpl $0x70, %edx
jne 0x2611
movl %r12d, -0x48(%rbp)
cmpb $0x70, (%r15,%rax)
leaq 0x6a51(%rip), %r8       # 0x9020
leaq -0x58(%rbp), %r14
jne 0x2774
movslq %r12d, %rax
addq %r15, %rax
incq %rax
xorl %edx, %edx
movb 0x1(%rdx,%r8), %sil
cmpq $0x4, %rdx
je 0x26a2
leaq 0x1(%rdx), %rdi
cmpb (%rax,%rdx), %sil
movq %rdi, %rdx
je 0x25e4
testb %sil, %sil
sete %al
addl %edi, %r12d
movl %r12d, %ecx
jmp 0x26a8
movl %r12d, -0x48(%rbp)
cmpq $0x0, -0x40(%rbp)
leaq -0x58(%rbp), %r13
je 0x2627
movl $0x0, -0x38(%rbp)
movq %r13, %rdi
callq 0x27ba
movl %eax, %r14d
testl %eax, %eax
je 0x267b
movl %r14d, %r12d
negl %r12d
cmovsl %r14d, %r12d
leal -0x1(%r12), %r15d
cmpl 0xf0(%rbx), %r12d
jle 0x265a
movq %rbx, %rdi
xorl %edx, %edx
callq 0x2864
jmp 0x2645
leal (%r15,%r15), %eax
testl %r14d, %r14d
leal 0x1(%r15,%r15), %ecx
cmovgl %eax, %ecx
movl %ecx, -0x64(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x64(%rbp), %rsi
callq 0x5b5e
jmp 0x2627
leaq -0x40(%rbp), %rdi
movq -0x70(%rbp), %r14
movq %r14, %rsi
callq 0x6c20
movq %rbx, %rdi
movq %r14, %rsi
callq 0x29d4
movq -0x60(%rbp), %rax
incl %eax
movq %rax, -0x60(%rbp)
jmp 0x26c6
testb %sil, %sil
sete %al
movl %ecx, -0x48(%rbp)
testb %al, %al
je 0x2774
movq %r14, %rdi
callq 0x27ba
movq %r14, %rdi
callq 0x27ba
movl %eax, -0x2c(%rbp)
movq -0x58(%rbp), %r14
movq -0x50(%rbp), %r15
movl -0x44(%rbp), %r13d
movl -0x48(%rbp), %r12d
movq %r15, %rdi
movl %r13d, %esi
movq %r14, %rdx
callq 0x2210
testq %rax, %rax
jne 0x2561
jmp 0x26fe
movl $0x0, -0x2c(%rbp)
movq $0x0, -0x60(%rbp)
movl %r12d, -0x48(%rbp)
movl -0x2c(%rbp), %eax
cmpl %eax, -0x60(%rbp)
jne 0x273f
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x2728
xorl %ebx, %ebx
movl %ebx, -0x38(%rbp)
callq 0x2180
movq $0x0, -0x40(%rbp)
movl %ebx, -0x34(%rbp)
movq %r15, %rdi
callq 0x2180
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x22de
jmp 0x270a
movl $0x8, %edi
callq 0x20a0
movq 0xa829(%rip), %rcx      # 0xcf80
addq $0x10, %rcx
movq %rcx, (%rax)
movq 0xa83b(%rip), %rsi      # 0xcfa0
movq 0xa804(%rip), %rdx      # 0xcf70
movq %rax, %rdi
callq 0x2250
leaq -0x48(%rbp), %rdi
movq %r15, %rsi
callq 0x22b0
jmp 0x2784
jmp 0x2784
movq %rax, %rbx
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x27a8
xorl %r14d, %r14d
movl %r14d, -0x38(%rbp)
callq 0x2180
movq $0x0, -0x40(%rbp)
movl %r14d, -0x34(%rbp)
movq -0x50(%rbp), %rdi
callq 0x2180
movq %rbx, %rdi
callq 0x2270
nop