// File: /workspace/github_cpp_makefile_star2_O2/wrighteagle2d[P]wrighteaglebase/Debug/../src/Parser.cpp
// Function: Parser::ParseSense(char*)
void Parser::ParseSense(char *msg) {
  if (!PlayerParam::instance().isCoach() ||
      !PlayerParam::instance().isTrainer()) {
    TimeTest::instance().Update(
        mpObserver->CurrentTime()); // player每周期都有sense
  }

  NetworkTest::instance().Update(mpObserver->CurrentTime());
  NetworkTest::instance().Begin("Sense");

  parser::get_word(&msg);
  parser::get_next_word(&msg); // skip 'view'
  parser::get_next_word(&msg); // skip 'mode'
  parser::get_next_word(&msg); // skip not used view quality

  ViewWidth view_width = VW_None;
  switch (msg[1]) {
  case 'o':
    view_width = VW_Normal;
    break; /* normal */
  case 'a':
    view_width = VW_Narrow;
    break; /* narrow */
  case 'i':
    view_width = VW_Wide;
    break; /* wide   */
  default:
    PARSE_ERROR("Unknown view quality");
    break;
  }

  double stamina = parser::get_double(&msg);
  double effort = parser::get_double(&msg);
  double capacity = parser::get_double(&msg);

  double speed = parser::get_double(&msg);
  double speed_dir = parser::get_double(&msg);
  double neck_dir = parser::get_double(&msg);

  int kicks = parser::get_int(&msg);
  int dashes = parser::get_int(&msg);
  int turns = parser::get_int(&msg);
  int says = parser::get_int(&msg);
  int turn_necks = parser::get_int(&msg);
  int catchs = parser::get_int(&msg);
  int moves = parser::get_int(&msg);
  int change_views = parser::get_int(&msg);

  int arm_movable_ban = parser::get_int(&msg); // 直到下次手臂能动的剩余周期数
  int arm_expires = parser::get_int(&msg); // 直到手臂动作失效剩余的周期数
  double arm_target_dist = parser::get_double(&msg); // 指向的目标的距离
  AngleDeg arm_target_dir = parser::get_double(&msg); // 指向的目标的方向
  int points = parser::get_int(&msg);                 // point count
  parser::get_next_word(&msg);                        // focus
  parser::get_next_word(&msg);                        // target
  parser::get_next_word(&msg);                        // side
  char focus_side = msg[0];

  Unum focus_unum = 0;
  if (focus_side != 'l' && focus_side != 'r') { // 没有特别注意的队员
    focus_side = '?';
  } else { // 特别注意的队员号码
    focus_unum = parser::get_int(&msg);
  }
  int focuses = parser::get_int(&msg);
  int tackle_expires = parser::get_int(&msg);
  int tackles = parser::get_int(&msg);

  //以下是碰撞和犯规信息
  mpObserver->ClearCollisionState();

  parser::get_word(&msg);      // (collision {none|[(ball)][(player)][(post)]})
  parser::get_next_word(&msg); // skip 'collision'
  if (msg[0] != 'n') {
    do {
      switch (msg[1]) {
      case 'a':
        mpObserver->SetCollideWithBall();
        break;
      case 'l':
        mpObserver->SetCollideWithPlayer();
        break;
      case 'o':
        mpObserver->SetCollideWithPost();
        break;
      }
      parser::get_next_word(&msg);
    } while (msg[0] != 'f' && msg[0]);
  }

  int foul_charged_cycle = 0;
  CardType card_type = CR_None;

  if (msg[0]) { // v14
    foul_charged_cycle = parser::get_int(
        &msg); // (foul (charged CYCLE) (card {none|yellow|red})))
    parser::get_word(&msg);
    parser::get_next_word(&msg); // skip 'card'

    switch (msg[0]) {
    case 'n':
      break;
    case 'y':
      card_type = CR_Yellow;
      break;
    case 'r':
      card_type = CR_Red;
      break;
    }
  }

  mpObserver->SetSenseBody(
      view_width, stamina, effort, capacity,

      speed, speed_dir, neck_dir,

      kicks, dashes, turns, says, turn_necks, catchs, moves, change_views,

      arm_movable_ban, arm_expires, arm_target_dist, arm_target_dir, points,

      focus_side, focus_unum, focuses,

      tackle_expires, tackles,

      foul_charged_cycle, card_type, mpObserver->CurrentTime());

  NetworkTest::instance().SetCommandExecuteCount(
      dashes, kicks, turns, says, turn_necks, catchs, moves, change_views,
      points, tackles, focuses);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rdi, %rbx
movq %rsi, -0x30(%rbp)
callq 0x38d94
cmpb $0x1, 0x31a5(%rax)
jne 0x35b1d
callq 0x38d94
cmpb $0x0, 0x31a6(%rax)
jne 0x35b32
callq 0x4254e
movq 0x10(%rbx), %rcx
movq 0xc(%rcx), %rsi
movq %rax, %rdi
callq 0x425b0
callq 0x3018a
movq 0x10(%rbx), %rsi
addq $0xc, %rsi
movq %rax, %rdi
callq 0x3050c
callq 0x3018a
movq %rax, %r14
leaq 0x2386e(%rip), %rsi     # 0x593c4
leaq -0xf8(%rbp), %r15
leaq -0x39(%rbp), %rdx
movq %r15, %rdi
callq 0x10e4a
movq %r14, %rdi
movq %r15, %rsi
callq 0x301ec
leaq -0xf8(%rbp), %rdi
callq 0x9240
leaq -0x30(%rbp), %r14
movq %r14, %rdi
callq 0x38145
movq %r14, %rdi
callq 0x38180
movq %r14, %rdi
callq 0x38180
movq %r14, %rdi
callq 0x38180
movq (%r14), %rax
movzbl 0x1(%rax), %eax
cmpl $0x61, %eax
je 0x35bc4
cmpl $0x69, %eax
je 0x35bc0
xorl %ecx, %ecx
cmpl $0x6f, %eax
jne 0x35bc7
pushq $0x2
jmp 0x35bc6
pushq $0x3
jmp 0x35bc6
pushq $0x1
popq %rcx
movl %ecx, -0x38(%rbp)
leaq -0x30(%rbp), %r15
movq %r15, %rdi
callq 0x381af
movsd %xmm0, -0x98(%rbp)
movq %r15, %rdi
callq 0x381af
movsd %xmm0, -0x90(%rbp)
movq %r15, %rdi
callq 0x381af
movsd %xmm0, -0x88(%rbp)
movq %r15, %rdi
callq 0x381af
movsd %xmm0, -0x80(%rbp)
movq %r15, %rdi
callq 0x381af
movsd %xmm0, -0x78(%rbp)
movq %r15, %rdi
callq 0x381af
movsd %xmm0, -0x70(%rbp)
movq %r15, %rdi
callq 0x38103
movl %eax, %r14d
movq %r15, %rdi
callq 0x38103
movl %eax, %r13d
movq %r15, %rdi
callq 0x38103
movl %eax, -0x44(%rbp)
movq %r15, %rdi
callq 0x38103
movl %eax, -0x40(%rbp)
movq %r15, %rdi
callq 0x38103
movq %rax, -0xd0(%rbp)
movq %r15, %rdi
callq 0x38103
movq %rax, -0xd8(%rbp)
movq %r15, %rdi
callq 0x38103
movq %rax, -0xc8(%rbp)
movq %r15, %rdi
callq 0x38103
movq %rax, -0xc0(%rbp)
movq %r15, %rdi
callq 0x38103
movq %rax, -0x68(%rbp)
movq %r15, %rdi
callq 0x38103
movq %rax, -0xb0(%rbp)
movq %r15, %rdi
callq 0x381af
movsd %xmm0, -0x60(%rbp)
movq %r15, %rdi
callq 0x381af
movsd %xmm0, -0x58(%rbp)
movq %r15, %rdi
callq 0x38103
movq %rax, -0xb8(%rbp)
movq %r15, %rdi
callq 0x38180
movq %r15, %rdi
callq 0x38180
movq %r15, %rdi
callq 0x38180
movq (%r15), %rax
movzbl (%rax), %r12d
cmpl $0x72, %r12d
movl %r14d, -0x4c(%rbp)
movl %r13d, -0x48(%rbp)
je 0x35d04
cmpl $0x6c, %r12d
jne 0x35d12
leaq -0x30(%rbp), %rdi
callq 0x38103
movl %eax, %r15d
jmp 0x35d18
xorl %r15d, %r15d
movb $0x3f, %r12b
leaq -0x30(%rbp), %r14
movq %r14, %rdi
callq 0x38103
movq %rax, -0xa8(%rbp)
movq %r14, %rdi
callq 0x38103
movl %eax, %r13d
movq %r14, %rdi
callq 0x38103
movq %rax, -0xa0(%rbp)
movq 0x10(%rbx), %rax
andw $0x0, 0x1b0(%rax)
movb $0x0, 0x1b2(%rax)
movq %r14, %rdi
callq 0x38145
movq %r14, %rdi
callq 0x38180
movq (%r14), %rax
cmpb $0x6e, (%rax)
je 0x35dc4
movzbl 0x1(%rax), %eax
cmpl $0x6f, %eax
je 0x35d9d
cmpl $0x6c, %eax
je 0x35d90
cmpl $0x61, %eax
jne 0x35da8
movq 0x10(%rbx), %rax
movb $0x1, 0x1b2(%rax)
jmp 0x35da8
movq 0x10(%rbx), %rax
movb $0x1, 0x1b1(%rax)
jmp 0x35da8
movq 0x10(%rbx), %rax
movb $0x1, 0x1b0(%rax)
movq %r14, %rdi
callq 0x38180
movq -0x30(%rbp), %rax
movzbl (%rax), %ecx
testl %ecx, %ecx
je 0x35e86
cmpl $0x66, %ecx
jne 0x35d70
movl %r12d, -0x34(%rbp)
movq %r13, %r12
movq %r15, %r13
leaq -0x30(%rbp), %r15
movq %r15, %rdi
callq 0x38103
movl %eax, %r14d
movq %r15, %rdi
callq 0x38145
movq %r15, %rdi
callq 0x38180
movq (%r15), %rax
movzbl (%rax), %ecx
cmpl $0x72, %ecx
je 0x35e3f
xorl %eax, %eax
cmpl $0x79, %ecx
movl -0x38(%rbp), %esi
movsd -0x98(%rbp), %xmm0
movsd -0x90(%rbp), %xmm1
movsd -0x88(%rbp), %xmm2
movsd -0x80(%rbp), %xmm3
movsd -0x78(%rbp), %xmm4
movsd -0x70(%rbp), %xmm5
movq -0x68(%rbp), %r11
movsd -0x60(%rbp), %xmm6
movsd -0x58(%rbp), %xmm7
movq %r13, %r15
jne 0x35e7d
pushq $0x1
popq %rax
jmp 0x35e7d
pushq $0x2
popq %rax
movl -0x38(%rbp), %esi
movsd -0x98(%rbp), %xmm0
movsd -0x90(%rbp), %xmm1
movsd -0x88(%rbp), %xmm2
movsd -0x80(%rbp), %xmm3
movsd -0x78(%rbp), %xmm4
movsd -0x70(%rbp), %xmm5
movq -0x68(%rbp), %r11
movsd -0x60(%rbp), %xmm6
movsd -0x58(%rbp), %xmm7
movq %r13, %r15
movq %r12, %r13
movl -0x34(%rbp), %r12d
jmp 0x35ec3
xorl %r14d, %r14d
xorl %eax, %eax
movl -0x38(%rbp), %esi
movsd -0x98(%rbp), %xmm0
movsd -0x90(%rbp), %xmm1
movsd -0x88(%rbp), %xmm2
movsd -0x80(%rbp), %xmm3
movsd -0x78(%rbp), %xmm4
movsd -0x70(%rbp), %xmm5
movq -0x68(%rbp), %r11
movsd -0x60(%rbp), %xmm6
movsd -0x58(%rbp), %xmm7
movq 0x10(%rbx), %rdi
subq $0x8, %rsp
movsbl %r12b, %r10d
movl -0x4c(%rbp), %edx
movl -0x48(%rbp), %ecx
movl -0x44(%rbp), %r8d
movl -0x40(%rbp), %r9d
pushq 0xc(%rdi)
pushq %rax
pushq %r14
pushq -0xa0(%rbp)
pushq %r13
pushq -0xa8(%rbp)
pushq %r15
pushq %r10
movq -0xb8(%rbp), %r15
pushq %r15
pushq -0xb0(%rbp)
pushq %r11
movq -0xc0(%rbp), %r13
pushq %r13
movq -0xc8(%rbp), %r12
pushq %r12
movq -0xd8(%rbp), %r14
pushq %r14
movq -0xd0(%rbp), %rbx
pushq %rbx
callq 0x32fb0
addq $0x80, %rsp
callq 0x3018a
movq %rax, %rdi
movl -0x48(%rbp), %esi
movl -0x4c(%rbp), %edx
movl -0x44(%rbp), %ecx
movl -0x40(%rbp), %r8d
movl %ebx, %r9d
pushq -0xa8(%rbp)
pushq -0xa0(%rbp)
pushq %r15
pushq %r13
pushq %r12
pushq %r14
callq 0x308e4
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0xf8(%rbp), %rdi
callq 0x9240
movq %rbx, %rdi
callq 0x98b0
nop