// File: 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
subq $0x2c0, %rsp            # imm = 0x2C0
movq %rsi, %rax
movq %rdi, %rsi
movq %rsi, -0x8(%rbp)
movq %rax, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
leaq -0x230(%rbp), %rdi
movq %rdi, -0x288(%rbp)
movl $0x8, %edx
callq 0x2320
movq -0x288(%rbp), %rdi
callq 0x2310
movb %al, -0x27d(%rbp)
jmp 0x2691
movb -0x27d(%rbp), %al
testb $0x1, %al
jne 0x26ca
jmp 0x269d
movl $0x1, %edi
callq 0x2270
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x258(%rbp)
movl %eax, -0x25c(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x2060
jmp 0x28e0
leaq -0x230(%rbp), %rdi
leaq -0x260(%rbp), %rsi
callq 0x20f0
movq %rax, -0x290(%rbp)
jmp 0x26e6
movq -0x290(%rbp), %rdi
leaq -0x264(%rbp), %rsi
callq 0x20f0
jmp 0x26fb
movl -0x260(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
leaq -0x230(%rbp), %rdi
leaq -0x260(%rbp), %rsi
callq 0x20f0
jmp 0x271c
movl -0x260(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
leaq -0x230(%rbp), %rdi
leaq -0x260(%rbp), %rsi
callq 0x20f0
movq %rax, -0x298(%rbp)
jmp 0x2744
movq -0x298(%rbp), %rdi
leaq -0x264(%rbp), %rsi
callq 0x20f0
movq %rax, -0x2a0(%rbp)
jmp 0x2760
movq -0x2a0(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x22a0
movb %al, -0x2a1(%rbp)
jmp 0x277e
movb -0x2a1(%rbp), %al
testb $0x1, %al
jne 0x278a
jmp 0x27e8
movl -0x260(%rbp), %eax
movl %eax, -0x244(%rbp)
movl -0x264(%rbp), %edx
movq -0x20(%rbp), %rax
movl (%rax), %ecx
addl %edx, %ecx
movl %ecx, (%rax)
movl -0x264(%rbp), %eax
movl %eax, -0x248(%rbp)
movl -0x264(%rbp), %eax
movl -0x260(%rbp), %ecx
imull %ecx, %eax
movl %eax, -0x240(%rbp)
movl $0x0, -0x234(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x24c(%rbp), %rsi
callq 0x48e0
jmp 0x27e3
jmp 0x2728
movq -0x10(%rbp), %rdi
callq 0x49a0
movq %rax, -0x270(%rbp)
movq -0x10(%rbp), %rdi
callq 0x49d0
movq %rax, -0x278(%rbp)
movq -0x270(%rbp), %rdi
movq -0x278(%rbp), %rsi
leaq -0x23d(%rip), %rdx      # 0x25e0
callq 0x4950
jmp 0x2824
movl $0x0, -0x27c(%rbp)
movslq -0x27c(%rbp), %rax
movq %rax, -0x2b0(%rbp)
movq -0x10(%rbp), %rdi
callq 0x4a00
movq %rax, %rcx
movq -0x2b0(%rbp), %rax
cmpq %rcx, %rax
ja 0x288c
movl -0x27c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2b4(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x27c(%rbp), %rsi
callq 0x4a30
movl -0x2b4(%rbp), %ecx
movl %ecx, (%rax)
movl -0x27c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x27c(%rbp)
jmp 0x282e
leaq -0x230(%rbp), %rdi
callq 0x2050
jmp 0x289a
movq 0x15737(%rip), %rdi     # 0x17fd8
leaq 0xd7b8(%rip), %rsi      # 0x10060
callq 0x21c0
movq %rax, -0x2c0(%rbp)
jmp 0x28b6
movq -0x2c0(%rbp), %rdi
movq 0x15704(%rip), %rsi     # 0x17fc8
callq 0x2200
jmp 0x28cb
leaq -0x230(%rbp), %rdi
callq 0x2060
addq $0x2c0, %rsp            # imm = 0x2C0
popq %rbp
retq
movq -0x258(%rbp), %rdi
callq 0x2380
nopl (%rax)