// File: /workspace/github_cpp_makefile_star2_O1/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 0x221e1
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 0x2213e
movq 0x20(%rsp), %rbp
decl %ebp
xorl %r13d, %r13d
leaq 0x1bc57(%rip), %rax     # 0x3dd08
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 0x22126
movq 0x8(%rax,%r13,8), %r14
movq %r12, %rdi
callq 0x1d9f4
cmpl 0x8(%r14), %eax
jne 0x22126
movq 0x28(%rsp), %rax
movq %rax, (%r12)
movq 0x28(%r12), %rdi
leaq 0x38(%r12), %rax
cmpq %rax, %rdi
je 0x22108
movq (%rax), %rsi
incq %rsi
callq 0x62f0
movl $0x48, %esi
movq %r12, %rdi
callq 0x62f0
movq 0x8(%rbx), %rax
movq (%rax), %rax
movq $0x0, (%rax,%r13,8)
jmp 0x22136
movq %r12, 0x30(%rsp)
movq %rsp, %rdi
movq %r15, %rsi
callq 0x22576
incq %r13
cmpq %r13, %rbp
jne 0x220bf
cmpl $0x0, 0x20(%rsp)
je 0x22173
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rdx
addq $-0x8, %rdx
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x2216b
movq (%rdx), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%rsp)
jmp 0x22173
movq %rsp, %rdi
callq 0x1ca86
movq 0x8(%rsp), %rax
subq (%rsp), %rax
shrq $0x3, %rax
movq 0x8(%rbx), %rcx
movq (%rcx), %rdx
cmpq %rdx, 0x8(%rcx)
je 0x22191
movq %rdx, 0x8(%rcx)
testl %eax, %eax
je 0x221cb
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 0x221bd
movq (%rdx), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0x221c2
callq 0x1ca86
addq $0x8, %r15
decq %r14
jne 0x2219b
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x221e1
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x62f0
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x221f6
jmp 0x221f6
jmp 0x221f6
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x2220f
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x62f0
movq %rbx, %rdi
callq 0x6550