// File: fulhax[P]ncpamixer/src/config.cpp
// Function: Config::readConfig()
bool Config::readConfig()
{
    FILE *f = fopen(full_path.c_str(), "rb");
    if (f == nullptr) {
        fprintf(stderr, "Unable to open config file '%s'.\n", full_path.c_str());
        return false;
    }

    while (feof(f) == 0) {
      char line[MAX_LINE] = {0};
      bool instring = false;
      std::string key;
      std::string val;
      std::string *current = &key;

      if (fgets(&line[0], MAX_LINE, f) == nullptr) {
        break;
      }

      char *tmp = &line[0];

      while (*tmp != '\0' && *tmp != '\n' && *tmp != '\r') {
        if (*tmp == '=') {
          current = &val;
        } else if (*tmp == '#') {
          break;
        } else if (*tmp == '"') {
          instring = !instring;
        } else if (*tmp != ' ' || instring) {
          current->append(tmp, 1);
        }

        tmp++;
      }

      if (key.length() > 0) {
        config[key] = val;
      }
    }

    fclose(f);
    return true;
}

// Assembly:
subq $0x1e8, %rsp            # imm = 0x1E8
movq %rdi, 0x1d8(%rsp)
movq 0x1d8(%rsp), %rdi
movq %rdi, 0x30(%rsp)
addq $0x30, %rdi
callq 0x11210
movq %rax, %rdi
leaq 0x105e5(%rip), %rsi     # 0x204a4
callq 0x7820
movq %rax, 0x1d0(%rsp)
cmpq $0x0, 0x1d0(%rsp)
jne 0xff17
movq 0x30(%rsp), %rdi
movq 0x1b0c5(%rip), %rax     # 0x2afa8
movq (%rax), %rax
movq %rax, 0x28(%rsp)
addq $0x30, %rdi
callq 0x11210
movq 0x28(%rsp), %rdi
movq %rax, %rdx
leaq 0x105a4(%rip), %rsi     # 0x204a7
movb $0x0, %al
callq 0x79b0
movb $0x0, 0x1e7(%rsp)
jmp 0x1012c
jmp 0xff19
movq 0x1d0(%rsp), %rdi
callq 0x7a50
cmpl $0x0, %eax
jne 0x10117
leaq 0xa0(%rsp), %rdi
movq %rdi, 0x18(%rsp)
xorl %esi, %esi
movl $0x12c, %edx            # imm = 0x12C
callq 0x73d0
movb $0x0, 0x9f(%rsp)
leaq 0x78(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x7950
leaq 0x58(%rsp), %rdi
callq 0x7950
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rdi
movq %rax, 0x50(%rsp)
movq 0x1d0(%rsp), %rdx
movl $0x12c, %esi            # imm = 0x12C
callq 0x7aa0
movq %rax, 0x20(%rsp)
jmp 0xff91
movq 0x20(%rsp), %rax
cmpq $0x0, %rax
jne 0xffd0
movl $0x3, 0x40(%rsp)
jmp 0x100f2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x48(%rsp)
movl %eax, 0x44(%rsp)
leaq 0x58(%rsp), %rdi
callq 0x7480
leaq 0x78(%rsp), %rdi
callq 0x7480
jmp 0x1013d
leaq 0xa0(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, 0xf(%rsp)
je 0x10015
movq 0x38(%rsp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0xa, %ecx
movb %al, 0xf(%rsp)
je 0x10015
movq 0x38(%rsp), %rax
movsbl (%rax), %eax
cmpl $0xd, %eax
setne %al
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0x10022
jmp 0x100b3
movq 0x38(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x3d, %eax
jne 0x1003b
leaq 0x58(%rsp), %rax
movq %rax, 0x50(%rsp)
jmp 0x100a0
movq 0x38(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x23, %eax
jne 0x1004a
jmp 0x100b3
movq 0x38(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x22, %eax
jne 0x1006b
movb 0x9f(%rsp), %al
xorb $-0x1, %al
andb $0x1, %al
movb %al, 0x9f(%rsp)
jmp 0x1009c
movq 0x38(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x20, %eax
jne 0x10082
testb $0x1, 0x9f(%rsp)
je 0x1009a
movq 0x50(%rsp), %rdi
movq 0x38(%rsp), %rsi
movl $0x1, %edx
callq 0x70c0
jmp 0x10098
jmp 0x1009a
jmp 0x1009c
jmp 0x1009e
jmp 0x100a0
movq 0x38(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x38(%rsp)
jmp 0xffdd
leaq 0x78(%rsp), %rdi
callq 0x7a20
cmpq $0x0, %rax
jbe 0x100ea
movq 0x30(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x10c80
movq %rax, (%rsp)
jmp 0x100d8
movq (%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x7070
jmp 0x100e8
jmp 0x100ea
movl $0x0, 0x40(%rsp)
leaq 0x58(%rsp), %rdi
callq 0x7480
leaq 0x78(%rsp), %rdi
callq 0x7480
movl 0x40(%rsp), %eax
testl %eax, %eax
je 0x10112
jmp 0x10110
jmp 0x10117
jmp 0xff19
movq 0x1d0(%rsp), %rdi
callq 0x7690
movb $0x1, 0x1e7(%rsp)
movb 0x1e7(%rsp), %al
andb $0x1, %al
addq $0x1e8, %rsp            # imm = 0x1E8
retq
movq 0x48(%rsp), %rdi
callq 0x7c40
nopw (%rax,%rax)