// File: alex-courtis[P]xlayoutdisplay/main.cpp
// Function: main
int main(int argc, char **argv) {
    try {
        Settings settings;
        try {
            // file options
            ifstream ifs(resolveEnvPath("XDG_CONFIG_HOME", ".xlayoutdisplay"));
            if (!ifs)
                ifs = ifstream(resolveEnvPath("HOME", ".xlayoutdisplay"));
            if (!ifs)
                ifs = ifstream("/etc/xlayoutdisplay");
            if (ifs) {
                parseCfgFile(ifs, settings);
            }

            // command line options override
            parseArgs(argc, argv, settings);

        } catch (invalid_argument &e) {
            cerr << argv[0] << ": " << e.what() << endl << endl;
            usage(cerr);
            return EXIT_FAILURE;
        }

        // execute
        return WEXITSTATUS(layout(settings));
    } catch (const exception &e) {
        cerr << argv[0] << ": " << e.what() << ", exiting\n";
        return EXIT_FAILURE;
    } catch (...) {
        cerr << argv[0] << ": unknown exception, exiting\n";
        return EXIT_FAILURE;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x740, %rsp            # imm = 0x740
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x16790
leaq 0x2b114(%rip), %rsi     # 0x40ead
leaq 0x2b11d(%rip), %rdx     # 0x40ebd
leaq -0x298(%rbp), %rdi
callq 0x167f0
jmp 0x15dae
leaq -0x278(%rbp), %rdi
leaq -0x298(%rbp), %rsi
movl $0x8, %edx
callq 0x7830
jmp 0x15dc8
leaq -0x298(%rbp), %rdi
callq 0x7320
movq -0x278(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x278(%rbp,%rax), %rdi
callq 0x7240
movb %al, -0x6f1(%rbp)
jmp 0x15df4
movb -0x6f1(%rbp), %al
testb $0x1, %al
jne 0x15e03
jmp 0x15eff
leaq 0x2b0ae(%rip), %rsi     # 0x40eb8
leaq 0x2b0ac(%rip), %rdx     # 0x40ebd
leaq -0x4d0(%rbp), %rdi
callq 0x167f0
jmp 0x15e1f
leaq -0x4b0(%rbp), %rdi
leaq -0x4d0(%rbp), %rsi
movl $0x8, %edx
callq 0x7830
jmp 0x15e39
leaq -0x278(%rbp), %rdi
leaq -0x4b0(%rbp), %rsi
callq 0x7840
jmp 0x15e4e
leaq -0x4b0(%rbp), %rdi
callq 0x7130
leaq -0x4d0(%rbp), %rdi
callq 0x7320
jmp 0x15eff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2a0(%rbp)
movl %eax, -0x2a4(%rbp)
jmp 0x15ff7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2a0(%rbp)
movl %eax, -0x2a4(%rbp)
leaq -0x298(%rbp), %rdi
callq 0x7320
jmp 0x15ff7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2a0(%rbp)
movl %eax, -0x2a4(%rbp)
jmp 0x15feb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2a0(%rbp)
movl %eax, -0x2a4(%rbp)
jmp 0x15eee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2a0(%rbp)
movl %eax, -0x2a4(%rbp)
leaq -0x4b0(%rbp), %rdi
callq 0x7130
leaq -0x4d0(%rbp), %rdi
callq 0x7320
jmp 0x15feb
movq -0x278(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x278(%rbp,%rax), %rdi
callq 0x7240
movb %al, -0x6f2(%rbp)
jmp 0x15f1f
movb -0x6f2(%rbp), %al
testb $0x1, %al
jne 0x15f2b
jmp 0x15f88
leaq 0x2af9b(%rip), %rsi     # 0x40ecd
leaq -0x6d8(%rbp), %rdi
movl $0x8, %edx
callq 0x7990
jmp 0x15f45
leaq -0x278(%rbp), %rdi
leaq -0x6d8(%rbp), %rsi
callq 0x7840
jmp 0x15f5a
leaq -0x6d8(%rbp), %rdi
callq 0x7130
jmp 0x15f88
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2a0(%rbp)
movl %eax, -0x2a4(%rbp)
leaq -0x6d8(%rbp), %rdi
callq 0x7130
jmp 0x15feb
movq -0x278(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x278(%rbp,%rax), %rdi
callq 0x7680
movb %al, -0x6f3(%rbp)
jmp 0x15fa8
movb -0x6f3(%rbp), %al
testb $0x1, %al
jne 0x15fb4
jmp 0x15fc8
leaq -0x278(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x14db0
jmp 0x15fc6
jmp 0x15fc8
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq -0x70(%rbp), %rdx
callq 0x157e0
jmp 0x15fda
leaq -0x278(%rbp), %rdi
callq 0x7130
jmp 0x16105
leaq -0x278(%rbp), %rdi
callq 0x7130
movl -0x2a4(%rbp), %eax
movl $0x3, %ecx
cmpl %ecx, %eax
jne 0x1613f
movq -0x2a0(%rbp), %rdi
callq 0x71d0
movq %rax, -0x6e0(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movq 0x47fbd(%rip), %rdi     # 0x5dfe8
callq 0x74a0
movq %rax, -0x700(%rbp)
jmp 0x16039
movq -0x700(%rbp), %rdi
leaq 0x2a797(%rip), %rsi     # 0x407de
callq 0x74a0
movq %rax, -0x708(%rbp)
jmp 0x16055
movq -0x6e0(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq -0x708(%rbp), %rdi
movq %rax, %rsi
callq 0x74a0
movq %rax, -0x710(%rbp)
jmp 0x1607d
movq -0x710(%rbp), %rdi
movq 0x47ec5(%rip), %rsi     # 0x5df50
callq 0x7510
movq %rax, -0x718(%rbp)
jmp 0x16099
movq -0x718(%rbp), %rdi
movq 0x47ea9(%rip), %rsi     # 0x5df50
callq 0x7510
jmp 0x160ae
movq 0x47f33(%rip), %rdi     # 0x5dfe8
callq 0x14d80
jmp 0x160bc
movl $0x1, -0x4(%rbp)
movl $0x1, -0x6e4(%rbp)
callq 0x7860
jmp 0x160ed
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2a0(%rbp)
movl %eax, -0x2a4(%rbp)
callq 0x7860
jmp 0x16103
jmp 0x16131
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2a0(%rbp)
movl %eax, -0x2a4(%rbp)
jmp 0x1613f
jmp 0x1613f
leaq -0x70(%rbp), %rdi
callq 0x10ab0
movl %eax, -0x71c(%rbp)
jmp 0x16116
movl -0x71c(%rbp), %eax
andl $0xff00, %eax           # imm = 0xFF00
sarl $0x8, %eax
movl %eax, -0x4(%rbp)
movl $0x1, -0x6e4(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x168c0
jmp 0x16289
leaq -0x70(%rbp), %rdi
callq 0x168c0
movl -0x2a4(%rbp), %eax
movl $0x2, %ecx
cmpl %ecx, %eax
jne 0x161fe
movq -0x2a0(%rbp), %rdi
callq 0x71d0
movq %rax, -0x6f0(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movq 0x47e6c(%rip), %rdi     # 0x5dfe8
callq 0x74a0
movq %rax, -0x728(%rbp)
jmp 0x1618a
movq -0x728(%rbp), %rdi
leaq 0x2a646(%rip), %rsi     # 0x407de
callq 0x74a0
movq %rax, -0x730(%rbp)
jmp 0x161a6
movq -0x6f0(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq -0x730(%rbp), %rdi
movq %rax, %rsi
callq 0x74a0
movq %rax, -0x738(%rbp)
jmp 0x161ce
movq -0x738(%rbp), %rdi
leaq 0x2ad18(%rip), %rsi     # 0x40ef4
callq 0x74a0
jmp 0x161e3
movl $0x1, -0x4(%rbp)
movl $0x1, -0x6e4(%rbp)
callq 0x7860
jmp 0x16289
movq -0x2a0(%rbp), %rdi
callq 0x71d0
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movq 0x47dd0(%rip), %rdi     # 0x5dfe8
callq 0x74a0
movq %rax, -0x740(%rbp)
jmp 0x16226
movq -0x740(%rbp), %rdi
leaq 0x2acad(%rip), %rsi     # 0x40ee1
callq 0x74a0
jmp 0x1623b
movl $0x1, -0x4(%rbp)
movl $0x1, -0x6e4(%rbp)
callq 0x7860
jmp 0x16289
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2a0(%rbp)
movl %eax, -0x2a4(%rbp)
callq 0x7860
jmp 0x1626c
jmp 0x16295
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2a0(%rbp)
movl %eax, -0x2a4(%rbp)
callq 0x7860
jmp 0x16287
jmp 0x16295
movl -0x4(%rbp), %eax
addq $0x740, %rsp            # imm = 0x740
popq %rbp
retq
movq -0x2a0(%rbp), %rdi
callq 0x7930
movq %rax, %rdi
callq 0x8a00
nopl (%rax)