// File: /workspace/github_cpp_makefile_star2_O2/kelwinfc[P]ci4721-Fernandez-Gyomrey/src/block.cpp
// Function: dump_blocks_definition(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void dump_blocks_definition(string filename){
    ofstream fout;
    
    fout.open((filename+".blocks").c_str());
    
    for (uint index = 0 ; index != list_of_blocks.size(); index++)
    {
        // Bloque basico
        fout << " B" << list_of_blocks[index]->index << ":\n";
        
        fout << "+--------------------------\n";
        
        // Lista de instrucciones
        list<inst*>::iterator it = 
            list_of_blocks[index]->instructions.linst->begin();
        for ( ; it != list_of_blocks[index]->instructions.linst->end(); ++it ){
            inst* current_inst = *it;
            fout << "| " << current_inst->to_string(false) << endl;
        }
        fout << "|\n";
        
        // Salida obligatoria
        if ( list_of_blocks[index]->mandatory_exit ){
            fout << "| --> B" << list_of_blocks[index]->mandatory_exit->index;
        } else {
            fout << "| --> ";
        }
        fout << endl;
        
        // Salidas opcionales
        if ( list_of_blocks[index]->sucessors.size() != 0 ){
            vector<Block*>::iterator it =
            list_of_blocks[index]->sucessors.begin();
            fout << "| -->";
            for ( ; it != list_of_blocks[index]->sucessors.end(); ++it ){
                fout << " B" << (*it)->index;
            }
            fout << endl;
        }
        
        fout << "+--------------------------\n\n";
    }
    
    fout.close();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x228, %rsp            # imm = 0x228
movq %rdi, %rbx
leaq 0x28(%rsp), %rdi
callq 0x64f0
leaq 0x119f1(%rip), %rdx     # 0x28c2d
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x125c2
movq 0x8(%rsp), %rsi
leaq 0x28(%rsp), %rdi
pushq $0x10
popq %rdx
callq 0x6060
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x65c8
xorl %r14d, %r14d
leaq 0xe0d3(%rip), %r13      # 0x25345
leaq 0x28(%rsp), %r15
movl %r14d, %r14d
leaq 0x2112f(%rip), %rcx     # 0x383b0
movq 0x8(%rcx), %rax
subq (%rcx), %rax
sarq $0x3, %rax
cmpq %r14, %rax
je 0x1742f
movq %r15, %rdi
movq %r13, %rsi
callq 0x62b0
leaq 0x21109(%rip), %rcx     # 0x383b0
movq (%rcx), %rcx
movq (%rcx,%r14,8), %rcx
movl (%rcx), %esi
movq %rax, %rdi
callq 0x6510
movq %rax, %rdi
leaq 0xe058(%rip), %rsi      # 0x2531a
callq 0x62b0
movq %r15, %rdi
leaq 0xe04c(%rip), %rsi      # 0x2531d
callq 0x62b0
leaq 0x210d3(%rip), %rax     # 0x383b0
movq (%rax), %rax
movq (%rax,%r14,8), %rax
movq 0x8(%rax), %rax
movq %rax, %r13
movq (%r13), %r13
cmpq %rax, %r13
je 0x17347
movq 0x10(%r13), %r12
movq %r15, %rdi
leaq 0xe038(%rip), %rsi      # 0x2533a
callq 0x62b0
movq %rax, %rbp
movq (%r12), %rax
movq %rbx, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq *(%rax)
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x62a0
movq %rax, %rdi
callq 0x6130
movq %rbx, %rdi
callq 0x65c8
leaq 0x21076(%rip), %rax     # 0x383b0
movq (%rax), %rax
movq (%rax,%r14,8), %rax
movq 0x8(%rax), %rax
jmp 0x172eb
movq %r15, %rdi
leaq 0xdfec(%rip), %rsi      # 0x2533d
callq 0x62b0
leaq 0xdfe8(%rip), %r13      # 0x25345
leaq 0x2104c(%rip), %rax     # 0x383b0
movq (%rax), %rax
movq (%rax,%r14,8), %rax
cmpq $0x0, 0x10(%rax)
je 0x1739f
movq %r15, %rdi
leaq 0xdfc4(%rip), %rsi      # 0x25340
callq 0x62b0
leaq 0x21028(%rip), %rcx     # 0x383b0
movq (%rcx), %rcx
movq (%rcx,%r14,8), %rcx
movq 0x10(%rcx), %rcx
movl (%rcx), %esi
movq %rax, %rdi
callq 0x6510
jmp 0x173ae
movq %r15, %rdi
leaq 0xdf9f(%rip), %rsi      # 0x25348
callq 0x62b0
movq %r15, %rdi
callq 0x6130
leaq 0x20ff3(%rip), %rax     # 0x383b0
movq (%rax), %rax
movq (%rax,%r14,8), %rax
movq 0x18(%rax), %r12
cmpq %r12, 0x20(%rax)
je 0x17418
movq %r15, %rdi
leaq 0xdf77(%rip), %rsi      # 0x2534f
callq 0x62b0
leaq 0x20fcc(%rip), %rax     # 0x383b0
movq (%rax), %rax
movq (%rax,%r14,8), %rax
cmpq 0x20(%rax), %r12
je 0x17410
movq %r15, %rdi
movq %r13, %rsi
callq 0x62b0
movq (%r12), %rcx
movl (%rcx), %esi
movq %rax, %rdi
callq 0x6510
addq $0x8, %r12
jmp 0x173dd
movq %r15, %rdi
callq 0x6130
movq %r15, %rdi
leaq 0xdf33(%rip), %rsi      # 0x25355
callq 0x62b0
incl %r14d
jmp 0x17277
leaq 0x28(%rsp), %rdi
callq 0x6400
leaq 0x28(%rsp), %rdi
callq 0x65d0
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x17465
jmp 0x1746a
jmp 0x17465
jmp 0x17465
jmp 0x17465
jmp 0x17465
jmp 0x17465
jmp 0x17465
movq %rax, %rbx
jmp 0x17477
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x65c8
leaq 0x28(%rsp), %rdi
callq 0x65d0
movq %rbx, %rdi
callq 0x6530