// File: /workspace/github_cpp_makefile_star2_O2/Myyura[P]MyyuraSat/./source/./solver_basic.cpp
// Function: MyyuraSat::Solver::reloc_all(MyyuraSat::ClauseAllocator&)
void Solver::reloc_all(ClauseAllocator& to) {
    // Watchers:
    _watches.clean_all();
    for (int v = 0; v < n_variables(); v++) {
        for (int s = 0; s < 2; s++) {
            Literal p(v, s);
            Vector<_Watcher>& ws = _watches[p];
            for (int j = 0; j < ws.size(); j++) {
                _ca.reloc(ws[j].cref, to);
            }
        }
    }

    // Occlits
    _occur_lit.clean_all();
    for (int v = 0; v < n_variables(); v++) {
        for (int s = 0; s < 2; s++) {
            Literal p(v, s);
            Vector<CRARef>& cs = _occur_lit[p];
            for (int j = 0; j < cs.size(); j++) {
                _ca.reloc(cs[j], to);
            }
        }
    }

    // Reasons:
    for (int i = 0; i < _trail.size(); i++) {
        Variable v = _trail[i].variable();

        /**
         * Note: it is not safe to call 'locked()' on a relocated clause. This 
         * is why we keep 'dangling' reasons here. It is safe and does not hurt.
         */
        if (reason(v) != CRAREF_UNDEF && 
            (_ca[reason(v)].reloced() || is_locked(_ca[reason(v)]))) {
            if (is_removed(reason(v))) {
                throw std::logic_error("Solver::reloc_all : reason is already removed!");
            }

            _ca.reloc(_variable_info[v].reason, to);
        }
    }

    int i, j;
    // Learnts:
    for (i = j = 0; i < _learnts.size(); i++) {
        if (!is_removed(_learnts[i])) {
            _ca.reloc(_learnts[i], to);
            _learnts[j++] = _learnts[i];
        }
    }
    _learnts.shrink(i - j);


    // Original:
    for (i = j = 0; i < _clauses.size(); i++) {
        if (!is_removed(_clauses[i])) {
            _ca.reloc(_clauses[i], to);
            _clauses[j++] = _clauses[i];
        }
    }
    _clauses.shrink(i - j);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %rbx
movq %rdi, %r14
addq $0x88, %rdi
movq %rdi, -0x50(%rbp)
callq 0x4bdc
leaq 0xf8(%r14), %r15
xorl %eax, %eax
movq %r14, -0x48(%rbp)
cmpl 0xf0(%r14), %eax
jge 0x30ab
leal (%rax,%rax), %ecx
movl %ecx, -0x3c(%rbp)
xorl %esi, %esi
movq %rax, -0x38(%rbp)
cmpl $0x2, %esi
je 0x30a7
movl %esi, -0x30(%rbp)
orl -0x3c(%rbp), %esi
movq -0x50(%rbp), %rdi
callq 0x671e
movq %rax, %r13
xorl %r14d, %r14d
xorl %r12d, %r12d
movslq 0x8(%r13), %rax
cmpq %rax, %r12
jge 0x3098
movq (%r13), %rsi
addq %r14, %rsi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x4c3c
incq %r12
addq $0x8, %r14
jmp 0x3074
movl -0x30(%rbp), %esi
incl %esi
movq -0x48(%rbp), %r14
movq -0x38(%rbp), %rax
jmp 0x3057
incl %eax
jmp 0x3042
leaq 0x1a0(%r14), %rdi
movq %rdi, -0x50(%rbp)
callq 0x4c84
xorl %eax, %eax
cmpl 0xf0(%r14), %eax
jge 0x3126
leal (%rax,%rax), %ecx
movl %ecx, -0x3c(%rbp)
xorl %esi, %esi
movq %rax, -0x38(%rbp)
cmpl $0x2, %esi
je 0x3122
movl %esi, -0x30(%rbp)
orl -0x3c(%rbp), %esi
movq -0x50(%rbp), %rdi
callq 0x682a
movq %rax, %r13
xorl %r14d, %r14d
xorl %r12d, %r12d
movslq 0x8(%r13), %rax
cmpq %rax, %r12
jge 0x3113
movq (%r13), %rsi
addq %r14, %rsi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x4c3c
incq %r12
addq $0x4, %r14
jmp 0x30ef
movl -0x30(%rbp), %esi
incl %esi
movq -0x48(%rbp), %r14
movq -0x38(%rbp), %rax
jmp 0x30d2
incl %eax
jmp 0x30bd
leaq 0x70(%r14), %rax
movq %rax, -0x30(%rbp)
xorl %r12d, %r12d
movslq 0x30(%r14), %rax
cmpq %rax, %r12
jge 0x31d6
movq 0x28(%r14), %rax
movl (%rax,%r12,4), %r13d
sarl %r13d
movq %r14, %rdi
movl %r13d, %esi
callq 0x4cf0
cmpl $-0x1, %eax
je 0x31ce
movq %r14, %rdi
movl %r13d, %esi
callq 0x4cf0
movq %r15, %rdi
movl %eax, %esi
callq 0x5a5e
testb $0x10, (%rax)
jne 0x3197
movq %r14, %rdi
movl %r13d, %esi
callq 0x4cf0
movq %r15, %rdi
movl %eax, %esi
callq 0x5a5e
movq %r14, %rdi
movq %rax, %rsi
callq 0x4d02
testb %al, %al
je 0x31ce
movq %r14, %rdi
movl %r13d, %esi
callq 0x4cf0
movq %r14, %rdi
movl %eax, %esi
callq 0x4d76
testb %al, %al
jne 0x32d8
movq -0x30(%rbp), %rdi
movl %r13d, %esi
callq 0x4d94
movq %r15, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x4c3c
incq %r12
jmp 0x3131
leaq 0x18(%r14), %rax
movq %rax, -0x38(%rbp)
xorl %r14d, %r14d
xorl %r13d, %r13d
movl $0x0, -0x30(%rbp)
movq -0x48(%rbp), %r12
movslq 0x20(%r12), %rax
cmpq %rax, %r13
jge 0x3243
movq 0x18(%r12), %rax
movl (%rax,%r14), %esi
movq %r12, %rdi
callq 0x4d76
testb %al, %al
jne 0x323a
movq -0x38(%rbp), %r12
movq (%r12), %rsi
addq %r14, %rsi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x4c3c
movq (%r12), %rax
movl (%rax,%r14), %ecx
movl -0x30(%rbp), %esi
movslq %esi, %rdx
incl %esi
movl %esi, -0x30(%rbp)
movl %ecx, (%rax,%rdx,4)
incq %r13
addq $0x4, %r14
jmp 0x31eb
subl -0x30(%rbp), %r13d
movq -0x38(%rbp), %rdi
movl %r13d, %esi
callq 0x4df2
leaq 0x8(%r12), %rax
movq %rax, -0x38(%rbp)
xorl %r14d, %r14d
xorl %r13d, %r13d
xorl %r12d, %r12d
movq -0x48(%rbp), %rdi
movslq 0x10(%rdi), %rax
cmpq %rax, %r13
jge 0x32bb
movq 0x8(%rdi), %rax
movl (%rax,%r14), %esi
callq 0x4d76
testb %al, %al
jne 0x32b2
movl %r12d, -0x30(%rbp)
movq -0x38(%rbp), %r12
movq (%r12), %rsi
addq %r14, %rsi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x4c3c
movq (%r12), %rax
movl -0x30(%rbp), %r12d
movl (%rax,%r14), %ecx
movslq %r12d, %rdx
incl %r12d
movl %ecx, (%rax,%rdx,4)
incq %r13
addq $0x4, %r14
jmp 0x3265
subl %r12d, %r13d
movq -0x38(%rbp), %rdi
movl %r13d, %esi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4df2
pushq $0x10
popq %rdi
callq 0x20a0
movq %rax, %rbx
leaq 0x4dad(%rip), %rsi      # 0x8097
movq %rax, %rdi
callq 0x21b0
movq 0x9cdf(%rip), %rsi      # 0xcfd8
movq 0x9c90(%rip), %rdx      # 0xcf90
movq %rbx, %rdi
callq 0x2230
movq %rax, %r14
movq %rbx, %rdi
callq 0x20e0
movq %r14, %rdi
callq 0x2250
nop