// File: /workspace/github_cpp_makefile_star2_O1/maramire[P]SP_PSO/parallel_main.cpp
// Function: openInstance(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::vector<Item, std::allocator<Item>>&, int&, int&, int&)
void openInstance(string filepath, Item_vector &items, int &strip_width, int &max_height, int &n_items)
{ 

    ifstream file(filepath);
    Item item;
    
    if (!file.is_open())
    {
        exit(EXIT_FAILURE);
    }

    /* Saving first two lines */
    int col1, col2;


    file >> col1 >> col2;
    strip_width = col1;


    file >> col1;
    n_items = col1;
    
    
    
    
    /* Reading Line */
    while(file >> col1 >> col2)
    {
        item.width = col1;
        max_height+= col2; // Updating max height for setting upper bound.
        item.height = col2;
        item.area = col2 * col1;
        item.rotated = 0;
        items.push_back(item);
    }

    /* Sort by area */
    sort(items.begin(), items.end(), compareByArea);

    /* Set new ID's according to area */ 
    for (int i = 0; i <= items.size(); i++)
    {
        items[i].id = i+1;
    }    
    
    /* Finish */     
    file.close();    
    cout << "Instance ready!"<< endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x238, %rsp            # imm = 0x238
movq %r8, %r12
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %rsi
leaq -0x258(%rbp), %rdi
movl $0x8, %edx
callq 0x2290
leaq -0x1e0(%rbp), %rdi
callq 0x2060
testb %al, %al
je 0x2776
leaq -0x258(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x2100
leaq -0x30(%rbp), %rsi
movq %rax, %rdi
callq 0x2100
leaq -0x2c(%rbp), %rsi
movl (%rsi), %eax
movl %eax, (%r15)
leaq -0x258(%rbp), %rdi
callq 0x2100
leaq -0x2c(%rbp), %r15
movl (%r15), %eax
movl %eax, (%r12)
leaq -0x258(%rbp), %r12
leaq -0x30(%rbp), %r13
movq %r12, %rdi
movq %r15, %rsi
callq 0x2100
movq %rax, %rdi
movq %r13, %rsi
callq 0x2100
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x2687
movl -0x2c(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x30(%rbp), %ecx
addl %ecx, (%r14)
movl %ecx, -0x48(%rbp)
imull %eax, %ecx
movl %ecx, -0x40(%rbp)
movl $0x0, -0x34(%rbp)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x2679
movups -0x4c(%rbp), %xmm0
movups -0x40(%rbp), %xmm1
movups %xmm1, 0xc(%rsi)
movups %xmm0, (%rsi)
addq $0x1c, 0x8(%rbx)
jmp 0x2619
movq %rbx, %rdi
leaq -0x4c(%rbp), %rdx
callq 0x45ca
jmp 0x2619
movq (%rbx), %r14
movq 0x8(%rbx), %r15
movabsq $0x6db6db6db6db6db7, %r12 # imm = 0x6DB6DB6DB6DB6DB7
cmpq %r15, %r14
je 0x26dc
movq %r15, %rax
subq %r14, %rax
sarq $0x2, %rax
imulq %r12, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
leaq -0x153(%rip), %rcx      # 0x256c
movq %r14, %rdi
movq %r15, %rsi
callq 0x4755
leaq -0x165(%rip), %rdx      # 0x256c
movq %r14, %rdi
movq %r15, %rsi
callq 0x48c7
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
imulq %r12, %rcx
movq $-0x1, %rdx
leal 0x2(%rdx), %esi
movl %esi, (%rax)
incq %rdx
addq $0x1c, %rax
cmpq %rdx, %rcx
jne 0x26f5
leaq -0x258(%rbp), %rdi
callq 0x2050
movq 0x78bf(%rip), %rbx      # 0x9fd8
leaq 0x4940(%rip), %rsi      # 0x7060
movl $0xf, %edx
movq %rbx, %rdi
callq 0x21e0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq 0x788d(%rip), %rdi      # 0x9fd8
callq 0x2030
movq %rax, %rdi
callq 0x2110
leaq -0x258(%rbp), %rdi
callq 0x2070
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %edi
callq 0x2200
jmp 0x2782
movq %rax, %rbx
leaq -0x258(%rbp), %rdi
callq 0x2070
movq %rbx, %rdi
callq 0x22f0