// File: /workspace/github_cpp_makefile_star2_O2/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 $0x38, %rsp
movq %rdi, %r15
movq 0xa50b(%rip), %rdi      # 0xcf98
leaq 0x566f(%rip), %rsi      # 0x8103
callq 0x2110
movq %rax, %rdi
callq 0x2090
leaq 0x88(%r15), %rax
movq %rax, -0x58(%rbp)
leaq 0xf8(%r15), %rax
movq %rax, -0x60(%rbp)
pushq $-0x1
popq %rax
movl %eax, -0x3c(%rbp)
movslq 0xe8(%r15), %rax
cmpl 0x30(%r15), %eax
jge 0x2cbf
leal 0x1(%rax), %ecx
movl %ecx, 0xe8(%r15)
movq 0x28(%r15), %rcx
movl (%rcx,%rax,4), %eax
movl %eax, -0x40(%rbp)
movq -0x58(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x5436
movq %rax, %r12
movq (%rax), %rax
movq %rax, %r14
movq %rax, %r13
movq %r12, -0x48(%rbp)
movslq 0x8(%r12), %rcx
leaq (%rax,%rcx,8), %rax
cmpq %rax, %r13
je 0x2ca8
movl 0x4(%r13), %ebx
movq %r15, %rdi
movl %ebx, %esi
callq 0x4a5c
movb %al, -0x38(%rbp)
leaq -0x38(%rbp), %rdi
leaq 0xa637(%rip), %rsi      # 0xd164
callq 0x4a7e
testb %al, %al
je 0x2b4a
movq (%r13), %rax
addq $0x8, %r13
movq %rax, (%r14)
addq $0x8, %r14
jmp 0x2c97
movq %r15, %r12
movl (%r13), %esi
movq -0x60(%rbp), %rdi
movl %esi, -0x30(%rbp)
callq 0x5a5e
movq %rax, %r15
movl -0x40(%rbp), %eax
xorl $0x1, %eax
movl 0x4(%r15), %esi
cmpl %eax, %esi
jne 0x2b7a
movl 0x8(%r15), %esi
movl %esi, 0x4(%r15)
movl %eax, 0x8(%r15)
movl %eax, -0x4c(%rbp)
addq $0x8, %r13
movl -0x30(%rbp), %eax
movl %eax, -0x38(%rbp)
movl %esi, -0x34(%rbp)
cmpl %ebx, %esi
movl %esi, -0x50(%rbp)
je 0x2bbd
movq %r12, %rdi
callq 0x4a5c
movb %al, -0x29(%rbp)
leaq -0x29(%rbp), %rdi
leaq 0xa5bd(%rip), %rsi      # 0xd164
callq 0x4a7e
testb %al, %al
je 0x2bbd
movq -0x38(%rbp), %rax
movq %rax, (%r14)
addq $0x8, %r14
jmp 0x2c1d
pushq $0x2
popq %rbx
movl (%r15), %eax
shrl $0x5, %eax
cmpq %rax, %rbx
jae 0x2c22
movl 0x4(%r15,%rbx,4), %esi
movq %r12, %rdi
callq 0x4a5c
movb %al, -0x29(%rbp)
leaq -0x29(%rbp), %rdi
leaq 0xa57f(%rip), %rsi      # 0xd165
callq 0x4aa8
incq %rbx
testb %al, %al
je 0x2bc0
movl (%r15,%rbx,4), %eax
movl %eax, 0x8(%r15)
movl -0x4c(%rbp), %eax
movl %eax, (%r15,%rbx,4)
movl 0x8(%r15), %esi
xorl $0x1, %esi
movq -0x58(%rbp), %rdi
callq 0x671e
movq %rax, %rdi
leaq -0x38(%rbp), %rsi
callq 0x5222
movq %r12, %r15
jmp 0x2c93
movq -0x38(%rbp), %rax
movq %rax, (%r14)
addq $0x8, %r14
movq %r12, %r15
movq %r12, %rdi
movl -0x50(%rbp), %ebx
movl %ebx, %esi
callq 0x4a5c
movb %al, -0x29(%rbp)
leaq -0x29(%rbp), %rdi
leaq 0xa51a(%rip), %rsi      # 0xd165
callq 0x4a7e
testb %al, %al
je 0x2c86
movl 0x30(%r15), %eax
movl %eax, 0xe8(%r15)
movq -0x48(%rbp), %r12
movslq 0x8(%r12), %rax
shlq $0x3, %rax
addq (%r12), %rax
cmpq %rax, %r13
je 0x2ca0
movq (%r13), %rax
addq $0x8, %r13
movq %rax, (%r14)
addq $0x8, %r14
jmp 0x2c63
movq %r15, %rdi
movl %ebx, %esi
movl -0x30(%rbp), %edx
callq 0x29a6
movq -0x48(%rbp), %r12
movq (%r12), %rax
jmp 0x2aff
movl -0x30(%rbp), %eax
movl %eax, -0x3c(%rbp)
jmp 0x2c97
subq %r14, %r13
shrq $0x3, %r13
movq %r12, %rdi
movl %r13d, %esi
callq 0x546e
jmp 0x2abd
movq 0xa2d2(%rip), %rdi      # 0xcf98
leaq 0x5459(%rip), %rsi      # 0x8126
callq 0x2110
movq %rax, %rdi
callq 0x2090
movl -0x3c(%rbp), %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq