// File: /workspace/github_cpp_makefile_star2_O1/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 $0xb8, %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 0x7a28
movq 0x8(%r12), %r15
xorl %ebx, %ebx
xorl %r13d, %r13d
movq $0x0, (%rsp)
xorl %ebp, %ebp
movzbl (%r15,%rbx), %r12d
leal 0x3(%r13), %eax
cmpl $0x3, %eax
ja 0x4e56
leaq 0x537a(%rip), %rcx      # 0xa118
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsbl %r12b, %esi
leaq 0x10(%rsp), %rdi
callq 0x32e0
xorl %eax, %eax
cmpl $0x5e, %r12d
sete %al
leal -0x3(%rax,%rax,4), %r13d
movzbl %bpl, %ebp
movl $0x1, %eax
cmovnel %eax, %ebp
jmp 0x4ea6
movsbl %r12b, %esi
leaq 0x10(%rsp), %rdi
callq 0x32e0
cmpl $0x25, %r12d
je 0x4e92
cmpl $0x3e, %r12d
je 0x4e8a
movl $0xfffffffe, %r13d      # imm = 0xFFFFFFFE
cmpl $0x7b, %r12d
je 0x4ea6
movb $0x1, %bpl
jmp 0x4e2f
xorl %r13d, %r13d
cmpl $0x22, %r12d
je 0x4e7e
cmpl $0x25, %r12d
jne 0x4ea6
movq $0x0, 0x18(%rsp)
movq 0x10(%rsp), %rax
movb $0x0, (%rax)
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
jmp 0x4ea6
movsbl %r12b, %esi
leaq 0x10(%rsp), %rdi
callq 0x32e0
xorl %r13d, %r13d
cmpl $0x7d, %r12d
setne %r13b
addl $-0x3, %r13d
jmp 0x4ea6
testl %r13d, %r13d
js 0x4f81
movsbl %r12b, %esi
leaq 0x10(%rsp), %rdi
callq 0x32e0
decl %r13d
movzbl %bpl, %ebp
movl $0x1, %eax
cmovel %eax, %ebp
jmp 0x4ea6
movq (%rsp), %rax
xorb $0x1, %al
movq %rax, (%rsp)
jmp 0x4ea6
movl $0x1, %r13d
jmp 0x4ea6
movq $0x0, 0x18(%rsp)
movq 0x10(%rsp), %rax
movb $0x0, (%rax)
xorl %r13d, %r13d
testb $0x1, %bpl
je 0x4f53
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 0x5a42
leaq 0x58(%rsp), %r13
movq %r13, %rdi
leaq 0x10(%rsp), %rsi
movq %r12, %rdx
callq 0x6364
movq 0x30(%rsp), %rdi
movq %r13, %rsi
callq 0x7a56
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x4f14
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x3390
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x4f30
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x3390
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x4f4c
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x3390
xorl %r13d, %r13d
xorl %ebp, %ebp
jmp 0x4f79
testl %r13d, %r13d
jne 0x4f79
movq (%r14), %rcx
addq 0x8(%r14), %rcx
movq 0x8(%rsp), %rax
cmpq %rcx, %rax
je 0x4fb5
cmpb %r12b, (%rax)
jne 0x4fd5
incq %rax
movq %rax, 0x8(%rsp)
xorl %r13d, %r13d
incq %rbx
jmp 0x4d85
leaq 0xa8(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x5267(%rip), %rsi      # 0xa1fb
leaq 0x5275(%rip), %rdx      # 0xa210
leaq 0x98(%rsp), %rdi
callq 0x4074
leaq 0x98(%rsp), %rsi
callq 0x4a84
movl $0x30, %edi
callq 0x31c0
movq %rax, %r14
leaq 0x5248(%rip), %rsi      # 0xa211
movq %rax, %rdi
xorl %edx, %edx
callq 0x60e4
jmp 0x4ff3
movl $0x30, %edi
callq 0x31c0
movq %rax, %r14
leaq 0x523f(%rip), %rsi      # 0xa228
movq %rax, %rdi
xorl %edx, %edx
callq 0x60e4
leaq 0x8ce6(%rip), %rsi      # 0xdce0
leaq 0x1127(%rip), %rdx      # 0x6128
movq %r14, %rdi
callq 0x3570
jmp 0x500b
movq %rax, %rbx
movq %r14, %rdi
callq 0x3280
jmp 0x50a2
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r14, %rdi
je 0x50a2
movq 0xa8(%rsp), %rsi
jmp 0x5093
jmp 0x509f
jmp 0x509f
movq %rax, %rbx
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x505e
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x3390
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x507f
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x3390
jmp 0x507f
movq %rax, %rbx
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x50a2
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x3390
jmp 0x50a2
jmp 0x509f
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x50be
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3390
movq %rbx, %rdi
callq 0x3590