// File: /workspace/github_cpp_makefile_star2_O1/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 $0xf8, %rsp
movq %rdi, %r14
movq (%rsi), %rax
cmpq 0x8(%rsi), %rax
je 0x35c5b
movq %rsi, %r15
leaq -0xf8(%rbp), %r13
movl $0x0, (%r13)
xorl %eax, %eax
movq %rax, 0x8(%r13)
movq %r13, 0x10(%r13)
movq %r13, 0x18(%r13)
movq %rax, 0x20(%r13)
leaq -0xd0(%rbp), %rsi
movq %rax, (%rsi)
leaq -0x100(%rbp), %rdi
callq 0x37004
movq %r14, -0x108(%rbp)
movq (%r15), %rcx
movq 0x8(%r15), %rax
subq %rcx, %rax
je 0x35ce6
xorl %ebx, %ebx
movq %rbx, %r14
shlq $0x7, %r14
leaq (%rcx,%r14), %r12
addq $0x60, %r12
movq %r12, %rdi
leaq 0xe55d(%rip), %rsi      # 0x4403d
callq 0x40f0
testl %eax, %eax
je 0x35b5f
movq %r12, %rdi
leaq 0xe53b(%rip), %rsi      # 0x4402e
callq 0x40f0
testl %eax, %eax
je 0x35b5f
movq %r12, %rdi
leaq 0xe521(%rip), %rsi      # 0x44027
callq 0x40f0
testl %eax, %eax
je 0x35b5f
movq %r12, %rdi
leaq 0xe511(%rip), %rsi      # 0x4402a
callq 0x40f0
testl %eax, %eax
je 0x35b5f
movq %r12, %rdi
leaq 0xe505(%rip), %rsi      # 0x44031
callq 0x40f0
testl %eax, %eax
je 0x35b5f
movq %r12, %rdi
leaq 0xe4f6(%rip), %rsi      # 0x44035
callq 0x40f0
testl %eax, %eax
je 0x35b5f
movq %r12, %rdi
leaq 0xe4e7(%rip), %rsi      # 0x44039
callq 0x40f0
testl %eax, %eax
jne 0x35c3c
movq (%r15), %rax
movq (%rax,%r14), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x43d0
movq %rax, -0xd0(%rbp)
leaq 0x1(%rbx), %rcx
movq %rcx, -0x80(%rbp)
movq -0xf0(%rbp), %rdx
movq %r13, %rcx
testq %rdx, %rdx
je 0x35bab
movq %r13, %rcx
xorl %esi, %esi
cmpq %rax, 0x20(%rdx)
setb %sil
cmovaeq %rdx, %rcx
movq 0x10(%rdx,%rsi,8), %rdx
testq %rdx, %rdx
jne 0x35b93
movq %r13, %rdx
cmpq %r13, %rcx
je 0x35bbe
cmpq 0x20(%rcx), %rax
cmovbq %r13, %rcx
movq %rcx, %rdx
cmpq %r13, %rdx
jne 0x35bd6
leaq -0x100(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x19a32
movq -0x80(%rbp), %rax
movq 0x8(%r15), %rcx
subq (%r15), %rcx
sarq $0x7, %rcx
cmpq %rcx, %rax
jae 0x35c3c
movq -0xf0(%rbp), %rdx
movq %r13, %rcx
testq %rdx, %rdx
je 0x35c14
movq %r13, %rcx
xorl %esi, %esi
cmpq %rax, 0x20(%rdx)
setb %sil
cmovaeq %rdx, %rcx
movq 0x10(%rdx,%rsi,8), %rdx
testq %rdx, %rdx
jne 0x35bfc
movq %r13, %rdx
cmpq %r13, %rcx
je 0x35c27
cmpq 0x20(%rcx), %rax
cmovbq %r13, %rcx
movq %rcx, %rdx
cmpq %r13, %rdx
jne 0x35c3c
leaq -0x100(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x19a32
incq %rbx
movq (%r15), %rcx
movq 0x8(%r15), %rax
subq %rcx, %rax
sarq $0x7, %rax
cmpq %rax, %rbx
jb 0x35ac7
jmp 0x35cea
pxor %xmm0, %xmm0
movdqa %xmm0, -0x100(%rbp)
xorl %ecx, %ecx
movq %rcx, -0xf0(%rbp)
leaq -0xc8(%rbp), %rax
movdqa %xmm0, 0x8(%rax)
movdqa %xmm0, 0x18(%rax)
movdqa %xmm0, -0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq %rcx, 0x20(%rax)
leaq 0x8(%r14), %rdx
movq 0x8(%rax), %rsi
movl $0x0, 0x8(%r14)
testq %rsi, %rsi
je 0x36198
movq %rsi, 0x10(%r14)
leaq -0xa8(%rbp), %rcx
movq -0x10(%rcx), %rdi
movq %rdi, 0x18(%r14)
movq -0x8(%rcx), %rdi
movq %rdi, 0x20(%r14)
movq %rdx, 0x8(%rsi)
movq (%rcx), %rdx
movq %rdx, 0x28(%r14)
movq $0x0, -0x18(%rcx)
movq %rax, -0x10(%rcx)
movq %rax, -0x8(%rcx)
jmp 0x361ac
sarq $0x7, %rax
movq %rax, -0x118(%rbp)
movq -0xf0(%rbp), %rdx
movq %r13, %rcx
testq %rdx, %rdx
je 0x35d1b
movq %r13, %rcx
xorl %esi, %esi
cmpq %rax, 0x20(%rdx)
setb %sil
cmovaeq %rdx, %rcx
movq 0x10(%rdx,%rsi,8), %rdx
testq %rdx, %rdx
jne 0x35d03
movq %r13, %rdx
cmpq %r13, %rcx
je 0x35d2e
cmpq 0x20(%rcx), %rax
cmovbq %r13, %rcx
movq %rcx, %rdx
cmpq %r13, %rdx
jne 0x35d46
leaq -0x100(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0x19a32
pxor %xmm0, %xmm0
movdqa %xmm0, -0x50(%rbp)
xorl %eax, %eax
movq %rax, -0x40(%rbp)
leaq -0xc8(%rbp), %rdi
movdqu %xmm0, 0x20(%rdi)
movdqu %xmm0, 0x10(%rdi)
movdqu %xmm0, (%rdi)
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, 0x30(%rdi)
movq %rax, 0x30(%rdi)
movq %rax, -0x8(%rdi)
movq -0xe8(%rbp), %rbx
movq 0x20(%rbx), %rsi
shlq $0x7, %rsi
addq (%r15), %rsi
callq 0x36966
movq %rbx, %rdi
callq 0x4350
movq %rax, %rbx
leaq -0x78(%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 -0x80(%rbp), %rdi
callq 0x369a2
movq %r14, (%rax)
movq $0x1, -0x30(%rbp)
movq (%r15), %rsi
movq 0x8(%r15), %rax
subq %rsi, %rax
cmpq $0x81, %rax
setb %al
cmpq %r13, %rbx
sete %cl
orb %al, %cl
jne 0x35ed4
movl $0x1, %eax
leaq -0x30(%rbp), %r12
cmpq 0x20(%rbx), %rax
jne 0x35e84
decq %rax
movq %rax, -0x90(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x36a0c
incq -0xd0(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0xc8(%rbp), %rsi
leaq -0xc8(%rbp), %rdi
callq 0x37782
movq -0xd0(%rbp), %r14
leaq -0x80(%rbp), %rdi
movq %r12, %rsi
callq 0x36a48
movq %r14, (%rax)
movq -0x30(%rbp), %rsi
shlq $0x7, %rsi
addq (%r15), %rsi
leaq -0xc8(%rbp), %rdi
callq 0x36966
movq %rbx, %rdi
callq 0x4350
movq %rax, %rbx
jmp 0x35ead
shlq $0x7, %rax
addq %rax, %rsi
leaq -0xc8(%rbp), %rdi
callq 0x36966
movq -0xd0(%rbp), %r14
leaq -0x80(%rbp), %rdi
movq %r12, %rsi
callq 0x36a48
movq %r14, (%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 0x35ed4
cmpq %r13, %rbx
jne 0x35e05
movq 0x20(%rbx), %rax
decq %rax
leaq -0xd0(%rbp), %rsi
movq %rax, 0x40(%rsi)
leaq -0x50(%rbp), %rdi
callq 0x36a0c
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 -0x80(%rbp), %rdi
callq 0x369a2
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 0x36144
addq $0x20, %r15
movq 0x2608a(%rip), %r12     # 0x5bfd0
movq -0x10(%r15), %r13
cmpq %r13, -0x18(%r15)
je 0x3602e
movq %r13, %r14
addq $-0x20, %r14
movq %r14, %rdi
leaq 0xe0d8(%rip), %rsi      # 0x4403d
callq 0x40f0
testl %eax, %eax
je 0x360b8
movq %r14, %rdi
leaq 0xe0b2(%rip), %rsi      # 0x4402e
callq 0x40f0
testl %eax, %eax
je 0x3606f
movq %r14, %rdi
leaq 0xe094(%rip), %rsi      # 0x44027
callq 0x40f0
testl %eax, %eax
je 0x3606f
movq %r14, %rdi
leaq 0xe080(%rip), %rsi      # 0x4402a
callq 0x40f0
testl %eax, %eax
je 0x3606f
movq %r14, %rdi
leaq 0xe070(%rip), %rsi      # 0x44031
callq 0x40f0
testl %eax, %eax
je 0x3606f
movq %r14, %rdi
leaq 0xe05d(%rip), %rsi      # 0x44035
callq 0x40f0
testl %eax, %eax
je 0x3606f
movq %r14, %rdi
leaq 0xe04a(%rip), %rsi      # 0x44039
callq 0x40f0
testl %eax, %eax
je 0x3606f
movq 0x20(%r15), %rax
incq %rax
movq %rax, -0x30(%rbp)
leaq -0x80(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x36a48
movq 0x8(%r15), %rsi
cmpq 0x10(%r15), %rsi
jne 0x36115
movq %r15, %rdi
movq %rax, %rdx
callq 0x266ec
jmp 0x36130
movl $0x17, %edx
movq %r12, %rdi
leaq 0x126ff(%rip), %rsi     # 0x4873c
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 0x36130
movq -0x80(%r13), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x43d0
movq %rax, -0x30(%rbp)
movq 0x20(%r15), %rax
incq %rax
movq %rax, -0x110(%rbp)
leaq -0x80(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x36a48
movq 0x8(%r15), %rsi
cmpq 0x10(%r15), %rsi
je 0x360f0
movq (%rax), %rax
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%r15)
jmp 0x360fb
movq -0x80(%r13), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x43d0
movq %rax, -0x30(%rbp)
leaq -0x80(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x36a48
movq 0x8(%r15), %rsi
cmpq 0x10(%r15), %rsi
jne 0x36115
movq %r15, %rdi
movq %rax, %rdx
callq 0x266ec
jmp 0x36130
movq %r15, %rdi
movq %rax, %rdx
callq 0x266ec
leaq -0x80(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x36a48
movq 0x8(%r15), %rsi
cmpq 0x10(%r15), %rsi
je 0x36125
movq (%rax), %rax
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%r15)
jmp 0x36130
movq %r15, %rdi
movq %rax, %rdx
callq 0x266ec
leaq 0x48(%r15), %rax
addq $0x28, %r15
cmpq %rbx, %r15
movq %rax, %r15
jne 0x35f46
leaq -0x50(%rbp), %rsi
leaq -0x80(%rbp), %rdx
movq -0x108(%rbp), %r14
movq %r14, %rdi
callq 0x36adc
leaq -0x80(%rbp), %rdi
callq 0x13952
movq -0xb0(%rbp), %rdi
testq %rdi, %rdi
je 0x36175
callq 0x42b0
leaq -0xc8(%rbp), %rdi
callq 0x13f3a
leaq -0x50(%rbp), %rdi
callq 0x14d98
leaq -0x100(%rbp), %rdi
callq 0x13eae
jmp 0x361eb
movq $0x0, 0x10(%r14)
movq %rdx, 0x18(%r14)
movq %rdx, 0x20(%r14)
leaq 0x28(%r14), %rcx
xorl %eax, %eax
movq %rax, (%rcx)
leaq -0x100(%rbp), %rbx
movq (%rbx), %rcx
movq %rcx, 0x30(%r14)
movq 0x8(%rbx), %rcx
movq %rcx, 0x38(%r14)
movq 0x10(%rbx), %rcx
movq %rcx, 0x40(%r14)
movq %rax, 0x10(%rbx)
movdqa %xmm0, (%rbx)
leaq -0xd0(%rbp), %rdi
callq 0x13952
movq %rbx, %rdi
callq 0x14d98
movq %r14, %rax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x36213
jmp 0x3621c
jmp 0x3621c
jmp 0x3621c
movq %rax, %rbx
jmp 0x36228
jmp 0x36213
jmp 0x3621c
jmp 0x3621c
movq %rax, %rbx
jmp 0x3623d
jmp 0x3621c
jmp 0x3621c
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
callq 0x13952
leaq -0xd0(%rbp), %rdi
callq 0x36ab2
leaq -0x50(%rbp), %rdi
callq 0x14d98
leaq -0x100(%rbp), %rdi
callq 0x13eae
movq %rbx, %rdi
callq 0x4560
nop