// File: cybozu[P]yrmcds/cybozu/config_parser.cpp
// Function: cybozu::config_parser::load(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void config_parser::load(const std::string& path) {
    m_config.clear();

    std::ifstream is(path);
    if( !is )
        throw std::runtime_error("failed to open " + path);
    unsigned int lineno = 0;

    for( std::string l; std::getline(is, l); ) {
        lineno++;

        ltrim(l);
        rtrim(l);
        if( l.empty() || l[0] == '#' ) continue;

        std::size_t n = l.find('=');
        if( n == std::string::npos )
            throw parse_error(path, lineno);
        std::string key = l.substr(0, n);
        rtrim(key);
        std::string value = l.substr(n+1);
        ltrim(value);

        // unquote the value
        std::size_t len = value.size();
        if( len >= 2 && value[0] == '"' && value[len-1] == '"' ) {
            value = value.substr(1, len-2);
        }

        set(key, value);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x330, %rsp            # imm = 0x330
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x2f0(%rbp)
callq 0x28ca0
movq -0x10(%rbp), %rsi
leaq -0x218(%rbp), %rdi
movl $0x8, %edx
callq 0x8ab0
movq -0x218(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x218(%rbp,%rax), %rdi
callq 0x8290
movb %al, -0x2e1(%rbp)
jmp 0x287d8
movb -0x2e1(%rbp), %al
testb $0x1, %al
jne 0x287e7
jmp 0x288b8
movb $0x1, -0x249(%rbp)
movl $0x10, %edi
callq 0x82f0
movq %rax, -0x2f8(%rbp)
movq -0x10(%rbp), %rdx
leaq 0x524af(%rip), %rsi     # 0x7acb9
leaq -0x248(%rbp), %rdi
callq 0xe550
jmp 0x28818
movq -0x2f8(%rbp), %rdi
leaq -0x248(%rbp), %rsi
callq 0x8ac0
jmp 0x2882d
movq -0x2f8(%rbp), %rdi
movb $0x0, -0x249(%rbp)
movq 0x867ae(%rip), %rsi     # 0xaeff0
movq 0x86727(%rip), %rdx     # 0xaef70
callq 0x8b70
jmp 0x28c0a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
jmp 0x28bf2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
jmp 0x2889c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
leaq -0x248(%rbp), %rdi
callq 0x83f0
testb $0x1, -0x249(%rbp)
jne 0x288a7
jmp 0x288b3
movq -0x2f8(%rbp), %rdi
callq 0x8490
jmp 0x28bf2
movl $0x0, -0x250(%rbp)
leaq -0x270(%rbp), %rdi
callq 0x8930
leaq -0x218(%rbp), %rdi
leaq -0x270(%rbp), %rsi
callq 0x80b0
movq %rax, -0x300(%rbp)
jmp 0x288ea
movq -0x300(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x8810
movb %al, -0x301(%rbp)
jmp 0x28908
movb -0x301(%rbp), %al
testb $0x1, %al
jne 0x2893c
jmp 0x28914
leaq -0x270(%rbp), %rdi
callq 0x83f0
jmp 0x28bdd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
jmp 0x28bcf
movl -0x250(%rbp), %eax
incl %eax
movl %eax, -0x250(%rbp)
leaq -0x270(%rbp), %rdi
callq 0x28c10
jmp 0x28958
leaq -0x270(%rbp), %rdi
callq 0x28c50
jmp 0x28966
leaq -0x270(%rbp), %rdi
callq 0x8b10
testb $0x1, %al
jne 0x2899e
xorl %eax, %eax
movl %eax, %esi
leaq -0x270(%rbp), %rdi
callq 0x8d10
movq %rax, -0x310(%rbp)
jmp 0x2898f
movq -0x310(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x23, %eax
jne 0x289a3
jmp 0x288ce
leaq -0x270(%rbp), %rdi
movl $0x3d, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x8860
movq %rax, -0x278(%rbp)
cmpq $-0x1, -0x278(%rbp)
jne 0x28a33
movl $0x10, %edi
callq 0x82f0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x318(%rbp)
movq -0x10(%rbp), %rsi
movl -0x250(%rbp), %edx
callq 0x28cc0
jmp 0x289f1
movq -0x318(%rbp), %rdi
leaq 0x85a19(%rip), %rsi     # 0xae418
leaq 0x40a(%rip), %rdx       # 0x28e10
callq 0x8b70
jmp 0x28c0a
movq -0x318(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
callq 0x8490
jmp 0x28bcf
movq -0x278(%rbp), %rcx
xorl %eax, %eax
movl %eax, %edx
leaq -0x298(%rbp), %rdi
leaq -0x270(%rbp), %rsi
callq 0x8670
jmp 0x28a53
leaq -0x298(%rbp), %rdi
callq 0x28c50
jmp 0x28a61
movq -0x278(%rbp), %rdx
incq %rdx
leaq -0x2b8(%rbp), %rdi
leaq -0x270(%rbp), %rsi
movq $-0x1, %rcx
callq 0x8670
jmp 0x28a87
leaq -0x2b8(%rbp), %rdi
callq 0x28c10
jmp 0x28a95
leaq -0x2b8(%rbp), %rdi
callq 0x8450
movq %rax, -0x2c0(%rbp)
cmpq $0x2, -0x2c0(%rbp)
jb 0x28b8a
xorl %eax, %eax
movl %eax, %esi
leaq -0x2b8(%rbp), %rdi
callq 0x8d10
movq %rax, -0x320(%rbp)
jmp 0x28acf
movq -0x320(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x22, %eax
jne 0x28b8a
movq -0x2c0(%rbp), %rsi
decq %rsi
leaq -0x2b8(%rbp), %rdi
callq 0x8d10
movq %rax, -0x328(%rbp)
jmp 0x28b01
movq -0x328(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x22, %eax
jne 0x28b8a
movq -0x2c0(%rbp), %rcx
addq $-0x2, %rcx
leaq -0x2e0(%rbp), %rdi
leaq -0x2b8(%rbp), %rsi
movl $0x1, %edx
callq 0x8670
jmp 0x28b35
leaq -0x2b8(%rbp), %rdi
leaq -0x2e0(%rbp), %rsi
callq 0x8790
leaq -0x2e0(%rbp), %rdi
callq 0x83f0
jmp 0x28b8a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
jmp 0x28bc3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
leaq -0x2b8(%rbp), %rdi
callq 0x83f0
jmp 0x28bc3
movq -0x2f0(%rbp), %rdi
leaq -0x298(%rbp), %rsi
leaq -0x2b8(%rbp), %rdx
callq 0x28e30
jmp 0x28ba6
leaq -0x2b8(%rbp), %rdi
callq 0x83f0
leaq -0x298(%rbp), %rdi
callq 0x83f0
jmp 0x288ce
leaq -0x298(%rbp), %rdi
callq 0x83f0
leaq -0x270(%rbp), %rdi
callq 0x83f0
jmp 0x28bf2
leaq -0x218(%rbp), %rdi
callq 0x8150
addq $0x330, %rsp            # imm = 0x330
popq %rbp
retq
leaq -0x218(%rbp), %rdi
callq 0x8150
movq -0x220(%rbp), %rdi
callq 0x8bc0
nopw (%rax,%rax)