// File: /workspace/github_cpp_makefile_star2_O3/acliusBackHome[P]kamaya/dist/BaseBlock.cpp
// Function: BaseBlock::get_base_blocks(std::vector<std::tuple<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::tuple<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>> const&)
BaseBlockListAndMap BaseBlock::get_base_blocks(const vector<Qua> &qua_list) {
    if (qua_list.empty()) {
        return BaseBlockListAndMap(vector<BaseBlock>(), map<size_t, size_t>());
    }
    set<size_t> tags; //标记基本块的标记
    tags.insert(0);
    for (size_t i = 0; i < qua_list.size(); ++i) {
        const string &op = get<0>(qua_list[i]);
        if (op == "jmp" || op == "j>" || op == "j<" || op == "j<=" ||
            op == "j>=" || op == "j==" || op == "j!=") {
            size_t jump_adr = strtoull(get<3>(qua_list[i]).c_str(), nullptr, 10),
                    next_instr = i + 1;
            if (tags.find(jump_adr) == tags.end()) {
                tags.insert(jump_adr);
            }
            if (next_instr < qua_list.size()) {
                if (tags.find(next_instr) == tags.end()) {
                    tags.insert(next_instr);
                }
            }
        }
    }
    size_t last_qua = qua_list.size();
    if (tags.find(last_qua) == tags.end()) {
        tags.insert(last_qua);
    }
    vector<BaseBlock> res;
    BaseBlock block_now;
    block_now.block_id = block_now.begin_index = 0;
    auto iter = tags.begin();
    block_now.qua_list.emplace_back(qua_list[*iter]);
    iter++;
    // 建立行号到基本块id的映射
    map<size_t, size_t> line2block_id;
    line2block_id[0] = block_now.block_id;
    for (size_t i = 1; i < qua_list.size(); ++i) {
        if (iter == tags.end()) {
            break;
        }
        if (i == *iter) {
            block_now.end_index = i - 1;
            res.emplace_back(block_now);
            block_now.block_id++;
            block_now.begin_index = i;
            block_now.qua_list.clear();
            line2block_id[i] = block_now.block_id;
            block_now.qua_list.emplace_back(qua_list[i]);
            iter++;
        } else {
            block_now.qua_list.emplace_back(qua_list[i]);
            line2block_id[i] = block_now.block_id;
        }
    }
    block_now.end_index = *iter - 1;
    res.emplace_back(block_now);
    // 结束
    line2block_id[qua_list.size()] = res.size();
    for (auto &each : res) {
        if (each.qua_list.empty()) {
            cout << "bug: 有空的基本块" << endl;
            continue;
        }
        const auto &block_last_qua = each.qua_list[each.qua_list.size() - 1];
        const string &op = get<0>(block_last_qua);
        if (op == "jmp") {
            size_t jump_adr = strtoull(get<3>(block_last_qua).c_str(), nullptr, 10);
            each.jump_to.emplace_back(line2block_id[jump_adr]);
        } else if (op == "j>" || op == "j<" || op == "j<=" ||
                   op == "j>=" || op == "j==" || op == "j!=") {
            size_t jump_adr = strtoull(get<3>(block_last_qua).c_str(), nullptr, 10),
                    next_instr = each.end_index + 1;
            each.jump_to.emplace_back(line2block_id[jump_adr]);
            each.jump_to.emplace_back(line2block_id[next_instr]);
        } else {
            size_t next_instr = each.end_index + 1;
            each.jump_to.emplace_back(line2block_id[next_instr]);
        }
    }
    return BaseBlockListAndMap(res, line2block_id);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rdi, %rbx
movq (%rsi), %rax
cmpq 0x8(%rsi), %rax
je 0x3533e
movq %rsi, %r15
leaq -0x78(%rbp), %rcx
movl $0x0, (%rcx)
xorl %eax, %eax
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
leaq -0xd0(%rbp), %rsi
movq %rax, (%rsi)
leaq -0x80(%rbp), %rdi
callq 0x36692
movq %rbx, -0x88(%rbp)
movq (%r15), %rax
movq 0x8(%r15), %rcx
subq %rax, %rcx
je 0x353a7
xorl %ebx, %ebx
leaq -0x80(%rbp), %r14
movq %rbx, %r12
shlq $0x7, %r12
leaq (%rax,%r12), %r13
addq $0x60, %r13
movq %r13, %rdi
leaq 0xde85(%rip), %rsi      # 0x4303d
callq 0x40f0
testl %eax, %eax
je 0x3523b
movq %r13, %rdi
leaq 0xde63(%rip), %rsi      # 0x4302e
callq 0x40f0
testl %eax, %eax
je 0x3523b
movq %r13, %rdi
leaq 0xde49(%rip), %rsi      # 0x43027
callq 0x40f0
testl %eax, %eax
je 0x3523b
movq %r13, %rdi
leaq 0xde39(%rip), %rsi      # 0x4302a
callq 0x40f0
testl %eax, %eax
je 0x3523b
movq %r13, %rdi
leaq 0xde2d(%rip), %rsi      # 0x43031
callq 0x40f0
testl %eax, %eax
je 0x3523b
movq %r13, %rdi
leaq 0xde1e(%rip), %rsi      # 0x43035
callq 0x40f0
testl %eax, %eax
je 0x3523b
movq %r13, %rdi
leaq 0xde0f(%rip), %rsi      # 0x43039
callq 0x40f0
testl %eax, %eax
je 0x3523b
incq %rbx
jmp 0x35325
movq (%r15), %rax
movq (%rax,%r12), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x43d0
movq %rax, -0xd0(%rbp)
incq %rbx
movq %rbx, -0x100(%rbp)
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0x352a9
leaq -0x78(%rbp), %r8
movq %r8, %rcx
movq %rdi, %rdx
movq 0x20(%rdi), %rsi
xorl %edi, %edi
cmpq %rax, %rsi
setb %dil
movq %rdx, %r8
cmovbq %rcx, %r8
movq 0x10(%rdx,%rdi,8), %rdi
testq %rdi, %rdi
jne 0x3526c
leaq -0x78(%rbp), %rdi
cmpq %rdi, %r8
je 0x352a9
cmpq %rax, %rsi
cmovbq %rcx, %rdx
movq %rbx, %rcx
cmpq 0x20(%rdx), %rax
jae 0x352bf
movq %r14, %rdi
leaq -0xd0(%rbp), %rsi
callq 0x19ab8
movq -0x100(%rbp), %rcx
movq 0x8(%r15), %rax
subq (%r15), %rax
sarq $0x7, %rax
cmpq %rax, %rcx
jae 0x35325
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0x35316
leaq -0x78(%rbp), %r8
movq %r8, %rax
movq %rdi, %rdx
movq 0x20(%rdi), %rsi
xorl %edi, %edi
cmpq %rcx, %rsi
setb %dil
movq %rdx, %r8
cmovbq %rax, %r8
movq 0x10(%rdx,%rdi,8), %rdi
testq %rdi, %rdi
jne 0x352dc
leaq -0x78(%rbp), %rdi
cmpq %rdi, %r8
je 0x35316
cmpq %rcx, %rsi
cmovbq %rax, %rdx
cmpq 0x20(%rdx), %rcx
jae 0x35325
movq %r14, %rdi
leaq -0x100(%rbp), %rsi
callq 0x19ab8
movq (%r15), %rax
movq 0x8(%r15), %rcx
subq %rax, %rcx
sarq $0x7, %rcx
cmpq %rcx, %rbx
jb 0x3519f
jmp 0x353ab
leaq -0xc8(%rbp), %rax
xorl %ecx, %ecx
movq %rcx, 0x8(%rax)
xorps %xmm0, %xmm0
movaps %xmm0, -0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq %rcx, 0x20(%rax)
leaq 0x8(%rbx), %rax
movq %rcx, 0x10(%rbx)
movq %rax, 0x18(%rbx)
movq %rax, 0x20(%rbx)
movl $0x0, 0x8(%rbx)
movups %xmm0, 0x28(%rbx)
movups %xmm0, 0x38(%rbx)
movq %rbx, %r14
leaq -0x80(%rbp), %rbx
movq %rcx, 0x10(%rbx)
movaps %xmm0, (%rbx)
leaq -0xd0(%rbp), %rdi
callq 0x13a36
movq %rbx, %rdi
movq %r14, %rbx
callq 0x14e5a
jmp 0x3587d
sarq $0x7, %rcx
movq %rcx, -0x110(%rbp)
movq -0x70(%rbp), %r8
testq %r8, %r8
je 0x353fa
leaq -0x78(%rbp), %r9
movq %r9, %rdx
movq %r8, %rsi
movq 0x20(%r8), %rdi
xorl %r8d, %r8d
cmpq %rcx, %rdi
setb %r8b
movq %rsi, %r9
cmovbq %rdx, %r9
movq 0x10(%rsi,%r8,8), %r8
testq %r8, %r8
jne 0x353bf
leaq -0x78(%rbp), %r8
cmpq %r8, %r9
je 0x353fa
cmpq %rcx, %rdi
cmovbq %rdx, %rsi
cmpq 0x20(%rsi), %rcx
jae 0x3540d
leaq -0x80(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x19ab8
movq (%r15), %rax
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
xorl %ecx, %ecx
movq %rcx, -0x40(%rbp)
leaq -0xc8(%rbp), %rdi
movups %xmm0, 0x20(%rdi)
movups %xmm0, 0x10(%rdi)
movups %xmm0, (%rdi)
movq $-0x1, 0x38(%rdi)
movq %rcx, 0x30(%rdi)
movq %rcx, -0x8(%rdi)
movq -0x68(%rbp), %rbx
movq 0x20(%rbx), %rsi
shlq $0x7, %rsi
addq %rax, %rsi
callq 0x35ff8
movq %rbx, %rdi
callq 0x4350
movq %rax, %rbx
leaq -0xf8(%rbp), %rax
movl $0x0, (%rax)
xorl %ecx, %ecx
movq %rcx, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq %rcx, 0x20(%rax)
movq -0xd0(%rbp), %r14
leaq -0x30(%rbp), %rsi
movq %rcx, (%rsi)
leaq -0x100(%rbp), %rdi
callq 0x36034
movq %r14, (%rax)
movq $0x1, -0x30(%rbp)
movq (%r15), %rsi
movq 0x8(%r15), %rax
subq %rsi, %rax
cmpq $0x81, %rax
setb %al
leaq -0x78(%rbp), %rcx
cmpq %rcx, %rbx
sete %cl
orb %al, %cl
jne 0x355a5
movl $0x1, %eax
leaq -0x100(%rbp), %r14
leaq -0x30(%rbp), %r12
cmpq 0x20(%rbx), %rax
jne 0x35552
decq %rax
movq %rax, -0x90(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x3609c
incq -0xd0(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0xc8(%rbp), %rsi
leaq -0xc8(%rbp), %rdi
callq 0x36e2c
movq -0xd0(%rbp), %r13
movq %r14, %rdi
movq %r12, %rsi
callq 0x360d8
movq %r13, (%rax)
movq -0x30(%rbp), %rsi
shlq $0x7, %rsi
addq (%r15), %rsi
leaq -0xc8(%rbp), %rdi
callq 0x35ff8
movq %rbx, %rdi
callq 0x4350
movq %rax, %rbx
jmp 0x3557a
shlq $0x7, %rax
addq %rax, %rsi
leaq -0xc8(%rbp), %rdi
callq 0x35ff8
movq -0xd0(%rbp), %r13
movq %r14, %rdi
movq %r12, %rsi
callq 0x360d8
movq %r13, (%rax)
movq -0x30(%rbp), %rax
incq %rax
movq %rax, -0x30(%rbp)
movq (%r15), %rsi
movq 0x8(%r15), %rcx
subq %rsi, %rcx
sarq $0x7, %rcx
cmpq %rcx, %rax
jae 0x355a5
leaq -0x78(%rbp), %rcx
cmpq %rcx, %rbx
jne 0x354d4
movq 0x20(%rbx), %rax
decq %rax
leaq -0xd0(%rbp), %rsi
movq %rax, 0x40(%rsi)
leaq -0x50(%rbp), %rdi
callq 0x3609c
movq -0x50(%rbp), %rbx
movq 0x8(%r15), %rax
subq (%r15), %rax
movq -0x48(%rbp), %r14
sarq $0x7, %rax
leaq -0x30(%rbp), %rsi
movq %rax, (%rsi)
leaq -0x100(%rbp), %rdi
callq 0x36034
subq %rbx, %r14
sarq $0x3, %r14
movabsq $-0x71c71c71c71c71c7, %rcx # imm = 0x8E38E38E38E38E39
imulq %r14, %rcx
movq %rcx, (%rax)
movq -0x50(%rbp), %r15
movq -0x48(%rbp), %rbx
cmpq %rbx, %r15
je 0x35824
addq $0x20, %r15
movq 0x259b6(%rip), %r12     # 0x5afd0
movq -0x10(%r15), %r13
cmpq %r13, -0x18(%r15)
je 0x35705
movq %r13, %r14
addq $-0x20, %r14
movq %r14, %rdi
leaq 0xda04(%rip), %rsi      # 0x4303d
callq 0x40f0
testl %eax, %eax
je 0x35792
movq %r14, %rdi
leaq 0xd9de(%rip), %rsi      # 0x4302e
callq 0x40f0
testl %eax, %eax
je 0x35746
movq %r14, %rdi
leaq 0xd9c0(%rip), %rsi      # 0x43027
callq 0x40f0
testl %eax, %eax
je 0x35746
movq %r14, %rdi
leaq 0xd9ac(%rip), %rsi      # 0x4302a
callq 0x40f0
testl %eax, %eax
je 0x35746
movq %r14, %rdi
leaq 0xd99c(%rip), %rsi      # 0x43031
callq 0x40f0
testl %eax, %eax
je 0x35746
movq %r14, %rdi
leaq 0xd989(%rip), %rsi      # 0x43035
callq 0x40f0
testl %eax, %eax
je 0x35746
movq %r14, %rdi
leaq 0xd976(%rip), %rsi      # 0x43039
callq 0x40f0
testl %eax, %eax
je 0x35746
movq 0x20(%r15), %rax
incq %rax
movq %rax, -0x30(%rbp)
leaq -0x100(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x360d8
movq 0x8(%r15), %rsi
cmpq 0x10(%r15), %rsi
jne 0x357f5
movq %r15, %rdi
movq %rax, %rdx
callq 0x26040
jmp 0x35810
movl $0x17, %edx
movq %r12, %rdi
leaq 0x12028(%rip), %rsi     # 0x4773c
callq 0x4340
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x42c0
movsbl %al, %esi
movq %r12, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4220
jmp 0x35810
movq -0x80(%r13), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x43d0
movq %rax, -0x30(%rbp)
movq 0x20(%r15), %rax
incq %rax
movq %rax, -0x108(%rbp)
leaq -0x100(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x360d8
movq 0x8(%r15), %rsi
cmpq 0x10(%r15), %rsi
je 0x357cd
movq (%rax), %rax
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%r15)
jmp 0x357d8
movq -0x80(%r13), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x43d0
movq %rax, -0x30(%rbp)
leaq -0x100(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x360d8
movq 0x8(%r15), %rsi
cmpq 0x10(%r15), %rsi
jne 0x357f5
movq %r15, %rdi
movq %rax, %rdx
callq 0x26040
jmp 0x35810
movq %r15, %rdi
movq %rax, %rdx
callq 0x26040
leaq -0x100(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x360d8
movq 0x8(%r15), %rsi
cmpq 0x10(%r15), %rsi
je 0x35805
movq (%rax), %rax
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%r15)
jmp 0x35810
movq %r15, %rdi
movq %rax, %rdx
callq 0x26040
leaq 0x48(%r15), %rax
addq $0x28, %r15
cmpq %rbx, %r15
movq %rax, %r15
jne 0x3561a
leaq -0x50(%rbp), %rsi
leaq -0x100(%rbp), %rdx
movq -0x88(%rbp), %rdi
callq 0x3616a
leaq -0x100(%rbp), %rdi
callq 0x13a36
movq -0xb0(%rbp), %rdi
testq %rdi, %rdi
movq -0x88(%rbp), %rbx
je 0x3585f
callq 0x42b0
leaq -0xc8(%rbp), %rdi
callq 0x1401e
leaq -0x50(%rbp), %rdi
callq 0x14e5a
leaq -0x80(%rbp), %rdi
callq 0x13f92
movq %rbx, %rax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x358ae
jmp 0x358a7
jmp 0x358ae
jmp 0x358ae
movq %rax, %rbx
jmp 0x358bd
jmp 0x358a7
jmp 0x358ae
jmp 0x358ae
jmp 0x358ae
movq %rax, %rbx
jmp 0x358d2
jmp 0x358ae
movq %rax, %rbx
leaq -0x100(%rbp), %rdi
callq 0x13a36
leaq -0xd0(%rbp), %rdi
callq 0x36140
leaq -0x50(%rbp), %rdi
callq 0x14e5a
leaq -0x80(%rbp), %rdi
callq 0x13f92
movq %rbx, %rdi
callq 0x4560
nop