// File: /workspace/github_cpp_makefile_star2_O2/maramire[P]SP_PSO/parallel_main.cpp
// Function: RecursePacking(Strip&, std::vector<int, std::allocator<int>>&, std::vector<Item, std::allocator<Item>>&)
void RecursePacking(Strip &s2, vector<int> &permutation, Item_vector &items)
{

    for (int i = 0; i < permutation.size(); i++)
    {
        int item_id = permutation[i]-1;

        if (s2.height >= items[item_id].height && s2.width >= items[item_id].width)
        {
            /* Place item */
            items[item_id].x_position = s2.x_position;
            items[item_id].y_position = s2.y_position;

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

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

            /* Erase */
            permutation.erase(permutation.begin() + i);
            
            if (s3.width*s3.height>s4.height*s4.width)
            {
                s2=s3; RecursePacking(s2,permutation,items);
                s2=s4; RecursePacking(s2,permutation,items);
                
            }
            else
            {
                s2=s4; RecursePacking(s2,permutation,items);
                s2=s3; RecursePacking(s2,permutation,items);
        
            }   

        }
        else{
            continue;
        }
        
    }
    return;   
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r8
movq %rdi, %r15
xorl %edi, %edi
xorl %r9d, %r9d
movq %rdx, -0x38(%rbp)
movq %rsi, -0x30(%rbp)
movq (%r8), %rsi
movq 0x8(%r8), %rax
subq %rsi, %rax
sarq $0x2, %rax
cmpq %r9, %rax
jbe 0x2ac3
movslq (%rsi,%rdi), %rcx
movl (%r15), %ebx
movq (%rdx), %rax
imulq $0x1c, %rcx, %rcx
movl -0x18(%rax,%rcx), %r12d
subl %r12d, %ebx
jl 0x2ab7
addq %rcx, %rax
movl 0x4(%r15), %ecx
movl -0x14(%rax), %r13d
movl %ecx, %r14d
subl %r13d, %r14d
jl 0x2ab7
addq %rdi, %rsi
movl 0x8(%r15), %r10d
movl %r10d, -0x40(%rbp)
movl %r10d, -0xc(%rax)
movl 0xc(%r15), %r11d
movq %r11, -0x50(%rbp)
movl %r11d, -0x8(%rax)
leal (%r11,%r12), %eax
movl %eax, -0x44(%rbp)
addl %r10d, %r13d
movq %rdi, -0x60(%rbp)
movq %r8, %rdi
movq %r9, -0x58(%rbp)
movl %ecx, -0x3c(%rbp)
callq 0x3a7a
movl -0x3c(%rbp), %r8d
movl %r8d, %eax
imull %ebx, %eax
movl %r14d, %ecx
imull %r12d, %ecx
cmpl %ecx, %eax
movl %r12d, %eax
cmovgl %ebx, %eax
movl %r14d, %ecx
cmovgl %r8d, %ecx
movl %r13d, %edx
movl -0x40(%rbp), %r10d
cmovgl %r10d, %edx
movq -0x50(%rbp), %r9
movl %r9d, %esi
movl -0x44(%rbp), %edi
cmovgl %edi, %esi
cmovgl %r12d, %ebx
cmovgl %r14d, %r8d
movl %r8d, %r12d
cmovlel %r10d, %r13d
cmovgl %r9d, %edi
movl %edi, %r14d
movl %eax, (%r15)
movl %ecx, 0x4(%r15)
movl %edx, 0x8(%r15)
movl %esi, 0xc(%r15)
movq %r15, %rdi
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x2975
movl %ebx, (%r15)
movl %r12d, 0x4(%r15)
movl %r13d, 0x8(%r15)
movl %r14d, 0xc(%r15)
movq %r15, %rdi
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x2975
movq -0x58(%rbp), %r9
movq -0x60(%rbp), %rdi
movq -0x30(%rbp), %r8
movq -0x38(%rbp), %rdx
incq %r9
addq $0x4, %rdi
jmp 0x2999
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq