// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movq 0x8(%rdi), %rax
subq (%rdi), %rax
shrq $0x2, %rax
movq %rax, 0x10(%rsp)
movl $0x0, 0x50(%rdi)
movq $0x0, 0x48(%rdi)
cmpl $0x0, 0xb18c(%rip)      # 0x12370
jle 0x7220
movq 0x58(%rbx), %rax
xorl %ecx, %ecx
cmpl $0x0, 0xb181(%rip)      # 0x12374
jle 0x7211
movq (%rax,%rcx,8), %rdx
xorl %esi, %esi
movl $0x0, (%rdx,%rsi,4)
incq %rsi
movslq 0xb168(%rip), %rdi      # 0x12374
cmpq %rdi, %rsi
jl 0x71fb
incq %rcx
movslq 0xb155(%rip), %rdx      # 0x12370
cmpq %rdx, %rcx
jl 0x71ec
cmpl $0x0, 0x10(%rsp)
jle 0x733f
leaq 0x4c(%rbx), %rax
movq %rax, 0x18(%rsp)
movq 0xb125(%rip), %rax      # 0x12360
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, 0x10(%rsp)
xorl %r15d, %r15d
xorl %r14d, %r14d
movl %r15d, 0xc(%rsp)
movl %r15d, 0x8(%rsp)
movq (%rbx), %rax
movslq (%rax,%r14,4), %r12
leaq -0x1(%r12), %rsi
movq 0xb0e6(%rip), %rax      # 0x12358
movq 0x20(%rsp), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdx
cmpq %rsi, %rdx
jbe 0x7380
leaq (%rsi,%rsi,2), %rcx
movl 0x4(%rax,%rcx,4), %r13d
movl 0x8(%rax,%rcx,4), %ebp
movq 0x58(%rbx), %rax
movq %rax, (%rsp)
movl %ebp, %esi
movl %r13d, %edx
leaq 0xc(%rsp), %rcx
leaq 0x8(%rsp), %r8
movq 0x18(%rsp), %r9
callq 0x6f7d
testb %al, %al
je 0x731b
movl 0xc(%rsp), %ecx
movl 0x8(%rsp), %eax
testl %ebp, %ebp
jle 0x730b
movslq %ecx, %rdx
movslq %eax, %rsi
movq 0x58(%rbx), %rdi
leal (%rcx,%rbp), %r9d
leal (%rax,%r13), %r8d
movslq %r8d, %r8
movslq %r9d, %r9
testl %r13d, %r13d
jle 0x7303
movq (%rdi,%rdx,8), %r10
movq %rsi, %r11
movl %r12d, (%r10,%r11,4)
incq %r11
cmpq %r8, %r11
jl 0x72f7
incq %rdx
cmpq %r9, %rdx
jl 0x72eb
movq 0x18(%rbx), %rdx
movl %ecx, (%rdx,%r14,4)
movq 0x30(%rbx), %rcx
movl %eax, (%rcx,%r14,4)
imull %ebp, %r13d
xorps %xmm0, %xmm0
cvtsi2ss %r13d, %xmm0
addss 0x48(%rbx), %xmm0
movss %xmm0, 0x48(%rbx)
incq %r14
cmpq 0x10(%rsp), %r14
jne 0x7255
movss 0x48(%rbx), %xmm0
movl 0x4c(%rbx), %eax
movl 0xb023(%rip), %ecx      # 0x12370
imull %eax, %ecx
cvtsi2ss %ecx, %xmm1
mulss 0x5ca8(%rip), %xmm0     # 0xd004
divss %xmm1, %xmm0
movss %xmm0, 0x48(%rbx)
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
movss %xmm0, 0x50(%rbx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x60af(%rip), %rdi      # 0xd436
xorl %eax, %eax
callq 0x4380