// File: alex-courtis[P]xlayoutdisplay/src/calculations.cpp
// Function: orderOutputs(std::__cxx11::list<std::shared_ptr<Output>, std::allocator<std::shared_ptr<Output>>> const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>> const&)
const std::list<std::shared_ptr<Output>> orderOutputs(const list<shared_ptr<Output>> &outputs, const vector<string> &order) {
    list<shared_ptr<Output>> orderedOutputs(outputs);

    // stack all the preferred, available outputs
    stack<shared_ptr<Output>> preferredOutputs;
    for (const auto &name : order) {
        for (const auto &output : outputs) {
            if (strcasecmp(name.c_str(), output->name.c_str()) == 0) {
                preferredOutputs.push(output);
            }
        }
    }

    // move preferred to the front
    while (!preferredOutputs.empty()) {
        orderedOutputs.remove(preferredOutputs.top());
        orderedOutputs.push_front(preferredOutputs.top());
        preferredOutputs.pop();
    }

    return orderedOutputs;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0xd0(%rbp)
movq %rdi, %rax
movq %rax, -0xc8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movb $0x0, -0x19(%rbp)
movq -0x10(%rbp), %rsi
callq 0xbdd0
leaq -0x70(%rbp), %rdi
callq 0xbe90
jmp 0xa7a0
movq -0x18(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rdi
callq 0xbec0
movq %rax, -0x90(%rbp)
movq -0x88(%rbp), %rdi
callq 0xbef0
movq %rax, -0x98(%rbp)
leaq -0x90(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0xbf20
testb $0x1, %al
jne 0xa7ed
jmp 0xa900
leaq -0x90(%rbp), %rdi
callq 0xbf60
movq %rax, -0xa0(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rdi
callq 0xbf80
movq %rax, -0xb0(%rbp)
movq -0xa8(%rbp), %rdi
callq 0xbfb0
movq %rax, -0xb8(%rbp)
leaq -0xb0(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0xbfe0
testb $0x1, %al
jne 0xa84d
jmp 0xa8ed
leaq -0xb0(%rbp), %rdi
callq 0xc010
movq %rax, -0xc0(%rbp)
movq -0xa0(%rbp), %rdi
callq 0x71e0
movq %rax, -0xd8(%rbp)
movq -0xc0(%rbp), %rdi
callq 0xc040
movq %rax, %rdi
callq 0x71e0
movq -0xd8(%rbp), %rdi
movq %rax, %rsi
callq 0x7570
cmpl $0x0, %eax
jne 0xa8da
movq -0xc0(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0xc060
jmp 0xa8ad
jmp 0xa8da
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0xa9ab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0xc260
jmp 0xa9ab
jmp 0xa8dc
leaq -0xb0(%rbp), %rdi
callq 0xc090
jmp 0xa831
jmp 0xa8ef
leaq -0x90(%rbp), %rdi
callq 0xc0b0
jmp 0xa7d1
jmp 0xa902
leaq -0x70(%rbp), %rdi
callq 0xc0d0
movb %al, -0xd9(%rbp)
jmp 0xa913
movb -0xd9(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0xa921
jmp 0xa97c
leaq -0x70(%rbp), %rdi
callq 0xc1e0
movq %rax, -0xe8(%rbp)
jmp 0xa933
movq -0xe8(%rbp), %rsi
movq -0xd0(%rbp), %rdi
callq 0xc0f0
jmp 0xa948
leaq -0x70(%rbp), %rdi
callq 0xc1e0
movq %rax, -0xf0(%rbp)
jmp 0xa95a
movq -0xf0(%rbp), %rsi
movq -0xd0(%rbp), %rdi
callq 0xc200
jmp 0xa96f
leaq -0x70(%rbp), %rdi
callq 0xc240
jmp 0xa97a
jmp 0xa902
movb $0x1, -0x19(%rbp)
leaq -0x70(%rbp), %rdi
callq 0xc260
testb $0x1, -0x19(%rbp)
jne 0xa99b
movq -0xd0(%rbp), %rdi
callq 0xc280
movq -0xc8(%rbp), %rax
addq $0xf0, %rsp
popq %rbp
retq
movq -0xd0(%rbp), %rdi
callq 0xc280
movq -0x78(%rbp), %rdi
callq 0x7930