// File: alex-courtis[P]xlayoutdisplay/main.cpp
// Function: parseCfgFile(std::basic_ifstream<char, std::char_traits<char>>&, Settings&)
void parseCfgFile(ifstream &ifs, Settings &settings) {
    string line;
    while (getline(ifs, line)) {

        // comments and empties
        if (regex_match(line, regex("\\s*#.*")) || regex_match(line, regex("\\s*"))) {
            continue;
        }

        // name=val
        smatch match;
        if (!regex_match(line, match, regex("\\s*(\\S+)\\s*=\\s*(\\S+)\\s*")) || match.size() != 3) {
            continue;
        }

        if (match[1] == "dpi") {
            settings.dpi = parseLong(match[1], match[2]);
        } else if (match[1] == "rate") {
            settings.rate = parseLong(match[1], match[2]);
        } else if (match[1] == "mirror") {
            settings.mirror = parseBool(match[2]);
        } else if (match[1] == "order") {
            settings.order.push_back(match[2]);
        } else if (match[1] == "primary") {
            settings.primary = match[2];
        } else if (match[1] == "quiet") {
            settings.quiet = parseBool(match[2]);
        } else if (match[1] == "wait") {
            settings.wait = parseLong(match[1], match[2]);
        } else {
            throw invalid_argument("unrecognised file option '" + match[0].str() + "'");
        }
    }

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x390, %rsp            # imm = 0x390
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x7740
movq -0x8(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x70e0
movq %rax, -0x280(%rbp)
jmp 0x14de2
movq -0x280(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x7680
movb %al, -0x281(%rbp)
jmp 0x14e00
movb -0x281(%rbp), %al
testb $0x1, %al
jne 0x14e0f
jmp 0x157b5
movb $0x0, -0x81(%rbp)
leaq 0x2c00e(%rip), %rsi     # 0x40e2b
leaq -0x60(%rbp), %rdi
movl $0x10, %edx
callq 0x16300
jmp 0x14e2d
leaq -0x30(%rbp), %rdi
leaq -0x60(%rbp), %rsi
xorl %edx, %edx
callq 0x162b0
movb %al, -0x282(%rbp)
jmp 0x14e44
movb -0x282(%rbp), %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x283(%rbp)
jne 0x14e9c
jmp 0x14e59
leaq 0x2bfe6(%rip), %rsi     # 0x40e46
leaq -0x80(%rbp), %rdi
movl $0x10, %edx
callq 0x16300
jmp 0x14e70
movb $0x1, -0x81(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x80(%rbp), %rsi
xorl %edx, %edx
callq 0x162b0
movb %al, -0x284(%rbp)
jmp 0x14e8e
movb -0x284(%rbp), %al
movb %al, -0x283(%rbp)
jmp 0x14e9c
movb -0x283(%rbp), %al
movb %al, -0x285(%rbp)
testb $0x1, -0x81(%rbp)
jne 0x14eb3
jmp 0x14ebc
leaq -0x80(%rbp), %rdi
callq 0x163a0
leaq -0x60(%rbp), %rdi
callq 0x163a0
movb -0x285(%rbp), %al
testb $0x1, %al
jne 0x14ed1
jmp 0x14f25
jmp 0x14dcc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x157c7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x14f17
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
testb $0x1, -0x81(%rbp)
jne 0x14f0c
jmp 0x14f15
leaq -0x80(%rbp), %rdi
callq 0x163a0
jmp 0x14f17
leaq -0x60(%rbp), %rdi
callq 0x163a0
jmp 0x157c7
leaq -0xa8(%rbp), %rdi
callq 0x16460
jmp 0x14f33
leaq 0x2bef8(%rip), %rsi     # 0x40e32
leaq -0xc8(%rbp), %rdi
movl $0x10, %edx
callq 0x16300
jmp 0x14f4d
leaq -0x30(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
leaq -0xc8(%rbp), %rdx
xorl %ecx, %ecx
callq 0x164a0
movb %al, -0x286(%rbp)
jmp 0x14f6e
movb -0x286(%rbp), %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x287(%rbp)
jne 0x14f83
jmp 0x14f9c
leaq -0xa8(%rbp), %rdi
callq 0x16500
cmpq $0x3, %rax
setne %al
movb %al, -0x287(%rbp)
movb -0x287(%rbp), %al
movb %al, -0x288(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x163a0
movb -0x288(%rbp), %al
testb $0x1, %al
jne 0x14fc0
jmp 0x14ffd
movl $0x2, -0xcc(%rbp)
jmp 0x15785
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x157a7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x163a0
jmp 0x157a7
leaq -0xa8(%rbp), %rdi
movl $0x1, %esi
callq 0x16580
movq %rax, -0x290(%rbp)
jmp 0x15017
movq -0x290(%rbp), %rdi
leaq 0x2be25(%rip), %rsi     # 0x40e4a
callq 0x16550
movb %al, -0x291(%rbp)
jmp 0x15032
movb -0x291(%rbp), %al
testb $0x1, %al
jne 0x15041
jmp 0x1511d
leaq -0xa8(%rbp), %rdi
movl $0x1, %esi
callq 0x16580
movq %rax, -0x2a0(%rbp)
jmp 0x1505b
movq -0x2a0(%rbp), %rsi
leaq -0xf0(%rbp), %rdi
callq 0x165f0
jmp 0x15070
leaq -0xa8(%rbp), %rdi
movl $0x2, %esi
callq 0x16580
movq %rax, -0x2a8(%rbp)
jmp 0x1508a
movq -0x2a8(%rbp), %rsi
leaq -0x110(%rbp), %rdi
callq 0x165f0
jmp 0x1509f
leaq -0xf0(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x14bf0
movq %rax, -0x2b0(%rbp)
jmp 0x150bb
movq -0x2b0(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
leaq -0x110(%rbp), %rdi
callq 0x7320
leaq -0xf0(%rbp), %rdi
callq 0x7320
jmp 0x1577b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x1510c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x7320
leaq -0xf0(%rbp), %rdi
callq 0x7320
jmp 0x157a7
leaq -0xa8(%rbp), %rdi
movl $0x1, %esi
callq 0x16580
movq %rax, -0x2b8(%rbp)
jmp 0x15137
movq -0x2b8(%rbp), %rdi
leaq 0x2bd09(%rip), %rsi     # 0x40e4e
callq 0x16550
movb %al, -0x2b9(%rbp)
jmp 0x15152
movb -0x2b9(%rbp), %al
testb $0x1, %al
jne 0x15161
jmp 0x1523e
leaq -0xa8(%rbp), %rdi
movl $0x1, %esi
callq 0x16580
movq %rax, -0x2c8(%rbp)
jmp 0x1517b
movq -0x2c8(%rbp), %rsi
leaq -0x130(%rbp), %rdi
callq 0x165f0
jmp 0x15190
leaq -0xa8(%rbp), %rdi
movl $0x2, %esi
callq 0x16580
movq %rax, -0x2d0(%rbp)
jmp 0x151aa
movq -0x2d0(%rbp), %rsi
leaq -0x150(%rbp), %rdi
callq 0x165f0
jmp 0x151bf
leaq -0x130(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x14bf0
movq %rax, -0x2d8(%rbp)
jmp 0x151db
movq -0x2d8(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
leaq -0x150(%rbp), %rdi
callq 0x7320
leaq -0x130(%rbp), %rdi
callq 0x7320
jmp 0x15779
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x1522d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x150(%rbp), %rdi
callq 0x7320
leaq -0x130(%rbp), %rdi
callq 0x7320
jmp 0x157a7
leaq -0xa8(%rbp), %rdi
movl $0x1, %esi
callq 0x16580
movq %rax, -0x2e0(%rbp)
jmp 0x15258
movq -0x2e0(%rbp), %rdi
leaq 0x2b0be(%rip), %rsi     # 0x40324
callq 0x16550
movb %al, -0x2e1(%rbp)
jmp 0x15273
movb -0x2e1(%rbp), %al
testb $0x1, %al
jne 0x15282
jmp 0x15303
leaq -0xa8(%rbp), %rdi
movl $0x2, %esi
callq 0x16580
movq %rax, -0x2f0(%rbp)
jmp 0x1529c
movq -0x2f0(%rbp), %rsi
leaq -0x170(%rbp), %rdi
callq 0x165f0
jmp 0x152b1
leaq -0x170(%rbp), %rdi
callq 0x14b70
movb %al, -0x2f1(%rbp)
jmp 0x152c5
movb -0x2f1(%rbp), %cl
movq -0x10(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x12(%rax)
leaq -0x170(%rbp), %rdi
callq 0x7320
jmp 0x15777
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x170(%rbp), %rdi
callq 0x7320
jmp 0x157a7
leaq -0xa8(%rbp), %rdi
movl $0x1, %esi
callq 0x16580
movq %rax, -0x300(%rbp)
jmp 0x1531d
movq -0x300(%rbp), %rdi
leaq 0x2bb28(%rip), %rsi     # 0x40e53
callq 0x16550
movb %al, -0x301(%rbp)
jmp 0x15338
movb -0x301(%rbp), %al
testb $0x1, %al
jne 0x15347
jmp 0x153c8
movq -0x10(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x318(%rbp)
leaq -0xa8(%rbp), %rdi
movl $0x2, %esi
callq 0x16580
movq %rax, -0x310(%rbp)
jmp 0x15370
movq -0x310(%rbp), %rsi
leaq -0x190(%rbp), %rdi
callq 0x165f0
jmp 0x15385
movq -0x318(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x16620
jmp 0x1539a
leaq -0x190(%rbp), %rdi
callq 0x7320
jmp 0x15775
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x190(%rbp), %rdi
callq 0x7320
jmp 0x157a7
leaq -0xa8(%rbp), %rdi
movl $0x1, %esi
callq 0x16580
movq %rax, -0x320(%rbp)
jmp 0x153e2
movq -0x320(%rbp), %rdi
leaq 0x2b28c(%rip), %rsi     # 0x4067c
callq 0x16550
movb %al, -0x321(%rbp)
jmp 0x153fd
movb -0x321(%rbp), %al
testb $0x1, %al
jne 0x15409
jmp 0x1545d
leaq -0xa8(%rbp), %rdi
movl $0x2, %esi
callq 0x16580
movq %rax, -0x330(%rbp)
jmp 0x15423
movq -0x330(%rbp), %rsi
leaq -0x1b0(%rbp), %rdi
callq 0x165f0
jmp 0x15438
movq -0x10(%rbp), %rdi
addq $0x30, %rdi
leaq -0x1b0(%rbp), %rsi
callq 0x7660
leaq -0x1b0(%rbp), %rdi
callq 0x7320
jmp 0x15773
leaq -0xa8(%rbp), %rdi
movl $0x1, %esi
callq 0x16580
movq %rax, -0x338(%rbp)
jmp 0x15477
movq -0x338(%rbp), %rdi
leaq 0x2b9d4(%rip), %rsi     # 0x40e59
callq 0x16550
movb %al, -0x339(%rbp)
jmp 0x15492
movb -0x339(%rbp), %al
testb $0x1, %al
jne 0x154a1
jmp 0x15522
leaq -0xa8(%rbp), %rdi
movl $0x2, %esi
callq 0x16580
movq %rax, -0x348(%rbp)
jmp 0x154bb
movq -0x348(%rbp), %rsi
leaq -0x1d0(%rbp), %rdi
callq 0x165f0
jmp 0x154d0
leaq -0x1d0(%rbp), %rdi
callq 0x14b70
movb %al, -0x349(%rbp)
jmp 0x154e4
movb -0x349(%rbp), %cl
movq -0x10(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x50(%rax)
leaq -0x1d0(%rbp), %rdi
callq 0x7320
jmp 0x15771
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x1d0(%rbp), %rdi
callq 0x7320
jmp 0x157a7
leaq -0xa8(%rbp), %rdi
movl $0x1, %esi
callq 0x16580
movq %rax, -0x358(%rbp)
jmp 0x1553c
movq -0x358(%rbp), %rdi
leaq 0x2b915(%rip), %rsi     # 0x40e5f
callq 0x16550
movb %al, -0x359(%rbp)
jmp 0x15557
movb -0x359(%rbp), %al
testb $0x1, %al
jne 0x15566
jmp 0x15643
leaq -0xa8(%rbp), %rdi
movl $0x1, %esi
callq 0x16580
movq %rax, -0x368(%rbp)
jmp 0x15580
movq -0x368(%rbp), %rsi
leaq -0x1f0(%rbp), %rdi
callq 0x165f0
jmp 0x15595
leaq -0xa8(%rbp), %rdi
movl $0x2, %esi
callq 0x16580
movq %rax, -0x370(%rbp)
jmp 0x155af
movq -0x370(%rbp), %rsi
leaq -0x210(%rbp), %rdi
callq 0x165f0
jmp 0x155c4
leaq -0x1f0(%rbp), %rdi
leaq -0x210(%rbp), %rsi
callq 0x14bf0
movq %rax, -0x378(%rbp)
jmp 0x155e0
movq -0x378(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x58(%rax)
leaq -0x210(%rbp), %rdi
callq 0x7320
leaq -0x1f0(%rbp), %rdi
callq 0x7320
jmp 0x1576f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x15632
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x7320
leaq -0x1f0(%rbp), %rdi
callq 0x7320
jmp 0x157a7
movb $0x1, -0x271(%rbp)
movl $0x10, %edi
callq 0x7260
movq %rax, -0x388(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0xa8(%rbp), %rdi
callq 0x16580
movq %rax, -0x380(%rbp)
jmp 0x15674
movq -0x380(%rbp), %rsi
leaq -0x270(%rbp), %rdi
callq 0x16650
jmp 0x15689
leaq 0x2b7d4(%rip), %rsi     # 0x40e64
leaq -0x250(%rbp), %rdi
leaq -0x270(%rbp), %rdx
callq 0x12260
jmp 0x156a5
leaq 0x2b03c(%rip), %rdx     # 0x406e8
leaq -0x230(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0x8100
jmp 0x156c1
movq -0x388(%rbp), %rdi
leaq -0x230(%rbp), %rsi
callq 0x7910
jmp 0x156d6
movq -0x388(%rbp), %rdi
movb $0x0, -0x271(%rbp)
movq 0x488dd(%rip), %rsi     # 0x5dfc8
movq 0x488be(%rip), %rdx     # 0x5dfb0
callq 0x78c0
jmp 0x157d9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x15756
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x1574a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x1573e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x7320
leaq -0x250(%rbp), %rdi
callq 0x7320
leaq -0x270(%rbp), %rdi
callq 0x7320
testb $0x1, -0x271(%rbp)
jne 0x15761
jmp 0x1576d
movq -0x388(%rbp), %rdi
callq 0x73c0
jmp 0x157a7
jmp 0x15771
jmp 0x15773
jmp 0x15775
jmp 0x15777
jmp 0x15779
jmp 0x1577b
movl $0x0, -0xcc(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x16710
movl -0xcc(%rbp), %eax
testl %eax, %eax
je 0x157a2
jmp 0x1579d
jmp 0x14dcc
jmp 0x14dcc
leaq -0xa8(%rbp), %rdi
callq 0x16710
jmp 0x157c7
leaq -0x30(%rbp), %rdi
callq 0x7320
addq $0x390, %rsp            # imm = 0x390
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x7320
movq -0x38(%rbp), %rdi
callq 0x7930
nopl (%rax)