// File: /workspace/github_cpp_makefile_star2_O3/Myyura[P]MyyuraSat/./source/./solver_search.cpp
// Function: MyyuraSat::Solver::propagate()
CRARef Solver::propagate() {
    std::cout << "propagate begin! =================" << std::endl;
    CRARef conflict = CRAREF_UNDEF;

    for (; _queue_head < _trail.size();) {
        // 'p' is enqueued fact to propagate
        Literal p = _trail[_queue_head++];
        Vector<_Watcher>& ws = _watches.lookup(p);
        Vector<_Watcher>::Iterator i, j;

        for (i = j = ws.begin(); i != ws.end();) {
            // Try to avoid inspecting the clause:
            Literal blocker = (*i).blocker;
            if (value(blocker) == LIFTED_BOOLEAN_TRUE) {
                *j++ = *i++;
                continue;
            }

            CRARef cr = (*i).cref;
            // std::cout << "cr: " << cr << " | size: " << _ca.size() << std::endl;
            Clause& c = _ca[cr];

            // Make sure the false literal is _data[1]:
            Literal false_lit = ~p;
            if (c[0] == false_lit) {
                c[0] = c[1];
                c[1] = false_lit;
            }
            i++;

            // If 0th watch is true, then clause is already satisfied.
            Literal first = c[0];
            _Watcher w(cr, first);
            if (first != blocker && value(first) == LIFTED_BOOLEAN_TRUE) {
                *j++ = w; 
                continue; 
            }

            // Look for new watch:
            bool found_watch = false;
            for (int k = 2; k < c.size(); k++) {
                if (value(c[k]) != LIFTED_BOOLEAN_FALSE) {
                    c[1] = c[k];
                    c[k] = false_lit;
                    _watches[~c[1]].push(w);
                    found_watch = true;
                    break;
                }
            }

            if (!found_watch) {
                // Did not find watch -- clause is unit under assignment:
                *j++ = w;
                if (value(first) == LIFTED_BOOLEAN_FALSE){
                    conflict = cr;
                    _queue_head = _trail.size();
                    // Copy the remaining watches:
                    while (i != ws.end()) {
                        *j++ = *i++;
                    }
                } else {
                    unchecked_enqueue(first, cr);
                }
            }
        }

        ws.shrink(i - j);
    }
    std::cout << "propagate end! =================" << std::endl;
    return conflict;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %r14
movq 0x929d(%rip), %rbx      # 0xbf98
leaq 0x541d(%rip), %rsi      # 0x811f
movl $0x22, %edx
movq %rbx, %rdi
callq 0x2150
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2120
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20e0
movl 0xe8(%r14), %eax
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
cmpl 0x30(%r14), %eax
jge 0x300f
leaq 0x88(%r14), %rcx
movq %rcx, -0x68(%rbp)
leaq 0x58(%r14), %rcx
movq %rcx, -0x48(%rbp)
leaq 0xf8(%r14), %rcx
movq %rcx, -0x70(%rbp)
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
xorl %r15d, %r15d
movq %r14, -0x58(%rbp)
leal 0x1(%rax), %ecx
movl %ecx, 0xe8(%r14)
movq 0x28(%r14), %rcx
cltq
movl (%rcx,%rax,4), %eax
movl %eax, -0x34(%rbp)
movq -0x68(%rbp), %rdi
leaq -0x34(%rbp), %rsi
callq 0x6278
movq %rax, %r13
movq (%rax), %rbx
cmpl $0x0, 0x8(%rax)
je 0x2fe6
movq %rbx, %r12
movq %r13, -0x40(%rbp)
movl 0x4(%rbx), %r14d
movl %r14d, %esi
sarl %esi
movq -0x48(%rbp), %rdi
callq 0x6abc
movb (%rax), %al
movl %r14d, %ecx
andb $0x1, %cl
xorb %al, %cl
movb 0x939e(%rip), %dl       # 0xc174
movl %edx, %esi
andb $0x2, %sil
andb %sil, %al
xorl %edi, %edi
testb %sil, %sil
sete %dil
cmpb %dl, %cl
cmovnel %r15d, %edi
orb %al, %dil
je 0x2e07
movq (%rbx), %rax
addq $0x8, %rbx
movq %rax, (%r12)
addq $0x8, %r12
jmp 0x2fcf
xorl %r15d, %r15d
movl (%rbx), %esi
movq -0x70(%rbp), %rdi
movl %esi, -0x30(%rbp)
callq 0x687e
movq %rax, %r13
movl -0x34(%rbp), %eax
xorl $0x1, %eax
movl 0x4(%r13), %ecx
cmpl %eax, %ecx
jne 0x2e35
movl 0x8(%r13), %ecx
movl %ecx, 0x4(%r13)
movl %eax, 0x8(%r13)
movl %eax, -0x5c(%rbp)
addq $0x8, %rbx
movl -0x30(%rbp), %eax
movl %eax, -0x50(%rbp)
movl %ecx, -0x4c(%rbp)
cmpl %r14d, %ecx
je 0x2e9b
movl %ecx, %esi
sarl %esi
movq -0x48(%rbp), %rdi
movl %ecx, %r14d
callq 0x6abc
movb (%rax), %al
movl %r14d, %ecx
andb $0x1, %cl
xorb %al, %cl
movb 0x930a(%rip), %dl       # 0xc174
movl %edx, %esi
andb $0x2, %sil
andb %sil, %al
xorl %edi, %edi
testb %sil, %sil
sete %dil
cmpb %dl, %cl
movl %r14d, %ecx
cmovnel %r15d, %edi
orb %al, %dil
je 0x2e9b
movq -0x50(%rbp), %rax
movq %rax, (%r12)
addq $0x8, %r12
jmp 0x2fc8
movl %ecx, -0x60(%rbp)
cmpl $0x60, (%r13)
jb 0x2efe
movl $0x2, %r14d
movl 0x4(%r13,%r14,4), %r15d
movl %r15d, %esi
sarl %esi
movq -0x48(%rbp), %rdi
callq 0x6abc
movb (%rax), %al
andb $0x1, %r15b
xorb %al, %r15b
movb 0x92a7(%rip), %dil      # 0xc175
xorl %edx, %edx
movl %edi, %ecx
andb $0x2, %cl
sete %sil
cmpb %dil, %r15b
je 0x2ee2
xorl %edx, %edx
jmp 0x2ee5
movb %sil, %dl
andb %al, %cl
orb %cl, %dl
je 0x2f9b
incq %r14
movl (%r13), %eax
shrl $0x5, %eax
cmpq %rax, %r14
jb 0x2eab
movq -0x50(%rbp), %rax
movq %rax, (%r12)
addq $0x8, %r12
movl -0x60(%rbp), %r14d
movl %r14d, %esi
sarl %esi
movq -0x48(%rbp), %rdi
callq 0x6abc
movb (%rax), %al
movl %r14d, %ecx
andb $0x1, %cl
xorb %al, %cl
movb 0x9249(%rip), %dl       # 0xc175
movl %edx, %esi
andb $0x2, %sil
andb %sil, %al
xorl %edi, %edi
testb %sil, %sil
sete %dil
cmpb %dl, %cl
movl $0x0, %r15d
cmovnel %r15d, %edi
orb %al, %dil
je 0x2f8a
movq -0x58(%rbp), %rcx
movl 0x30(%rcx), %eax
movl %eax, 0xe8(%rcx)
movq -0x40(%rbp), %r13
movslq 0x8(%r13), %rax
shlq $0x3, %rax
addq (%r13), %rax
cmpq %rax, %rbx
je 0x2f82
movq (%rbx), %rax
addq $0x8, %rbx
movq %rax, (%r12)
addq $0x8, %r12
jmp 0x2f60
movl -0x30(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x2fcf
movq -0x58(%rbp), %rdi
movl %r14d, %esi
movl -0x30(%rbp), %edx
callq 0x2bf4
jmp 0x2fcb
movl 0x4(%r13,%r14,4), %eax
movl %eax, 0x8(%r13)
movl -0x5c(%rbp), %eax
movl %eax, 0x4(%r13,%r14,4)
movl 0x8(%r13), %esi
xorl $0x1, %esi
movq -0x68(%rbp), %rdi
callq 0x7298
movq %rax, %rdi
leaq -0x50(%rbp), %rsi
callq 0x6068
xorl %r15d, %r15d
movq -0x40(%rbp), %r13
movslq 0x8(%r13), %rax
shlq $0x3, %rax
addq (%r13), %rax
cmpq %rax, %rbx
jne 0x2db4
jmp 0x2fe9
movq %rbx, %r12
subq %r12, %rbx
shrq $0x3, %rbx
movq %r13, %rdi
movl %ebx, %esi
callq 0x62b0
movq -0x58(%rbp), %r14
movl 0xe8(%r14), %eax
cmpl 0x30(%r14), %eax
jl 0x2d7a
leaq 0x512c(%rip), %rsi      # 0x8142
movl $0x20, %edx
movq 0x8f76(%rip), %rbx      # 0xbf98
movq %rbx, %rdi
callq 0x2150
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2120
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20e0
movl -0x2c(%rbp), %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop