// File: /workspace/github_cpp_makefile_star2_O1/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 0xa243(%rip), %rbx      # 0xcf98
leaq 0x63c3(%rip), %rsi      # 0x911f
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 0x3069
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 0x6400
movq %rax, %r13
movq (%rax), %rbx
cmpl $0x0, 0x8(%rax)
je 0x3040
movq %rbx, %r12
movq %r13, -0x40(%rbp)
movl 0x4(%rbx), %r14d
movl %r14d, %esi
sarl %esi
movq -0x48(%rbp), %rdi
callq 0x6c82
movb (%rax), %al
movl %r14d, %ecx
andb $0x1, %cl
xorb %al, %cl
movb 0xa344(%rip), %dl       # 0xd174
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 0x2e61
movq (%rbx), %rax
addq $0x8, %rbx
movq %rax, (%r12)
addq $0x8, %r12
jmp 0x3029
xorl %r15d, %r15d
movl (%rbx), %esi
movq -0x70(%rbp), %rdi
movl %esi, -0x30(%rbp)
callq 0x6a4e
movq %rax, %r13
movl -0x34(%rbp), %ecx
xorl $0x1, %ecx
cmpl %ecx, 0x4(%rax)
jne 0x2e8c
movl 0x8(%r13), %eax
movl %eax, 0x4(%r13)
movl %ecx, 0x8(%r13)
movl %ecx, -0x5c(%rbp)
addq $0x8, %rbx
movl 0x4(%r13), %ecx
movl -0x30(%rbp), %eax
movl %eax, -0x50(%rbp)
movl %ecx, -0x4c(%rbp)
cmpl %r14d, %ecx
movl %ecx, %r14d
je 0x2ef4
movl %r14d, %esi
sarl %esi
movq -0x48(%rbp), %rdi
callq 0x6c82
movb (%rax), %al
movl %r14d, %ecx
andb $0x1, %cl
xorb %al, %cl
movb 0xa2ae(%rip), %dl       # 0xd174
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 0x2ef4
movq -0x50(%rbp), %rax
movq %rax, (%r12)
addq $0x8, %r12
jmp 0x3022
movl %r14d, -0x60(%rbp)
cmpl $0x60, (%r13)
jb 0x2f58
movl $0x2, %r14d
movl 0x4(%r13,%r14,4), %r15d
movl %r15d, %esi
sarl %esi
movq -0x48(%rbp), %rdi
callq 0x6c82
movb (%rax), %al
andb $0x1, %r15b
xorb %al, %r15b
movb 0xa24d(%rip), %dil      # 0xd175
xorl %edx, %edx
movl %edi, %ecx
andb $0x2, %cl
sete %sil
cmpb %dil, %r15b
je 0x2f3c
xorl %edx, %edx
jmp 0x2f3f
movb %sil, %dl
andb %al, %cl
orb %cl, %dl
je 0x2ff5
incq %r14
movl (%r13), %eax
shrl $0x5, %eax
cmpq %rax, %r14
jb 0x2f05
movq -0x50(%rbp), %rax
movq %rax, (%r12)
addq $0x8, %r12
movl -0x60(%rbp), %r14d
movl %r14d, %esi
sarl %esi
movq -0x48(%rbp), %rdi
callq 0x6c82
movb (%rax), %al
movl %r14d, %ecx
andb $0x1, %cl
xorb %al, %cl
movb 0xa1ef(%rip), %dl       # 0xd175
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 0x2fe4
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 0x2fdc
movq (%rbx), %rax
addq $0x8, %rbx
movq %rax, (%r12)
addq $0x8, %r12
jmp 0x2fba
movl -0x30(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x3029
movq -0x58(%rbp), %rdi
movl %r14d, %esi
movl -0x30(%rbp), %edx
callq 0x2c48
jmp 0x3025
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 0x746e
movq %rax, %rdi
leaq -0x50(%rbp), %rsi
callq 0x61f4
xorl %r15d, %r15d
movq -0x40(%rbp), %r13
movslq 0x8(%r13), %rax
shlq $0x3, %rax
addq (%r13), %rax
cmpq %rax, %rbx
jne 0x2e0e
jmp 0x3043
movq %rbx, %r12
subq %r12, %rbx
shrq $0x3, %rbx
movq %r13, %rdi
movl %ebx, %esi
callq 0x6438
movq -0x58(%rbp), %r14
movl 0xe8(%r14), %eax
cmpl 0x30(%r14), %eax
jl 0x2dd4
leaq 0x60d2(%rip), %rsi      # 0x9142
movl $0x20, %edx
movq 0x9f1c(%rip), %rbx      # 0xcf98
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