// File: /workspace/github_cpp_makefile_star2_O3/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), %r15
subq (%rdi), %r15
shrq $0x2, %r15
movl $0x0, 0x50(%rdi)
movq $0x0, 0x48(%rdi)
movq 0x58(%rdi), %rdi
callq 0x6e9c
testl %r15d, %r15d
jle 0x748d
leaq 0x4c(%rbx), %rax
movq %rax, 0x18(%rsp)
movq 0xb0df(%rip), %rax      # 0x12360
movq %rax, 0x20(%rsp)
andl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
xorl %r14d, %r14d
movq %r15, 0x10(%rsp)
xorl %eax, %eax
movl %eax, 0xc(%rsp)
movl %eax, 0x8(%rsp)
movq (%rbx), %rax
movslq (%rax,%r14,4), %r12
leaq -0x1(%r12), %rsi
movq 0xb0a6(%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 0x74d1
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 0x6f51
testb %al, %al
movdqa 0x5d53(%rip), %xmm5     # 0xd060
movdqa 0x5d5b(%rip), %xmm6     # 0xd070
movdqa 0x5d63(%rip), %xmm7     # 0xd080
pcmpeqd %xmm8, %xmm8
je 0x7469
movl 0xc(%rsp), %ecx
movl 0x8(%rsp), %eax
testl %ebp, %ebp
jle 0x7454
movslq %ecx, %rdx
movslq %eax, %rsi
movq 0x58(%rbx), %rdi
leal (%rcx,%rbp), %r8d
leal (%rax,%r13), %r9d
movslq %r9d, %r10
movslq %r8d, %r8
leaq 0x1(%rsi), %r9
cmpq %r10, %r9
cmovgq %r9, %r10
subq %rsi, %r10
leaq 0x3(%r10), %r9
andq $-0x4, %r9
decq %r10
movq %r10, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
shlq $0x2, %rsi
pxor %xmm7, %xmm0
testl %r13d, %r13d
jle 0x7448
movq (%rdi,%rdx,8), %r10
addq %rsi, %r10
addq $0xc, %r10
xorl %r11d, %r11d
movq %r11, %xmm1
pshufd $0x44, %xmm1, %xmm1     # xmm1 = xmm1[0,1,0,1]
movdqa %xmm1, %xmm2
por %xmm6, %xmm2
pxor %xmm7, %xmm2
movdqa %xmm2, %xmm3
pcmpgtd %xmm0, %xmm3
pcmpeqd %xmm0, %xmm2
pshufd $0xf5, %xmm2, %xmm4     # xmm4 = xmm2[1,1,3,3]
pand %xmm3, %xmm4
pshufd $0xf5, %xmm3, %xmm2     # xmm2 = xmm3[1,1,3,3]
por %xmm4, %xmm2
movd %xmm2, %r15d
notl %r15d
testb $0x1, %r15b
je 0x73d9
movl %r12d, -0xc(%r10,%r11,4)
pxor %xmm8, %xmm2
pextrw $0x4, %xmm2, %r15d
testb $0x1, %r15b
je 0x73ef
movl %r12d, -0x8(%r10,%r11,4)
por %xmm5, %xmm1
pxor %xmm7, %xmm1
movdqa %xmm1, %xmm2
pcmpgtd %xmm0, %xmm2
pcmpeqd %xmm0, %xmm1
pshufd $0xf5, %xmm1, %xmm3     # xmm3 = xmm1[1,1,3,3]
pand %xmm2, %xmm3
pshufd $0xf5, %xmm2, %xmm1     # xmm1 = xmm2[1,1,3,3]
por %xmm3, %xmm1
pxor %xmm8, %xmm1
pextrw $0x0, %xmm1, %r15d
testb $0x1, %r15b
je 0x742b
movl %r12d, -0x4(%r10,%r11,4)
pextrw $0x4, %xmm1, %r15d
testb $0x1, %r15b
je 0x743b
movl %r12d, (%r10,%r11,4)
addq $0x4, %r11
cmpq %r11, %r9
jne 0x7392
incq %rdx
cmpq %r8, %rdx
jl 0x737b
movq 0x18(%rbx), %rdx
movl %ecx, (%rdx,%r14,4)
movq 0x30(%rbx), %rcx
movl %eax, (%rcx,%r14,4)
movq 0x10(%rsp), %r15
imull %ebp, %r13d
xorps %xmm0, %xmm0
cvtsi2ss %r13d, %xmm0
addss 0x48(%rbx), %xmm0
movss %xmm0, 0x48(%rbx)
incq %r14
cmpq %r15, %r14
jne 0x7295
jmp 0x7492
movss 0x48(%rbx), %xmm0
movl 0x4c(%rbx), %eax
movl 0xaed5(%rip), %ecx      # 0x12370
imull %eax, %ecx
xorps %xmm1, %xmm1
cvtsi2ss %ecx, %xmm1
mulss 0x5b57(%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 0x5f9e(%rip), %rdi      # 0xd476
xorl %eax, %eax
callq 0x4380