// File: /workspace/github_cpp_makefile_star2_O3/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)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq %rdx, 0x30(%rsp)
movq %rdx, %rdi
callq 0x7968
movq 0x8(%r12), %r15
xorl %ebx, %ebx
leaq 0x539d(%rip), %r13      # 0xa118
xorl %r12d, %r12d
movq $0x0, (%rsp)
movzbl (%r15,%rbx), %ebp
leal 0x3(%r12), %eax
cmpl $0x3, %eax
ja 0x4e44
movslq (%r13,%rax,4), %rax
addq %r13, %rax
jmpq *%rax
movsbl %bpl, %esi
leaq 0x10(%rsp), %rdi
callq 0x32e0
movl $0x2, %r12d
cmpl $0x5e, %ebp
jne 0x4e5b
jmp 0x4f3f
movsbl %bpl, %esi
leaq 0x10(%rsp), %rdi
callq 0x32e0
cmpl $0x25, %ebp
je 0x4f0d
cmpl $0x3e, %ebp
je 0x4f05
movl $0xfffffffe, %r12d      # imm = 0xFFFFFFFE
cmpl $0x7b, %ebp
jne 0x4e5b
jmp 0x4f3f
cmpl $0x22, %ebp
je 0x4ef9
cmpl $0x25, %ebp
jne 0x4f1e
movq $0x0, 0x18(%rsp)
movq 0x10(%rsp), %rax
movb $0x0, (%rax)
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
jmp 0x4f3f
movsbl %bpl, %esi
leaq 0x10(%rsp), %rdi
callq 0x32e0
xorl %r12d, %r12d
cmpl $0x7d, %ebp
setne %r12b
addl $-0x3, %r12d
jmp 0x4f3f
movsbl %bpl, %esi
leaq 0x10(%rsp), %rdi
callq 0x32e0
decl %r12d
jne 0x4f3f
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 0x59b6
leaq 0x58(%rsp), %rbp
movq %rbp, %rdi
leaq 0x10(%rsp), %rsi
movq %r12, %rdx
callq 0x62ce
movq 0x30(%rsp), %rdi
movq %rbp, %rsi
callq 0x7996
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x4ebf
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x3390
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x4edb
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x3390
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x4f3c
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x3390
jmp 0x4f3c
movq (%rsp), %rax
xorb $0x1, %al
movq %rax, (%rsp)
jmp 0x4f1e
movl $0x1, %r12d
jmp 0x4f3f
movq $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 0x4f47
cmpb %bpl, (%rax)
jne 0x4f67
incq %rax
movq %rax, 0x8(%rsp)
xorl %r12d, %r12d
incq %rbx
jmp 0x4d86
movl $0x30, %edi
callq 0x31c0
movq %rax, %r14
leaq 0x52a0(%rip), %rsi      # 0xa1fb
movq %rax, %rdi
xorl %edx, %edx
callq 0x604e
jmp 0x4f85
movl $0x30, %edi
callq 0x31c0
movq %rax, %r14
leaq 0x5297(%rip), %rsi      # 0xa212
movq %rax, %rdi
xorl %edx, %edx
callq 0x604e
leaq 0x8d54(%rip), %rsi      # 0xdce0
leaq 0x10ff(%rip), %rdx      # 0x6092
movq %r14, %rdi
callq 0x3570
jmp 0x4f9d
movq %rax, %rbx
movq %r14, %rdi
callq 0x3280
jmp 0x5015
jmp 0x5012
movq %rax, %rbx
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x4fd1
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x3390
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x4ff2
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x3390
jmp 0x4ff2
movq %rax, %rbx
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x5015
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x3390
jmp 0x5015
jmp 0x5012
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x5031
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3390
movq %rbx, %rdi
callq 0x3590
nop