// File: /workspace/github_cpp_makefile_star2_O3/zyLiu6707[P]Arknights-Pull-Simulation/./utils.h
// Function: display_simulation_results(std::vector<unsigned long long, std::allocator<unsigned long long>> const&, std::unordered_map<unsigned long long, unsigned long long, std::hash<unsigned long long>, std::equal_to<unsigned long long>, std::allocator<std::pair<unsigned long long const, unsigned long long>>>&, unsigned long long, unsigned long long, unsigned int, timespec const&, timespec const&)
void display_simulation_results(
    const std::vector<unsigned long long int>& result,
    std::unordered_map<unsigned long long int, unsigned long long int>&
        rare_event,
    unsigned long long int star6_count,
    unsigned long long int target_star6_count, unsigned int seed,
    const struct timespec& start, const struct timespec& end) {
  std::cout << "...finished\n" << std::endl;

  // Simulation summary
  std::cout << "SIMULATION SUMMARY" << std::endl;
  std::cout << "-------------------------" << std::endl;
  std::cout << "Time spent: " << calc_time(start, end) << "s" << std::endl;
  std::cout << "Random seed for this simulation: " << seed << std::endl;
  std::cout << "Star 6 times: " << star6_count << std::endl;
  std::cout << "Target star 6 times: " << target_star6_count << std::endl;

  std::cout << std::endl;

  // Displaying raw data
  std::cout << "RAW DATA" << std::endl;
  std::cout << "-------------------------" << std::endl;
  std::cout << "First " << raw_data_showing_limit << " raw data:" << std::endl;
  std::cout << "\t";
  for (unsigned int i = 0; i < 10; ++i) {
    std::cout << i + 1 << ":\t";
  }
  std::cout << std::endl;
  for (size_t i = 0; i < raw_data_showing_limit; ++i) {
    if (i % 10 == 0) {
      std::cout << i / 10 + 1 << ":\t";
    }
    std::cout << result[i] << '\t';
    if (i % 10 == 9) {
      std::cout << std::endl;
    }
  }
  // If raw_data_showing_limit is not a multiple of 10, print an extra new line
  std::cout << std::endl;
  if (raw_data_showing_limit % 10 != 0) {
    std::cout << std::endl;
  }

  std::cout << std::endl;

  // Displaying rare events
  std::cout << "RARE EVENTS" << std::endl;
  std::cout << "-------------------------" << std::endl;
  std::cout << "Rare events happend " << rare_event.size() << " times in total"
            << std::endl;
  if (rare_event.size() != 0 && rare_event_showing_limit > 0) {
    std::cout << "Some rare events are (only showing "
              << rare_event_showing_limit << " of them here):" << std::endl;

    size_t counter = 0;
    for (const auto& p : rare_event) {
      if (counter < rare_event_showing_limit) {
        std::cout
            << "\tEvent \"Pulling " << p.first
            << " times to get the target star6 at the last pull\" happend "
            << p.second << " times" << std::endl;
        counter++;
      }
    }
    std::cout << std::endl;
    std::cout << "Note: Since the rare events are very sensitive to the error of the actual distribution\n"
                 "      of generated random numbers (i.e., we want a perfect uniform distribution, but\n"
                 "      there would be error under limited times of random number generating), the\n"
                 "      estimated probabilities for these rare events will not be accurate.\n"
                 "      Hence will not show the estimated probabilities of those rare events."
              << std::endl;
  }

  std::cout << std::endl;

  // Displaying the estimated probability
  // that you succeed *on* N-th pull
  std::cout << "ESTIMATED PROBABILITY" << std::endl;
  std::cout << "-------------------------" << std::endl;
  for (unsigned int i = 1;
       i < std::min(estimated_prob_showing_limit, result.size());
       ++i) {  // skip the unused index 0

    std::cout << "Pr(S_" << i
              << ") = " << (100.0 * result[i]) / target_star6_count << " %"
              << std::endl;
  }

  std::cout << std::endl;

  // Displaying the cumulated probability
  // Here "cumulated" means that you succeed *within* N pulls
  double cumulated_probability = 0.0;
  std::cout << "CUMULATED PROBABILITY" << std::endl;
  std::cout << "-------------------------" << std::endl;
  for (unsigned int i = 1;
       i < std::min(estimated_prob_showing_limit, result.size()); ++i) {
    cumulated_probability += result[i];
    std::cout << "Pr(W_" << i
              << ") = " << (100.0 * cumulated_probability) / target_star6_count
              << " %" << std::endl;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, %r13
movl %r8d, %r12d
movq %rcx, 0x10(%rsp)
movq %rdx, %r15
movq %rsi, 0x20(%rsp)
movq %rdi, %rbx
movq 0x70(%rsp), %rbp
movq 0x6df7(%rip), %r14      # 0xafd0
leaq 0x40d3(%rip), %rsi      # 0x82b3
movl $0xc, %edx
movq %r14, %rdi
callq 0x21c0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
leaq 0x40a5(%rip), %rsi      # 0x82c0
movl $0x12, %edx
movq %r14, %rdi
callq 0x21c0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
leaq 0x407d(%rip), %rsi      # 0x82d3
movl $0x19, %edx
movq %r14, %rdi
callq 0x21c0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
leaq 0x405c(%rip), %rsi      # 0x82ed
movl $0xc, %edx
movq %r14, %rdi
callq 0x21c0
cvtsi2sdq (%r13), %xmm1
cvtsi2sdq 0x8(%r13), %xmm2
movsd 0x2d56(%rip), %xmm3     # 0x7008
mulsd %xmm3, %xmm1
cvtsi2sdq (%rbp), %xmm0
cvtsi2sdq 0x8(%rbp), %xmm4
addsd %xmm2, %xmm1
mulsd %xmm3, %xmm0
addsd %xmm4, %xmm0
movapd %xmm0, %xmm2
subsd %xmm1, %xmm2
divsd %xmm3, %xmm2
cmpltsd %xmm1, %xmm0
andnpd %xmm2, %xmm0
movq %r14, %rdi
callq 0x2230
movq %rax, %rbp
leaq 0x411f(%rip), %rsi      # 0x8414
movl $0x1, %r13d
movl $0x1, %edx
movq %rax, %rdi
callq 0x21c0
movq (%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %rbp, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
leaq 0x3fc3(%rip), %rsi      # 0x82fa
movl $0x21, %edx
movq %r14, %rdi
callq 0x21c0
movl %r12d, %esi
movq %r14, %rdi
callq 0x20f0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %r12, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
leaq 0x3f9c(%rip), %rsi      # 0x831c
movl $0xe, %edx
movq %r14, %rdi
callq 0x21c0
movq %r14, %rdi
movq %r15, %rsi
callq 0x20e0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
leaq 0x3f62(%rip), %rsi      # 0x832b
movl $0x15, %edx
movq %r14, %rdi
callq 0x21c0
movq %r14, %rdi
movq 0x10(%rsp), %rsi
callq 0x20e0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
leaq 0x3f06(%rip), %rsi      # 0x8341
movl $0x8, %edx
movq %r14, %rdi
callq 0x21c0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
movl $0x19, %edx
movq %r14, %rdi
leaq 0x3e55(%rip), %rsi      # 0x82d3
callq 0x21c0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
leaq 0x3e99(%rip), %rsi      # 0x834a
movl $0x6, %edx
movq %r14, %rdi
callq 0x21c0
movl $0x64, %esi
movq %r14, %rdi
callq 0x20f0
movq %rax, %r15
leaq 0x3e7c(%rip), %rsi      # 0x8351
movl $0xa, %edx
movq %rax, %rdi
callq 0x21c0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
leaq 0x3e4d(%rip), %rsi      # 0x835d
movl $0x1, %edx
movq %r14, %rdi
callq 0x21c0
leaq 0x3e38(%rip), %r15      # 0x835c
movq %r14, %rdi
movq %r13, %rsi
callq 0x20f0
movl $0x2, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x21c0
incq %r13
cmpq $0xb, %r13
jne 0x4524
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
xorl %r13d, %r13d
movl $0xff, %ebp
leaq 0xf(%rsp), %r12
movl %r13d, %eax
andl %ebp, %eax
imull $0xcd, %eax, %eax
shrl $0xb, %eax
leal (%rax,%rax), %ecx
leal (%rcx,%rcx,4), %r15d
negl %r15d
andl %ebp, %r15d
leaq (%r15,%r13), %rcx
testb %cl, %cl
jne 0x45c0
incb %al
movzbl %al, %esi
movq %r14, %rdi
callq 0x20f0
movl $0x2, %edx
movq %rax, %rdi
leaq 0x3da1(%rip), %rsi      # 0x835c
callq 0x21c0
addq %r13, %r15
addq $-0x9, %r15
movq (%rbx), %rax
movq (%rax,%r13,8), %rsi
movq %r14, %rdi
callq 0x20e0
movb $0x9, 0xf(%rsp)
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x21c0
testb %r15b, %r15b
jne 0x4617
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
incq %r13
cmpq $0x64, %r13
jne 0x457c
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
leaq 0x3ce6(%rip), %rsi      # 0x835f
movl $0xb, %edx
movq %r14, %rdi
callq 0x21c0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
leaq 0x3c1f(%rip), %rsi      # 0x82d3
movl $0x19, %edx
movq %r14, %rdi
callq 0x21c0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
leaq 0x3c7c(%rip), %rsi      # 0x836b
movl $0x14, %edx
movq %r14, %rdi
callq 0x21c0
movq 0x20(%rsp), %r12
movq 0x18(%r12), %rsi
movq %r14, %rdi
callq 0x20f0
movq %rax, %r15
leaq 0x3c68(%rip), %rsi      # 0x8380
movl $0xf, %edx
movq %rax, %rdi
callq 0x21c0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
cmpq $0x0, 0x18(%r12)
je 0x48db
movq 0x6871(%rip), %r15      # 0xafd0
leaq 0x3c2a(%rip), %rsi      # 0x8390
movl $0x23, %edx
movq %r15, %rdi
callq 0x21c0
movl $0xa, %esi
movq %r15, %rdi
callq 0x20f0
movq %rax, %r15
leaq 0x3c2a(%rip), %rsi      # 0x83b4
movl $0xf, %edx
movq %rax, %rdi
callq 0x21c0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
movq 0x10(%r12), %rbp
testq %rbp, %rbp
je 0x4872
xorl %r15d, %r15d
movq 0x67fa(%rip), %r12      # 0xafd0
cmpq $0x9, %r15
ja 0x4865
movl $0x10, %edx
movq %r12, %rdi
leaq 0x3bd5(%rip), %rsi      # 0x83c4
callq 0x21c0
movq 0x8(%rbp), %rsi
movq %r12, %rdi
callq 0x20e0
movq %rax, %r13
movl $0x39, %edx
movq %rax, %rdi
leaq 0x3bc3(%rip), %rsi      # 0x83d5
callq 0x21c0
movq 0x10(%rbp), %rsi
movq %r13, %rdi
callq 0x20e0
movq %rax, %r13
movl $0x6, %edx
movq %rax, %rdi
leaq 0x3bda(%rip), %rsi      # 0x840f
callq 0x21c0
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %r13, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
incq %r15
movq (%rbp), %rbp
testq %rbp, %rbp
jne 0x47d6
movq 0x6757(%rip), %r15      # 0xafd0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
leaq 0x3b6f(%rip), %rsi      # 0x8416
movl $0x192, %edx            # imm = 0x192
movq %r15, %rdi
callq 0x21c0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
leaq 0x3ca0(%rip), %rsi      # 0x85a9
movl $0x15, %edx
movq %r14, %rdi
callq 0x21c0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
leaq 0x398f(%rip), %rsi      # 0x82d3
movl $0x19, %edx
movq %r14, %rdi
callq 0x21c0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
movq 0x8(%rbx), %rax
subq (%rbx), %rax
movsd 0x10(%rsp), %xmm0
movapd %xmm0, 0x20(%rsp)
cmpq $0x9, %rax
jb 0x4a9c
movapd 0x20(%rsp), %xmm0
unpcklps 0x269e(%rip), %xmm0     # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x26a6(%rip), %xmm0     # 0x7050
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movapd %xmm1, 0x10(%rsp)
movl $0x1, %r15d
movq 0x6607(%rip), %r12      # 0xafd0
movl $0x3e8, %r13d           # imm = 0x3E8
movl $0x5, %edx
movq %r12, %rdi
leaq 0x3be1(%rip), %rsi      # 0x85bf
callq 0x21c0
movq %r12, %rdi
movq %r15, %rsi
callq 0x20f0
movq %rax, %rbp
movl $0x4, %edx
movq %rax, %rdi
leaq 0x3bc5(%rip), %rsi      # 0x85c5
callq 0x21c0
movq (%rbx), %rax
movsd (%rax,%r15,8), %xmm1
unpcklps 0x262b(%rip), %xmm1     # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x2633(%rip), %xmm1     # 0x7050
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x25ff(%rip), %xmm0     # 0x7030
divsd 0x10(%rsp), %xmm0
movq %rbp, %rdi
callq 0x2230
movq %rax, %rbp
movl $0x2, %edx
movq %rax, %rdi
leaq 0x3b79(%rip), %rsi      # 0x85ca
callq 0x21c0
movq (%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %rbp, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
movq 0x8(%rbx), %rax
subq (%rbx), %rax
sarq $0x3, %rax
cmpq %r13, %rax
cmovaeq %r13, %rax
incq %r15
cmpq %r15, %rax
ja 0x49cf
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
leaq 0x3b03(%rip), %rsi      # 0x85cd
movl $0x15, %edx
movq %r14, %rdi
callq 0x21c0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
leaq 0x37ce(%rip), %rsi      # 0x82d3
movl $0x19, %edx
movq %r14, %rdi
callq 0x21c0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
subq %rax, %rcx
cmpq $0x9, %rcx
jb 0x4c77
movapd 0x20(%rsp), %xmm0
unpcklps 0x24e6(%rip), %xmm0     # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x24ee(%rip), %xmm0     # 0x7050
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movapd %xmm1, 0x20(%rsp)
xorpd %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
movl $0x1, %r14d
movq 0x6445(%rip), %r15      # 0xafd0
leaq 0x3a38(%rip), %rbp      # 0x85ca
movl $0x3e8, %r13d           # imm = 0x3E8
movsd (%rax,%r14,8), %xmm0
unpcklps 0x249b(%rip), %xmm0     # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x24a3(%rip), %xmm0     # 0x7050
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd 0x10(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
movl $0x5, %edx
movq %r15, %rdi
leaq 0x3a0b(%rip), %rsi      # 0x85e3
callq 0x21c0
movq %r15, %rdi
movq %r14, %rsi
callq 0x20f0
movq %rax, %r12
movl $0x4, %edx
movq %rax, %rdi
leaq 0x39cb(%rip), %rsi      # 0x85c5
callq 0x21c0
movsd 0x10(%rsp), %xmm0
mulsd 0x2423(%rip), %xmm0     # 0x7030
divsd 0x20(%rsp), %xmm0
movq %r12, %rdi
callq 0x2230
movq %rax, %r12
movl $0x2, %edx
movq %rax, %rdi
movq %rbp, %rsi
callq 0x21c0
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %r12, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r13, %rcx
cmovaeq %r13, %rcx
incq %r14
cmpq %r14, %rcx
ja 0x4b98
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq