// File: /workspace/github_cpp_makefile_star2_O2/wrighteagle2d[P]wrighteaglebase/Debug/../src/ServerParam.cpp
// Function: ServerParam::MaintainConsistency()
void ServerParam::MaintainConsistency() {
  M_kickable_area = M_player_size + M_kickable_margin + M_ball_size;
  M_control_radius_width = M_control_radius - M_player_size;

  M_max_catchable_area =
      Vector(M_catchable_area_l, 0.5 * M_catchable_area_w).Mod();
  M_one_minus_ball_decay = 1.0 - M_ball_decay;
  M_log_ball_decay = log(M_ball_decay);

  M_ball_decay_array[0] = 1.0;
  for (int i = 1; i < 100; ++i) {
    M_ball_decay_array[i] = M_ball_decay_array[i - 1] * M_ball_decay;
  }

  // set the field information
  M_left_line =
      Line(Vector(-PITCH_LENGTH / 2.0, 0.0), Vector(-PITCH_LENGTH / 2.0, 1.0));
  M_right_line =
      Line(Vector(PITCH_LENGTH / 2.0, 0.0), Vector(PITCH_LENGTH / 2.0, 1.0));
  M_top_line =
      Line(Vector(0.0, -PITCH_WIDTH / 2.0), Vector(1.0, -PITCH_WIDTH / 2.0));
  M_bottom_line =
      Line(Vector(0.0, PITCH_WIDTH / 2.0), Vector(1.0, PITCH_WIDTH / 2.0));

  M_pitch_rectanglar = Rectangular(-PITCH_LENGTH / 2.0, PITCH_LENGTH / 2.0,
                                   -PITCH_WIDTH / 2.0, PITCH_WIDTH / 2.0);
  M_active_rectanglar =
      Rectangular(-PITCH_LENGTH / 2.0 + 1.0, PITCH_LENGTH / 2.0 - 1.0,
                  -PITCH_WIDTH / 2.0 + 1.0, PITCH_WIDTH / 2.0 - 1.0);
  M_our_penalty_area = Rectangular(
      -PITCH_LENGTH / 2.0, -PITCH_LENGTH / 2.0 + PENALTY_AREA_LENGTH,
      -PENALTY_AREA_WIDTH / 2.0, PENALTY_AREA_WIDTH / 2.0);
  M_opp_penalty_area =
      Rectangular(PITCH_LENGTH / 2.0 - PENALTY_AREA_LENGTH, PITCH_LENGTH / 2.0,
                  -PENALTY_AREA_WIDTH / 2.0, PENALTY_AREA_WIDTH / 2.0);
  M_our_goal_area =
      Rectangular(-PITCH_LENGTH / 2.0, -PITCH_LENGTH / 2.0 + GOAL_AREA_LENGTH,
                  -GOAL_AREA_WIDTH / 2.0, GOAL_AREA_WIDTH / 2.0);
  M_opp_goal_area =
      Rectangular(PITCH_LENGTH / 2.0 - GOAL_AREA_LENGTH, PITCH_LENGTH / 2.0,
                  -GOAL_AREA_WIDTH / 2.0, GOAL_AREA_WIDTH / 2.0);

  M_our_left_goal_kick_point = M_our_goal_area.TopRightCorner();
  M_our_right_goal_kick_point = M_our_goal_area.BottomRightCorner();
  M_opp_left_goal_kick_point = M_opp_goal_area.TopLeftCorner();
  M_opp_right_goal_kick_point = M_opp_goal_area.BottomLeftCorner();

  M_our_left_goal_post.SetValue(-PITCH_LENGTH / 2.0, -M_goal_width / 2.0);
  M_our_right_goal_post.SetValue(-PITCH_LENGTH / 2.0, M_goal_width / 2.0);
  M_opp_left_goal_post.SetValue(PITCH_LENGTH / 2.0, -M_goal_width / 2.0);
  M_opp_right_goal_post.SetValue(PITCH_LENGTH / 2.0, M_goal_width / 2.0);

  M_pitch_top_left_point = M_pitch_rectanglar.TopLeftCorner();
  M_pitch_bottom_left_point = M_pitch_rectanglar.BottomLeftCorner();
  M_pitch_top_right_point = M_pitch_rectanglar.TopRightCorner();
  M_pitch_bottom_right_point = M_pitch_rectanglar.BottomRightCorner();

  M_our_goal = Vector(-PITCH_LENGTH / 2.0, 0.0);
  M_opp_goal = Vector(PITCH_LENGTH / 2.0, 0.0);

  M_ball_run_dist_with_max_speed = M_ball_speed_max / M_one_minus_ball_decay;
  M_max_tackle_dist =
      Sqrt(M_tackle_dist * M_tackle_dist + M_tackle_width * M_tackle_width);

  M_effort_dec_stamina = M_effort_dec_thr * M_stamina_max;
  M_effort_inc_stamina = M_effort_inc_thr * M_stamina_max;
  M_recover_dec_stamina = M_recover_dec_thr * M_stamina_max;

  M_half_time = M_half_time * 1000 / M_simulator_step;
  M_extra_half_time = M_extra_half_time * 1000 / M_simulator_step;

  M_max_tackle_area = 0.0;
  int exponent = Max(M_foul_exponent, M_tackle_exponent);

  for (double x = 0.0; x <= M_tackle_dist; x += 0.01) {
    for (double y = 0.0; y <= M_tackle_width; y += 0.01) {
      double prob = 1.0 - MinMax(0.0,
                                 pow(x / M_tackle_dist, exponent) +
                                     pow(y / M_tackle_width, exponent),
                                 1.0);

      if (prob > FLOAT_EPS) {
        M_max_tackle_area = Max(M_max_tackle_area, Sqrt(Sqr(x) + Sqr(y)));
      }
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, %rbx
movsd 0x3018(%rdi), %xmm1
movsd 0x30e0(%rdi), %xmm0
movsd 0x3118(%rdi), %xmm2
addsd %xmm1, %xmm2
addsd 0x30d8(%rdi), %xmm2
movsd %xmm2, 0x31a8(%rdi)
movsd 0x3120(%rdi), %xmm2
subsd %xmm1, %xmm2
movsd %xmm2, 0x3128(%rdi)
movsd 0x31b8(%rdi), %xmm1
mulsd 0x19b8a(%rip), %xmm1    # 0x57848
movsd 0x31b0(%rdi), %xmm2
mulsd %xmm1, %xmm1
mulsd %xmm2, %xmm2
addsd %xmm1, %xmm2
sqrtsd %xmm2, %xmm1
movsd %xmm1, 0x3458(%rdi)
movsd 0x19362(%rip), %xmm1    # 0x57048
subsd %xmm0, %xmm1
movsd %xmm1, 0x3460(%rdi)
callq 0x93f0
movsd 0x19349(%rip), %xmm1    # 0x57048
movsd %xmm0, 0x3468(%rbx)
movabsq $0x3ff0000000000000, %r13 # imm = 0x3FF0000000000000
movq %r13, 0x3470(%rbx)
movsd 0x30e0(%rbx), %xmm0
xorl %eax, %eax
cmpq $0x63, %rax
je 0x3dd3a
mulsd %xmm0, %xmm1
movsd %xmm1, 0x3478(%rbx,%rax,8)
incq %rax
jmp 0x3dd22
movabsq $-0x3fb5c00000000000, %rax # imm = 0xC04A400000000000
leaq -0x68(%rbp), %r14
movq %rax, (%r14)
andq $0x0, 0x8(%r14)
leaq -0x58(%rbp), %r15
movq %rax, (%r15)
movq %r13, 0x8(%r15)
leaq -0x98(%rbp), %r12
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x12e9a
movq 0x10(%r12), %rax
movq %rax, 0x37a0(%rbx)
movups (%r12), %xmm0
movups %xmm0, 0x3790(%rbx)
movabsq $0x404a400000000000, %rax # imm = 0x404A400000000000
movq %rax, (%r14)
andq $0x0, 0x8(%r14)
movq %rax, (%r15)
movq %r13, 0x8(%r15)
leaq -0x98(%rbp), %r14
leaq -0x68(%rbp), %r15
leaq -0x58(%rbp), %r12
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x12e9a
movq 0x10(%r14), %rax
movq %rax, 0x37b8(%rbx)
movups (%r14), %xmm0
movups %xmm0, 0x37a8(%rbx)
andq $0x0, (%r15)
movabsq $-0x3fbf000000000000, %rax # imm = 0xC041000000000000
movq %rax, 0x8(%r15)
movq %r13, (%r12)
movq %rax, 0x8(%r12)
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x12e9a
movq 0x10(%r14), %rax
movq %rax, 0x37d0(%rbx)
movups (%r14), %xmm0
movups %xmm0, 0x37c0(%rbx)
andq $0x0, (%r15)
movabsq $0x4041000000000000, %rax # imm = 0x4041000000000000
movq %rax, 0x8(%r15)
movq %r13, (%r12)
movq %rax, 0x8(%r12)
movq %rax, %r15
leaq -0x68(%rbp), %rsi
leaq -0x58(%rbp), %rdx
movq %r14, %rdi
callq 0x12e9a
movq 0x10(%r14), %rax
movq %rax, 0x37e8(%rbx)
movups (%r14), %xmm0
movups %xmm0, 0x37d8(%rbx)
movabsq $-0x3fb5c00000000000, %rdi # imm = 0xC04A400000000000
movq %rdi, 0x37f0(%rbx)
movabsq $0x404a400000000000, %r9 # imm = 0x404A400000000000
movq %r9, 0x37f8(%rbx)
movabsq $-0x3fbf000000000000, %r8 # imm = 0xC041000000000000
movq %r8, 0x3800(%rbx)
movq %r15, 0x3808(%rbx)
movabsq $-0x3fb6400000000000, %rax # imm = 0xC049C00000000000
movq %rax, 0x3810(%rbx)
movabsq $0x4049c00000000000, %rax # imm = 0x4049C00000000000
movq %rax, 0x3818(%rbx)
movabsq $-0x3fbf800000000000, %rax # imm = 0xC040800000000000
movq %rax, 0x3820(%rbx)
movabsq $0x4040800000000000, %rax # imm = 0x4040800000000000
movq %rax, 0x3828(%rbx)
movq %rdi, 0x3830(%rbx)
movabsq $-0x3fbe000000000000, %rax # imm = 0xC042000000000000
movq %rax, 0x3838(%rbx)
movabsq $-0x3fcbd70a3d70a3d7, %rax # imm = 0xC03428F5C28F5C29
movq %rax, 0x3840(%rbx)
movabsq $0x403428f5c28f5c29, %rcx # imm = 0x403428F5C28F5C29
movq %rcx, 0x3848(%rbx)
movabsq $0x4042000000000000, %rdx # imm = 0x4042000000000000
movq %rdx, 0x3850(%rbx)
movq %r9, 0x3858(%rbx)
movq %rax, 0x3860(%rbx)
movq %rcx, 0x3868(%rbx)
movq %rdi, 0x3870(%rbx)
movabsq $-0x3fb8800000000000, %rax # imm = 0xC047800000000000
movq %rax, 0x3878(%rbx)
movabsq $-0x3fddae147ae147ae, %rcx # imm = 0xC02251EB851EB852
movq %rcx, 0x3880(%rbx)
movabsq $0x402251eb851eb852, %rdx # imm = 0x402251EB851EB852
movq %rdx, 0x3888(%rbx)
movabsq $0x4047800000000000, %rsi # imm = 0x4047800000000000
movq %rsi, 0x3890(%rbx)
movq %r9, 0x3898(%rbx)
movq %rcx, 0x38a0(%rbx)
movq %rdx, 0x38a8(%rbx)
movq %rax, 0x38d0(%rbx)
movq %rcx, 0x38d8(%rbx)
movq %rax, 0x38e0(%rbx)
movq %rdx, 0x38e8(%rbx)
movq %rsi, 0x38f0(%rbx)
movq %rcx, 0x38f8(%rbx)
movq %rsi, 0x3900(%rbx)
movq %rdx, 0x3908(%rbx)
movsd 0x3008(%rbx), %xmm0
movsd 0x19083(%rip), %xmm1    # 0x57060
mulsd %xmm0, %xmm1
movq %rdi, 0x3910(%rbx)
movsd %xmm1, 0x3918(%rbx)
mulsd 0x19850(%rip), %xmm0    # 0x57848
movq %rdi, 0x3920(%rbx)
movsd %xmm0, 0x3928(%rbx)
movq %r9, 0x3930(%rbx)
movsd %xmm1, 0x3938(%rbx)
movq %r9, 0x3940(%rbx)
movsd %xmm0, 0x3948(%rbx)
movq %rdi, 0x3950(%rbx)
movq %r8, 0x3958(%rbx)
movq %rdi, 0x3960(%rbx)
movq %r15, 0x3968(%rbx)
movq %r9, 0x3970(%rbx)
movq %r8, 0x3978(%rbx)
movq %r9, 0x3980(%rbx)
movq %r15, 0x3988(%rbx)
movq %rdi, 0x38b0(%rbx)
andq $0x0, 0x38b8(%rbx)
movq %r9, 0x38c0(%rbx)
andq $0x0, 0x38c8(%rbx)
movsd 0x30f8(%rbx), %xmm0
divsd 0x3460(%rbx), %xmm0
movsd %xmm0, 0x3448(%rbx)
movsd 0x32f8(%rbx), %xmm1
movsd 0x3310(%rbx), %xmm0
movapd %xmm0, %xmm2
mulsd %xmm0, %xmm2
movapd %xmm1, %xmm3
mulsd %xmm1, %xmm3
addsd %xmm2, %xmm3
sqrtsd %xmm3, %xmm2
movsd %xmm2, 0x3450(%rbx)
movsd 0x3048(%rbx), %xmm2
movsd 0x3080(%rbx), %xmm3
mulsd %xmm2, %xmm3
movsd %xmm3, 0x3430(%rbx)
movsd 0x3098(%rbx), %xmm3
mulsd %xmm2, %xmm3
movsd %xmm3, 0x3440(%rbx)
mulsd 0x3060(%rbx), %xmm2
movsd %xmm2, 0x3438(%rbx)
imull $0x3e8, 0x3238(%rbx), %eax # imm = 0x3E8
movl 0x3284(%rbx), %ecx
cltd
idivl %ecx
movl %eax, 0x3238(%rbx)
imull $0x3e8, 0x3388(%rbx), %eax # imm = 0x3E8
cltd
idivl %ecx
movl %eax, 0x3388(%rbx)
andq $0x0, 0x3300(%rbx)
movsd 0x3318(%rbx), %xmm2
maxsd 0x33e0(%rbx), %xmm2
cvttpd2dq %xmm2, %xmm2
cvtdq2pd %xmm2, %xmm2
movapd %xmm2, -0x80(%rbp)
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm1
jb 0x3e23b
movapd %xmm2, %xmm1
mulsd %xmm2, %xmm1
movsd %xmm1, -0x38(%rbp)
xorpd %xmm3, %xmm3
movsd %xmm2, -0x40(%rbp)
ucomisd %xmm3, %xmm0
jb 0x3e226
movapd %xmm2, %xmm0
divsd 0x32f8(%rbx), %xmm0
movsd %xmm3, -0x30(%rbp)
movaps -0x80(%rbp), %xmm1
callq 0x98a0
movsd %xmm0, -0x48(%rbp)
movsd -0x30(%rbp), %xmm0
divsd 0x3310(%rbx), %xmm0
movaps -0x80(%rbp), %xmm1
callq 0x98a0
addsd -0x48(%rbp), %xmm0
maxsd 0x1a11c(%rip), %xmm0    # 0x582e0
movsd 0x18e7c(%rip), %xmm2    # 0x57048
movapd %xmm2, %xmm1
minsd %xmm0, %xmm1
movapd %xmm2, %xmm0
subsd %xmm1, %xmm0
movsd -0x30(%rbp), %xmm3
ucomisd 0x18e57(%rip), %xmm0    # 0x57040
jbe 0x3e20c
movapd %xmm3, %xmm0
mulsd %xmm3, %xmm0
addsd -0x38(%rbp), %xmm0
sqrtsd %xmm0, %xmm0
maxsd 0x3300(%rbx), %xmm0
movsd %xmm0, 0x3300(%rbx)
addsd 0x19504(%rip), %xmm3    # 0x57718
movsd 0x3310(%rbx), %xmm0
movsd -0x40(%rbp), %xmm2
jmp 0x3e178
addsd 0x194ea(%rip), %xmm2    # 0x57718
movsd 0x32f8(%rbx), %xmm1
jmp 0x3e158
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq