// File: grmauri[P]pmm/pmm.cpp
// Function: vns(double, tSolucao&, double&, double&)
void vns(const double tempo_max, Solucao &s, double &tempo_melhor, double &tempo_total)
{
    int v;
    clock_t hI, hF;
    Solucao s_vizinha;
    printf("\n\n>>> EXECUTANDO O VNS...\n\n");
    hI = clock();
    heuConAle(s);
    calcFO(s);
    hF = clock();
    tempo_melhor = ((double)(hF - hI))/CLOCKS_PER_SEC;
    #ifdef DBG
        printf("FO: %d\tTempo: %.2f\n", s.funObj, tempo_melhor);
    #endif
    tempo_total = tempo_melhor;
    while(tempo_total < tempo_max)
    {
        v = 0;
        while(v < 2)
        {
            memcpy(&s_vizinha, &s, sizeof(s));
            if(v == 0)
                gerar_vizinha(s_vizinha);
            else
                gerar_vizinha2(s_vizinha);
            heuBLPM(s_vizinha);
            if(s_vizinha.funObj > s.funObj)
            {
                memcpy(&s, &s_vizinha, sizeof(s_vizinha));
                hF = clock();
                tempo_melhor = ((double)(hF - hI))/CLOCKS_PER_SEC;
                #ifdef DBG
                    printf("FO: %d\tTempo: %.2f\n", s.funObj, tempo_melhor);
                #endif
                v = 0;
            }
            else
                v++;
        }
        hF = clock();
        tempo_total = ((double)(hF - hI))/CLOCKS_PER_SEC;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x8e0, %rsp            # imm = 0x8E0
movsd %xmm0, -0x8(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
leaq 0x2df3(%rip), %rdi      # 0x7136
movb $0x0, %al
callq 0x2050
callq 0x2100
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
callq 0x4690
movq -0x10(%rbp), %rdi
callq 0x46f0
callq 0x2100
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
subq -0x30(%rbp), %rax
cvtsi2sd %rax, %xmm0
movsd 0x2cad(%rip), %xmm1     # 0x7030
divsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
movq -0x10(%rbp), %rax
movl 0x898(%rax), %esi
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
leaq 0x2d26(%rip), %rdi      # 0x70ce
movb $0x1, %al
callq 0x2050
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
movq -0x20(%rbp), %rax
movsd %xmm0, (%rax)
movq -0x20(%rbp), %rax
movsd (%rax), %xmm1
movsd -0x8(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x44dc
movl $0x0, -0x24(%rbp)
cmpl $0x2, -0x24(%rbp)
jge 0x44ad
movq -0x10(%rbp), %rsi
leaq -0x8d4(%rbp), %rdi
movl $0x89c, %edx            # imm = 0x89C
callq 0x2140
cmpl $0x0, -0x24(%rbp)
jne 0x4410
leaq -0x8d4(%rbp), %rdi
callq 0x4810
jmp 0x441c
leaq -0x8d4(%rbp), %rdi
callq 0x5140
leaq -0x8d4(%rbp), %rdi
callq 0x4c30
movl -0x3c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x898(%rcx), %eax
jle 0x449f
movq -0x10(%rbp), %rdi
leaq -0x8d4(%rbp), %rsi
movl $0x89c, %edx            # imm = 0x89C
callq 0x2140
callq 0x2100
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
subq -0x30(%rbp), %rax
cvtsi2sd %rax, %xmm0
movsd 0x2bc6(%rip), %xmm1     # 0x7030
divsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
movq -0x10(%rbp), %rax
movl 0x898(%rax), %esi
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
leaq 0x2c3f(%rip), %rdi      # 0x70ce
movb $0x1, %al
callq 0x2050
movl $0x0, -0x24(%rbp)
jmp 0x44a8
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x43dd
callq 0x2100
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
subq -0x30(%rbp), %rax
cvtsi2sd %rax, %xmm0
movsd 0x2b65(%rip), %xmm1     # 0x7030
divsd %xmm1, %xmm0
movq -0x20(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x43bf
addq $0x8e0, %rsp            # imm = 0x8E0
popq %rbp
retq
nopw %cs:(%rax,%rax)