// File: alex-courtis[P]xlayoutdisplay/src/Output.cpp
// Function: Output::Output(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, Output::State const&, std::__cxx11::list<std::shared_ptr<Mode const>, std::allocator<std::shared_ptr<Mode const>>> const&, std::shared_ptr<Mode const> const&, std::shared_ptr<Mode const> const&, std::shared_ptr<Pos const> const&, std::shared_ptr<Edid const> const&)
Output::Output(const string &name,
             const State &state,
             const list<shared_ptr<const Mode>> &modes,
             const shared_ptr<const Mode> &currentMode,
             const shared_ptr<const Mode> &preferredMode,
             const shared_ptr<const Pos> &currentPos,
             const shared_ptr<const Edid> &edid) :
        name(name),
        state(state),
        modes(modes),
        currentMode(currentMode),
        preferredMode(preferredMode),
        optimalMode(calculateOptimalMode(modes, preferredMode)),
        currentPos(currentPos),
        edid(edid) {
    switch (state) {
        case active:
            if (!currentMode) throw invalid_argument("active Output '" + name + "' has no currentMode");
            if (!currentPos) throw invalid_argument("active Output '" + name + "' has no currentPos");
            if (modes.empty()) throw invalid_argument("active Output '" + name + "' has no modes");
            break;
        case connected:
            if (modes.empty()) throw invalid_argument("connected Output '" + name + "' has no modes");
            break;
        default:
            break;
    }

    // active / connected must have NULL or valid preferred mode
    if (state == active || state == connected) {
        if (preferredMode && find(this->modes.begin(), this->modes.end(), preferredMode) == this->modes.end())
            throw invalid_argument("Output '" + name + "' has preferredMode not present in modes");
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x260, %rsp            # imm = 0x260
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x1d8(%rbp)
movq %rdi, %rax
movq %rax, -0x1e0(%rbp)
movq -0x10(%rbp), %rsi
callq 0x7210
movq -0x1d8(%rbp), %rdi
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, 0x20(%rdi)
addq $0x28, %rdi
movq %rdi, -0x1d0(%rbp)
movq -0x20(%rbp), %rsi
callq 0x9420
jmp 0x8cff
movq -0x1e0(%rbp), %rdi
addq $0x40, %rdi
movq %rdi, -0x1f8(%rbp)
movq -0x28(%rbp), %rsi
callq 0x94e0
movq -0x1e0(%rbp), %rdi
addq $0x50, %rdi
movq %rdi, -0x1f0(%rbp)
movq -0x30(%rbp), %rsi
callq 0x94e0
movq -0x1e0(%rbp), %rdi
addq $0x60, %rdi
movq %rdi, -0x1e8(%rbp)
movq -0x20(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0xbc60
jmp 0x8d56
movq -0x1e0(%rbp), %rdi
addq $0x70, %rdi
movq %rdi, -0x220(%rbp)
movq 0x10(%rbp), %rsi
callq 0x9510
movq -0x1e0(%rbp), %rdi
subq $-0x80, %rdi
movq %rdi, -0x218(%rbp)
movq 0x18(%rbp), %rsi
callq 0x9540
movq -0x1e0(%rbp), %rdi
movb $0x0, 0x90(%rdi)
addq $0x98, %rdi
movq %rdi, -0x210(%rbp)
callq 0x9570
movq -0x1e0(%rbp), %rdi
addq $0xa8, %rdi
movq %rdi, -0x208(%rbp)
callq 0x9590
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x1fc(%rbp)
testl %eax, %eax
je 0x8e0f
jmp 0x8dd9
movl -0x1fc(%rbp), %eax
subl $0x1, %eax
je 0x90e2
jmp 0x91da
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x9407
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x93e3
movq -0x28(%rbp), %rdi
callq 0x95b0
testb $0x1, %al
jne 0x8ef2
movb $0x1, -0x81(%rbp)
movl $0x10, %edi
callq 0x7260
movq %rax, -0x228(%rbp)
movq -0x10(%rbp), %rdx
leaq 0x373ea(%rip), %rsi     # 0x4022d
leaq -0x80(%rbp), %rdi
callq 0x95d0
jmp 0x8e4e
leaq 0x373e8(%rip), %rdx     # 0x4023d
leaq -0x60(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x8100
jmp 0x8e64
movq -0x228(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x7910
jmp 0x8e76
movq -0x228(%rbp), %rdi
movb $0x0, -0x81(%rbp)
movq 0x5513d(%rip), %rsi     # 0x5dfc8
movq 0x5511e(%rip), %rdx     # 0x5dfb0
callq 0x78c0
jmp 0x941c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x8ed6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x8ecd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x7320
leaq -0x80(%rbp), %rdi
callq 0x7320
testb $0x1, -0x81(%rbp)
jne 0x8ee1
jmp 0x8eed
movq -0x228(%rbp), %rdi
callq 0x73c0
jmp 0x93a7
movq 0x10(%rbp), %rdi
callq 0x96e0
testb $0x1, %al
jne 0x8fe7
movb $0x1, -0xc9(%rbp)
movl $0x10, %edi
callq 0x7260
movq %rax, -0x230(%rbp)
movq -0x10(%rbp), %rdx
leaq 0x37307(%rip), %rsi     # 0x4022d
leaq -0xc8(%rbp), %rdi
callq 0x95d0
jmp 0x8f34
leaq 0x37317(%rip), %rdx     # 0x40252
leaq -0xa8(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x8100
jmp 0x8f50
movq -0x230(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x7910
jmp 0x8f65
movq -0x230(%rbp), %rdi
movb $0x0, -0xc9(%rbp)
movq 0x5504e(%rip), %rsi     # 0x5dfc8
movq 0x5502f(%rip), %rdx     # 0x5dfb0
callq 0x78c0
jmp 0x941c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x8fcb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x8fbf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x7320
leaq -0xc8(%rbp), %rdi
callq 0x7320
testb $0x1, -0xc9(%rbp)
jne 0x8fd6
jmp 0x8fe2
movq -0x230(%rbp), %rdi
callq 0x73c0
jmp 0x93a7
movq -0x20(%rbp), %rdi
callq 0x9700
testb $0x1, %al
jne 0x8ff9
jmp 0x90dd
movb $0x1, -0x111(%rbp)
movl $0x10, %edi
callq 0x7260
movq %rax, -0x238(%rbp)
movq -0x10(%rbp), %rdx
leaq 0x37211(%rip), %rsi     # 0x4022d
leaq -0x110(%rbp), %rdi
callq 0x95d0
jmp 0x902a
leaq 0x37235(%rip), %rdx     # 0x40266
leaq -0xf0(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x8100
jmp 0x9046
movq -0x238(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x7910
jmp 0x905b
movq -0x238(%rbp), %rdi
movb $0x0, -0x111(%rbp)
movq 0x54f58(%rip), %rsi     # 0x5dfc8
movq 0x54f39(%rip), %rdx     # 0x5dfb0
callq 0x78c0
jmp 0x941c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x90c1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x90b5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x7320
leaq -0x110(%rbp), %rdi
callq 0x7320
testb $0x1, -0x111(%rbp)
jne 0x90cc
jmp 0x90d8
movq -0x238(%rbp), %rdi
callq 0x73c0
jmp 0x93a7
jmp 0x91dc
movq -0x20(%rbp), %rdi
callq 0x9700
testb $0x1, %al
jne 0x90f4
jmp 0x91d8
movb $0x1, -0x159(%rbp)
movl $0x10, %edi
callq 0x7260
movq %rax, -0x240(%rbp)
movq -0x10(%rbp), %rdx
leaq 0x3715e(%rip), %rsi     # 0x40275
leaq -0x158(%rbp), %rdi
callq 0x95d0
jmp 0x9125
leaq 0x3713a(%rip), %rdx     # 0x40266
leaq -0x138(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x8100
jmp 0x9141
movq -0x240(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x7910
jmp 0x9156
movq -0x240(%rbp), %rdi
movb $0x0, -0x159(%rbp)
movq 0x54e5d(%rip), %rsi     # 0x5dfc8
movq 0x54e3e(%rip), %rdx     # 0x5dfb0
callq 0x78c0
jmp 0x941c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x91bc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x91b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x138(%rbp), %rdi
callq 0x7320
leaq -0x158(%rbp), %rdi
callq 0x7320
testb $0x1, -0x159(%rbp)
jne 0x91c7
jmp 0x91d3
movq -0x240(%rbp), %rdi
callq 0x73c0
jmp 0x93a7
jmp 0x91dc
jmp 0x91dc
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x91f2
movq -0x18(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x939e
movq -0x30(%rbp), %rdi
callq 0x95b0
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x241(%rbp)
jne 0x920f
jmp 0x929e
movq -0x1e0(%rbp), %rdi
addq $0x28, %rdi
movq %rdi, -0x258(%rbp)
callq 0x97a0
movq -0x258(%rbp), %rdi
movq %rax, -0x170(%rbp)
callq 0x97d0
movq %rax, -0x178(%rbp)
movq -0x30(%rbp), %rdx
movq -0x170(%rbp), %rdi
movq -0x178(%rbp), %rsi
callq 0x9750
movq %rax, -0x250(%rbp)
jmp 0x9260
movq -0x1e0(%rbp), %rdi
movq -0x250(%rbp), %rax
movq %rax, -0x168(%rbp)
addq $0x28, %rdi
callq 0x97d0
movq %rax, -0x180(%rbp)
leaq -0x168(%rbp), %rdi
leaq -0x180(%rbp), %rsi
callq 0x9720
movb %al, -0x241(%rbp)
movb -0x241(%rbp), %al
testb $0x1, %al
jne 0x92ad
jmp 0x939c
movb $0x1, -0x1c1(%rbp)
movl $0x10, %edi
callq 0x7260
movq %rax, -0x260(%rbp)
movq -0x10(%rbp), %rdx
leaq 0x36faf(%rip), %rsi     # 0x4027f
leaq -0x1c0(%rbp), %rdi
callq 0x95d0
jmp 0x92de
leaq 0x36fa3(%rip), %rdx     # 0x40288
leaq -0x1a0(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x8100
jmp 0x92fa
movq -0x260(%rbp), %rdi
leaq -0x1a0(%rbp), %rsi
callq 0x7910
jmp 0x930f
movq -0x260(%rbp), %rdi
movb $0x0, -0x1c1(%rbp)
movq 0x54ca4(%rip), %rsi     # 0x5dfc8
movq 0x54c85(%rip), %rdx     # 0x5dfb0
callq 0x78c0
jmp 0x941c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x93a7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x9383
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x9377
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0x7320
leaq -0x1c0(%rbp), %rdi
callq 0x7320
testb $0x1, -0x1c1(%rbp)
jne 0x938e
jmp 0x939a
movq -0x260(%rbp), %rdi
callq 0x73c0
jmp 0x93a7
jmp 0x939e
addq $0x260, %rsp            # imm = 0x260
popq %rbp
retq
movq -0x208(%rbp), %rdi
callq 0x9800
movq -0x210(%rbp), %rdi
callq 0x9820
movq -0x218(%rbp), %rdi
callq 0x9840
movq -0x220(%rbp), %rdi
callq 0x9800
movq -0x1e8(%rbp), %rdi
callq 0x9820
movq -0x1f0(%rbp), %rdi
callq 0x9820
movq -0x1f8(%rbp), %rdi
callq 0x9820
movq -0x1d0(%rbp), %rdi
callq 0x9860
movq -0x1d8(%rbp), %rdi
callq 0x7320
movq -0x38(%rbp), %rdi
callq 0x7930
nopl (%rax)