// File: cmaureir[P]strip-packing/main.cpp
// Function: main
int main(int argc, char *argv[]) {

    // Configuration
    string path;
    if(!check_flags(argc,argv,path)){
        return 1;
    }
    read_input_file(path);

    // Algorithm
    //int iteration = 0;
    //int loop;
    int watch_best;
    int best_fitness;

    solutions_generation(sols);
    fitness_calculation(sols);

    solutions_improvement(sols);
    refset_build();

    save_best_solution(refset);
    refset_tmp = refset;

    do {
        // number of new solutions in the RefSet
        loop = 0;
        while (get_difference(refset_tmp,refset) != 0)
        {
            refset_tmp = refset;
            solutions_combination();
            fitness_calculation(new_set);
            new_set = solutions_improvement2(new_set);
            //solutions_improvement(new_set);
            refset_modification(new_set);
            loop++;
        }
        save_best_solution(refset);

        /* A: If we find the optimal, stop */
        if(best.p == 100){
            iteration = max_iter;
        }
        /* A: end */

        refset_rebuild();
        iteration++;
        print_one_solution(best);
        //print_strip(best);
        //print_tikz(best);
    } while (iteration < max_iter);
    //print_one_solution(best);
    //print_strip(best);
    print_tikz(best);

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x200, %rsp            # imm = 0x200
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x30(%rbp), %rdi
movq %rdi, -0x1e0(%rbp)
callq 0x4420
movq -0x1e0(%rbp), %rdx
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0x7630
movb %al, -0x1d1(%rbp)
jmp 0x49a4
movb -0x1d1(%rbp), %al
testb $0x1, %al
jne 0x49d4
jmp 0x49b0
movl $0x1, -0x4(%rbp)
movl $0x1, -0x40(%rbp)
jmp 0x4d95
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x4daa
leaq -0x60(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x4120
jmp 0x49e3
leaq -0x60(%rbp), %rdi
callq 0x7c40
jmp 0x49ee
leaq -0x60(%rbp), %rdi
callq 0x4190
leaq 0x1d942(%rip), %rdi     # 0x22340
callq 0xa0e0
jmp 0x4a05
leaq 0x1d934(%rip), %rdi     # 0x22340
callq 0xa080
jmp 0x4a13
leaq 0x1d926(%rip), %rdi     # 0x22340
callq 0xa420
jmp 0x4a21
callq 0xa590
jmp 0x4a28
leaq 0x1d929(%rip), %rsi     # 0x22358
leaq -0x80(%rbp), %rdi
callq 0x4dc0
jmp 0x4a3a
leaq -0x80(%rbp), %rdi
callq 0xa660
jmp 0x4a45
leaq -0x80(%rbp), %rdi
callq 0x4eb0
leaq 0x1d91b(%rip), %rdi     # 0x22370
leaq 0x1d8fc(%rip), %rsi     # 0x22358
callq 0x4f10
jmp 0x4a63
jmp 0x4a65
leaq 0x1d9b8(%rip), %rax     # 0x22424
movl $0x0, (%rax)
leaq 0x1d8f7(%rip), %rsi     # 0x22370
leaq -0x98(%rbp), %rdi
callq 0x4dc0
jmp 0x4a87
leaq 0x1d8ca(%rip), %rsi     # 0x22358
leaq -0xb0(%rbp), %rdi
callq 0x4dc0
jmp 0x4a9c
leaq -0x98(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0xb6a0
movl %eax, -0x1e4(%rbp)
jmp 0x4ab7
leaq -0xb0(%rbp), %rdi
callq 0x4eb0
leaq -0x98(%rbp), %rdi
callq 0x4eb0
movl -0x1e4(%rbp), %eax
cmpl $0x0, %eax
je 0x4c59
leaq 0x1d88b(%rip), %rdi     # 0x22370
leaq 0x1d86c(%rip), %rsi     # 0x22358
callq 0x4f10
jmp 0x4af3
callq 0xa6b0
jmp 0x4afa
leaq 0x1d887(%rip), %rdi     # 0x22388
callq 0xa080
jmp 0x4b08
leaq 0x1d879(%rip), %rsi     # 0x22388
leaq -0xe0(%rbp), %rdi
callq 0x4dc0
jmp 0x4b1d
leaq -0xc8(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0xb130
jmp 0x4b32
leaq 0x1d84f(%rip), %rdi     # 0x22388
movq %rdi, -0x1f0(%rbp)
leaq -0xc8(%rbp), %rsi
movq %rsi, -0x1f8(%rbp)
callq 0x5160
movq -0x1f8(%rbp), %rdi
callq 0x4eb0
leaq -0xe0(%rbp), %rdi
callq 0x4eb0
movq -0x1f0(%rbp), %rsi
leaq -0xf8(%rbp), %rdi
callq 0x4dc0
jmp 0x4b80
leaq -0xf8(%rbp), %rdi
callq 0xaf30
jmp 0x4b8e
leaq -0xf8(%rbp), %rdi
callq 0x4eb0
leaq 0x1d883(%rip), %rax     # 0x22424
movl (%rax), %ecx
addl $0x1, %ecx
leaq 0x1d877(%rip), %rax     # 0x22424
movl %ecx, (%rax)
jmp 0x4a72
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x4190
jmp 0x4daa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x4eb0
jmp 0x4daa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x4c0e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x4eb0
leaq -0x98(%rbp), %rdi
callq 0x4eb0
jmp 0x4daa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x4eb0
jmp 0x4daa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x4eb0
jmp 0x4daa
leaq 0x1d6f8(%rip), %rsi     # 0x22358
leaq -0x110(%rbp), %rdi
callq 0x4dc0
jmp 0x4c6e
leaq -0x110(%rbp), %rdi
callq 0xa660
jmp 0x4c7c
leaq -0x110(%rbp), %rdi
callq 0x4eb0
leaq 0x1d711(%rip), %rax     # 0x223a0
movss 0x48(%rax), %xmm0
movss 0x12368(%rip), %xmm1    # 0x17004
ucomiss %xmm1, %xmm0
jne 0x4ccf
jp 0x4ccf
leaq 0x1d776(%rip), %rax     # 0x22420
movl $0x64, (%rax)
jmp 0x4ccf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x4eb0
jmp 0x4daa
callq 0xb420
jmp 0x4cd6
leaq 0x1d743(%rip), %rax     # 0x22420
movl (%rax), %ecx
incl %ecx
movl %ecx, (%rax)
leaq 0x1d6b6(%rip), %rsi     # 0x223a0
leaq -0x170(%rbp), %rdi
callq 0x5190
jmp 0x4cf8
leaq -0x170(%rbp), %rdi
callq 0x7f80
jmp 0x4d06
leaq -0x170(%rbp), %rdi
callq 0x5250
leaq 0x1d707(%rip), %rax     # 0x22420
cmpl $0x64, (%rax)
jl 0x4a65
leaq 0x1d677(%rip), %rsi     # 0x223a0
leaq -0x1d0(%rbp), %rdi
callq 0x5190
jmp 0x4d37
leaq -0x1d0(%rbp), %rdi
callq 0x8050
jmp 0x4d45
leaq -0x1d0(%rbp), %rdi
callq 0x5250
movl $0x0, -0x4(%rbp)
movl $0x1, -0x40(%rbp)
jmp 0x4d95
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x170(%rbp), %rdi
callq 0x5250
jmp 0x4daa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x1d0(%rbp), %rdi
callq 0x5250
jmp 0x4daa
leaq -0x30(%rbp), %rdi
callq 0x4190
movl -0x4(%rbp), %eax
addq $0x200, %rsp            # imm = 0x200
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x4190
movq -0x38(%rbp), %rdi
callq 0x4550
nopl (%rax)