// File: /workspace/github_cpp_makefile_star2_O3/kelwinfc[P]ci4721-Fernandez-Gyomrey/src/optimizer.cpp
// Function: next_instruction_jumps(Block&)
void next_instruction_jumps(Block& code){
    if ( code.w_vector ){
        unsigned int nsize = code.instructions.vinst->size();
        
        // Guardar las instrucciones que no sean saltos a la siguiente
        // instruccion
        vector<inst*> new_insts;
        for (unsigned int i=0; i+1<nsize; i++){
            quad* current_inst = (quad*)(*(code.instructions.vinst))[i];
            quad* next_inst    = (quad*)(*(code.instructions.vinst))[i+1];
            
            if (    current_inst->op == quad::GOTO 
                 && current_inst->get_goal_label() == next_inst->label
               )
            {
                delete current_inst;
                (*(code.instructions.vinst))[i] = 0;
            } else {
                new_insts.push_back( current_inst );
            }
        }
        if ( nsize ){
            new_insts.push_back( code.instructions.vinst->back() );
        }
        unsigned int goal_size = new_insts.size();
        
        code.instructions.vinst->clear();
        for (unsigned int i=0; i<goal_size; i++){
            code.instructions.vinst->push_back( new_insts[i] );
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
cmpb $0x1, 0x4(%rdi)
jne 0x2223c
movq %rdi, %rbx
movq 0x8(%rdi), %rax
movq 0x8(%rax), %rcx
subq (%rax), %rcx
shrq $0x3, %rcx
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movq %rcx, 0x20(%rsp)
cmpl $0x2, %ecx
jb 0x22196
movq 0x20(%rsp), %rbp
decl %ebp
xorl %r13d, %r13d
leaq 0x1cbff(%rip), %rax     # 0x3ed08
addq $0x10, %rax
movq %rax, 0x28(%rsp)
leaq 0x30(%rsp), %r15
movq 0x8(%rbx), %rax
movq (%rax), %rax
movq (%rax,%r13,8), %r12
cmpl $0x16, 0xc(%r12)
jne 0x2217e
movq 0x8(%rax,%r13,8), %r14
movq %r12, %rdi
callq 0x1da7c
cmpl 0x8(%r14), %eax
jne 0x2217e
movq 0x28(%rsp), %rax
movq %rax, (%r12)
movq 0x28(%r12), %rdi
leaq 0x38(%r12), %rax
cmpq %rax, %rdi
je 0x22160
movq (%rax), %rsi
incq %rsi
callq 0x6300
movl $0x48, %esi
movq %r12, %rdi
callq 0x6300
movq 0x8(%rbx), %rax
movq (%rax), %rax
movq $0x0, (%rax,%r13,8)
jmp 0x2218e
movq %r12, 0x30(%rsp)
movq %rsp, %rdi
movq %r15, %rsi
callq 0x225c0
incq %r13
cmpq %r13, %rbp
jne 0x22117
cmpl $0x0, 0x20(%rsp)
je 0x221cb
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rdx
addq $-0x8, %rdx
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x221c3
movq (%rdx), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%rsp)
jmp 0x221cb
movq %rsp, %rdi
callq 0x1caea
movq (%rsp), %rdi
movq 0x8(%rsp), %rax
subq %rdi, %rax
shrq $0x3, %rax
movq 0x8(%rbx), %rcx
movq (%rcx), %rdx
cmpq %rdx, 0x8(%rcx)
je 0x221ec
movq %rdx, 0x8(%rcx)
testl %eax, %eax
je 0x2222a
movl %eax, %r14d
xorl %r15d, %r15d
movq 0x8(%rbx), %rdi
movq (%rsp), %rdx
addq %r15, %rdx
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x22218
movq (%rdx), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0x2221d
callq 0x1caea
addq $0x8, %r15
decq %r14
jne 0x221f6
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x2223c
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x6300
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x22251
jmp 0x22251
jmp 0x22251
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x2226a
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x6300
movq %rbx, %rdi
callq 0x6560