// File: cmaureir[P]strip-packing/scattersearch.cpp
// Function: fitness_calculation_one(solution&)
void fitness_calculation_one(solution &tmp){

    //cout << "fitness_calculation_one()" << endl;
    int j;
    int n = (int)tmp.items.size();
    int item, item_w, item_h;
    int a, b;

    tmp.height  = 0;
    tmp.fitness = 0.0;
    tmp.p = 0.0;
    clear_strip(tmp.strip);

    for (j = 0; j < n; j++)
    {
        a = 0;
        b = 0;
        item   = tmp.items[j];
        item_w = bs.at(item-1).width;
        item_h = bs.at(item-1).height;
        if(search_fit(item,item_w,item_h, a, b, tmp.height, tmp.strip)){
            place_item(item,item_w,item_h, a, b, tmp.strip);
            tmp.a[j] = a;
            tmp.b[j] = b;
        }
        tmp.p += item_w * item_h;
    }
    tmp.p = (tmp.p*100)/(float)(strip_width * tmp.height);
    tmp.fitness = tmp.height;
    //print_one_solution(tmp);
    //print_strip(tmp);
    //getchar();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x53e0
movl %eax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movl $0x0, 0x4c(%rax)
movq -0x8(%rbp), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x50(%rax)
movq -0x8(%rbp), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x48(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
callq 0x9aa0
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0xa02d
movl $0x0, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x8(%rbp), %rdi
movslq -0xc(%rbp), %rsi
callq 0xbcc0
movl (%rax), %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
leaq 0x184a5(%rip), %rdi     # 0x22400
callq 0xbc80
movl 0x8(%rax), %eax
movl %eax, -0x18(%rbp)
movl -0x14(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
leaq 0x1848a(%rip), %rdi     # 0x22400
callq 0xbc80
movl 0x4(%rax), %eax
movl %eax, -0x1c(%rbp)
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
movl -0x1c(%rbp), %edx
movq -0x8(%rbp), %r9
addq $0x4c, %r9
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
leaq -0x20(%rbp), %rcx
leaq -0x24(%rbp), %r8
movq %rax, (%rsp)
callq 0x9b60
testb $0x1, %al
jne 0x9fb1
jmp 0xa006
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
movl -0x1c(%rbp), %edx
movl -0x20(%rbp), %ecx
movl -0x24(%rbp), %r8d
movq -0x8(%rbp), %rax
movq 0x58(%rax), %r9
callq 0x9e60
movl -0x20(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x8(%rbp), %rdi
addq $0x18, %rdi
movslq -0xc(%rbp), %rsi
callq 0xbcc0
movl -0x2c(%rbp), %ecx
movl %ecx, (%rax)
movl -0x24(%rbp), %eax
movl %eax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
movslq -0xc(%rbp), %rsi
callq 0xbcc0
movl -0x28(%rbp), %ecx
movl %ecx, (%rax)
movl -0x18(%rbp), %eax
imull -0x1c(%rbp), %eax
cvtsi2ss %eax, %xmm0
movq -0x8(%rbp), %rax
addss 0x48(%rax), %xmm0
movss %xmm0, 0x48(%rax)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x9f1f
movq -0x8(%rbp), %rax
movss 0xcfcb(%rip), %xmm0     # 0x17004
mulss 0x48(%rax), %xmm0
movl 0x183d4(%rip), %eax     # 0x22418
movq -0x8(%rbp), %rcx
imull 0x4c(%rcx), %eax
cvtsi2ss %eax, %xmm1
divss %xmm1, %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x48(%rax)
movq -0x8(%rbp), %rax
cvtsi2ssl 0x4c(%rax), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x50(%rax)
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)