// File: /workspace/github_cpp_makefile_star2_O1/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 0x6d5d(%rip), %r14      # 0xafd0
leaq 0x3ff9(%rip), %rsi      # 0x8273
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 0x3fcb(%rip), %rsi      # 0x8280
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 0x3fa3(%rip), %rsi      # 0x8293
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 0x3f82(%rip), %rsi      # 0x82ad
movl $0xc, %edx
movq %r14, %rdi
callq 0x21c0
cvtsi2sdq (%r13), %xmm1
cvtsi2sdq 0x8(%r13), %xmm2
movsd 0x2cbc(%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 0x4045(%rip), %rsi      # 0x83d4
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 0x3ee9(%rip), %rsi      # 0x82ba
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 0x3ec2(%rip), %rsi      # 0x82dc
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 0x3e88(%rip), %rsi      # 0x82eb
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 0x3e2c(%rip), %rsi      # 0x8301
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 0x3d7b(%rip), %rsi      # 0x8293
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 0x3dbf(%rip), %rsi      # 0x830a
movl $0x6, %edx
movq %r14, %rdi
callq 0x21c0
movl $0x64, %esi
movq %r14, %rdi
callq 0x20f0
movq %rax, %r15
leaq 0x3da2(%rip), %rsi      # 0x8311
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 0x3d73(%rip), %rsi      # 0x831d
movl $0x1, %edx
movq %r14, %rdi
callq 0x21c0
leaq 0x3d5e(%rip), %r15      # 0x831c
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 0x45be
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 %r15d, %r15d
movabsq $-0x3333333333333333, %rbp # imm = 0xCCCCCCCCCCCCCCCD
leaq 0xf(%rsp), %r13
movq %r15, %rax
mulq %rbp
shrq $0x3, %rdx
leaq (%rdx,%rdx), %r12
leaq (%r12,%r12,4), %rax
cmpq %r15, %rax
jne 0x4654
incq %rdx
movq %r14, %rdi
movq %rdx, %rsi
callq 0x20f0
movl $0x2, %edx
movq %rax, %rdi
leaq 0x3ccd(%rip), %rsi      # 0x831c
callq 0x21c0
leaq (%r12,%r12,4), %r12
addq $0x9, %r12
movq (%rbx), %rax
movq (%rax,%r15,8), %rsi
movq %r14, %rdi
callq 0x20e0
movb $0x9, 0xf(%rsp)
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x21c0
cmpq %r15, %r12
jne 0x46ac
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 %r15
cmpq $0x64, %r15
jne 0x461b
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 0x3c11(%rip), %rsi      # 0x831f
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 0x3b4a(%rip), %rsi      # 0x8293
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 0x3ba7(%rip), %rsi      # 0x832b
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 0x3b93(%rip), %rsi      # 0x8340
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 0x4970
movq 0x67dc(%rip), %r15      # 0xafd0
leaq 0x3b55(%rip), %rsi      # 0x8350
movl $0x23, %edx
movq %r15, %rdi
callq 0x21c0
movl $0xa, %esi
movq %r15, %rdi
callq 0x20f0
movq %rax, %r15
leaq 0x3b55(%rip), %rsi      # 0x8374
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 0x4907
xorl %r15d, %r15d
movq 0x6765(%rip), %r12      # 0xafd0
cmpq $0x9, %r15
ja 0x48fa
movl $0x10, %edx
movq %r12, %rdi
leaq 0x3b00(%rip), %rsi      # 0x8384
callq 0x21c0
movq 0x8(%rbp), %rsi
movq %r12, %rdi
callq 0x20e0
movq %rax, %r13
movl $0x39, %edx
movq %rax, %rdi
leaq 0x3aee(%rip), %rsi      # 0x8395
callq 0x21c0
movq 0x10(%rbp), %rsi
movq %r13, %rdi
callq 0x20e0
movq %rax, %r13
movl $0x6, %edx
movq %rax, %rdi
leaq 0x3b05(%rip), %rsi      # 0x83cf
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 0x486b
movq 0x66c2(%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 0x3a9a(%rip), %rsi      # 0x83d6
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 0x3bcb(%rip), %rsi      # 0x8569
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 0x38ba(%rip), %rsi      # 0x8293
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 0x4b31
movapd 0x20(%rsp), %xmm0
unpcklps 0x2609(%rip), %xmm0     # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x2611(%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 0x6572(%rip), %r12      # 0xafd0
movl $0x3e8, %r13d           # imm = 0x3E8
movl $0x5, %edx
movq %r12, %rdi
leaq 0x3b0c(%rip), %rsi      # 0x857f
callq 0x21c0
movq %r12, %rdi
movq %r15, %rsi
callq 0x20f0
movq %rax, %rbp
movl $0x4, %edx
movq %rax, %rdi
leaq 0x3af0(%rip), %rsi      # 0x8585
callq 0x21c0
movq (%rbx), %rax
movsd (%rax,%r15,8), %xmm1
unpcklps 0x2596(%rip), %xmm1     # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x259e(%rip), %xmm1     # 0x7050
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x256a(%rip), %xmm0     # 0x7030
divsd 0x10(%rsp), %xmm0
movq %rbp, %rdi
callq 0x2230
movq %rax, %rbp
movl $0x2, %edx
movq %rax, %rdi
leaq 0x3aa4(%rip), %rsi      # 0x858a
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 0x4a64
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 0x3a2e(%rip), %rsi      # 0x858d
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 0x36f9(%rip), %rsi      # 0x8293
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 0x4d0c
movapd 0x20(%rsp), %xmm0
unpcklps 0x2451(%rip), %xmm0     # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x2459(%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 0x63b0(%rip), %r15      # 0xafd0
leaq 0x3963(%rip), %rbp      # 0x858a
movl $0x3e8, %r13d           # imm = 0x3E8
movsd (%rax,%r14,8), %xmm0
unpcklps 0x2406(%rip), %xmm0     # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x240e(%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 0x3936(%rip), %rsi      # 0x85a3
callq 0x21c0
movq %r15, %rdi
movq %r14, %rsi
callq 0x20f0
movq %rax, %r12
movl $0x4, %edx
movq %rax, %rdi
leaq 0x38f6(%rip), %rsi      # 0x8585
callq 0x21c0
movsd 0x10(%rsp), %xmm0
mulsd 0x238e(%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 0x4c2d
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq