// File: /workspace/github_cpp_makefile_star2_O3/maramire[P]SP_PSO/parallel_main.cpp
// Function: HR(std::vector<Item, std::allocator<Item>>&, Strip&, int, Particle&)
void HR(Item_vector &items, Strip &s, int n_items, Particle &particle)
{

    vector<int> permutation = particle.permutation;
    int fitness = 0;
    int i = 0;

    while(!permutation.empty())
    {
        
        int item_id = permutation[i]-1;
        int original_height;
        
        if (items[item_id].height > items[item_id].width)
        {
            original_height = items[item_id].height;
            items[item_id].height = items[item_id].width;
            items[item_id].width = original_height;
            items[item_id].rotated = 1;
        }           

        /* it is already defined, but convenience */
        items[item_id].x_position = s.x_position;
        items[item_id].y_position = s.y_position; 

        fitness += items[item_id].height;         

        /* Resize strip S1 */
        Strip s1 = {};
        s1.y_position = s.y_position + items[item_id].height;
        s1.x_position = s.x_position;
        s1.height = s.height - items[item_id].height;
        s1.width = s.width;

        /* Generate new strip S2 */
        Strip s2 = {};
        s2.x_position = s.x_position + items[item_id].width;
        s2.y_position = s.y_position;
        s2.height = items[item_id].height;
        s2.width = s.width - items[item_id].width;

        s = s1;

        /* Erase */
        permutation.erase(permutation.begin() + i);

        RecursePacking(s2,permutation,items);

    }      
            
    particle.fitness = fitness;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r14
movq %rdi, %r15
leaq -0x58(%rbp), %r12
movq %r12, %rdi
movq %rcx, -0x60(%rbp)
movq %rcx, %rsi
callq 0x412c
movq (%r12), %rdi
movq 0x8(%r12), %rdx
xorl %ebx, %ebx
cmpq %rdx, %rdi
je 0x2e7a
movslq (%rdi), %rax
movq (%r15), %rsi
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %r8
addq %rax, %r8
leaq (%rsi,%r8), %rax
movl -0x18(%rsi,%r8), %ecx
movl -0x14(%rsi,%r8), %r12d
cmpl %r12d, %ecx
jle 0x2df0
movl %r12d, -0x18(%rax)
movl %ecx, -0x14(%rax)
movl $0x1, -0x4(%rax)
jmp 0x2df3
movl %ecx, %r12d
movl 0x8(%r14), %ecx
movl %ecx, -0xc(%rax)
movl 0xc(%r14), %esi
movl %esi, -0x8(%rax)
leal (%r12,%rsi), %r8d
movl (%r14), %r9d
movl 0x4(%r14), %r10d
subl %r12d, %r9d
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
movl -0x14(%rax), %r11d
leal (%r11,%rcx), %r13d
movl %r13d, -0x38(%rbp)
movl %esi, -0x34(%rbp)
movl -0x18(%rax), %eax
movl %eax, -0x40(%rbp)
subl %r11d, %r10d
movl %r10d, -0x3c(%rbp)
movl %r9d, (%r14)
movl %ecx, 0x8(%r14)
movl %r8d, 0xc(%r14)
leaq 0x4(%rdi), %rsi
cmpq %rdx, %rsi
je 0x2e52
subq %rsi, %rdx
callq 0x22a0
movq -0x50(%rbp), %rdx
addl %r12d, %ebx
addq $-0x4, %rdx
movq %rdx, -0x50(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x58(%rbp), %rsi
movq %r15, %rdx
callq 0x2bc7
movq -0x58(%rbp), %rdi
movq -0x50(%rbp), %rdx
jmp 0x2db3
movq -0x60(%rbp), %rax
movl %ebx, 0x18(%rax)
testq %rdi, %rdi
je 0x2e92
movq -0x48(%rbp), %rsi
subq %rdi, %rsi
callq 0x21c0
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq