// File: 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
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rsi
leaq -0x28(%rbp), %rdi
movl $0x400, %edx            # imm = 0x400
callq 0x2750
leaq -0x38(%rbp), %rdi
callq 0x7480
jmp 0x2490
movl $0x0, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movl $0x0, -0x50(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x27e0
movb %al, -0x65(%rbp)
jmp 0x24b3
movb -0x65(%rbp), %al
testb $0x1, %al
jne 0x24bf
jmp 0x26fe
leaq -0x28(%rbp), %rdi
callq 0x2830
jmp 0x24ca
leaq -0x28(%rbp), %rdi
callq 0x28b0
movb %al, -0x66(%rbp)
jmp 0x24d8
movb -0x66(%rbp), %al
movsbl %al, %eax
cmpl $0x0, %eax
jne 0x2510
jmp 0x24a5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x2739
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x7640
jmp 0x2739
leaq -0x28(%rbp), %rdi
callq 0x28b0
movb %al, -0x67(%rbp)
jmp 0x251e
movb -0x67(%rbp), %al
movsbl %al, %eax
cmpl $0x70, %eax
jne 0x25b8
leaq 0xcb4e(%rip), %rsi      # 0xf082
leaq -0x28(%rbp), %rdi
callq 0x28d0
movb %al, -0x68(%rbp)
jmp 0x2542
movb -0x68(%rbp), %al
testb $0x1, %al
jne 0x254b
jmp 0x2575
leaq -0x28(%rbp), %rdi
callq 0x2940
movl %eax, -0x6c(%rbp)
jmp 0x2559
movl -0x6c(%rbp), %eax
movl %eax, -0x48(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x2940
movl %eax, -0x70(%rbp)
jmp 0x256d
movl -0x70(%rbp), %eax
movl %eax, -0x4c(%rbp)
jmp 0x25b3
movq 0x13a2c(%rip), %rax     # 0x15fa8
movq (%rax), %rax
movq %rax, -0x80(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x28b0
movb %al, -0x71(%rbp)
jmp 0x2591
movq -0x80(%rbp), %rdi
movb -0x71(%rbp), %al
movsbl %al, %edx
leaq 0xcae6(%rip), %rsi      # 0xf088
movb $0x0, %al
callq 0x2190
movl $0x3, %edi
callq 0x2160
jmp 0x26f9
leaq -0x28(%rbp), %rdi
callq 0x28b0
movb %al, -0x81(%rbp)
jmp 0x25c9
movb -0x81(%rbp), %al
movsbl %al, %eax
cmpl $0x63, %eax
je 0x25f6
leaq -0x28(%rbp), %rdi
callq 0x28b0
movb %al, -0x82(%rbp)
jmp 0x25e8
movb -0x82(%rbp), %al
movsbl %al, %eax
cmpl $0x70, %eax
jne 0x25fb
jmp 0x24a5
movl -0x50(%rbp), %eax
incl %eax
movl %eax, -0x50(%rbp)
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
callq 0x74b0
jmp 0x2610
jmp 0x2612
leaq -0x28(%rbp), %rdi
callq 0x2940
movl %eax, -0x88(%rbp)
jmp 0x2623
movl -0x88(%rbp), %eax
movl %eax, -0x54(%rbp)
cmpl $0x0, -0x54(%rbp)
jne 0x2637
jmp 0x26e6
movl -0x54(%rbp), %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
subl $0x1, %eax
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %eax
movl %eax, -0x90(%rbp)
movq -0x10(%rbp), %rdi
callq 0x7530
movl %eax, -0x8c(%rbp)
jmp 0x2661
movl -0x90(%rbp), %eax
movl -0x8c(%rbp), %ecx
cmpl %ecx, %eax
jl 0x2690
movq -0x10(%rbp), %rdi
movb 0x13adb(%rip), %al      # 0x16156
movb %al, -0x59(%rbp)
movzbl -0x59(%rbp), %esi
movl $0x1, %edx
callq 0x2aa0
jmp 0x268e
jmp 0x2647
cmpl $0x0, -0x54(%rbp)
jle 0x26a8
movl -0x58(%rbp), %esi
leaq -0x60(%rbp), %rdi
xorl %edx, %edx
callq 0x7430
jmp 0x26a6
jmp 0x26d2
movl -0x58(%rbp), %esi
leaq -0x64(%rbp), %rdi
xorl %edx, %edx
callq 0x7430
jmp 0x26b8
leaq -0x64(%rbp), %rdi
callq 0x75b0
movl %eax, -0x94(%rbp)
jmp 0x26c9
movl -0x94(%rbp), %eax
movl %eax, -0x60(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x7550
jmp 0x26e1
jmp 0x2612
movq -0x10(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x75f0
jmp 0x26f5
jmp 0x26f7
jmp 0x26f9
jmp 0x24a5
movl -0x50(%rbp), %eax
cmpl -0x4c(%rbp), %eax
je 0x271e
movq 0x1389b(%rip), %rax     # 0x15fa8
movq (%rax), %rdi
leaq 0xc993(%rip), %rsi      # 0xf0aa
movb $0x0, %al
callq 0x2190
leaq -0x38(%rbp), %rdi
callq 0x7640
leaq -0x28(%rbp), %rdi
callq 0x2c40
addq $0xa0, %rsp
popq %rbp
retq
leaq -0x28(%rbp), %rdi
callq 0x2c40
movq -0x40(%rbp), %rdi
callq 0x2230
nopl (%rax,%rax)