// File: /workspace/github_cpp_makefile_star2_O1/ctz[P]openssl-bench/bench.cc
// Function: test_handshake_resume(unsigned int, Context&, Context&, bool)
static void test_handshake_resume(const unsigned n_threads, Context &server_ctx,
                                  Context &client_ctx,
                                  const bool with_tickets) {
  const size_t handshakes = apply_work_multiplier(4096);

  server_ctx.enable_resume();
  client_ctx.enable_resume();

  std::string prefix_server, prefix_client;

  if (!with_tickets) {
    server_ctx.disable_tickets();
    client_ctx.disable_tickets();
    prefix_server = "handshake-resume\tserver\t";
    prefix_client = "handshake-resume\tclient\t";

#ifdef BORINGSSL
    if (server_ctx.is_tls13()) {
      printf("!!! BoringSSL does not support stateful resumption for TLS1.3\n");
      return;
    }
#endif
  } else {
    prefix_server = "handshake-ticket\tserver\t";
    prefix_client = "handshake-ticket\tclient\t";
  }

  SSL_SESSION *client_session;

  {
    Conn initial_server(server_ctx.open());
    Conn initial_client(client_ctx.open());
    initial_client.set_sni("localhost");
    do_handshake(initial_client, initial_server);

    // pass some data to ensure ticket receipt
    initial_server.write((const uint8_t *)"hello", 5);
    initial_server.transfer_to(initial_client);

    uint8_t buf[5];
    initial_client.read(buf, 5);

    initial_client.show_kx();
    client_session = initial_client.get_session();
    assert(SSL_SESSION_is_resumable(client_session));
    initial_server.ragged_close();

    prefix_server += initial_client.get_cipher_string();
    prefix_client += initial_client.get_cipher_string();
  }

  client_ctx.bodge_disable_resume();

  std::vector<std::thread> threads;
  std::vector<Timings> results(n_threads);

  for (unsigned i = 0; i < n_threads; i++) {
    threads.push_back(std::thread(
        &test_handshake_resume_one, std::ref(results[i]), std::ref(server_ctx),
        std::ref(client_ctx), client_session, handshakes));
  }

  for (unsigned i = 0; i < n_threads; i++) {
    threads[i].join();
  }

  server_ctx.dump_sess_stats();
  print_results(prefix_server.c_str(), prefix_client.c_str(), results,
                handshakes, "handshakes/s");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movl %ecx, %ebx
movq %rdx, %r14
movq %rsi, %r13
movl %edi, %ebp
movl $0x1000, %edi           # imm = 0x1000
callq 0x4b52
movq %rax, 0x40(%rsp)
movq %r13, %rdi
callq 0x6540
movq %r14, 0x10(%rsp)
movq %r14, %rdi
callq 0x6540
leaq 0x58(%rsp), %r15
movq %r15, -0x10(%r15)
xorl %eax, %eax
movq %rax, -0x8(%r15)
movb %al, (%r15)
leaq 0xb0(%rsp), %r12
movq %r12, -0x10(%r12)
movq %rax, -0x8(%r12)
movb %al, (%r12)
testl %ebx, %ebx
je 0x407d
leaq 0x35a8(%rip), %rcx      # 0x7608
leaq 0x48(%rsp), %rdi
movl $0x18, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0x3410
leaq 0x35a6(%rip), %rcx      # 0x7621
jmp 0x40df
movq (%r13), %rdi
callq 0x3420
movq (%r13), %rdi
orq $0x4000, %rax           # imm = 0x4000
movq %rax, %rsi
callq 0x3520
movq 0x10(%rsp), %rax
movq (%rax), %rdi
callq 0x3420
movq 0x10(%rsp), %rcx
movq (%rcx), %rdi
orq $0x4000, %rax           # imm = 0x4000
movq %rax, %rsi
callq 0x3520
leaq 0x48(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x350b(%rip), %rcx      # 0x75d6
movl $0x18, %r8d
xorl %esi, %esi
callq 0x3410
leaq 0x3510(%rip), %rcx      # 0x75ef
leaq 0xa0(%rsp), %rdi
movq 0x8(%rdi), %rdx
movl $0x18, %r8d
xorl %esi, %esi
callq 0x3410
movq (%r13), %rdi
callq 0x32d0
leaq 0xe0(%rsp), %rdi
movq %rax, %rsi
callq 0x5a48
movq 0x10(%rsp), %rax
movq (%rax), %rdi
callq 0x32d0
leaq 0x68(%rsp), %rdi
movq %rax, %rsi
callq 0x5a48
leaq 0x330f(%rip), %rsi      # 0x7441
leaq 0x68(%rsp), %rdi
callq 0x6210
leaq 0x32fe(%rip), %rsi      # 0x7441
leaq 0x68(%rsp), %rdi
callq 0x6210
leaq 0x68(%rsp), %rbx
leaq 0xe0(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4be2
testb %al, %al
jne 0x415a
leaq 0x34ca(%rip), %rsi      # 0x763a
leaq 0xe0(%rsp), %rdi
movl $0x5, %edx
callq 0x5de0
leaq 0xe0(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x5dfe
leaq 0x68(%rsp), %rdi
leaq 0x38(%rsp), %rsi
movl $0x5, %edx
callq 0x5e92
leaq 0x68(%rsp), %rdi
callq 0x6590
leaq 0x68(%rsp), %rdi
callq 0x65f8
movq %rax, 0xd8(%rsp)
movq %rax, %rdi
callq 0x33c0
testl %eax, %eax
je 0x4445
movq 0xe0(%rsp), %rdi
movl $0x3, %esi
callq 0x3080
leaq 0x18(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x5ac2
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
leaq 0x48(%rsp), %rdi
callq 0x3100
leaq 0x28(%rsp), %r14
movq -0x10(%r14), %rdi
cmpq %r14, %rdi
je 0x4224
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x32c0
leaq 0x18(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x5ac2
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
leaq 0xa0(%rsp), %rdi
callq 0x3100
movq 0x18(%rsp), %rdi
cmpq %r14, %rdi
je 0x4261
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x32c0
leaq 0x68(%rsp), %rdi
callq 0x5b4a
leaq 0xe0(%rsp), %rdi
callq 0x5b4a
movq 0x10(%rsp), %rax
movq (%rax), %rdi
movl $0x2, %edx
movl $0x2c, %esi
xorl %ecx, %ecx
callq 0x3260
xorps %xmm0, %xmm0
movaps %xmm0, 0xe0(%rsp)
movq $0x0, 0xf0(%rsp)
movl %ebp, %ebx
leaq 0x68(%rsp), %rdi
leaq 0x18(%rsp), %rdx
movq %rbx, %rsi
callq 0x590e
testl %ebp, %ebp
je 0x4393
movq %rbx, %r15
shlq $0x4, %r15
xorl %r14d, %r14d
leaq 0x18(%rsp), %r12
leaq 0xe0(%rsp), %rbp
leaq 0xe4c(%rip), %rax       # 0x512e
movq %rax, 0x38(%rsp)
movq 0x68(%rsp), %rax
addq %r14, %rax
movq %rax, 0xd0(%rsp)
movq %r13, 0xc8(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0xc0(%rsp)
leaq 0x40(%rsp), %rax
movq %rax, (%rsp)
movq %r12, %rdi
leaq 0x38(%rsp), %rsi
leaq 0xd0(%rsp), %rdx
leaq 0xc8(%rsp), %rcx
leaq 0xc0(%rsp), %r8
leaq 0xd8(%rsp), %r9
callq 0x6626
movq %rbp, %rdi
movq %r12, %rsi
callq 0x5be2
cmpq $0x0, 0x18(%rsp)
jne 0x44e5
addq $0x10, %r14
cmpq %r14, %r15
jne 0x42db
shlq $0x3, %rbx
xorl %r14d, %r14d
leaq 0x58(%rsp), %r15
leaq 0xb0(%rsp), %r12
movq 0xe0(%rsp), %rdi
addq %r14, %rdi
callq 0x34b0
addq $0x8, %r14
cmpq %r14, %rbx
jne 0x437a
movq %r13, %rdi
callq 0x66e8
movq 0x48(%rsp), %rdi
movsd 0x40(%rsp), %xmm1
unpcklps 0x2c63(%rip), %xmm1     # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x2c6b(%rip), %xmm1     # 0x7020
movq 0xa0(%rsp), %rsi
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
leaq 0x30fb(%rip), %rcx      # 0x74cb
leaq 0x68(%rsp), %rbx
movq %rbx, %rdx
callq 0x49bd
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x43f2
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
leaq 0xe0(%rsp), %rdi
callq 0x5b80
movq 0xa0(%rsp), %rdi
cmpq %r12, %rdi
je 0x441c
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x32c0
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x4433
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x32c0
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x31f4(%rip), %rdi      # 0x7640
leaq 0x2d85(%rip), %rsi      # 0x71d8
leaq 0x320f(%rip), %rcx      # 0x7669
movl $0x2aa, %edx            # imm = 0x2AA
callq 0x31d0
jmp 0x44bc
movq %rax, %rbx
jmp 0x44d6
jmp 0x44a9
movq %rax, %rbx
movq 0x18(%rsp), %rdi
cmpq %r14, %rdi
jne 0x448f
jmp 0x44ed
jmp 0x44ea
movq %rax, %rbx
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x44ed
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x32c0
jmp 0x44ed
jmp 0x44ea
movq %rax, %rbx
jmp 0x44f7
jmp 0x44a9
jmp 0x44ea
movq %rax, %rbx
jmp 0x4504
jmp 0x44ea
jmp 0x44bc
jmp 0x44bc
cmpq $0x0, 0x18(%rsp)
jne 0x44e5
movq %rax, %rbx
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x44d6
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
leaq 0xe0(%rsp), %rdi
callq 0x5b80
jmp 0x4504
callq 0x30e0
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x5b4a
leaq 0xe0(%rsp), %rdi
callq 0x5b4a
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x4529
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x32c0
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x4545
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x32c0
movq %rbx, %rdi
callq 0x34c0