// File: gasparfm[P]anapache/anapacheapp.cpp
// Function: AnapacheApp::parseLine(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>>&)
int AnapacheApp::parseLine(std :: string line, std :: map < std :: string, std :: string > & res)
{
  std::string::iterator lineit = line.begin();
  int kk = 0;
  bool keywordFound = false;
  std::string kword;
  bool quotes = false;
  int state = 0;		/* current state:
				   0 - Just reading
				   -1 - Reading first keyword character (a % has been read before)
				   -2 - Read a { as first keyword char, so let's wait for }" 
				   -3 - Waiting for keyword last char 
				   2  - Two characters pending
				   1  - One character pending */
  res.clear();
  for (char f : logFormat)
    {
      switch (state)
	{
	case 0:
	  if (f == '%')
	    {
	      state = -1;
	      kword.clear();
	    }
	  else if (f=='"')
	    quotes = !quotes;
	  break;
	case -1:
	  kword+=f;
	  if (f == '{')
	    state = -2;
	  else if (f == '>')
	    state = 1;
	  else if (f == '%')
	    {
	      state = 0;
	      kword.clear();
	    }
	  else
	    keywordFound = true;
	  break;
	case -2:
	  kword+=f;
	  if (f == '}')
	    state=-3;
	  break;
	case -3:
	  kword+=f;
	  if (f == '^')
	    state = 2;
	  else
	    keywordFound = true;
	  break;
	default:
	  if (state<0)
	    panic ("You shouldn't be here");
	  kword+=f;
	  if (--state==0)
	    keywordFound = true;
	}

      if (keywordFound)
	{
	  keywordFound = false;
	  auto data = readLogData(lineit, quotes, line.end());
	  res.insert({kword, data});

	  state = 0;
	}
      else if (state==0)
	{
	  if (lineit == line.end())
	    throw AnaException("Unexpected end of line");
	  else if (*lineit != f)
	    throw AnaException ("Unexpected character");
	  /* std::cout << "CHAR: '"<<*lineit<<"' EXPECTED: '"<<f<<"'\n"; */
	  ++lineit;
	  /* Normal character */
	}
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rsi, -0x140(%rbp)
movq %rdi, %rax
movq -0x140(%rbp), %rdi
movq %rdi, -0x138(%rbp)
movq %rax, -0x8(%rbp)
movq %rdi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x130(%rbp)
callq 0x43b0
movq %rax, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movb $0x0, -0x25(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x45e0
movb $0x0, -0x49(%rbp)
movl $0x0, -0x50(%rbp)
movq -0x18(%rbp), %rdi
callq 0x8850
movq -0x130(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
callq 0x43b0
movq %rax, -0x60(%rbp)
movq -0x58(%rbp), %rdi
callq 0x4270
movq %rax, -0x68(%rbp)
leaq -0x60(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x8870
testb $0x1, %al
jne 0x6b0a
jmp 0x6f2b
leaq -0x60(%rbp), %rdi
callq 0x88b0
movb (%rax), %al
movb %al, -0x69(%rbp)
movl -0x50(%rbp), %eax
addl $0x3, %eax
movl %eax, %ecx
movq %rcx, -0x148(%rbp)
subl $0x3, %eax
ja 0x6c36
movq -0x148(%rbp), %rax
leaq 0xc5e6(%rip), %rcx      # 0x13124
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsbl -0x69(%rbp), %eax
cmpl $0x25, %eax
jne 0x6b62
movl $0xffffffff, -0x50(%rbp) # imm = 0xFFFFFFFF
leaq -0x48(%rbp), %rdi
callq 0x45a0
jmp 0x6b77
movsbl -0x69(%rbp), %eax
cmpl $0x22, %eax
jne 0x6b75
movb -0x49(%rbp), %al
xorb $-0x1, %al
andb $0x1, %al
movb %al, -0x49(%rbp)
jmp 0x6b77
jmp 0x6cf8
movsbl -0x69(%rbp), %esi
leaq -0x48(%rbp), %rdi
callq 0x4290
jmp 0x6b8b
movsbl -0x69(%rbp), %eax
cmpl $0x7b, %eax
jne 0x6bae
movl $0xfffffffe, -0x50(%rbp) # imm = 0xFFFFFFFE
jmp 0x6be3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x6f2d
movsbl -0x69(%rbp), %eax
cmpl $0x3e, %eax
jne 0x6bc0
movl $0x1, -0x50(%rbp)
jmp 0x6be1
movsbl -0x69(%rbp), %eax
cmpl $0x25, %eax
jne 0x6bdb
movl $0x0, -0x50(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x45a0
jmp 0x6bdf
movb $0x1, -0x25(%rbp)
jmp 0x6be1
jmp 0x6be3
jmp 0x6cf8
movsbl -0x69(%rbp), %esi
leaq -0x48(%rbp), %rdi
callq 0x4290
jmp 0x6bf7
movsbl -0x69(%rbp), %eax
cmpl $0x7d, %eax
jne 0x6c07
movl $0xfffffffd, -0x50(%rbp) # imm = 0xFFFFFFFD
jmp 0x6cf8
movsbl -0x69(%rbp), %esi
leaq -0x48(%rbp), %rdi
callq 0x4290
jmp 0x6c1b
movsbl -0x69(%rbp), %eax
cmpl $0x5e, %eax
jne 0x6c2d
movl $0x2, -0x50(%rbp)
jmp 0x6c31
movb $0x1, -0x25(%rbp)
jmp 0x6cf8
cmpl $0x0, -0x50(%rbp)
jge 0x6cd5
leaq -0xa1(%rbp), %rdi
movq %rdi, -0x150(%rbp)
callq 0x46e0
movq -0x150(%rbp), %rdx
leaq 0xc5b6(%rip), %rsi      # 0x13217
leaq -0xa0(%rbp), %rdi
callq 0x5700
jmp 0x6c6f
movq -0x130(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x64e0
jmp 0x6c84
leaq -0xa0(%rbp), %rdi
callq 0x47a8
leaq -0xa1(%rbp), %rdi
callq 0x4490
jmp 0x6cd5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x6cc4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x47a8
leaq -0xa1(%rbp), %rdi
callq 0x4490
jmp 0x6f2d
movsbl -0x69(%rbp), %esi
leaq -0x48(%rbp), %rdi
callq 0x4290
jmp 0x6ce4
movl -0x50(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x50(%rbp)
cmpl $0x0, %eax
jne 0x6cf6
movb $0x1, -0x25(%rbp)
jmp 0x6cf8
testb $0x1, -0x25(%rbp)
je 0x6e07
movq -0x138(%rbp), %rdi
movb $0x0, -0x25(%rbp)
movzbl -0x49(%rbp), %eax
movl %eax, -0x154(%rbp)
callq 0x4270
movl -0x154(%rbp), %ecx
movq -0x130(%rbp), %rsi
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %r8
andl $0x1, %ecx
leaq -0xc8(%rbp), %rdi
leaq -0x20(%rbp), %rdx
callq 0x7ac0
jmp 0x6d4c
movq -0x18(%rbp), %rax
movq %rax, -0x160(%rbp)
leaq -0x110(%rbp), %rdi
leaq -0x48(%rbp), %rsi
leaq -0xc8(%rbp), %rdx
callq 0x8910
jmp 0x6d70
movq -0x160(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x88d0
movb %dl, -0x169(%rbp)
movq %rax, -0x168(%rbp)
jmp 0x6d92
movb -0x169(%rbp), %al
movq -0x168(%rbp), %rcx
movq %rcx, -0x120(%rbp)
movb %al, -0x118(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x8970
movl $0x0, -0x50(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x47a8
jmp 0x6f1b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x6df6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x8970
leaq -0xc8(%rbp), %rdi
callq 0x47a8
jmp 0x6f2d
cmpl $0x0, -0x50(%rbp)
jne 0x6f19
movq -0x138(%rbp), %rdi
callq 0x4270
movq %rax, -0x128(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x89a0
testb $0x1, %al
jne 0x6e3a
jmp 0x6e9d
movl $0x30, %edi
callq 0x4210
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x178(%rbp)
leaq 0xc3d5(%rip), %rsi      # 0x1322d
xorl %edx, %edx
callq 0x83b0
jmp 0x6e61
movq -0x178(%rbp), %rdi
leaq 0x14e61(%rip), %rsi     # 0x1bcd0
leaq 0x15da(%rip), %rdx      # 0x8450
callq 0x46a0
jmp 0x6f3f
movq -0x178(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
callq 0x4310
jmp 0x6f2d
leaq -0x20(%rbp), %rdi
callq 0x88b0
movsbl (%rax), %eax
movsbl -0x69(%rbp), %ecx
cmpl %ecx, %eax
je 0x6f0e
movl $0x30, %edi
callq 0x4210
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x180(%rbp)
leaq 0xc375(%rip), %rsi      # 0x13244
xorl %edx, %edx
callq 0x83b0
jmp 0x6ed8
movq -0x180(%rbp), %rdi
leaq 0x14dea(%rip), %rsi     # 0x1bcd0
leaq 0x1563(%rip), %rdx      # 0x8450
callq 0x46a0
jmp 0x6f3f
movq -0x180(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
callq 0x4310
jmp 0x6f2d
jmp 0x6f10
leaq -0x20(%rbp), %rdi
callq 0x89e0
jmp 0x6f1b
jmp 0x6f1d
leaq -0x60(%rbp), %rdi
callq 0x89e0
jmp 0x6af4
ud2
leaq -0x48(%rbp), %rdi
callq 0x47a8
movq -0x78(%rbp), %rdi
callq 0x46c0
nop