// File: /workspace/github_cpp_makefile_star2_O2/biotomas[P]ipasir/sat/minisat220/minisat-220/minisat/core/Solver.cc
// Function: Minisat::Solver::analyze(unsigned int, Minisat::vec<Minisat::Lit, int>&, int&)
void Solver::analyze(CRef confl, vec<Lit>& out_learnt, int& out_btlevel)
{
    int pathC = 0;
    Lit p     = lit_Undef;

    // Generate conflict clause:
    //
    out_learnt.push();      // (leave room for the asserting literal)
    int index   = trail.size() - 1;

    do{
        assert(confl != CRef_Undef); // (otherwise should be UIP)
        Clause& c = ca[confl];

        if (c.learnt())
            claBumpActivity(c);

        for (int j = (p == lit_Undef) ? 0 : 1; j < c.size(); j++){
            Lit q = c[j];

            if (!seen[var(q)] && level(var(q)) > 0){
                varBumpActivity(var(q));
                seen[var(q)] = 1;
                if (level(var(q)) >= decisionLevel())
                    pathC++;
                else
                    out_learnt.push(q);
            }
        }
        
        // Select next clause to look at:
        while (!seen[var(trail[index--])]);
        p     = trail[index+1];
        confl = reason(var(p));
        seen[var(p)] = 0;
        pathC--;

    }while (pathC > 0);
    out_learnt[0] = ~p;

    // Simplify conflict clause:
    //
    int i, j;
    out_learnt.copyTo(analyze_toclear);
    if (ccmin_mode == 2){
        for (i = j = 1; i < out_learnt.size(); i++)
            if (reason(var(out_learnt[i])) == CRef_Undef || !litRedundant(out_learnt[i]))
                out_learnt[j++] = out_learnt[i];
        
    }else if (ccmin_mode == 1){
        for (i = j = 1; i < out_learnt.size(); i++){
            Var x = var(out_learnt[i]);

            if (reason(x) == CRef_Undef)
                out_learnt[j++] = out_learnt[i];
            else{
                Clause& c = ca[reason(var(out_learnt[i]))];
                for (int k = 1; k < c.size(); k++)
                    if (!seen[var(c[k])] && level(var(c[k])) > 0){
                        out_learnt[j++] = out_learnt[i];
                        break; }
            }
        }
    }else
        i = j = out_learnt.size();

    max_literals += out_learnt.size();
    out_learnt.shrink(i - j);
    tot_literals += out_learnt.size();

    // Find correct backtrack level:
    //
    if (out_learnt.size() == 1)
        out_btlevel = 0;
    else{
        int max_i = 1;
        // Find the first literal assigned at the next-highest level:
        for (int i = 2; i < out_learnt.size(); i++)
            if (level(var(out_learnt[i])) > level(var(out_learnt[max_i])))
                max_i = i;
        // Swap-in this literal at index 1:
        Lit p             = out_learnt[max_i];
        out_learnt[max_i] = out_learnt[1];
        out_learnt[1]     = p;
        out_btlevel       = level(var(p));
    }

    for (int j = 0; j < analyze_toclear.size(); j++) seen[var(analyze_toclear[j])] = 0;    // ('seen[]' is now cleared)
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, 0x10(%rsp)
movl %esi, %ebp
movq %rdi, %rbx
movq %rdx, 0x8(%rsp)
movq %rdx, %rdi
callq 0x68ae
movl 0x170(%rbx), %r14d
decl %r14d
xorl %r12d, %r12d
pushq $-0x2
popq %r15
movq 0x2d8(%rbx), %rax
movl %ebp, %ecx
leaq (%rax,%rcx,4), %r13
testb $0x4, (%r13)
je 0x4897
movq %rbx, %rdi
movq %r13, %rsi
callq 0x68d6
xorl %ebp, %ebp
cmpl $-0x2, %r15d
setne %bpl
movq 0x8(%rsp), %r15
movl (%r13), %eax
shrl $0x5, %eax
cmpq %rax, %rbp
jae 0x492a
movl 0x4(%r13,%rbp,4), %esi
movl %esi, 0x4(%rsp)
sarl %esi
movq 0x318(%rbx), %rcx
movslq %esi, %rax
cmpb $0x0, (%rcx,%rax)
je 0x48d2
incq %rbp
jmp 0x48a6
movq 0x210(%rbx), %rcx
cmpl $0x0, 0x4(%rcx,%rax,8)
jle 0x48cd
movq %rbx, %rdi
callq 0x6968
movl 0x4(%rsp), %eax
sarl %eax
movq 0x318(%rbx), %rcx
cltq
movb $0x1, (%rcx,%rax)
movl 0x4(%rsp), %eax
sarl %eax
movq 0x210(%rbx), %rcx
cltq
movl 0x4(%rcx,%rax,8), %eax
cmpl 0x180(%rbx), %eax
jge 0x4925
movq %r15, %rdi
leaq 0x4(%rsp), %rsi
callq 0x375e
jmp 0x48cd
incl %r12d
jmp 0x48cd
movq 0x318(%rbx), %rax
movslq %r14d, %rcx
shlq $0x2, %rcx
addq 0x168(%rbx), %rcx
movl (%rcx), %r15d
movl %r15d, %edx
sarl %edx
movslq %edx, %rdx
addq $-0x4, %rcx
decl %r14d
cmpb $0x0, (%rax,%rdx)
je 0x493f
movq 0x210(%rbx), %rcx
movl (%rcx,%rdx,8), %ebp
movb $0x0, (%rax,%rdx)
leal -0x1(%r12), %eax
cmpl $0x1, %r12d
movl %eax, %r12d
jg 0x4878
xorl $0x1, %r15d
movq 0x8(%rsp), %r14
movq (%r14), %rax
movl %r15d, (%rax)
leaq 0x340(%rbx), %rsi
movq %r14, %rdi
callq 0x3674
movl 0x9c(%rbx), %eax
cmpl $0x1, %eax
je 0x49f8
cmpl $0x2, %eax
jne 0x4a88
pushq $0x1
popq %rbp
pushq $0x1
popq %r12
movslq 0x8(%r14), %r9
cmpq %r9, %r12
jge 0x4a92
movq (%r14), %rax
movl (%rax,%r12,4), %esi
movl %esi, %ecx
sarl %ecx
movq 0x210(%rbx), %rdx
movslq %ecx, %rcx
cmpl $-0x1, (%rdx,%rcx,8)
je 0x49eb
movq %rbx, %rdi
callq 0x4b5a
testb %al, %al
jne 0x49f3
movq (%r14), %rax
movl (%rax,%r12,4), %esi
movslq %ebp, %rcx
incl %ebp
movl %esi, (%rax,%rcx,4)
incq %r12
jmp 0x49b0
movq (%r14), %rax
movq 0x210(%rbx), %rcx
movq 0x2d8(%rbx), %rdx
leaq 0x8(%rdx), %rsi
pushq $0x1
popq %rbp
pushq $0x1
popq %rdi
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
movq %rdi, %r12
movslq 0x8(%r14), %r9
cmpq %r9, %r12
jge 0x4a92
movl (%rax,%r12,4), %r9d
movl %r9d, %r10d
sarl %r10d
movslq %r10d, %r10
movl (%rcx,%r10,8), %r14d
cmpq %r8, %r14
je 0x4a75
movl (%rdx,%r14,4), %r10d
shrl $0x5, %r10d
movq 0x318(%rbx), %r11
leaq (%rsi,%r14,4), %r14
movq %rdi, %r15
cmpq %r10, %r15
jae 0x4a7e
movl -0x4(%r14,%r15,4), %r13d
sarl %r13d
movslq %r13d, %r13
cmpb $0x0, (%r11,%r13)
jne 0x4a70
cmpl $0x0, 0x4(%rcx,%r13,8)
jg 0x4a75
incq %r15
jmp 0x4a51
movslq %ebp, %r10
incl %ebp
movl %r9d, (%rax,%r10,4)
incq %r12
movq 0x8(%rsp), %r14
jmp 0x4a1c
movl 0x8(%r14), %ebp
movslq %ebp, %r9
movl %ebp, %r12d
subl %ebp, %r12d
addq %r9, 0x138(%rbx)
movq %r14, %rdi
movl %r12d, %esi
callq 0x6694
movslq 0x8(%r14), %rax
addq %rax, 0x140(%rbx)
xorl %ecx, %ecx
cmpq $0x1, %rax
je 0x4b16
movq (%r14), %rdx
movq 0x210(%rbx), %rcx
pushq $0x1
popq %rdi
pushq $0x2
popq %rsi
movslq %edi, %r8
cmpq %rax, %rsi
jge 0x4b00
movl (%rdx,%rsi,4), %r9d
sarl %r9d
movslq %r9d, %r9
movl 0x4(%rcx,%r9,8), %r9d
movl (%rdx,%r8,4), %r8d
sarl %r8d
movslq %r8d, %r10
movl %esi, %r8d
cmpl 0x4(%rcx,%r10,8), %r9d
jg 0x4af8
movl %edi, %r8d
incq %rsi
movl %r8d, %edi
jmp 0x4aca
movl (%rdx,%r8,4), %eax
movl 0x4(%rdx), %esi
movl %esi, (%rdx,%r8,4)
movl %eax, 0x4(%rdx)
sarl %eax
cltq
movl 0x4(%rcx,%rax,8), %ecx
movq 0x10(%rsp), %rax
movl %ecx, (%rax)
xorl %eax, %eax
movslq 0x348(%rbx), %rcx
cmpq %rcx, %rax
jge 0x4b4a
movq 0x318(%rbx), %rcx
movq 0x340(%rbx), %rdx
movl (%rdx,%rax,4), %edx
sarl %edx
movslq %edx, %rdx
movb $0x0, (%rcx,%rdx)
incq %rax
jmp 0x4b1f
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop