// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rsi, %r14
movq %rdi, %r12
movq (%rsi), %rax
leaq 0x8(%rsp), %rcx
movq %rax, (%rcx)
leaq 0x20(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq %rdx, 0x30(%rsp)
movq %rdx, %rdi
callq 0x67e6
movq 0x8(%r12), %r15
xorl %ebx, %ebx
leaq 0x4a80(%rip), %r13      # 0x9118
xorl %r12d, %r12d
movq $0x0, (%rsp)
movzbl (%r15,%rbx), %ebp
leal 0x3(%r12), %eax
cmpl $0x3, %eax
ja 0x4752
movslq (%r13,%rax,4), %rax
addq %r13, %rax
jmpq *%rax
movsbl %bpl, %esi
leaq 0x10(%rsp), %rdi
callq 0x32c0
cmpl $0x5e, %ebp
jne 0x4769
pushq $0x2
jmp 0x47cb
movsbl %bpl, %esi
leaq 0x10(%rsp), %rdi
callq 0x32c0
cmpl $0x25, %ebp
je 0x47d1
cmpl $0x3e, %ebp
je 0x47c9
cmpl $0x7b, %ebp
jne 0x4769
pushq $-0x2
jmp 0x47cb
cmpl $0x22, %ebp
je 0x47bd
cmpl $0x25, %ebp
jne 0x47df
andq $0x0, 0x18(%rsp)
movq 0x10(%rsp), %rax
movb $0x0, (%rax)
pushq $-0x1
jmp 0x47cb
movsbl %bpl, %esi
leaq 0x10(%rsp), %rdi
callq 0x32c0
xorl %r12d, %r12d
cmpl $0x7d, %ebp
setne %r12b
addl $-0x3, %r12d
jmp 0x4800
movsbl %bpl, %esi
leaq 0x10(%rsp), %rdi
callq 0x32c0
decl %r12d
jne 0x4800
movq (%r14), %r8
addq 0x8(%r14), %r8
movzbl (%rsp), %ecx
andl $0x1, %ecx
leaq 0x38(%rsp), %r12
movq %r12, %rdi
leaq 0x8(%rsp), %rdx
callq 0x4e62
leaq 0x58(%rsp), %rbp
movq %rbp, %rdi
leaq 0x10(%rsp), %rsi
movq %r12, %rdx
callq 0x54b0
movq 0x30(%rsp), %rdi
movq %rbp, %rsi
callq 0x6814
movq %rbp, %rdi
callq 0x54e6
movq %r12, %rdi
callq 0x35d8
jmp 0x47fd
movq (%rsp), %rax
xorb $0x1, %al
movq %rax, (%rsp)
jmp 0x47df
pushq $0x1
popq %rax
movl %eax, %r12d
jmp 0x4800
andq $0x0, 0x18(%rsp)
movq 0x10(%rsp), %rax
movb $0x0, (%rax)
movq (%r14), %rcx
addq 0x8(%r14), %rcx
movq 0x8(%rsp), %rax
cmpq %rcx, %rax
je 0x4808
cmpb %bpl, (%rax)
jne 0x4826
incq %rax
movq %rax, 0x8(%rsp)
xorl %r12d, %r12d
incq %rbx
jmp 0x46a3
pushq $0x30
popq %rdi
callq 0x31a0
movq %rax, %r14
leaq 0x49e1(%rip), %rsi      # 0x91fb
movq %rax, %rdi
xorl %edx, %edx
callq 0x531c
jmp 0x4842
pushq $0x30
popq %rdi
callq 0x31a0
movq %rax, %r14
leaq 0x49da(%rip), %rsi      # 0x9212
movq %rax, %rdi
xorl %edx, %edx
callq 0x531c
leaq 0x9497(%rip), %rsi      # 0xdce0
leaq 0xb10(%rip), %rdx       # 0x5360
movq %r14, %rdi
callq 0x3520
jmp 0x485a
movq %rax, %rbx
movq %r14, %rdi
callq 0x3250
jmp 0x488c
jmp 0x4889
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x54e6
jmp 0x487b
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x35d8
jmp 0x488c
jmp 0x4889
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x35d8
movq %rbx, %rdi
callq 0x3530