// File: /workspace/github_cpp_makefile_star2_O2/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 0x10487(%rip), %xmm1    # 0x45e80
jbe 0x35a0b
movl 0x1aac168b(%rip), %eax  # 0x1aaf708c
cvtsi2sd %eax, %xmm2
divsd %xmm1, %xmm2
jmp 0x35a15
imull $0x3e8, %edx, %eax      # imm = 0x3E8
cvtsi2sd %eax, %xmm2
pushq %rbx
subq $0x10, %rsp
movl 0x2be68(%rip), %ebx     # 0x61888
cmpl $0x1, %ebx
jne 0x35a56
ucomisd 0x11743(%rip), %xmm0    # 0x47170
jbe 0x35aca
movl 0x1aac1653(%rip), %eax  # 0x1aaf708c
cvtsi2sd %eax, %xmm0
divsd %xmm1, %xmm0
mulsd 0x2be57(%rip), %xmm0    # 0x618a0
mulsd 0x11597(%rip), %xmm0    # 0x46fe8
jmp 0x35b39
movl %ebx, %eax
andl $-0x2, %eax
cmpl $0x2, %eax
jne 0x35b43
movsd %xmm0, (%rsp)
movsd %xmm2, 0x8(%rsp)
movslq %esi, %rax
leaq 0x1aac1617(%rip), %rcx  # 0x1aaf7090
movsd (%rcx,%rax,8), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, (%rcx,%rax,8)
movl 0x43b0(%rdi), %esi
movl %eax, %edi
callq 0x35949
movsd %xmm0, 0x1aac15dc(%rip) # 0x1aaf7078
cmpl $0x3, %ebx
jne 0x35af4
movsd 0x2bdf7(%rip), %xmm1    # 0x618a0
ucomisd %xmm0, %xmm1
movsd (%rsp), %xmm2
jbe 0x35af9
mulsd 0x116ac(%rip), %xmm1    # 0x47168
movsd %xmm1, 0x1aac15b4(%rip) # 0x1aaf7078
movapd %xmm1, %xmm0
jmp 0x35af9
ucomisd 0x10406(%rip), %xmm0    # 0x45ed8
movl 0x1aac15b4(%rip), %eax  # 0x1aaf708c
cvtsi2sd %eax, %xmm0
divsd %xmm1, %xmm0
mulsd 0x2bdb8(%rip), %xmm0    # 0x618a0
jbe 0x35b39
mulsd 0xe51e(%rip), %xmm0     # 0x44010
jmp 0x35b39
movsd (%rsp), %xmm2
ucomisd 0x1166f(%rip), %xmm2    # 0x47170
jbe 0x35b0d
movsd 0x114dd(%rip), %xmm1    # 0x46fe8
jmp 0x35b1f
ucomisd 0x103c3(%rip), %xmm2    # 0x45ed8
jbe 0x35b2b
movsd 0xe4f1(%rip), %xmm1     # 0x44010
mulsd %xmm1, %xmm0
movsd %xmm0, 0x1aac154d(%rip) # 0x1aaf7078
movsd 0x8(%rsp), %xmm1
mulsd %xmm0, %xmm1
movapd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x1aac1541(%rip)  # 0x1aaf7084
addq $0x10, %rsp
popq %rbx
retq