// File: /workspace/github_cpp_makefile_star2_O1/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), %r13
movl %eax, -0x18(%r13)
movw $0x0, -0x14(%r13)
movaps 0x178c9(%rip), %xmm0    # 0x98c70
movups %xmm0, -0x10(%r13)
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), %r14d
shlq $0x4, %rax
leaq (%rax,%rax,4), %rbx
leaq 0x175dc(%rip), %r15     # 0x989db
leaq 0x175cc(%rip), %r12     # 0x989d2
movq (%rbp), %rdi
addq %rbx, %rdi
movq %r15, %rsi
callq 0x50c0
testl %eax, %eax
je 0x8142c
movq (%rbp), %rdi
addq %rbx, %rdi
movq %r12, %rsi
callq 0x50c0
testl %eax, %eax
jne 0x81444
incl %r14d
movq (%rbp), %rsi
addq %rbx, %rsi
addq $0x50, %rbx
movq %r13, %rdi
callq 0x81b58
jmp 0x81406
movq (%rbp), %rsi
addq %rbx, %rsi
movq %r13, %rdi
callq 0x81b58
addq $0x50, %rbx
leaq 0x1751d(%rip), %r15     # 0x9897b
leaq 0x178bd(%rip), %r12     # 0x98d22
movq (%rbp), %rdi
addq %rbx, %rdi
movq %r15, %rsi
callq 0x50c0
testl %eax, %eax
je 0x8148b
movq (%rbp), %rdi
addq %rbx, %rdi
movq %r12, %rsi
callq 0x50c0
testl %eax, %eax
jne 0x814ab
incl %r14d
leaq 0x50(%rbx), %r13
addq (%rbp), %rbx
leaq 0x100(%rsp), %rdi
movq %rbx, %rsi
callq 0x81b58
movq %r13, %rbx
jmp 0x81465
movq 0x8(%rsp), %rdi
movq 0x8(%rdi), %rbx
subq (%rdi), %rbx
leaq 0xe8(%rsp), %rsi
callq 0x82216
sarq $0x6, %rbx
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rbx, %rax
movq %rax, 0x10(%rsp)
leaq 0x174f9(%rip), %rbx     # 0x989db
leaq 0x174e9(%rip), %r12     # 0x989d2
movslq %r14d, %r13
leaq (,%r13,4), %r15
addq %r13, %r15
shlq $0x4, %r15
movq (%rbp), %rdi
addq %r15, %rdi
movq %rbx, %rsi
callq 0x50c0
testl %eax, %eax
je 0x8154f
movq (%rbp), %rdi
addq %r15, %rdi
movq %r12, %rsi
callq 0x50c0
testl %eax, %eax
je 0x8154f
movq (%rbp), %rdi
addq %r15, %rdi
leaq 0x17470(%rip), %rsi     # 0x9899f
callq 0x50c0
testl %eax, %eax
je 0x8154f
movq (%rbp), %rdi
addq %r15, %rdi
leaq 0x16387(%rip), %rsi     # 0x978cd
callq 0x50c0
testl %eax, %eax
jne 0x81571
movq %rbp, %rdi
movq 0x8(%rsp), %rsi
movl %r14d, %edx
movq 0x18(%rsp), %rcx
movq 0x20(%rsp), %r8
callq 0x81368
movl %eax, %r14d
jmp 0x814e9
movslq 0x10(%rsp), %rax
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
movq (%rbp), %rdx
movq 0x20(%rdx,%r15), %rdx
movl 0x4(%rdx), %edx
leaq (%rax,%rax,2), %rax
shlq $0x6, %rax
movq %rax, 0x10(%rsp)
movl %edx, 0x8(%rcx,%rax)
addq (%rbp), %r15
leaq 0x17395(%rip), %rsi     # 0x9893b
movq %r15, %rdi
callq 0x50c0
testl %eax, %eax
je 0x81a2b
leaq 0x40(%rsp), %r12
leaq (,%r13,4), %rbx
addq %r13, %rbx
shlq $0x4, %rbx
movq (%rbp), %rdi
addq %rbx, %rdi
leaq 0x173d8(%rip), %rsi     # 0x989b0
callq 0x50c0
testl %eax, %eax
je 0x81a2b
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 0x17669(%rip), %xmm0    # 0x98c70
movups %xmm0, 0x30(%rsp)
movl $0x0, 0xa8(%rsp)
movq $0x0, 0xb0(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x50(%r12)
movups %xmm0, 0x40(%r12)
movups %xmm0, 0x30(%r12)
movups %xmm0, 0x20(%r12)
movups %xmm0, 0x10(%r12)
movups %xmm0, (%r12)
leaq 0xa8(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq %rax, 0xc0(%rsp)
movups %xmm0, 0x98(%r12)
movups %xmm0, 0x88(%r12)
movq %r12, %rdi
callq 0x81b58
leal 0x1(%r14), %r15d
movslq %r15d, %r13
leaq (,%r13,4), %rbx
addq %r13, %rbx
shlq $0x4, %rbx
movq (%rbp), %rdi
addq %rbx, %rdi
leaq 0x17403(%rip), %rsi     # 0x98aa2
callq 0x50c0
testl %eax, %eax
je 0x81817
addq (%rbp), %rbx
movq %rbx, %rdi
leaq 0x163ac(%rip), %rsi     # 0x97a66
callq 0x50c0
testl %eax, %eax
je 0x81814
movq %r13, %rax
shlq $0x4, %rax
leaq (%rax,%rax,4), %rbx
movq %r12, %r15
movq (%rbp), %rdi
addq %rbx, %rdi
leaq 0x17258(%rip), %rsi     # 0x9893b
callq 0x50c0
testl %eax, %eax
je 0x81814
movq (%rbp), %rdi
addq %rbx, %rdi
leaq 0x172b2(%rip), %rsi     # 0x989b0
callq 0x50c0
testl %eax, %eax
je 0x81814
movq (%rbp), %rdi
addq %rbx, %rdi
leaq 0x17385(%rip), %rsi     # 0x98a9e
callq 0x50c0
testl %eax, %eax
jne 0x8179c
movq 0x20(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x81fc4
movq (%rbp), %rcx
movq 0x20(%rcx,%rbx), %rdx
addq $0x4, %rdx
movq 0x8(%rax), %rsi
cmpq 0x10(%rax), %rsi
je 0x81756
movl (%rdx), %ecx
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rax)
jmp 0x8175e
movq %rax, %rdi
callq 0x7eb90
movq (%rbp), %rax
movq 0x20(%rax,%rbx), %rsi
addq $0x4, %rsi
movq 0x18(%rsp), %rdi
callq 0x81fc4
movq 0x8(%rax), %rsi
cmpq 0x10(%rax), %rsi
je 0x8178f
movl 0x28(%rsp), %ecx
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rax)
jmp 0x8179c
movq %rax, %rdi
leaq 0x28(%rsp), %rdx
callq 0x82e48
movq (%rbp), %rdi
addq %rbx, %rdi
leaq 0x171d1(%rip), %rsi     # 0x9897b
callq 0x50c0
testl %eax, %eax
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rsp), %rcx
leaq 0x18(%rax,%rcx), %rdi
cmovneq %r15, %rdi
movq (%rbp), %rsi
addq %rbx, %rsi
callq 0x81b58
incq %r13
movq (%rbp), %rax
leaq (%rax,%rbx), %rdi
addq $0x50, %rdi
leaq 0x172b9(%rip), %rsi     # 0x98aa2
callq 0x50c0
incl %r14d
testl %eax, %eax
je 0x81814
addq $0x50, %rbx
movq (%rbp), %rdi
addq %rbx, %rdi
leaq 0x1625f(%rip), %rsi     # 0x97a66
callq 0x50c0
testl %eax, %eax
jne 0x816d5
movl %r13d, %r15d
leaq (,%r13,4), %rbx
addq %r13, %rbx
shlq $0x4, %rbx
movq (%rbp), %rdi
addq %rbx, %rdi
leaq 0x1726e(%rip), %rsi     # 0x98aa2
callq 0x50c0
testl %eax, %eax
je 0x8186b
movq (%rbp), %rdi
addq %rbx, %rdi
leaq 0x1621b(%rip), %rsi     # 0x97a66
callq 0x50c0
testl %eax, %eax
je 0x8189f
addq (%rbp), %rbx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x81b58
movl %r15d, %r14d
jmp 0x81992
movq 0x20(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x81fc4
movq (%rbp), %rcx
movq 0x28(%rcx,%rbx), %rdx
addq $0x4, %rdx
movq 0x8(%rax), %rsi
cmpq 0x10(%rax), %rsi
je 0x818f1
movl (%rdx), %ecx
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rax)
jmp 0x818f9
addq (%rbp), %rbx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x81b58
movq 0x20(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x81fc4
addl $0x2, %r14d
movslq %r14d, %rcx
movq (%rbp), %rdx
leaq (%rcx,%rcx,4), %rbx
shlq $0x4, %rbx
movq 0x20(%rdx,%rbx), %rdx
addq $0x4, %rdx
movq 0x8(%rax), %rsi
cmpq 0x10(%rax), %rsi
je 0x8194c
movl (%rdx), %ecx
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rax)
jmp 0x81954
movq %rax, %rdi
callq 0x7eb90
movq (%rbp), %rax
movq 0x28(%rax,%rbx), %rsi
addq $0x4, %rsi
movq 0x18(%rsp), %rdi
callq 0x81fc4
movq 0x8(%rax), %rsi
cmpq 0x10(%rax), %rsi
je 0x8192a
movl 0x28(%rsp), %ecx
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rax)
jmp 0x81937
movq %rax, %rdi
leaq 0x28(%rsp), %rdx
callq 0x82e48
addq (%rbp), %rbx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x81b58
addl $0x2, %r14d
jmp 0x81992
movq %rax, %rdi
callq 0x7eb90
movq (%rbp), %rax
movq 0x20(%rax,%rbx), %rsi
addq $0x4, %rsi
movq 0x18(%rsp), %rdi
callq 0x81fc4
movq 0x8(%rax), %rsi
cmpq 0x10(%rax), %rsi
je 0x81985
movl 0x28(%rsp), %ecx
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rax)
jmp 0x81992
movq %rax, %rdi
leaq 0x28(%rsp), %rdx
callq 0x82e48
movq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x82216
leaq 0xd0(%rsp), %rdi
callq 0x82f24
leaq 0xa0(%rsp), %rdi
callq 0x82bb6
leaq 0x88(%rsp), %rdi
callq 0x81f94
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x819e2
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x5260
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x819f9
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x5260
movq %r12, %rdi
callq 0x6b198
movslq %r14d, %r13
leaq (,%r13,4), %rdi
addq %r13, %rdi
shlq $0x4, %rdi
addq (%rbp), %rdi
leaq 0x16f1d(%rip), %rsi     # 0x9893b
callq 0x50c0
testl %eax, %eax
jne 0x815bb
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 0x82f24
leaq 0x160(%rsp), %rdi
callq 0x82bb6
leaq 0x148(%rsp), %rbx
movq %rbx, %rdi
callq 0x81f94
movq -0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x81a90
movq 0x140(%rsp), %rsi
subq %rdi, %rsi
callq 0x5260
movq 0x118(%rsp), %rdi
testq %rdi, %rdi
leaq 0x100(%rsp), %rbx
je 0x81ab5
movq 0x128(%rsp), %rsi
subq %rdi, %rsi
callq 0x5260
incl %r14d
movq %rbx, %rdi
callq 0x6b198
movl %r14d, %eax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x81aee
jmp 0x81aee
jmp 0x81adf
jmp 0x81aee
jmp 0x81aee
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x82252
jmp 0x81af1
movq %rax, %rbx
leaq 0xe8(%rsp), %rdi
callq 0x82252
movq %rbx, %rdi
callq 0x53d0