// File: 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:
subq $0x2c8, %rsp            # imm = 0x2C8
movq %rdi, 0x40(%rsp)
movq %rdi, 0x2c0(%rsp)
leaq 0xc0(%rsp), %rdi
callq 0x6660
movq 0x40(%rsp), %rsi
leaq 0x2401c(%rip), %rdx     # 0x57da9
leaq 0xa0(%rsp), %rdi
callq 0x20f80
jmp 0x33d9c
leaq 0xa0(%rsp), %rdi
callq 0x6160
movq %rax, %rsi
leaq 0xc0(%rsp), %rdi
movl $0x10, %edx
callq 0x6080
jmp 0x33dc0
leaq 0xa0(%rsp), %rdi
callq 0x6778
movl $0x0, 0x90(%rsp)
movl 0x90(%rsp), %eax
movq %rax, 0x38(%rsp)
leaq 0x3a69d(%rip), %rdi     # 0x6e488
callq 0x34dc0
movq %rax, %rcx
movq 0x38(%rsp), %rax
cmpq %rcx, %rax
je 0x341a5
leaq 0x2051d(%rip), %rsi     # 0x54325
leaq 0xc0(%rsp), %rdi
callq 0x6370
movq %rax, 0x30(%rsp)
jmp 0x33e1c
movl 0x90(%rsp), %eax
movl %eax, %esi
leaq 0x3a65c(%rip), %rdi     # 0x6e488
callq 0x34f80
movq 0x30(%rsp), %rdi
movq (%rax), %rax
movl (%rax), %esi
callq 0x6690
movq %rax, 0x28(%rsp)
jmp 0x33e47
movq 0x28(%rsp), %rdi
leaq 0x204a7(%rip), %rsi     # 0x542fa
callq 0x6370
jmp 0x33e5a
leaq 0x2049c(%rip), %rsi     # 0x542fd
leaq 0xc0(%rsp), %rdi
callq 0x6370
jmp 0x33e70
movl 0x90(%rsp), %eax
movl %eax, %esi
leaq 0x3a608(%rip), %rdi     # 0x6e488
callq 0x34f80
movq (%rax), %rax
movq 0x8(%rax), %rdi
callq 0x34c70
movq %rax, 0x88(%rsp)
movl 0x90(%rsp), %eax
movl %eax, %esi
leaq 0x3a5df(%rip), %rdi     # 0x6e488
callq 0x34f80
movq (%rax), %rax
movq 0x8(%rax), %rdi
callq 0x34cc0
movq %rax, 0x80(%rsp)
leaq 0x88(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x34ca0
testb $0x1, %al
jne 0x33ee0
jmp 0x33fcd
leaq 0x88(%rsp), %rdi
callq 0x34cf0
movq (%rax), %rax
movq %rax, 0x78(%rsp)
leaq 0x2041e(%rip), %rsi     # 0x5431a
leaq 0xc0(%rsp), %rdi
callq 0x6370
movq %rax, 0x20(%rsp)
jmp 0x33f10
movq 0x78(%rsp), %rsi
movq (%rsi), %rax
movq (%rax), %rax
leaq 0x58(%rsp), %rdi
xorl %edx, %edx
callq *%rax
jmp 0x33f26
movq 0x20(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x6340
movq %rax, 0x18(%rsp)
jmp 0x33f3c
movq 0x18(%rsp), %rdi
movq 0x3a050(%rip), %rsi     # 0x6df98
callq 0x63d0
jmp 0x33f4f
leaq 0x58(%rsp), %rdi
callq 0x6778
leaq 0x88(%rsp), %rdi
callq 0x34d10
jmp 0x33e99
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
jmp 0x341c9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x6778
jmp 0x341c9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
leaq 0x58(%rsp), %rdi
callq 0x6778
jmp 0x341c9
leaq 0x20349(%rip), %rsi     # 0x5431d
leaq 0xc0(%rsp), %rdi
callq 0x6370
jmp 0x33fe3
movl 0x90(%rsp), %eax
movl %eax, %esi
leaq 0x3a495(%rip), %rdi     # 0x6e488
callq 0x34f80
movq (%rax), %rax
cmpq $0x0, 0x10(%rax)
je 0x34049
leaq 0x20317(%rip), %rsi     # 0x54320
leaq 0xc0(%rsp), %rdi
callq 0x6370
movq %rax, 0x10(%rsp)
jmp 0x3401d
movl 0x90(%rsp), %eax
movl %eax, %esi
leaq 0x3a45b(%rip), %rdi     # 0x6e488
callq 0x34f80
movq 0x10(%rsp), %rdi
movq (%rax), %rax
movq 0x10(%rax), %rax
movl (%rax), %esi
callq 0x6690
jmp 0x34047
jmp 0x34061
leaq 0x202d8(%rip), %rsi     # 0x54328
leaq 0xc0(%rsp), %rdi
callq 0x6370
jmp 0x3405f
jmp 0x34061
movq 0x39f30(%rip), %rsi     # 0x6df98
leaq 0xc0(%rsp), %rdi
callq 0x63d0
jmp 0x34077
movl 0x90(%rsp), %eax
movl %eax, %esi
leaq 0x3a401(%rip), %rdi     # 0x6e488
callq 0x34f80
movq (%rax), %rdi
addq $0x18, %rdi
callq 0x34dc0
cmpq $0x0, %rax
je 0x34177
movl 0x90(%rsp), %eax
movl %eax, %esi
leaq 0x3a3d6(%rip), %rdi     # 0x6e488
callq 0x34f80
movq (%rax), %rdi
addq $0x18, %rdi
callq 0x350a0
movq %rax, 0x50(%rsp)
leaq 0x20260(%rip), %rsi     # 0x5432f
leaq 0xc0(%rsp), %rdi
callq 0x6370
jmp 0x340de
jmp 0x340e0
movl 0x90(%rsp), %eax
movl %eax, %esi
leaq 0x3a398(%rip), %rdi     # 0x6e488
callq 0x34f80
movq (%rax), %rdi
addq $0x18, %rdi
callq 0x35110
movq %rax, 0x48(%rsp)
leaq 0x50(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x350d0
testb $0x1, %al
jne 0x3411b
jmp 0x3415f
leaq 0x20203(%rip), %rsi     # 0x54325
leaq 0xc0(%rsp), %rdi
callq 0x6370
movq %rax, 0x8(%rsp)
jmp 0x34136
leaq 0x50(%rsp), %rdi
callq 0x35140
movq 0x8(%rsp), %rdi
movq (%rax), %rax
movl (%rax), %esi
callq 0x6690
jmp 0x34151
jmp 0x34153
leaq 0x50(%rsp), %rdi
callq 0x35150
jmp 0x340e0
movq 0x39e32(%rip), %rsi     # 0x6df98
leaq 0xc0(%rsp), %rdi
callq 0x63d0
jmp 0x34175
jmp 0x34177
leaq 0x201b7(%rip), %rsi     # 0x54335
leaq 0xc0(%rsp), %rdi
callq 0x6370
jmp 0x3418d
jmp 0x3418f
movl 0x90(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x90(%rsp)
jmp 0x33dd8
leaq 0xc0(%rsp), %rdi
callq 0x6580
jmp 0x341b4
leaq 0xc0(%rsp), %rdi
callq 0x6780
addq $0x2c8, %rsp            # imm = 0x2C8
retq
leaq 0xc0(%rsp), %rdi
callq 0x6780
movq 0x98(%rsp), %rdi
callq 0x66b0
nopw %cs:(%rax,%rax)