// File: /workspace/github_cpp_makefile_star2_O2/grmauri[P]pmm/pmm.cpp
// Function: main
int main(int argc, char *argv[])
{
    #ifdef MODO_TESTE
        testar_alocacao();
        testar_estruturas();
        testar_heuConstrutivas();
        testar_buscaLocal();
    #else
        //---
        // parametros do executavel
        int seed = 0;
        int metodo = 1; // 0: SA; 1: BT; 2: GRASP; 3: AG; 4: VNS; 5: ILS
        string instancia = "pmm1.txt";
        double tempo_limite = 5;
        string saida = "saida.txt";
        // SA
        double alfa = 0.975;
        int sa_max = 2;
        double t_0 = 1000;
        double t_c = 0.01;
        // BT
        int tam_lista = 1;
        // GRASP
        int LRC = 15;
        // AG
        int pop = 1;
        int cro = 2;
        double mut = 7;
        double eli = 15;
        // VNS e ILS sem parametros especificos
        //---
        // usar os valores passados por parametro; caso contrario, usara os valores definidos acima
        if (argc > 1)
        {
            seed = stoi(argv[1]);
            metodo = stoi(argv[2]);
            instancia = argv[3];
            tempo_limite = stof(argv[4]);
            saida = argv[5];
            switch(metodo)
            {
                case 0:
                    alfa = stof(argv[6]);
                    sa_max = stoi(argv[7]);
                    t_0 = stof(argv[8]);
                    t_c = stof(argv[9]);
                    break;
                case 1:
                    tam_lista = stoi(argv[6]);
                    break;
                case 2:
                    LRC = stoi(argv[6]);
                    break;
                case 3:
                    pop = stoi(argv[6]);
                    cro = stoi(argv[7]);
                    mut = stof(argv[8]);
                    eli = stof(argv[9]);
                    break;
            }
        }
        //---
        srand(seed);

        lerDados(instancia);
        //testarDados("");
        ordenarObjetos();

        Solucao sol;
        string aux;
        double tempo_melhor, tempo_total;

        switch(metodo)
        {
            case 0:
                simulated_annealing(alfa, sa_max*(numObj*(numMoc+1)), t_0, t_c, tempo_limite, sol, tempo_melhor, tempo_total);
                aux = "SA";
                break;
            case 1:
                busca_tabu(tam_lista * (numObj*(numMoc+1)), tempo_limite, sol, tempo_melhor, tempo_total);
                aux = "BT";
                break;
            case 2:
                grasp(LRC, tempo_limite, sol, tempo_melhor, tempo_total);
                aux = "GRASP";
                break;
            case 3:
                algoritmo_genetico(pop * numObj, cro * numObj, mut, eli, tempo_limite, sol, tempo_melhor, tempo_total);
                aux = "AG";
                break;
            case 4:
                vns(tempo_limite, sol, tempo_melhor, tempo_total);
                aux = "VNS";
                break;
            case 5:
                ils(tempo_limite, sol, tempo_melhor, tempo_total);
                aux = "ILS";
                break;
        }

        //---
        // atualizar o arquivo de saida
        FILE *f = fopen(saida.c_str(),"at");
        fprintf(f, "%s\t%d\t\t%d\t%.5f\t\t%.5f\n", aux.c_str(), seed, sol.funObj, tempo_melhor, tempo_total);
        fclose(f);
    #endif

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x978, %rsp            # imm = 0x978
movq %rsi, %r12
movl %edi, %ebx
leaq 0x2d37(%rip), %rsi      # 0x5090
leaq 0x78(%rsp), %rdi
leaq 0xd8(%rsp), %rdx
callq 0x4bf6
leaq 0x2d27(%rip), %rsi      # 0x5099
leaq 0xb8(%rsp), %rdi
leaq 0xd8(%rsp), %rdx
callq 0x4bf6
movsd 0x2c79(%rip), %xmm0     # 0x5008
movsd %xmm0, 0x28(%rsp)
movsd 0x2c73(%rip), %xmm0     # 0x5010
movsd %xmm0, 0x70(%rsp)
pushq $0xf
popq %rax
movl %eax, 0x24(%rsp)
movsd 0x2c66(%rip), %xmm0     # 0x5018
movsd %xmm0, 0x38(%rsp)
movsd 0x2c60(%rip), %xmm0     # 0x5020
movsd %xmm0, 0x30(%rsp)
pushq $0x2
popq %r14
movsd 0x2c56(%rip), %xmm0     # 0x5028
movsd %xmm0, 0x68(%rsp)
pushq $0x1
popq %rbp
cmpl $0x2, %ebx
jl 0x25dd
movq 0x8(%r12), %rsi
leaq 0xd8(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x4bf6
leaq 0xd8(%rsp), %rdi
pushq $0xa
popq %rdx
xorl %esi, %esi
callq 0x4c31
movl %eax, %ebx
leaq 0xd8(%rsp), %rdi
callq 0x2080
movq 0x10(%r12), %rsi
leaq 0xd8(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x4bf6
leaq 0xd8(%rsp), %rdi
pushq $0xa
popq %rdx
xorl %esi, %esi
callq 0x4c31
movl %eax, %r13d
leaq 0xd8(%rsp), %rdi
callq 0x2080
movq 0x18(%r12), %rsi
leaq 0x78(%rsp), %rdi
callq 0x2200
movq 0x20(%r12), %rsi
leaq 0xd8(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x4bf6
leaq 0xd8(%rsp), %rdi
xorl %esi, %esi
callq 0x4c4d
movss %xmm0, 0x8(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0x2080
movq 0x28(%r12), %rsi
leaq 0xb8(%rsp), %rdi
callq 0x2200
cvtss2sd 0x8(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
cmpl $0x3, %r13d
ja 0x25f0
movl %r13d, %eax
leaq 0x2b81(%rip), %rcx      # 0x5050
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x30(%r12), %rsi
leaq 0xd8(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x4bf6
leaq 0xd8(%rsp), %rdi
xorl %esi, %esi
callq 0x4c4d
movss %xmm0, 0x38(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0x2080
movq 0x38(%r12), %rsi
leaq 0xd8(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x4bf6
leaq 0xd8(%rsp), %rdi
pushq $0xa
popq %rdx
xorl %esi, %esi
callq 0x4c31
movl %eax, %r15d
leaq 0xd8(%rsp), %rdi
callq 0x2080
movq 0x40(%r12), %rsi
leaq 0xd8(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x4bf6
leaq 0xd8(%rsp), %rdi
xorl %esi, %esi
callq 0x4c4d
movss %xmm0, 0x30(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0x2080
movq 0x48(%r12), %rsi
leaq 0xd8(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x4bf6
xorl %r13d, %r13d
leaq 0xd8(%rsp), %rdi
xorl %esi, %esi
callq 0x4c4d
cvtss2sd 0x38(%rsp), %xmm1
movsd %xmm1, 0x68(%rsp)
cvtss2sd 0x30(%rsp), %xmm1
movsd %xmm1, 0x30(%rsp)
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x38(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0x2080
jmp 0x25f3
movsd 0x2a4b(%rip), %xmm0     # 0x5030
movsd %xmm0, 0x8(%rsp)
xorl %ebx, %ebx
movl %ebp, %r13d
movl %r14d, %r15d
movl %ebp, %r12d
movl %ebx, %edi
callq 0x20f0
leaq 0x98(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x2160
leaq 0x98(%rsp), %rdi
callq 0x2a5b
leaq 0x98(%rsp), %rdi
callq 0x2080
callq 0x2b4a
leaq 0x50(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
cmpl $0x5, %r13d
ja 0x27b3
movl %r13d, %eax
leaq 0x2a0d(%rip), %rcx      # 0x5060
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl 0x5ad6(%rip), %eax      # 0x8138
incl %eax
imull 0x5ac8(%rip), %r15d     # 0x8134
imull %eax, %r15d
leaq 0xd8(%rsp), %rsi
leaq 0x18(%rsp), %rdx
leaq 0x10(%rsp), %rcx
movsd 0x68(%rsp), %xmm0
movl %r15d, %edi
movsd 0x30(%rsp), %xmm1
movsd 0x38(%rsp), %xmm2
movsd 0x8(%rsp), %xmm3
callq 0x2bfa
leaq 0x29fa(%rip), %rsi      # 0x50a3
jmp 0x27a9
leaq 0xd8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movsd 0x8(%rsp), %xmm0
callq 0x3631
leaq 0x29e0(%rip), %rsi      # 0x50b2
jmp 0x27a9
leaq 0xd8(%rsp), %rsi
leaq 0x18(%rsp), %rdx
leaq 0x10(%rsp), %rcx
movl 0x24(%rsp), %edi
movsd 0x8(%rsp), %xmm0
callq 0x31c9
leaq 0x29aa(%rip), %rsi      # 0x50a9
jmp 0x27a9
movl 0x5a2a(%rip), %eax      # 0x8134
imull %eax, %ebp
imull %eax, %r14d
leaq 0xd8(%rsp), %rdx
leaq 0x18(%rsp), %rcx
leaq 0x10(%rsp), %r8
movl %ebp, %edi
movl %r14d, %esi
movsd 0x70(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
movsd 0x8(%rsp), %xmm2
callq 0x32c2
leaq 0x2969(%rip), %rsi      # 0x50af
jmp 0x27a9
movl 0x59ea(%rip), %eax      # 0x8138
incl %eax
imull 0x59dc(%rip), %r12d     # 0x8134
imull %eax, %r12d
leaq 0xd8(%rsp), %rsi
leaq 0x18(%rsp), %rdx
leaq 0x10(%rsp), %rcx
movl %r12d, %edi
movsd 0x8(%rsp), %xmm0
callq 0x2e50
leaq 0x2923(%rip), %rsi      # 0x50a6
jmp 0x27a9
leaq 0xd8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movsd 0x8(%rsp), %xmm0
callq 0x377e
leaq 0x290d(%rip), %rsi      # 0x50b6
leaq 0x40(%rsp), %rdi
callq 0x2200
leaq 0xb8(%rsp), %r14
movq (%r14), %rdi
leaq 0x28f5(%rip), %rsi      # 0x50ba
callq 0x2110
movq %rax, %r15
leaq 0x40(%rsp), %r12
movq (%r12), %rdx
movl 0x970(%rsp), %r8d
movsd 0x18(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
leaq 0x28cc(%rip), %rsi      # 0x50bd
movq %rax, %rdi
movl %ebx, %ecx
movb $0x2, %al
callq 0x2180
movq %r15, %rdi
callq 0x2100
movq %r12, %rdi
callq 0x2080
movq %r14, %rdi
callq 0x2080
leaq 0x78(%rsp), %rdi
callq 0x2080
xorl %eax, %eax
addq $0x978, %rsp            # imm = 0x978
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x30(%r12), %rsi
leaq 0xd8(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x4bf6
leaq 0xd8(%rsp), %rdi
pushq $0xa
popq %rdx
xorl %esi, %esi
callq 0x4c31
movl %eax, 0x24(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0x2080
pushq $0x2
popq %r13
movl %r13d, %r15d
movl %ebp, %r12d
movl %r13d, %r14d
jmp 0x25f6
movq 0x30(%r12), %rsi
leaq 0xd8(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x4bf6
leaq 0xd8(%rsp), %rdi
pushq $0xa
popq %rdx
xorl %esi, %esi
callq 0x4c31
movl %eax, %r15d
leaq 0xd8(%rsp), %rdi
callq 0x2080
movq 0x38(%r12), %rsi
leaq 0xd8(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x4bf6
leaq 0xd8(%rsp), %rdi
pushq $0xa
popq %rdx
xorl %esi, %esi
callq 0x4c31
movl %eax, %r13d
leaq 0xd8(%rsp), %rdi
callq 0x2080
movq 0x40(%r12), %rsi
leaq 0xd8(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x4bf6
leaq 0xd8(%rsp), %rdi
xorl %esi, %esi
callq 0x4c4d
movss %xmm0, 0x28(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0x2080
movq 0x48(%r12), %rsi
leaq 0xd8(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x4bf6
movl %r13d, 0x60(%rsp)
movl %r15d, 0x64(%rsp)
leaq 0xd8(%rsp), %rdi
xorl %esi, %esi
callq 0x4c4d
cvtss2sd 0x28(%rsp), %xmm1
movsd %xmm1, 0x70(%rsp)
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x28(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0x2080
pushq $0x3
popq %r13
movl %r14d, %r15d
movl %ebp, %r12d
movl 0x64(%rsp), %ebp
movl 0x60(%rsp), %r14d
jmp 0x25f6
movq 0x30(%r12), %rsi
leaq 0xd8(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x4bf6
leaq 0xd8(%rsp), %rdi
pushq $0xa
popq %rdx
xorl %esi, %esi
callq 0x4c31
movl %eax, %r12d
leaq 0xd8(%rsp), %rdi
callq 0x2080
movl %ebp, %r13d
movl %r14d, %r15d
jmp 0x25f6
jmp 0x2a09
jmp 0x2a09
jmp 0x2a39
jmp 0x2a39
jmp 0x2a09
jmp 0x2a09
jmp 0x2a39
jmp 0x2a39
jmp 0x2a09
jmp 0x2a09
jmp 0x2a39
jmp 0x2a39
jmp 0x2a09
jmp 0x2a09
jmp 0x2a09
jmp 0x2a09
jmp 0x2a39
jmp 0x2a39
jmp 0x2a39
jmp 0x2a39
jmp 0x2a09
jmp 0x2a39
jmp 0x2a09
jmp 0x2a39
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
jmp 0x2a2d
jmp 0x2a39
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
jmp 0x2a2d
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x2080
jmp 0x2a3c
movq %rax, %rbx
jmp 0x2a49
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x2080
leaq 0x78(%rsp), %rdi
callq 0x2080
movq %rbx, %rdi
callq 0x21c0