// File: /workspace/github_cpp_makefile_star2_O1/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 0x6510
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %rdi
callq 0x16c42
leaq 0x15e66(%rip), %rsi     # 0x31c39
leaq 0x8(%rsp), %rdi
callq 0x65a0
movq 0x8(%rsp), %rsi
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
movl $0x10, %edx
callq 0x6070
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1be10
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x62f0
leaq 0x22599(%rip), %r14     # 0x3e3b0
movq 0x8(%r14), %rax
cmpq (%r14), %rax
je 0x1c05d
xorl %ebp, %ebp
leaq 0x12528(%rip), %r13     # 0x2e355
leaq 0x8(%rsp), %r12
movl $0x2, %edx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x6360
movq (%r14), %rax
movq (%rax,%rbp,8), %rax
movl (%rax), %esi
movq %rbx, %rdi
callq 0x6530
movl $0x2, %edx
movq %rax, %rdi
leaq 0x124c8(%rip), %rsi     # 0x2e32a
callq 0x6360
movl $0x1c, %edx
movq %rbx, %rdi
leaq 0x124b7(%rip), %rsi     # 0x2e32d
callq 0x6360
movq (%r14), %rax
movq (%rax,%rbp,8), %rax
movq 0x8(%rax), %rax
movq (%rax), %r15
cmpq %rax, %r15
je 0x1bf24
movq 0x10(%r15), %r13
movl $0x2, %edx
movq %rbx, %rdi
leaq 0x124a5(%rip), %rsi     # 0x2e34a
callq 0x6360
movq (%r13), %rax
movq %r12, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq *(%rax)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x6360
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x62b0
movsbl %al, %esi
movq %r13, %rdi
callq 0x6040
movq %rax, %rdi
callq 0x61f0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1bf10
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x62f0
movq (%r15), %r15
movq (%r14), %rax
movq (%rax,%rbp,8), %rax
cmpq 0x8(%rax), %r15
jne 0x1be92
movl $0x2, %edx
movq %rbx, %rdi
leaq 0x1241a(%rip), %rsi     # 0x2e34d
callq 0x6360
leaq 0x12416(%rip), %r13     # 0x2e355
movq (%r14), %rax
movq (%rax,%rbp,8), %rax
cmpq $0x0, 0x10(%rax)
je 0x1bf78
movl $0x7, %edx
movq %rbx, %rdi
leaq 0x123f4(%rip), %rsi     # 0x2e350
callq 0x6360
movq (%r14), %rax
movq (%rax,%rbp,8), %rax
movq 0x10(%rax), %rax
movl (%rax), %esi
movq %rbx, %rdi
callq 0x6530
jmp 0x1bf8c
movl $0x6, %edx
movq %rbx, %rdi
leaq 0x123d1(%rip), %rsi     # 0x2e358
callq 0x6360
movq 0x28(%rsp), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x62b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x6040
movq %rax, %rdi
callq 0x61f0
movq (%r14), %rax
movq (%rax,%rbp,8), %rax
movq 0x18(%rax), %r15
cmpq %r15, 0x20(%rax)
je 0x1c033
movl $0x5, %edx
movq %rbx, %rdi
leaq 0x1238a(%rip), %rsi     # 0x2e35f
callq 0x6360
movq (%r14), %rax
movq (%rax,%rbp,8), %rax
cmpq 0x20(%rax), %r15
je 0x1c00a
movl $0x2, %edx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x6360
movq (%r15), %rax
movl (%rax), %esi
movq %rbx, %rdi
callq 0x6530
addq $0x8, %r15
jmp 0x1bfda
movq 0x28(%rsp), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x62b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x6040
movq %rax, %rdi
callq 0x61f0
movl $0x1d, %edx
movq %rbx, %rdi
leaq 0x12323(%rip), %rsi     # 0x2e365
callq 0x6360
incl %ebp
movq 0x8(%r14), %rax
subq (%r14), %rax
sarq $0x3, %rax
cmpq %rbp, %rax
jne 0x1be32
leaq 0x28(%rsp), %rdi
callq 0x6410
movq 0x21f42(%rip), %rax     # 0x3dfb0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x30(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x28(%rsp,%rcx)
callq 0x6270
leaq 0x120(%rsp), %rdi
callq 0x6100
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1c0bd
jmp 0x1c0c2
jmp 0x1c0c2
jmp 0x1c0bd
jmp 0x1c0bd
jmp 0x1c0bd
jmp 0x1c0bd
jmp 0x1c0bd
jmp 0x1c0bd
movq %rax, %rbx
jmp 0x1c0e1
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1c0e1
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x62f0
leaq 0x28(%rsp), %rdi
callq 0x65c8
movq %rbx, %rdi
callq 0x6550