// File: /workspace/github_cpp_makefile_star2_O2/wrighteagle2d[P]wrighteaglebase/Debug/../src/Trainer.cpp
// Function: Trainer::ParseCondition(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void Trainer::ParseCondition(const std::string &content) {
  Trainer::Condition *nowCondition = mpEndCondition; //当前条件层
  bool beforeEquator = true;
  int n = 0;
  char name[128];
  char buffer[128];

  for (std::string::const_iterator it = content.begin(); it != content.end();
       it++) {
    switch (*it) {
    case '(':
      nowCondition = nowCondition->AddSubCondition(
          Condition(this, ET_Null, 0, 0, nowCondition, mConverse));
      break;
    case ')':
      buffer[n] = 0;
      if (n != 0)
        AddCondition(nowCondition, name, buffer);
      nowCondition = nowCondition->GetSuperCondition();
      beforeEquator = true;
      n = 0;
      break;
    case '&':
      buffer[n] = 0;
      if (nowCondition->GetConditionType() == ET_ORComplex) {
        Trainer::Condition *tmp;
        nowCondition->SetSuperCondition(
            new Trainer::Condition(this, ET_ANDComplex, 0, 0, 0, mConverse));
        tmp = nowCondition->GetSuperCondition();
        if (nowCondition == mpEndCondition) {
          mpEndCondition = tmp;
        }
        nowCondition = tmp;
        tmp = NULL;
      } else {
        nowCondition->SetConditionType(ET_ANDComplex);
      }
      if (n != 0)
        AddCondition(nowCondition, name, buffer);
      beforeEquator = true;
      n = 0;
      break;
    case '|':
      buffer[n] = 0;
      if (nowCondition->GetConditionType() ==
          ET_ANDComplex) //如果发生冲突，降一级
      {
        Trainer::Condition *tmp;
        nowCondition->SetSuperCondition(
            new Trainer::Condition(this, ET_ANDComplex, 0, 0, 0, mConverse));
        tmp = nowCondition->GetSuperCondition();
        if (nowCondition == mpEndCondition) {
          mpEndCondition = tmp;
        }
        nowCondition = tmp;
        tmp = NULL;
      } else {
        nowCondition->SetConditionType(ET_ORComplex);
      }
      if (n != 0)
        AddCondition(nowCondition, name, buffer);
      beforeEquator = true;
      n = 0;
      break;
    case '=':
      name[n] = 0;
      beforeEquator = !beforeEquator;
      n = 0;
      break;
    case ' ': //跳过空格
      break;
    default:
      if (beforeEquator) {
        name[n++] = *it;
      } else {
        buffer[n++] = *it;
      }
      break;
    }
  }
  if (n != 0) {
    buffer[n] = 0;
    AddCondition(nowCondition, name, buffer);
  }
  mpEndCondition->OptimizeConditionTree();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x168, %rsp            # imm = 0x168
movq %rsi, %r15
movq 0x158(%rdi), %r12
movq (%rsi), %rcx
leaq -0x78(%rbp), %r8
movb $0x1, %r10b
xorl %ebx, %ebx
movq %rcx, %r14
movq %rdi, -0x30(%rbp)
addq 0x8(%r15), %rcx
movslq %ebx, %rax
cmpq %rcx, %r14
je 0x455e0
movb (%r14), %cl
movzbl %cl, %edx
leal -0x20(%rdx), %esi
cmpl $0x9, %esi
ja 0x45431
leaq 0x1593c(%rip), %r9      # 0x5ad48
movslq (%r9,%rsi,4), %rdx
addq %r9, %rdx
jmpq *%rdx
movb $0x0, -0x110(%rbp,%rax)
cmpl $0xa, (%r12)
je 0x45452
movl $0x9, (%r12)
jmp 0x455a1
cmpl $0x3d, %edx
je 0x4557a
cmpl $0x7c, %edx
jne 0x454b6
movb $0x0, -0x110(%rbp,%rax)
cmpl $0x9, (%r12)
jne 0x45599
pushq $0x58
popq %rdi
callq 0x94d0
movq -0x30(%rbp), %rdi
movq %rax, %r13
movb 0x33(%rdi), %al
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%r13)
movups %xmm0, 0x28(%r13)
movq %rdi, 0x38(%r13)
movl $0x9, (%r13)
andl $0x0, 0x40(%r13)
movups %xmm0, 0x8(%r13)
movss 0x15919(%rip), %xmm0    # 0x5ada8
movups %xmm0, 0x44(%r13)
movb %al, 0x54(%r13)
movq %r13, 0x30(%r12)
cmpq 0x158(%rdi), %r12
jne 0x454ad
movq %r13, 0x158(%rdi)
leaq -0x78(%rbp), %r8
jmp 0x455a4
incl %ebx
testb $0x1, %r10b
je 0x4558a
movb %cl, -0x190(%rbp,%rax)
movb $0x1, %r10b
jmp 0x45594
movb $0x0, -0x110(%rbp,%rax)
testl %ebx, %ebx
je 0x454ff
movq -0x30(%rbp), %rdi
movq %r12, %rsi
leaq -0x190(%rbp), %rdx
leaq -0x110(%rbp), %rcx
callq 0x4563c
leaq -0x78(%rbp), %r8
movq -0x30(%rbp), %rdi
movq 0x30(%r12), %r13
movb $0x1, %r10b
jmp 0x455d0
movl %ebx, -0x34(%rbp)
movq %r15, %rbx
movl %r10d, %r15d
movb 0x33(%rdi), %al
xorps %xmm0, %xmm0
movups %xmm0, (%r8)
andq $0x0, 0x10(%r8)
movq %rdi, -0x58(%rbp)
andl $0x0, -0x90(%rbp)
movups %xmm0, -0x10(%r8)
movq %r12, -0x60(%rbp)
movsd 0x15710(%rip), %xmm0    # 0x5ac50
movups %xmm0, -0x50(%rbp)
andl $0x0, -0x40(%rbp)
movb %al, -0x3c(%rbp)
movq %r12, %rdi
leaq -0x90(%rbp), %rsi
movq %r8, %r12
callq 0x46008
movq %rax, %r13
movq %r12, %rdi
callq 0x4602e
movq -0x30(%rbp), %rdi
movq %r12, %r8
movl %r15d, %r10d
movq %rbx, %r15
movl -0x34(%rbp), %ebx
jmp 0x455d2
movb $0x0, -0x190(%rbp,%rax)
xorb $0x1, %r10b
xorl %ebx, %ebx
jmp 0x45594
movb %cl, -0x110(%rbp,%rax)
xorl %r10d, %r10d
movq %r12, %r13
jmp 0x455d2
movl $0xa, (%r12)
movq %r12, %r13
movb $0x1, %r10b
testl %ebx, %ebx
je 0x455d0
movq -0x30(%rbp), %rdi
movq %r13, %rsi
leaq -0x190(%rbp), %rdx
leaq -0x110(%rbp), %rcx
callq 0x4563c
movb $0x1, %r10b
leaq -0x78(%rbp), %r8
movq -0x30(%rbp), %rdi
xorl %ebx, %ebx
incq %r14
movq (%r15), %rcx
movq %r13, %r12
jmp 0x453e7
testl %ebx, %ebx
je 0x4560a
movb $0x0, -0x110(%rbp,%rax)
leaq -0x190(%rbp), %rdx
leaq -0x110(%rbp), %rcx
movq -0x30(%rbp), %rdi
movq %r12, %rsi
callq 0x4563c
movq -0x30(%rbp), %rdi
movq 0x158(%rdi), %rdi
callq 0x451ee
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq %r12, %rdi
callq 0x4602e
movq %rbx, %rdi
callq 0x98b0
nop