// File: ian-howell[P]configparser/src/config_parser.cpp
// Function: Config::Config(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
Config::Config(std::string filename)
{
    std::ifstream fin(filename);

    if (fin.good())
    {
        std::string line;
        std::string current_header = "";
        while (std::getline(fin, line))
        {
            trim(line);

            // Skip empty lines
            if (line.size() == 0)
                continue;

            switch (line[0])
            {
                case '#':
                case ';':
                    // Ignore comments
                    break;
                case '[':
                    // Section header
                    current_header = read_header(line);
                    break;
                default:
                    // Everything else will be configurations
                    read_configuration(line, current_header);
            }
        }
        fin.close();
    }
    else
    {
        throw std::runtime_error("File `" + filename + "` does not exist");
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x330, %rsp            # imm = 0x330
movq %rsi, -0x2e0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x2f0(%rbp)
movq %rdi, %rax
movq %rax, -0x2e8(%rbp)
callq 0x4ce0
movq -0x2e0(%rbp), %rsi
leaq -0x218(%rbp), %rdi
movl $0x8, %edx
callq 0x33c0
jmp 0x368e
movq -0x218(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x218(%rbp,%rax), %rdi
callq 0x3400
movb %al, -0x2f1(%rbp)
jmp 0x36ae
movb -0x2f1(%rbp), %al
testb $0x1, %al
jne 0x36bd
jmp 0x38d2
leaq -0x248(%rbp), %rdi
callq 0x3350
leaq -0x269(%rbp), %rdi
movq %rdi, -0x300(%rbp)
callq 0x3450
movq -0x300(%rbp), %rdx
leaq 0x5966(%rip), %rsi      # 0x9050
leaq -0x268(%rbp), %rdi
callq 0x4d00
jmp 0x36f8
leaq -0x269(%rbp), %rdi
callq 0x32c0
leaq -0x218(%rbp), %rdi
leaq -0x248(%rbp), %rsi
callq 0x3080
movq %rax, -0x308(%rbp)
jmp 0x3720
movq -0x308(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x3330
movb %al, -0x309(%rbp)
jmp 0x373e
movb -0x309(%rbp), %al
testb $0x1, %al
jne 0x374d
jmp 0x3896
movq -0x2e8(%rbp), %rdi
leaq -0x248(%rbp), %rsi
callq 0x3a10
jmp 0x3762
leaq -0x248(%rbp), %rdi
callq 0x31d0
cmpq $0x0, %rax
jne 0x37ea
jmp 0x3704
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
jmp 0x39e9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
jmp 0x39dd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
leaq -0x269(%rbp), %rdi
callq 0x32c0
jmp 0x38c1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
leaq -0x268(%rbp), %rdi
callq 0x31a0
jmp 0x38c1
xorl %eax, %eax
movl %eax, %esi
leaq -0x248(%rbp), %rdi
callq 0x34b0
movq %rax, -0x318(%rbp)
jmp 0x3803
movq -0x318(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x31c(%rbp)
subl $0x23, %eax
je 0x3834
jmp 0x381a
movl -0x31c(%rbp), %eax
subl $0x3b, %eax
je 0x3834
jmp 0x3827
movl -0x31c(%rbp), %eax
subl $0x5b, %eax
je 0x3836
jmp 0x3873
jmp 0x3891
movq -0x2e8(%rbp), %rsi
leaq -0x290(%rbp), %rdi
leaq -0x248(%rbp), %rdx
callq 0x3a50
jmp 0x3852
leaq -0x268(%rbp), %rdi
leaq -0x290(%rbp), %rsi
callq 0x3310
leaq -0x290(%rbp), %rdi
callq 0x31a0
jmp 0x3891
movq -0x2e8(%rbp), %rdi
leaq -0x248(%rbp), %rsi
leaq -0x268(%rbp), %rdx
callq 0x3c10
jmp 0x388f
jmp 0x3891
jmp 0x3704
leaq -0x218(%rbp), %rdi
callq 0x3090
jmp 0x38a4
leaq -0x268(%rbp), %rdi
callq 0x31a0
leaq -0x248(%rbp), %rdi
callq 0x31a0
jmp 0x39c8
leaq -0x248(%rbp), %rdi
callq 0x31a0
jmp 0x39dd
movb $0x1, -0x2d1(%rbp)
movl $0x10, %edi
callq 0x3150
movq -0x2e0(%rbp), %rdx
movq %rax, -0x328(%rbp)
leaq 0x572c(%rip), %rsi      # 0x9024
leaq -0x2d0(%rbp), %rdi
callq 0x4e00
jmp 0x3906
leaq 0x571e(%rip), %rdx      # 0x902b
leaq -0x2b0(%rbp), %rdi
leaq -0x2d0(%rbp), %rsi
callq 0x4db0
jmp 0x3922
movq -0x328(%rbp), %rdi
leaq -0x2b0(%rbp), %rsi
callq 0x33d0
jmp 0x3937
movq -0x328(%rbp), %rdi
movb $0x0, -0x2d1(%rbp)
movq 0xa6a4(%rip), %rsi      # 0xdff0
movq 0xa665(%rip), %rdx      # 0xdfb8
callq 0x3410
jmp 0x3a01
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
jmp 0x39af
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
jmp 0x39a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
leaq -0x2b0(%rbp), %rdi
callq 0x31a0
leaq -0x2d0(%rbp), %rdi
callq 0x31a0
testb $0x1, -0x2d1(%rbp)
jne 0x39ba
jmp 0x39c6
movq -0x328(%rbp), %rdi
callq 0x31f0
jmp 0x39dd
leaq -0x218(%rbp), %rdi
callq 0x30b0
addq $0x330, %rsp            # imm = 0x330
popq %rbp
retq
leaq -0x218(%rbp), %rdi
callq 0x30b0
movq -0x2f0(%rbp), %rdi
callq 0x4f10
movq -0x220(%rbp), %rdi
callq 0x3440
nopw %cs:(%rax,%rax)