// File: /workspace/github_cpp_makefile_star2_O3/sighingnow[P]compile-pascal/pl0_opt.cpp
// Function: BasicBlock::solveDAG()
void BasicBlock::solveDAG() {
    std::vector<TAC> irs;
    for (int i = 0; i < this->s; ++i) {
        irs.emplace_back(this->code[i]);
    }
    std::vector<int> stack;
    std::vector<DAGNode> t_nodes = G;

    while (!t_nodes.empty()) {
        auto iter = t_nodes.rbegin();
        bool flag = true;
        while (iter != t_nodes.rend()) {
            DAGNode & node = *iter;
            if (node.ready()) {
                stack.push_back(node.no);
                if (node.lhs != -1) {
                    t_nodes[node.lhs].lessFa();
                }
                if (node.op != "write_e" && node.op != "read" && node.rhs != -1) {
                    t_nodes[node.rhs].lessFa();
                }
                t_nodes.erase((++iter).base());
                flag = false;
                break;
            }
            else {
                iter++;
            }
        }
        if (flag) {
            std::cout << ";; DAG graph export warning: Circle found." << std::endl;
            break;
        }
    }
    auto r_iter = stack.rbegin();
    while (r_iter != stack.rend()) {
        int node = *r_iter;
        releaseLeaf(irs, G[node].item);
        r_iter++;
    }

    r_iter = stack.rbegin();
    while (r_iter != stack.rend()) {
        int node = *r_iter;
        if (!G[node].leaf) {
            this->trans(irs, node);
        }
        auto iter = G[node].items.begin();
        while (iter != G[node].items.end()) {
            if (*iter != G[node].item && (*iter)->t != Value::TYPE::IMM) {
                irs.push_back(TAC("=", *iter, G[node].item));
            }
            iter++;
        }
        r_iter++;
    }
    while (!this->IOBuf.empty()) {
        irs.emplace_back(this->IOBuf[0].second);
        this->IOBuf.erase(IOBuf.begin());
    }
    for (size_t i = t; i < this->code.size(); ++i) {
        irs.emplace_back(this->code[i]);
    }
    this->code.swap(irs);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rdi, %r12
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
cmpl $0x0, 0x10(%rdi)
jle 0x7ad79
xorl %ebx, %ebx
movq %rsp, %r14
xorl %r15d, %r15d
movq 0x18(%r12), %rsi
addq %rbx, %rsi
movq %r14, %rdi
callq 0x7c2b4
incq %r15
movslq 0x10(%r12), %rax
addq $0x50, %rbx
cmpq %rax, %r15
jl 0x7ad58
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
leaq 0x60(%r12), %rbp
leaq 0x60(%rsp), %rdi
movq %rbp, %rsi
callq 0x7c67c
leaq 0x20(%rsp), %rbx
leaq 0x17f43(%rip), %r14     # 0x92ceb
leaq 0x60(%rsp), %r13
movq %r12, 0x18(%rsp)
movq %rbp, 0x38(%rsp)
movq 0x60(%rsp), %rax
movq 0x68(%rsp), %rcx
cmpq %rcx, %rax
je 0x7aecd
movq %rcx, %r15
negq %r15
cmpq %rax, %rcx
je 0x7ae82
leaq -0x58(%rcx), %rbp
addq $0x58, %r15
cmpl $0x0, -0x54(%rcx)
movq %rbp, %rcx
jne 0x7add0
movq 0x28(%rsp), %rsi
cmpq 0x30(%rsp), %rsi
je 0x7ae06
movl (%rbp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x28(%rsp)
jmp 0x7ae11
movq %rbx, %rdi
movq %rbp, %rdx
callq 0x7d59a
movslq 0x50(%rbp), %rax
cmpq $-0x1, %rax
je 0x7ae28
movq 0x60(%rsp), %rcx
imulq $0x58, %rax, %rax
decl 0x4(%rcx,%rax)
leaq 0x30(%rbp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x50c0
testl %eax, %eax
je 0x7ae65
movq %r12, %rdi
leaq 0x162e7(%rip), %rsi     # 0x9112c
callq 0x50c0
testl %eax, %eax
je 0x7ae65
movslq 0x54(%rbp), %rax
cmpq $-0x1, %rax
je 0x7ae65
movq 0x60(%rsp), %rcx
imulq $0x58, %rax, %rax
decl 0x4(%rcx,%rax)
negq %r15
movq %r13, %rdi
movq %r15, %rsi
callq 0x7e452
movq 0x18(%rsp), %r12
movq 0x38(%rsp), %rbp
jmp 0x7adb7
movq 0x3f14f(%rip), %r15     # 0xb9fd8
leaq 0x17e67(%rip), %rsi     # 0x92cf7
movl $0x2a, %edx
movq %r15, %rdi
callq 0x52e0
movq 0x38(%rsp), %rbp
movq (%r15), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0x5240
movsbl %al, %esi
movq 0x3f118(%rip), %rdi     # 0xb9fd8
callq 0x5030
movq %rax, %rdi
callq 0x5190
movq 0x28(%rsp), %rbx
movq %rsp, %r15
cmpq 0x20(%rsp), %rbx
je 0x7aeff
movslq -0x4(%rbx), %rax
addq $-0x4, %rbx
movq 0x60(%r12), %rcx
imulq $0x58, %rax, %rax
movq 0x10(%rcx,%rax), %rdx
movq %r12, %rdi
movq %r15, %rsi
callq 0x7b202
jmp 0x7aed5
movq 0x28(%rsp), %rcx
cmpq %rcx, %rbx
je 0x7b07c
leaq 0x50(%rsp), %r14
leaq 0x98(%rsp), %rbx
movq (%rbp), %rax
movq %rcx, 0x78(%rsp)
movslq -0x4(%rcx), %rdx
imulq $0x58, %rdx, %r15
cmpb $0x0, 0x9(%rax,%r15)
jne 0x7af42
movq %r12, %rdi
movq %rsp, %rsi
callq 0x7b4a0
movq (%rbp), %rax
movq 0x18(%rax,%r15), %r12
cmpq 0x20(%rax,%r15), %r12
je 0x7b063
movq %r15, 0x80(%rsp)
movq (%r12), %rcx
cmpq 0x10(%rax,%r15), %rcx
je 0x7b054
cmpl $0x0, (%rcx)
je 0x7b054
movq %r14, 0x40(%rsp)
leaq 0x40(%rsp), %rdi
leaq 0x16195(%rip), %rsi     # 0x91118
leaq 0x1618f(%rip), %rdx     # 0x91119
callq 0x253d0
movq (%r12), %r13
movq (%rbp), %rax
movq 0x10(%rax,%r15), %r14
movq %rbx, 0x88(%rsp)
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
addq %rsi, %rdx
movq %rbx, %rbp
leaq 0x88(%rsp), %r15
movq %r15, %rdi
callq 0x351dc
movq %r13, 0xa8(%rsp)
movq %r14, 0xb0(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rbp)
movq %rbp, %rbx
movups %xmm0, 0x20(%rbp)
movq %rsp, %rdi
movq %r15, %rsi
callq 0x779d8
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
leaq 0x50(%rsp), %r14
je 0x7b00f
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x5260
movq 0x88(%rsp), %rdi
cmpq %rbx, %rdi
movq 0x38(%rsp), %rbp
movq 0x80(%rsp), %r15
je 0x7b039
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x5260
movq 0x40(%rsp), %rdi
cmpq %r14, %rdi
je 0x7b050
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x5260
movq (%rbp), %rax
addq $0x8, %r12
cmpq 0x20(%rax,%r15), %r12
jne 0x7af5a
movq 0x78(%rsp), %rcx
addq $-0x4, %rcx
cmpq 0x20(%rsp), %rcx
movq 0x18(%rsp), %r12
jne 0x7af1e
leaq 0xa8(%r12), %r14
movq %rsp, %r15
movq 0xa8(%r12), %rsi
cmpq 0xb0(%r12), %rsi
je 0x7b0b2
addq $0x8, %rsi
movq %r15, %rdi
callq 0x7c2b4
movq (%r14), %rsi
movq %r14, %rdi
callq 0x7e540
jmp 0x7b087
movslq 0x14(%r12), %rbx
movq 0x18(%r12), %rsi
movq 0x20(%r12), %rax
movq %rax, %rcx
subq %rsi, %rcx
sarq $0x4, %rcx
movabsq $-0x3333333333333333, %r15 # imm = 0xCCCCCCCCCCCCCCCD
imulq %r15, %rcx
cmpq %rbx, %rcx
jbe 0x7b11e
movq %rbx, %rax
shlq $0x4, %rax
leaq (%rax,%rax,4), %r12
movq %rsp, %r14
addq %r12, %rsi
movq %r14, %rdi
callq 0x7c2b4
incq %rbx
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rsi
movq 0x20(%rax), %rax
movq %rax, %rcx
subq %rsi, %rcx
sarq $0x4, %rcx
imulq %r15, %rcx
addq $0x50, %r12
cmpq %rcx, %rbx
jb 0x7b0ec
movq 0x18(%rsp), %rdi
movq 0x28(%rdi), %rcx
movaps (%rsp), %xmm0
movups %xmm0, 0x18(%rdi)
movq 0x10(%rsp), %rdx
movq %rdx, 0x28(%rdi)
movq %rsi, (%rsp)
movq %rax, 0x8(%rsp)
movq %rcx, 0x10(%rsp)
leaq 0x60(%rsp), %rdi
callq 0x7c714
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x7b167
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x5260
movq %rsp, %rdi
callq 0x652c0
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7b1a0
jmp 0x7b1a0
movq %rax, %rbx
jmp 0x7b1db
jmp 0x7b1a0
jmp 0x7b1a0
jmp 0x7b1a0
movq %rax, %rbx
jmp 0x7b1f2
jmp 0x7b1a0
jmp 0x7b1a0
jmp 0x7b1a0
movq %rax, %rbx
jmp 0x7b1b5
movq %rax, %rbx
jmp 0x7b1d1
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x650f6
leaq 0x50(%rsp), %r14
movq 0x40(%rsp), %rdi
cmpq %r14, %rdi
je 0x7b1d1
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x5260
leaq 0x60(%rsp), %rdi
callq 0x7c714
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x7b1f2
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x5260
movq %rsp, %rdi
callq 0x652c0
movq %rbx, %rdi
callq 0x53d0