// File: /workspace/github_cpp_makefile_star2_O3/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 0x1182f(%rip), %xmm1    # 0x5ee60
jbe 0x4d643
movl 0x1aabea53(%rip), %eax  # 0x1ab0c08c
cvtsi2sd %eax, %xmm2
divsd %xmm1, %xmm2
jmp 0x4d64d
imull $0x3e8, %edx, %eax      # imm = 0x3E8
cvtsi2sd %eax, %xmm2
movl 0x29235(%rip), %eax     # 0x76888
cmpl $0x1, %eax
jne 0x4d68c
ucomisd 0x12b70(%rip), %xmm0    # 0x601d0
jbe 0x4d71b
movl 0x1aabea20(%rip), %eax  # 0x1ab0c08c
xorps %xmm2, %xmm2
cvtsi2sd %eax, %xmm2
divsd %xmm1, %xmm2
mulsd 0x29221(%rip), %xmm2    # 0x768a0
mulsd 0x129b1(%rip), %xmm2    # 0x60038
jmp 0x4d76a
movl %eax, %ecx
andl $-0x2, %ecx
cmpl $0x2, %ecx
jne 0x4d774
movslq %esi, %rcx
leaq 0x1aabe9ec(%rip), %rdx  # 0x1ab0c090
movsd (%rdx,%rcx,8), %xmm3
subsd %xmm1, %xmm3
movsd %xmm3, (%rdx,%rcx,8)
movl 0x43b0(%rdi), %ecx
notl %ecx
addl 0x291ec(%rip), %ecx     # 0x768ac
xorl %edx, %edx
testl %ecx, %ecx
cmovgl %ecx, %edx
addl 0x291db(%rip), %edx     # 0x768a8
xorps %xmm1, %xmm1
cvtsi2sd %edx, %xmm1
divsd %xmm1, %xmm3
movsd %xmm3, 0x1aabe998(%rip) # 0x1ab0c078
cmpl $0x3, %eax
jne 0x4d707
movsd 0x291b3(%rip), %xmm1    # 0x768a0
ucomisd %xmm3, %xmm1
jbe 0x4d707
mulsd 0x12acd(%rip), %xmm1    # 0x601c8
movsd %xmm1, 0x1aabe975(%rip) # 0x1ab0c078
movapd %xmm1, %xmm3
ucomisd 0x12ac1(%rip), %xmm0    # 0x601d0
jbe 0x4d748
movsd 0x1291f(%rip), %xmm0    # 0x60038
jmp 0x4d75a
ucomisd 0x1179d(%rip), %xmm0    # 0x5eec0
movl 0x1aabe963(%rip), %eax  # 0x1ab0c08c
xorps %xmm2, %xmm2
cvtsi2sd %eax, %xmm2
divsd %xmm1, %xmm2
mulsd 0x29164(%rip), %xmm2    # 0x768a0
jbe 0x4d76a
mulsd 0xf8ca(%rip), %xmm2     # 0x5d010
jmp 0x4d76a
ucomisd 0x11770(%rip), %xmm0    # 0x5eec0
jbe 0x4d766
movsd 0xf8b6(%rip), %xmm0     # 0x5d010
mulsd %xmm0, %xmm3
movsd %xmm3, 0x1aabe912(%rip) # 0x1ab0c078
mulsd %xmm3, %xmm2
cvttsd2si %xmm2, %eax
movl %eax, 0x1aabe910(%rip)  # 0x1ab0c084
retq