// File: /workspace/github_cpp_makefile_star2_O1/kc885[P]SAT-Solver-with-CDCL/cdcl.cpp
// Function: ck_cdcl_solver::Solver::parse(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void parse(std::string filename){
            std::string line;
            std::ifstream ifs(filename);
            int clause_num = 0;
            while (ifs) {
                getline(ifs, line);
                
                //effective clause number
                int temp;
                
                if (line.size() > 0) {
                    if (line[0] == 'p') {
                        sscanf(line.c_str(), "p cnf %d %d", &variableNumber, &temp);
                        
                        //initialization
                        unsat = 0;
                        decisionVar.push_back(0);
                        for (int i =0;i <variableNumber;i++){
                            //undefined
                            val_decisionLevel.push_back(0);
                            decisionVar.push_back(0);
                            //antecedent.push_back(-1);
                            std::vector<int> temp1;
                            std::vector<int> temp2;
                            varToClause[i+1] = temp1;
                            varToClause[-i-1] = temp2;
                        }
                        val_decisionLevel.push_back(0);
                        decisionVar.push_back(0);
                        
                    } else if (line[0] == 'c' ){
                        continue;
                    } else {
                        //readClause(line, lits);
                        std::stringstream sin(line);
                        
                        //if a clause contain both a variable and its negation, this clause must evaluate to true so we can skip it.
                        int resolve_flag = 0;
                        
                        //counter for effective variable number in a clause
                        int count = 0;
                        
                        std::unordered_set<int> visited;
                        
                        int num;
                        while(sin >> num){
                            if(num == 0)
                                break;
                            if(visited.count(num) > 0)
                                continue;
                            else if(visited.count(-num) > 0)
                                resolve_flag = 1;
                            else{
                                visited.insert(num);
                                count++;
                                
                            }
                        }
                        if(count > 0 && resolve_flag == 0){
                            std::unordered_set<int> c;
                            
                            for(auto iter = visited.begin(); iter != visited.end(); iter++){
                                varToClause[*iter].push_back(clause_num);
                                c.insert(*iter);
                            }
                            
                            clauses.push_back(c);
                            clause_num++;
                        }
                        
                        
                    }
                }
                
            }
            for(int i =1;i <= variableNumber; i++){
                sor.push_back(i);
            }
            std::sort(sor.rbegin(),sor.rend(),[&](int i, int j)
                {return ((varToClause[i].size() + varToClause[-i].size()) < (varToClause[j].size() + varToClause[-j].size())) ;}
            );
          
            ifs.close();
        }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x468, %rsp            # imm = 0x468
movq %rdi, %rbx
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x260(%rsp), %rdi
movl $0x8, %edx
callq 0x21d0
movl $0x0, 0x8(%rsp)
movq 0x260(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x280(%rsp,%rax)
jne 0x2a84
leaq (%rsp,%rax), %rdi
addq $0x260, %rdi            # imm = 0x260
leaq 0x98(%rbx), %rax
movq %rax, 0x18(%rsp)
leaq 0x68(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x50(%rbx), %rax
movq %rax, 0x20(%rsp)
leaq 0x38(%rbx), %rax
movq %rax, 0x88(%rsp)
leaq 0x260(%rsp), %r14
leaq 0x28(%rsp), %r12
leaq 0xd0(%rsp), %rbp
leaq 0x98(%rsp), %r13
leaq 0xc(%rsp), %r15
movl $0xa, %esi
callq 0x2140
movsbl %al, %edx
movq %r14, %rdi
movq %r12, %rsi
callq 0x2230
cmpq $0x0, 0x30(%rsp)
je 0x2a63
movq 0x28(%rsp), %rdi
movzbl (%rdi), %eax
cmpl $0x63, %eax
je 0x2a63
cmpl $0x70, %eax
jne 0x270c
leaq 0x3997(%rip), %rsi      # 0x605f
movq 0x18(%rsp), %rdx
leaq 0x94(%rsp), %rcx
xorl %eax, %eax
callq 0x2150
xorl %eax, %eax
movl %eax, 0x9c(%rbx)
movl %eax, 0xd0(%rsp)
movq 0x70(%rbx), %rsi
cmpq 0x78(%rbx), %rsi
je 0x28bd
movl $0x0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x70(%rbx)
jmp 0x28ca
movq %rbp, %rdi
movq %r12, %rsi
movl $0x18, %edx
callq 0x21c0
leaq 0x80(%rsp), %rax
movq %rax, 0x50(%rsp)
movq $0x1, 0x58(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%rax)
movl $0x3f800000, 0x70(%rsp) # imm = 0x3F800000
movups %xmm0, -0x8(%rax)
xorl %r14d, %r14d
xorl %r12d, %r12d
movl %r12d, %ecx
movl %ecx, %r12d
movq %rbp, %rdi
movq %r15, %rsi
callq 0x20d0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x27c4
cmpl $0x0, 0xc(%rsp)
je 0x27c4
leaq 0x50(%rsp), %rdi
movq %r15, %rsi
callq 0x3546
testq %rax, %rax
jne 0x2751
xorl %eax, %eax
subl 0xc(%rsp), %eax
movl %eax, 0x98(%rsp)
leaq 0x50(%rsp), %rdi
movq %r13, %rsi
callq 0x3546
movl $0x1, %ecx
testq %rax, %rax
jne 0x274e
leaq 0x50(%rsp), %rdi
movq %rdi, 0x98(%rsp)
movq %r15, %rsi
movq %r13, %rdx
callq 0x35c0
incl %r14d
jmp 0x274b
testl %r14d, %r14d
setne %al
testl %r12d, %r12d
sete %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x2885
leaq 0xc8(%rsp), %rax
movq %rax, 0x98(%rsp)
movq $0x1, 0xa0(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%rax)
movl $0x3f800000, 0xb8(%rsp) # imm = 0x3F800000
movups %xmm0, -0x8(%rax)
movq 0x60(%rsp), %r12
testq %r12, %r12
je 0x2869
leaq 0x8(%r12), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x383e
movq 0x8(%rax), %rsi
cmpq 0x10(%rax), %rsi
je 0x2841
movl 0x8(%rsp), %ecx
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rax)
jmp 0x284e
movq %rax, %rdi
leaq 0x8(%rsp), %rdx
callq 0x3900
movq %r13, 0x48(%rsp)
movq %r13, %rdi
movq %r14, %rsi
leaq 0x48(%rsp), %rdx
callq 0x35c0
movq (%r12), %r12
jmp 0x2812
movq 0x88(%rsp), %rdi
movq %r13, %rsi
callq 0x2fc4
incl 0x8(%rsp)
movq %r13, %rdi
callq 0x3de2
leaq 0x50(%rsp), %rdi
callq 0x3de2
movq %rbp, %rdi
movq 0x6727(%rip), %rsi      # 0x8fc0
callq 0x2100
leaq 0x150(%rsp), %rdi
callq 0x2070
leaq 0x260(%rsp), %r14
leaq 0x28(%rsp), %r12
jmp 0x2a63
movq 0x10(%rsp), %rdi
movq %rbp, %rdx
callq 0x3038
movq 0x18(%rsp), %rax
cmpl $0x0, (%rax)
jle 0x29ea
xorl %r14d, %r14d
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movl $0x0, 0xd0(%rsp)
movq 0x58(%rbx), %rsi
cmpq 0x60(%rbx), %rsi
je 0x2906
movl $0x0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x58(%rbx)
jmp 0x2913
movq 0x20(%rsp), %rdi
movq %rbp, %rdx
callq 0x3038
movl $0x0, 0xd0(%rsp)
movq 0x70(%rbx), %rsi
cmpq 0x78(%rbx), %rsi
je 0x2938
movl $0x0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x70(%rbx)
jmp 0x2945
movq 0x10(%rsp), %rdi
movq %rbp, %rdx
callq 0x3038
xorl %eax, %eax
movq %rax, 0xe0(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0xd0(%rsp)
movq %rax, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
incl %r14d
movl %r14d, 0x98(%rsp)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x3174
movq %rax, %rdi
movq %rbp, %rsi
callq 0x2eee
movl %r12d, 0x98(%rsp)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x3174
movq %rax, %rdi
leaq 0x50(%rsp), %rsi
callq 0x2eee
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x29bc
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
movq 0xd0(%rsp), %rdi
testq %rdi, %rdi
je 0x29d9
movq 0xe0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
decl %r12d
movq 0x18(%rsp), %rax
cmpl (%rax), %r14d
jl 0x28e1
movl $0x0, 0xd0(%rsp)
movq 0x58(%rbx), %rsi
cmpq 0x60(%rbx), %rsi
je 0x2a17
movl $0x0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x58(%rbx)
leaq 0x260(%rsp), %r14
jmp 0x2a2c
movq 0x20(%rsp), %rdi
movq %rbp, %rdx
callq 0x3038
leaq 0x260(%rsp), %r14
movl $0x0, 0xd0(%rsp)
movq 0x70(%rbx), %rsi
cmpq 0x78(%rbx), %rsi
leaq 0x28(%rsp), %r12
je 0x2a56
movl $0x0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x70(%rbx)
jmp 0x2a63
movq 0x10(%rsp), %rdi
movq %rbp, %rdx
callq 0x3038
movq 0x260(%rsp), %rax
movq -0x18(%rax), %rax
leaq (%rsp,%rax), %rdi
addq $0x260, %rdi            # imm = 0x260
testb $0x5, 0x20(%rdi)
je 0x2687
movl $0x1, 0xd0(%rsp)
cmpl $0x0, 0x98(%rbx)
jle 0x2aef
leaq 0x80(%rbx), %r14
movl $0x1, %eax
leaq 0xd0(%rsp), %r15
movq 0x88(%rbx), %rsi
cmpq 0x90(%rbx), %rsi
je 0x2acb
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x88(%rbx)
jmp 0x2ad6
movq %r14, %rdi
movq %r15, %rdx
callq 0x3900
movl 0xd0(%rsp), %ecx
leal 0x1(%rcx), %eax
movl %eax, 0xd0(%rsp)
cmpl 0x98(%rbx), %ecx
jl 0x2aac
movq 0x80(%rbx), %r14
movq 0x88(%rbx), %r15
movq %r15, %rax
subq %r14, %rax
je 0x2b4c
leaq 0xd0(%rsp), %rdi
movq %r15, (%rdi)
leaq 0x50(%rsp), %rsi
movq %r14, (%rsi)
sarq $0x2, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %rbx, %rcx
callq 0x3e07
leaq 0x98(%rsp), %rdi
movq %r15, (%rdi)
leaq 0x48(%rsp), %rsi
movq %r14, (%rsi)
movq %rbx, %rdx
callq 0x3f83
leaq 0x260(%rsp), %rdi
callq 0x2040
leaq 0x260(%rsp), %rdi
callq 0x2050
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x2b82
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2170
addq $0x468, %rsp            # imm = 0x468
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2c04
jmp 0x2bb2
jmp 0x2bb2
jmp 0x2bb2
movq %rax, %rbx
jmp 0x2c3f
jmp 0x2bb7
jmp 0x2bb2
jmp 0x2c04
jmp 0x2bb2
jmp 0x2bb2
jmp 0x2bb2
jmp 0x2bb2
movq %rax, %rbx
jmp 0x2c32
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x3de2
jmp 0x2c07
jmp 0x2bcb
movq %rax, %rbx
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x2be5
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
movq 0xd0(%rsp), %rdi
testq %rdi, %rdi
je 0x2c32
movq 0xe0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
jmp 0x2c32
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x3de2
movq 0x63a8(%rip), %rsi      # 0x8fc0
leaq 0xd0(%rsp), %rdi
callq 0x2100
leaq 0x150(%rsp), %rdi
callq 0x2070
leaq 0x260(%rsp), %rdi
callq 0x2050
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x2c5b
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2170
movq %rbx, %rdi
callq 0x2210
nop