// File: /workspace/github_cpp_makefile_star2_O1/kobanium[P]Ray/src/mcts/SearchManager.cpp
// Function: CalculateNextPlayouts(game_info_t const*, int, double, double, int)
void
CalculateNextPlayouts( const game_info_t *game, const int color, const double best_wp, const double finish_time, const int threads )
{
  double po_per_sec;

  if (finish_time > 0.1) {
    po_per_sec = po_info.count / finish_time;
  } else {
    po_per_sec = PLAYOUT_SPEED * threads;
  }

  if (search_setting == SearchTimeStrategy::ConstantTimeMode) {
    if (best_wp > 0.95) {
      po_info.num = static_cast<int>(po_info.count / finish_time * const_thinking_time * 0.25);
    } else if (best_wp > 0.90) {
      po_info.num = static_cast<int>(po_info.count / finish_time * const_thinking_time * 0.50);
    } else {
      po_info.num = static_cast<int>(po_info.count / finish_time * const_thinking_time);

    }                     
  } else if (search_setting == SearchTimeStrategy::TimeControlMode ||
             search_setting == SearchTimeStrategy::TimeControlWithByoYomiMode) {
    ConsumeTime(color, finish_time);
    time_limit = CalculateNextTimeLimit(color, game->moves);
    if (search_setting == SearchTimeStrategy::TimeControlWithByoYomiMode &&
        time_limit < const_thinking_time) {
      time_limit = const_thinking_time * 0.85;
    }
    if (best_wp > 0.95) {
      time_limit *= 0.25;
    } else if (best_wp > 0.90) {
      time_limit *= 0.5;
    }
    po_info.num = static_cast<int>(po_per_sec * time_limit);
  }
}

// Assembly:
ucomisd 0x12df3(%rip), %xmm1    # 0x600f0
jbe 0x4d30f
movl 0x1aabdd87(%rip), %eax  # 0x1ab0b08c
cvtsi2sd %eax, %xmm2
divsd %xmm1, %xmm2
jmp 0x4d319
imull $0x3e8, %edx, %eax      # imm = 0x3E8
cvtsi2sd %eax, %xmm2
movl 0x28569(%rip), %eax     # 0x75888
cmpl $0x1, %eax
jne 0x4d358
ucomisd 0x12dcc(%rip), %xmm0    # 0x600f8
jbe 0x4d3e3
movl 0x1aabdd54(%rip), %eax  # 0x1ab0b08c
xorps %xmm2, %xmm2
cvtsi2sd %eax, %xmm2
divsd %xmm1, %xmm2
mulsd 0x28555(%rip), %xmm2    # 0x758a0
mulsd 0x12c15(%rip), %xmm2    # 0x5ff68
jmp 0x4d43a
movl %eax, %ecx
andl $-0x2, %ecx
cmpl $0x2, %ecx
jne 0x4d444
movslq %esi, %rcx
leaq 0x1aabdd20(%rip), %rdx  # 0x1ab0b090
movsd (%rdx,%rcx,8), %xmm3
subsd %xmm1, %xmm3
movsd %xmm3, (%rdx,%rcx,8)
movl 0x43b0(%rdi), %ecx
notl %ecx
addl 0x28520(%rip), %ecx     # 0x758ac
xorl %edx, %edx
testl %ecx, %ecx
cmovgl %ecx, %edx
addl 0x2850f(%rip), %edx     # 0x758a8
xorps %xmm1, %xmm1
cvtsi2sd %edx, %xmm1
divsd %xmm1, %xmm3
movsd %xmm3, 0x1aabdccc(%rip) # 0x1ab0b078
cmpl $0x3, %eax
jne 0x4d3cf
movsd 0x284e7(%rip), %xmm1    # 0x758a0
ucomisd %xmm3, %xmm1
jbe 0x4d3cf
mulsd 0x12d21(%rip), %xmm1    # 0x600e8
movsd %xmm1, 0x1aabdca9(%rip) # 0x1ab0b078
ucomisd 0x12d21(%rip), %xmm0    # 0x600f8
jbe 0x4d410
movsd 0x12b87(%rip), %xmm0    # 0x5ff68
jmp 0x4d422
ucomisd 0x11aad(%rip), %xmm0    # 0x5ee98
movl 0x1aabdc9b(%rip), %eax  # 0x1ab0b08c
xorps %xmm2, %xmm2
cvtsi2sd %eax, %xmm2
divsd %xmm1, %xmm2
mulsd 0x2849c(%rip), %xmm2    # 0x758a0
jbe 0x4d43a
mulsd 0xfc02(%rip), %xmm2     # 0x5d010
jmp 0x4d43a
ucomisd 0x11a80(%rip), %xmm0    # 0x5ee98
jbe 0x4d432
movsd 0xfbee(%rip), %xmm0     # 0x5d010
mulsd 0x1aabdc4e(%rip), %xmm0 # 0x1ab0b078
movsd %xmm0, 0x1aabdc46(%rip) # 0x1ab0b078
mulsd 0x1aabdc3e(%rip), %xmm2 # 0x1ab0b078
cvttsd2si %xmm2, %eax
movl %eax, 0x1aabdc40(%rip)  # 0x1ab0b084
retq