// File: tylerkaraszewski[P]Argyle/Config.cpp
// Function: Config::import()
void Config::import()
{

  FILE* file = fopen(m_configFile.c_str(), "r");
  if (file == NULL)
  {
    return;
  }

  char buffer[S_READ_SIZE];
  bool doneReading = false;
  size_t remaining = 0;
  while (!doneReading)
  {
    size_t readSize = S_READ_SIZE - remaining;
    size_t bytesRead = fread(buffer + remaining, 1, readSize, file);
    if (bytesRead < readSize)
    {
      doneReading = true;
    }

    // parse what we've read so far.
    vector<string> lines;
    char* start = buffer;
    char* end = buffer;
    while (end < (buffer + bytesRead + remaining))
    {
      // Skip to a useful character.
      if ((*start == '\n') || (*start == '\r'))
      {
        start++;
        end++;
        continue;
      }

      end++;
      if ((*end == '\n') || (*end == '\r'))
      {
        lines.push_back(string(start, end - start));
        start = end;
      }
    }
    for (size_t i = 0; i < lines.size(); i++)
    {
      parseLine(lines[i]);
    }
    remaining = end - start;
    memmove(buffer, start, remaining);
  }
  // We still have one line in the buffer if it didn't have a terminating newline.
  parseLine(string(buffer, remaining));

  int fileError = ferror(file);
  if (fileError)
  {
    // Log?
  }
  fclose(file);
  return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xf8(%rbp)
callq 0x4190
movq %rax, %rdi
leaq 0x2526(%rip), %rsi      # 0x1394f
callq 0x4480
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x1143e
jmp 0x117f2
movq 0x7f9b(%rip), %rax      # 0x193e0
movq %rsp, %rcx
movq %rcx, -0x18(%rbp)
movq %rax, %rdx
addq $0xf, %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x100(%rbp)
movq %rcx, %rsp
movq %rax, -0x20(%rbp)
movb $0x0, -0x21(%rbp)
movq $0x0, -0x30(%rbp)
movb -0x21(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x11485
jmp 0x1171a
movq -0x100(%rbp), %rdi
movq 0x7f4d(%rip), %rax      # 0x193e0
subq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
addq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rdx
movq -0x10(%rbp), %rcx
movl $0x1, %esi
callq 0x45a0
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x38(%rbp), %rax
jae 0x114c3
movb $0x1, -0x21(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x11d50
movq -0x100(%rbp), %rax
movq %rax, -0x60(%rbp)
movq %rax, -0x68(%rbp)
movq -0x100(%rbp), %rcx
movq -0x68(%rbp), %rax
addq -0x40(%rbp), %rcx
addq -0x30(%rbp), %rcx
cmpq %rcx, %rax
jae 0x1161c
movq -0x60(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xa, %eax
je 0x1150f
movq -0x60(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xd, %eax
jne 0x11529
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
jmp 0x114db
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xa, %eax
je 0x11551
movq -0x68(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xd, %eax
jne 0x11617
movq -0x60(%rbp), %rcx
movq %rcx, -0x118(%rbp)
movq -0x68(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x110(%rbp)
leaq -0x89(%rbp), %rdi
movq %rdi, -0x108(%rbp)
callq 0x46c0
movq -0x118(%rbp), %rsi
movq -0x110(%rbp), %rdx
movq -0x108(%rbp), %rcx
leaq -0x88(%rbp), %rdi
callq 0x4440
jmp 0x115a0
leaq -0x58(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x11d60
jmp 0x115b2
leaq -0x88(%rbp), %rdi
callq 0x4788
leaq -0x89(%rbp), %rdi
callq 0x4400
movq -0x68(%rbp), %rax
movq %rax, -0x60(%rbp)
jmp 0x11617
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x11606
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x4788
leaq -0x89(%rbp), %rdi
callq 0x4400
jmp 0x1170c
jmp 0x114db
movq $0x0, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0x120(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x11d90
movq %rax, %rcx
movq -0x120(%rbp), %rax
cmpq %rcx, %rax
jae 0x116db
movq -0xa8(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x11db0
movq %rax, %rsi
leaq -0xc8(%rbp), %rdi
callq 0x41b0
jmp 0x11672
movq -0xf8(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x11810
jmp 0x11687
leaq -0xc8(%rbp), %rdi
callq 0x4788
movq -0xa8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa8(%rbp)
jmp 0x11627
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x1170c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x4788
jmp 0x1170c
movq -0x100(%rbp), %rdi
movq -0x68(%rbp), %rax
movq -0x60(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x60(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x4640
leaq -0x58(%rbp), %rdi
callq 0x11dd0
jmp 0x11477
leaq -0x58(%rbp), %rdi
callq 0x11dd0
jmp 0x117f7
movq -0x30(%rbp), %rax
movq %rax, -0x130(%rbp)
leaq -0xe9(%rbp), %rdi
movq %rdi, -0x128(%rbp)
callq 0x46c0
movq -0x100(%rbp), %rsi
movq -0x130(%rbp), %rdx
movq -0x128(%rbp), %rcx
leaq -0xe8(%rbp), %rdi
callq 0x4440
jmp 0x1175b
movq -0xf8(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x11810
jmp 0x11770
leaq -0xe8(%rbp), %rdi
callq 0x4788
leaq -0xe9(%rbp), %rdi
callq 0x4400
movq -0x10(%rbp), %rdi
callq 0x4700
movl %eax, -0xf0(%rbp)
cmpl $0x0, -0xf0(%rbp)
je 0x117e2
jmp 0x117e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x117d4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x4788
leaq -0xe9(%rbp), %rdi
callq 0x4400
jmp 0x117f7
movq -0x10(%rbp), %rdi
callq 0x43a0
movq -0x18(%rbp), %rax
movq %rax, %rsp
movq %rbp, %rsp
popq %rbp
retq
movq -0x98(%rbp), %rdi
callq 0x46b0
nopw %cs:(%rax,%rax)