// File: /workspace/github_cpp_makefile_star2_O3/sighingnow[P]compile-pascal/pl0_opt.cpp
// Function: pl0_block_helper(std::vector<TAC, std::allocator<TAC>>&, std::vector<BasicBlock, std::allocator<BasicBlock>>&, int, std::map<int, std::vector<int, std::allocator<int>>, std::less<int>, std::allocator<std::pair<int const, std::vector<int, std::allocator<int>>>>>&, std::map<int, std::vector<int, std::allocator<int>>, std::less<int>, std::allocator<std::pair<int const, std::vector<int, std::allocator<int>>>>>&)
static int pl0_block_helper(std::vector<TAC> & code, std::vector<BasicBlock> & bbs, int p,
        std::map<int, std::vector<int>> & pres, std::map<int, std::vector<int>> & sufs)
{
    BasicBlock header(0, false);
    while (code[p].op == "param" || code[p].op == "paramref") {
        header.push(code[p++]);
    }
    header.push(code[p++]); // function or procedure.
    while (code[p].op == "def" || code[p].op == "allocret") {
        header.push(code[p++]);
    }
    int hidx = bbs.size();
    bbs.emplace_back(header);
    while (code[p].op == "param" || code[p].op == "paramref"
            || code[p].op == "function" || code[p].op == "procedure") {
        p = pl0_block_helper(code, bbs, p, pres, sufs);
    }
    bbs[hidx].setBegin(code[p].rd->iv);

    while (code[p].op != "endproc" && code[p].op != "endfunc") {
        BasicBlock body(code[p].rd->iv, true);
        body.push(code[p++]);
        while (code[p].op != "goto" && code[p].op != "call"
                && code[p].op != "endproc" && code[p].op != "endfunc") {
            if (code[p].op == "cmp") {
                sufs[body.no].emplace_back(code[p].rd->iv);
                pres[code[p].rd->iv].emplace_back(body.no);
            }
            if (code[p].op == "def") {
                // add temporary variable to symbol table.
                bbs[hidx].push(code[p++]);
            }
            else {
                body.push(code[p++]);
            }
        }
        if (code[p].op == "goto") {
            // goto label
            sufs[body.no].emplace_back(code[p].rs->iv);
            pres[code[p].rs->iv].emplace_back(body.no);
            body.push(code[p++]);
        }
        else if (code[p].op == "call") {
            // call ... -> ...
            // label: 
            body.push(code[p++]);
            sufs[body.no].emplace_back(code[p].rd->iv);
            pres[code[p].rd->iv].emplace_back(body.no);
        }
        else {
            body.push(code[p]);
        }

        bbs.emplace_back(body);
    }
    bbs[hidx].setEnd(bbs.back().no);
    bbs.back().is_end = true;
    return (++p);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movq %r8, 0x20(%rsp)
movq %rcx, 0x18(%rsp)
movq %rsi, 0x8(%rsp)
movq %rdi, %rbp
xorl %eax, %eax
leaq 0x100(%rsp), %r14
movl %eax, -0x18(%r14)
movw $0x0, -0x14(%r14)
movaps 0x17159(%rip), %xmm0    # 0x92c70
movups %xmm0, -0x10(%r14)
leaq 0x168(%rsp), %rcx
movl %eax, (%rcx)
movq $0x0, 0x8(%rcx)
xorps %xmm0, %xmm0
movups %xmm0, -0x68(%rcx)
movups %xmm0, -0x58(%rcx)
movups %xmm0, -0x48(%rcx)
movups %xmm0, -0x38(%rcx)
movups %xmm0, -0x28(%rcx)
movups %xmm0, -0x18(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movups %xmm0, 0x20(%rcx)
movups %xmm0, 0x30(%rcx)
movslq %edx, %rax
leal 0x1(%rax), %r12d
shlq $0x4, %rax
leaq (%rax,%rax,4), %rbx
leaq 0x16e6c(%rip), %r15     # 0x929db
leaq 0x16e5c(%rip), %r13     # 0x929d2
movq (%rbp), %rdi
addq %rbx, %rdi
movq %r15, %rsi
callq 0x50c0
testl %eax, %eax
je 0x7bb9c
movq (%rbp), %rdi
addq %rbx, %rdi
movq %r13, %rsi
callq 0x50c0
testl %eax, %eax
jne 0x7bbb4
incl %r12d
movq (%rbp), %rsi
addq %rbx, %rsi
addq $0x50, %rbx
movq %r14, %rdi
callq 0x7c2b4
jmp 0x7bb76
movq (%rbp), %rsi
addq %rbx, %rsi
movq %r14, %rdi
callq 0x7c2b4
addq $0x50, %rbx
leaq 0x16dad(%rip), %r15     # 0x9297b
leaq 0x1714d(%rip), %r13     # 0x92d22
movq (%rbp), %rdi
addq %rbx, %rdi
movq %r15, %rsi
callq 0x50c0
testl %eax, %eax
je 0x7bbfb
movq (%rbp), %rdi
addq %rbx, %rdi
movq %r13, %rsi
callq 0x50c0
testl %eax, %eax
jne 0x7bc1b
incl %r12d
leaq 0x50(%rbx), %r14
addq (%rbp), %rbx
leaq 0x100(%rsp), %rdi
movq %rbx, %rsi
callq 0x7c2b4
movq %r14, %rbx
jmp 0x7bbd5
movq 0x8(%rsp), %rdi
movq 0x8(%rdi), %rbx
subq (%rdi), %rbx
leaq 0xe8(%rsp), %rsi
callq 0x7c9a0
sarq $0x6, %rbx
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rbx, %rax
movq %rax, 0x10(%rsp)
leaq 0x16d89(%rip), %rbx     # 0x929db
leaq 0x16d79(%rip), %r15     # 0x929d2
movslq %r12d, %r14
leaq (%r14,%r14,4), %r13
shlq $0x4, %r13
movq (%rbp), %rdi
addq %r13, %rdi
movq %rbx, %rsi
callq 0x50c0
testl %eax, %eax
je 0x7bcb8
movq (%rbp), %rdi
addq %r13, %rdi
movq %r15, %rsi
callq 0x50c0
testl %eax, %eax
je 0x7bcb8
movq (%rbp), %rdi
addq %r13, %rdi
leaq 0x16d07(%rip), %rsi     # 0x9299f
callq 0x50c0
testl %eax, %eax
je 0x7bcb8
movq (%rbp), %rdi
addq %r13, %rdi
leaq 0x15c1e(%rip), %rsi     # 0x918cd
callq 0x50c0
testl %eax, %eax
jne 0x7bcd7
movq %rbp, %rdi
movq 0x8(%rsp), %rsi
movl %r12d, %edx
movq 0x18(%rsp), %rcx
movq 0x20(%rsp), %r8
callq 0x7bad8
movl %eax, %r12d
jmp 0x7bc59
movslq 0x10(%rsp), %rax
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
movq (%rbp), %rdx
leaq (%rdx,%r13), %rdi
movq 0x20(%rdx,%r13), %rdx
movl 0x4(%rdx), %edx
leaq (%rax,%rax,2), %rax
shlq $0x6, %rax
movq %rax, 0x10(%rsp)
movl %edx, 0x8(%rcx,%rax)
leaq 0x16c2f(%rip), %rsi     # 0x9293b
callq 0x50c0
testl %eax, %eax
je 0x7c188
leaq (%r14,%r14,4), %rbx
shlq $0x4, %rbx
movq (%rbp), %rdi
addq %rbx, %rdi
leaq 0x16c81(%rip), %rsi     # 0x929b0
callq 0x50c0
testl %eax, %eax
je 0x7c188
movq (%rbp), %rax
leaq (%rax,%rbx), %rsi
movq 0x20(%rax,%rbx), %rax
movl 0x4(%rax), %eax
movl %eax, 0x28(%rsp)
movw $0x1, 0x2c(%rsp)
movaps 0x16f12(%rip), %xmm0    # 0x92c70
movups %xmm0, 0x30(%rsp)
movl $0x0, 0xa8(%rsp)
movq $0x0, 0xb0(%rsp)
leaq 0x40(%rsp), %rdi
xorps %xmm0, %xmm0
movups %xmm0, 0x50(%rdi)
movups %xmm0, 0x40(%rdi)
movups %xmm0, 0x30(%rdi)
movups %xmm0, 0x20(%rdi)
movups %xmm0, 0x10(%rdi)
movups %xmm0, (%rdi)
leaq 0xa8(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq %rax, 0xc0(%rsp)
movups %xmm0, 0x98(%rdi)
movups %xmm0, 0x88(%rdi)
callq 0x7c2b4
movq 0x10(%rsp), %r14
leal 0x1(%r12), %r13d
movslq %r13d, %rbx
leaq (%rbx,%rbx,4), %r15
shlq $0x4, %r15
movq (%rbp), %rdi
addq %r15, %rdi
leaq 0x16cbb(%rip), %rsi     # 0x92aa2
callq 0x50c0
testl %eax, %eax
je 0x7bf83
movq (%rbp), %rdi
addq %r15, %rdi
leaq 0x15c64(%rip), %rsi     # 0x91a66
callq 0x50c0
testl %eax, %eax
je 0x7bf83
addq $0x50, %r15
leal 0x1(%r12), %r13d
movq (%rbp), %rax
leaq (%rax,%r15), %rdi
addq $-0x50, %rdi
leaq 0x16b10(%rip), %rsi     # 0x9293b
callq 0x50c0
testl %eax, %eax
je 0x7bf83
movq (%rbp), %rax
leaq (%rax,%r15), %rdi
addq $-0x50, %rdi
leaq 0x16b65(%rip), %rsi     # 0x929b0
callq 0x50c0
testl %eax, %eax
je 0x7bf83
movq (%rbp), %rax
leaq (%rax,%r15), %rdi
addq $-0x50, %rdi
leaq 0x16c33(%rip), %rsi     # 0x92a9e
callq 0x50c0
testl %eax, %eax
jne 0x7bef1
movq 0x20(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x7c744
movq (%rbp), %rcx
movq -0x30(%rcx,%r15), %rsi
leaq 0x4(%rsi), %rdx
movq 0x8(%rax), %rcx
cmpq 0x10(%rax), %rcx
je 0x7bea8
movl (%rdx), %edx
movl %edx, (%rcx)
addq $0x4, %rcx
movq %rcx, 0x8(%rax)
jmp 0x7bebc
movq %rax, %rdi
movq %rcx, %rsi
callq 0x792ca
movq (%rbp), %rax
movq -0x30(%rax,%r15), %rsi
addq $0x4, %rsi
movq 0x18(%rsp), %rdi
callq 0x7c744
movq 0x8(%rax), %rsi
cmpq 0x10(%rax), %rsi
je 0x7bee4
movl 0x28(%rsp), %ecx
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rax)
jmp 0x7bef1
movq %rax, %rdi
leaq 0x28(%rsp), %rdx
callq 0x7d59a
movq (%rbp), %rax
leaq (%rax,%r15), %rdi
addq $-0x50, %rdi
leaq 0x16a77(%rip), %rsi     # 0x9297b
callq 0x50c0
testl %eax, %eax
movq 0x8(%rsp), %rax
movq (%rax), %rax
leaq 0x18(%rax,%r14), %rdi
leaq 0x40(%rsp), %rax
cmovneq %rax, %rdi
movq (%rbp), %rax
leaq (%rax,%r15), %rsi
addq $-0x50, %rsi
callq 0x7c2b4
incq %rbx
movq (%rbp), %rdi
addq %r15, %rdi
leaq 0x16b5f(%rip), %rsi     # 0x92aa2
callq 0x50c0
testl %eax, %eax
je 0x7bf77
movq (%rbp), %rdi
addq %r15, %rdi
leaq 0x15b0c(%rip), %rsi     # 0x91a66
callq 0x50c0
addq $0x50, %r15
movl %r13d, %r12d
testl %eax, %eax
jne 0x7be13
movl %r13d, %r12d
leal 0x1(%r13), %eax
jmp 0x7bf80
movl %r12d, %eax
addl $0x2, %eax
movl %r13d, %r12d
movl %eax, %r13d
leaq (%rbx,%rbx,4), %rbx
shlq $0x4, %rbx
movq (%rbp), %rdi
addq %rbx, %rdi
leaq 0x16b09(%rip), %rsi     # 0x92aa2
callq 0x50c0
testl %eax, %eax
je 0x7bfd2
movq (%rbp), %rdi
addq %rbx, %rdi
leaq 0x15ab6(%rip), %rsi     # 0x91a66
callq 0x50c0
testl %eax, %eax
je 0x7c006
addq (%rbp), %rbx
leaq 0x40(%rsp), %rdi
movq %rbx, %rsi
callq 0x7c2b4
movl %r13d, %r12d
jmp 0x7c103
movq 0x20(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x7c744
movq (%rbp), %rcx
movq 0x28(%rcx,%rbx), %rsi
leaq 0x4(%rsi), %rdx
movq 0x8(%rax), %rcx
cmpq 0x10(%rax), %rcx
je 0x7c05a
movl (%rdx), %edx
movl %edx, (%rcx)
addq $0x4, %rcx
movq %rcx, 0x8(%rax)
jmp 0x7c06e
addq (%rbp), %rbx
leaq 0x40(%rsp), %rdi
movq %rbx, %rsi
callq 0x7c2b4
movq 0x20(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x7c744
addl $0x2, %r12d
movslq %r12d, %rcx
movq (%rbp), %rdx
leaq (%rcx,%rcx,4), %rbx
shlq $0x4, %rbx
movq 0x20(%rdx,%rbx), %rsi
leaq 0x4(%rsi), %rdx
movq 0x8(%rax), %rcx
cmpq 0x10(%rax), %rcx
je 0x7c0ba
movl (%rdx), %edx
movl %edx, (%rcx)
addq $0x4, %rcx
movq %rcx, 0x8(%rax)
jmp 0x7c0ce
movq %rax, %rdi
movq %rcx, %rsi
callq 0x792ca
movq (%rbp), %rax
movq 0x28(%rax,%rbx), %rsi
addq $0x4, %rsi
movq 0x18(%rsp), %rdi
callq 0x7c744
movq 0x8(%rax), %rsi
cmpq 0x10(%rax), %rsi
je 0x7c096
movl 0x28(%rsp), %ecx
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rax)
jmp 0x7c0a3
movq %rax, %rdi
leaq 0x28(%rsp), %rdx
callq 0x7d59a
addq (%rbp), %rbx
leaq 0x40(%rsp), %rdi
movq %rbx, %rsi
callq 0x7c2b4
addl $0x2, %r12d
jmp 0x7c103
movq %rax, %rdi
movq %rcx, %rsi
callq 0x792ca
movq (%rbp), %rax
movq 0x20(%rax,%rbx), %rsi
addq $0x4, %rsi
movq 0x18(%rsp), %rdi
callq 0x7c744
movq 0x8(%rax), %rsi
cmpq 0x10(%rax), %rsi
je 0x7c0f6
movl 0x28(%rsp), %ecx
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rax)
jmp 0x7c103
movq %rax, %rdi
leaq 0x28(%rsp), %rdx
callq 0x7d59a
movq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x7c9a0
leaq 0xd0(%rsp), %rdi
callq 0x7d676
leaq 0xa0(%rsp), %rdi
callq 0x7d344
leaq 0x88(%rsp), %rdi
callq 0x7c714
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x7c153
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x5260
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x7c16a
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x5260
leaq 0x40(%rsp), %rdi
callq 0x652c0
movslq %r12d, %r14
leaq (%r14,%r14,4), %rdi
shlq $0x4, %rdi
addq (%rbp), %rdi
jmp 0x7bd05
movq 0x8(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
movl -0xc0(%rcx), %edx
movq 0x10(%rsp), %rsi
movl %edx, 0xc(%rax,%rsi)
movb $0x1, -0xbb(%rcx)
leaq 0x190(%rsp), %rdi
callq 0x7d676
leaq 0x160(%rsp), %rdi
callq 0x7d344
leaq 0x148(%rsp), %rbx
movq %rbx, %rdi
callq 0x7c714
movq -0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x7c1ed
movq 0x140(%rsp), %rsi
subq %rdi, %rsi
callq 0x5260
movq 0x118(%rsp), %rdi
testq %rdi, %rdi
leaq 0x100(%rsp), %rbx
je 0x7c212
movq 0x128(%rsp), %rsi
subq %rdi, %rsi
callq 0x5260
incl %r12d
movq %rbx, %rdi
callq 0x652c0
movl %r12d, %eax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7c24b
jmp 0x7c24b
jmp 0x7c23c
jmp 0x7c24b
jmp 0x7c24b
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x7c9e0
jmp 0x7c24e
movq %rax, %rbx
leaq 0xe8(%rsp), %rdi
callq 0x7c9e0
movq %rbx, %rdi
callq 0x53d0