// File: 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
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x88(%rbp)
movq 0x12ec7(%rip), %rdi     # 0x15f98
leaq 0xc0a9(%rip), %rsi      # 0xf181
callq 0x20f0
movq %rax, %rdi
movq 0x12e79(%rip), %rsi     # 0x15f60
callq 0x2120
movl $0xffffffff, -0xc(%rbp) # imm = 0xFFFFFFFF
movq -0x88(%rbp), %rdi
movl 0xe8(%rdi), %eax
movl %eax, -0x8c(%rbp)
addq $0x28, %rdi
callq 0x7720
movl %eax, %ecx
movl -0x8c(%rbp), %eax
cmpl %ecx, %eax
jge 0x352e
movq -0x88(%rbp), %rax
movq %rax, %rdi
addq $0x28, %rdi
movl 0xe8(%rax), %esi
movl %esi, %ecx
addl $0x1, %ecx
movl %ecx, 0xe8(%rax)
callq 0x77a0
movq -0x88(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x10(%rbp)
addq $0x88, %rdi
leaq -0x10(%rbp), %rsi
callq 0x8e40
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x8ea0
movq %rax, -0x28(%rbp)
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x18(%rbp), %rdi
callq 0x8ec0
movq %rax, %rcx
movq -0x98(%rbp), %rax
cmpq %rcx, %rax
je 0x350f
movq -0x88(%rbp), %rdi
movq -0x20(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %esi
callq 0x7740
movb %al, -0x2d(%rbp)
leaq -0x2d(%rbp), %rdi
leaq 0x12f8c(%rip), %rsi     # 0x16154
callq 0x77c0
testb $0x1, %al
jne 0x31d3
jmp 0x31fc
movq -0x20(%rbp), %rcx
movq %rcx, %rax
addq $0x8, %rax
movq %rax, -0x20(%rbp)
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, -0x28(%rbp)
movq (%rcx), %rcx
movq %rcx, (%rax)
jmp 0x3174
movq -0x88(%rbp), %rdi
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x38(%rbp)
addq $0xf8, %rdi
movl -0x38(%rbp), %esi
callq 0x7aa0
movq %rax, -0x40(%rbp)
leaq -0x10(%rbp), %rdi
callq 0x75b0
movl %eax, -0x44(%rbp)
movq -0x40(%rbp), %rdi
xorl %esi, %esi
callq 0x8ee0
movq %rax, %rdi
leaq -0x44(%rbp), %rsi
callq 0x7820
testb $0x1, %al
jne 0x3248
jmp 0x3286
movq -0x40(%rbp), %rdi
movl $0x1, %esi
callq 0x8ee0
movq %rax, -0xa0(%rbp)
movq -0x40(%rbp), %rdi
xorl %esi, %esi
callq 0x8ee0
movq -0xa0(%rbp), %rcx
movl (%rcx), %ecx
movl %ecx, (%rax)
movq -0x40(%rbp), %rdi
movl $0x1, %esi
callq 0x8ee0
movl -0x44(%rbp), %ecx
movl %ecx, (%rax)
movq -0x20(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x20(%rbp)
movq -0x40(%rbp), %rdi
xorl %esi, %esi
callq 0x8ee0
movl (%rax), %eax
movl %eax, -0x48(%rbp)
movl -0x38(%rbp), %esi
movl -0x48(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %edx
leaq -0x50(%rbp), %rdi
callq 0x8a70
leaq -0x48(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x7870
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0xa1(%rbp)
jne 0x32d5
jmp 0x3303
movq -0x88(%rbp), %rdi
movl -0x48(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %esi
callq 0x7740
movb %al, -0x55(%rbp)
leaq -0x55(%rbp), %rdi
leaq 0x12e5c(%rip), %rsi     # 0x16154
callq 0x77c0
movb %al, -0xa1(%rbp)
movb -0xa1(%rbp), %al
testb $0x1, %al
jne 0x330f
jmp 0x332a
movq -0x28(%rbp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, -0x28(%rbp)
movq -0x50(%rbp), %rcx
movq %rcx, (%rax)
jmp 0x3174
movb $0x0, -0x5d(%rbp)
movl $0x2, -0x64(%rbp)
movl -0x64(%rbp), %eax
movl %eax, -0xa8(%rbp)
movq -0x40(%rbp), %rdi
callq 0x8b00
movl %eax, %ecx
movl -0xa8(%rbp), %eax
cmpl %ecx, %eax
jge 0x3432
movq -0x40(%rbp), %rdi
movl -0x64(%rbp), %esi
callq 0x8ee0
movq -0x88(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %esi
callq 0x7740
movb %al, -0x65(%rbp)
leaq -0x65(%rbp), %rdi
leaq 0x12dd0(%rip), %rsi     # 0x16155
callq 0x7840
testb $0x1, %al
jne 0x3393
jmp 0x3422
movq -0x40(%rbp), %rdi
movl -0x64(%rbp), %esi
callq 0x8ee0
movq %rax, -0xb8(%rbp)
movq -0x40(%rbp), %rdi
movl $0x1, %esi
callq 0x8ee0
movq -0xb8(%rbp), %rcx
movl (%rcx), %ecx
movl %ecx, (%rax)
movq -0x40(%rbp), %rdi
movl -0x64(%rbp), %esi
callq 0x8ee0
movq %rax, %rcx
movq -0x88(%rbp), %rax
movl -0x44(%rbp), %edx
movl %edx, (%rcx)
addq $0x88, %rax
movq %rax, -0xb0(%rbp)
movq -0x40(%rbp), %rdi
movl $0x1, %esi
callq 0x8ee0
movq %rax, %rdi
callq 0x75b0
movq -0xb0(%rbp), %rdi
movl %eax, -0x70(%rbp)
leaq -0x70(%rbp), %rsi
callq 0x7ba0
movq %rax, %rdi
leaq -0x50(%rbp), %rsi
callq 0x8a10
movb $0x1, -0x5d(%rbp)
jmp 0x3432
jmp 0x3424
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x3335
testb $0x1, -0x5d(%rbp)
jne 0x350a
movq -0x88(%rbp), %rdi
movq -0x28(%rbp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, -0x28(%rbp)
movq -0x50(%rbp), %rcx
movq %rcx, (%rax)
movl -0x48(%rbp), %eax
movl %eax, -0x78(%rbp)
movl -0x78(%rbp), %esi
callq 0x7740
movb %al, -0x71(%rbp)
leaq -0x71(%rbp), %rdi
leaq 0x12ce0(%rip), %rsi     # 0x16155
callq 0x77c0
testb $0x1, %al
jne 0x3480
jmp 0x34f0
movq -0x88(%rbp), %rdi
movl -0x38(%rbp), %eax
movl %eax, -0xc(%rbp)
addq $0x28, %rdi
callq 0x7720
movl %eax, %ecx
movq -0x88(%rbp), %rax
movl %ecx, 0xe8(%rax)
movq -0x20(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0x18(%rbp), %rdi
callq 0x8ec0
movq %rax, %rcx
movq -0xc0(%rbp), %rax
cmpq %rcx, %rax
je 0x34ee
movq -0x20(%rbp), %rcx
movq %rcx, %rax
addq $0x8, %rax
movq %rax, -0x20(%rbp)
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, -0x28(%rbp)
movq (%rcx), %rcx
movq %rcx, (%rax)
jmp 0x34a5
jmp 0x3508
movq -0x88(%rbp), %rdi
movl -0x48(%rbp), %eax
movl %eax, -0x7c(%rbp)
movl -0x38(%rbp), %edx
movl -0x7c(%rbp), %esi
callq 0x2f70
jmp 0x350a
jmp 0x3174
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rax
movq -0x28(%rbp), %rcx
subq %rcx, %rax
sarq $0x3, %rax
movl %eax, %esi
callq 0x8f00
jmp 0x30f3
movq 0x12a63(%rip), %rdi     # 0x15f98
leaq 0xbc68(%rip), %rsi      # 0xf1a4
callq 0x20f0
movq %rax, %rdi
movq 0x12a15(%rip), %rsi     # 0x15f60
callq 0x2120
movl -0xc(%rbp), %eax
addq $0xc0, %rsp
popq %rbp
retq
nopl (%rax)