// File: 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:
subq $0x5a8, %rsp            # imm = 0x5A8
movq %rsi, 0xa0(%rsp)
movq %rdi, 0x5a0(%rsp)
movq %rsi, 0x598(%rsp)
movq 0x5a0(%rsp), %rax
movq %rax, 0x98(%rsp)
leaq 0x578(%rsp), %rdi
callq 0x2250
movq 0xa0(%rsp), %rsi
leaq 0x370(%rsp), %rdi
movl $0x8, %edx
callq 0x2290
jmp 0x2758
movl $0x0, 0x360(%rsp)
movq 0x370(%rsp), %rax
movq -0x18(%rax), %rax
leaq 0x370(%rsp,%rax), %rdi
callq 0x2230
movb %al, 0x97(%rsp)
jmp 0x2785
movb 0x97(%rsp), %al
testb $0x1, %al
jne 0x2795
jmp 0x2d9c
leaq 0x370(%rsp), %rdi
leaq 0x578(%rsp), %rsi
callq 0x2040
jmp 0x27ac
leaq 0x578(%rsp), %rdi
callq 0x2120
cmpq $0x0, %rax
jbe 0x2d97
xorl %eax, %eax
movl %eax, %esi
leaq 0x578(%rsp), %rdi
callq 0x2310
movq %rax, 0x88(%rsp)
jmp 0x27de
movq 0x88(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x70, %eax
jne 0x2a4f
leaq 0x578(%rsp), %rdi
callq 0x20a0
movq 0x98(%rsp), %rdx
movq %rax, %rdi
addq $0x98, %rdx
leaq 0xa80f(%rip), %rsi      # 0xd027
xorl %eax, %eax
leaq 0x35c(%rsp), %rcx
callq 0x2190
movq 0x98(%rsp), %rdi
movl $0x0, 0x9c(%rdi)
addq $0x68, %rdi
movl $0x0, 0x358(%rsp)
leaq 0x358(%rsp), %rsi
callq 0x3550
jmp 0x2857
movl $0x0, 0x354(%rsp)
movq 0x98(%rsp), %rcx
movl 0x354(%rsp), %eax
cmpl 0x98(%rcx), %eax
jge 0x29fe
movq 0x98(%rsp), %rdi
addq $0x50, %rdi
movl $0x0, 0x350(%rsp)
leaq 0x350(%rsp), %rsi
callq 0x3550
jmp 0x28a3
movq 0x98(%rsp), %rdi
addq $0x68, %rdi
movl $0x0, 0x34c(%rsp)
leaq 0x34c(%rsp), %rsi
callq 0x3550
jmp 0x28c9
leaq 0x330(%rsp), %rdi
callq 0x32c0
leaq 0x318(%rsp), %rdi
callq 0x32c0
movq 0x98(%rsp), %rdi
movl 0x354(%rsp), %eax
incl %eax
movl %eax, 0x314(%rsp)
leaq 0x314(%rsp), %rsi
callq 0x3580
movq %rax, 0x80(%rsp)
jmp 0x2912
movq 0x80(%rsp), %rdi
leaq 0x330(%rsp), %rsi
callq 0x35b0
jmp 0x2929
movq 0x98(%rsp), %rdi
movl 0x354(%rsp), %eax
notl %eax
movl %eax, 0x310(%rsp)
leaq 0x310(%rsp), %rsi
callq 0x3580
movq %rax, 0x78(%rsp)
jmp 0x2955
movq 0x78(%rsp), %rdi
leaq 0x318(%rsp), %rsi
callq 0x35b0
jmp 0x2969
leaq 0x318(%rsp), %rdi
callq 0x3870
leaq 0x330(%rsp), %rdi
callq 0x3870
movl 0x354(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x354(%rsp)
jmp 0x2862
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x368(%rsp)
movl %eax, 0x364(%rsp)
jmp 0x2e8f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x368(%rsp)
movl %eax, 0x364(%rsp)
jmp 0x2e82
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x368(%rsp)
movl %eax, 0x364(%rsp)
leaq 0x318(%rsp), %rdi
callq 0x3870
leaq 0x330(%rsp), %rdi
callq 0x3870
jmp 0x2e82
movq 0x98(%rsp), %rdi
addq $0x50, %rdi
movl $0x0, 0x30c(%rsp)
leaq 0x30c(%rsp), %rsi
callq 0x3550
jmp 0x2a24
movq 0x98(%rsp), %rdi
addq $0x68, %rdi
movl $0x0, 0x308(%rsp)
leaq 0x308(%rsp), %rsi
callq 0x3550
jmp 0x2a4a
jmp 0x2d95
xorl %eax, %eax
movl %eax, %esi
leaq 0x578(%rsp), %rdi
callq 0x2310
movq %rax, 0x70(%rsp)
jmp 0x2a67
movq 0x70(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x63, %eax
jne 0x2a79
jmp 0x2763
movl $0x10, %edi
movl $0x8, %esi
callq 0x38d0
movl %eax, 0x6c(%rsp)
jmp 0x2a8e
movl 0x6c(%rsp), %edx
leaq 0x180(%rsp), %rdi
leaq 0x578(%rsp), %rsi
callq 0x2280
jmp 0x2aa9
movl $0x0, 0x17c(%rsp)
movl $0x0, 0x178(%rsp)
leaq 0x140(%rsp), %rdi
callq 0x38f0
leaq 0x180(%rsp), %rdi
leaq 0x13c(%rsp), %rsi
callq 0x20f0
movq %rax, 0x60(%rsp)
jmp 0x2ae8
movq 0x60(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x2230
movb %al, 0x5f(%rsp)
jmp 0x2b02
movb 0x5f(%rsp), %al
testb $0x1, %al
jne 0x2b0f
jmp 0x2bf7
cmpl $0x0, 0x13c(%rsp)
jne 0x2b37
jmp 0x2bf7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x368(%rsp)
movl %eax, 0x364(%rsp)
jmp 0x2d74
leaq 0x140(%rsp), %rdi
leaq 0x13c(%rsp), %rsi
callq 0x3900
movq %rax, 0x50(%rsp)
jmp 0x2b53
movq 0x50(%rsp), %rax
cmpq $0x0, %rax
jbe 0x2b63
jmp 0x2acc
movl 0x13c(%rsp), %eax
negl %eax
movl %eax, 0x138(%rsp)
leaq 0x140(%rsp), %rdi
leaq 0x138(%rsp), %rsi
callq 0x3900
movq %rax, 0x48(%rsp)
jmp 0x2b8f
movq 0x48(%rsp), %rax
cmpq $0x0, %rax
jbe 0x2ba7
movl $0x1, 0x17c(%rsp)
jmp 0x2bf0
leaq 0x140(%rsp), %rdi
leaq 0x13c(%rsp), %rsi
callq 0x3930
movb %dl, 0x3f(%rsp)
movq %rax, 0x40(%rsp)
jmp 0x2bc7
movb 0x3f(%rsp), %al
movq 0x40(%rsp), %rcx
movq %rcx, 0x128(%rsp)
movb %al, 0x130(%rsp)
movl 0x178(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x178(%rsp)
jmp 0x2bf2
jmp 0x2acc
cmpl $0x0, 0x178(%rsp)
jle 0x2d58
cmpl $0x0, 0x17c(%rsp)
jne 0x2d58
leaq 0xf0(%rsp), %rdi
callq 0x38f0
leaq 0x140(%rsp), %rdi
callq 0x3980
movq %rax, 0xe8(%rsp)
leaq 0x140(%rsp), %rdi
callq 0x39d0
movq %rax, 0xe0(%rsp)
leaq 0xe8(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x39b0
testb $0x1, %al
jne 0x2c68
jmp 0x2d1f
leaq 0xe8(%rsp), %rdi
callq 0x3a30
movq 0x98(%rsp), %rdi
movq %rax, %rsi
callq 0x3a00
movq %rax, 0x30(%rsp)
jmp 0x2c8c
movq 0x30(%rsp), %rdi
leaq 0x360(%rsp), %rsi
callq 0x3a50
jmp 0x2ca0
leaq 0xe8(%rsp), %rdi
callq 0x3a30
movq %rax, %rsi
leaq 0xf0(%rsp), %rdi
callq 0x3930
movb %dl, 0x27(%rsp)
movq %rax, 0x28(%rsp)
jmp 0x2cc8
movb 0x27(%rsp), %al
movq 0x28(%rsp), %rcx
movq %rcx, 0xd0(%rsp)
movb %al, 0xd8(%rsp)
leaq 0xe8(%rsp), %rdi
xorl %esi, %esi
callq 0x3ac0
movq %rax, 0xc8(%rsp)
jmp 0x2c35
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x368(%rsp)
movl %eax, 0x364(%rsp)
leaq 0xf0(%rsp), %rdi
callq 0x3b60
jmp 0x2d74
movq 0x98(%rsp), %rdi
addq $0x38, %rdi
leaq 0xf0(%rsp), %rsi
callq 0x3af0
jmp 0x2d3a
movl 0x360(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x360(%rsp)
leaq 0xf0(%rsp), %rdi
callq 0x3b60
leaq 0x140(%rsp), %rdi
callq 0x3b60
leaq 0x180(%rsp), %rdi
callq 0x2140
jmp 0x2d93
leaq 0x140(%rsp), %rdi
callq 0x3b60
leaq 0x180(%rsp), %rdi
callq 0x2140
jmp 0x2e82
jmp 0x2d95
jmp 0x2d97
jmp 0x2763
movl $0x1, 0xc4(%rsp)
movq 0x98(%rsp), %rcx
movl 0xc4(%rsp), %eax
cmpl 0x98(%rcx), %eax
jg 0x2dee
movq 0x98(%rsp), %rdi
subq $-0x80, %rdi
leaq 0xc4(%rsp), %rsi
callq 0x3a50
jmp 0x2dd9
jmp 0x2ddb
movl 0xc4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc4(%rsp)
jmp 0x2da7
movq 0x98(%rsp), %rsi
subq $-0x80, %rsi
movq %rsi, 0x8(%rsp)
leaq 0xb8(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x3be0
movq 0x8(%rsp), %rsi
leaq 0xb0(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x3c30
movq 0x98(%rsp), %rax
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq %rax, 0xa8(%rsp)
movq 0xa8(%rsp), %rdx
callq 0x3b70
jmp 0x2e51
leaq 0x370(%rsp), %rdi
callq 0x2050
jmp 0x2e60
leaq 0x370(%rsp), %rdi
callq 0x2060
leaq 0x578(%rsp), %rdi
callq 0x2100
addq $0x5a8, %rsp            # imm = 0x5A8
retq
leaq 0x370(%rsp), %rdi
callq 0x2060
leaq 0x578(%rsp), %rdi
callq 0x2100
movq 0x368(%rsp), %rdi
callq 0x22d0
nopl (%rax)