// File: ctz[P]openssl-bench/bench.cc
// Function: test_handshake_resume_one(Timings&, Context&, Context&, ssl_session_st*, unsigned long)
static void test_handshake_resume_one(Timings &timings_out, Context &server_ctx,
                                      Context &client_ctx,
                                      SSL_SESSION *client_session,
                                      const size_t handshakes) {
  double time_client = 0;
  double time_server = 0;

  LatencyOutput client_latency("client");
  LatencyOutput server_latency("server");

  for (size_t i = 0; i < handshakes; i++) {
    Conn server(server_ctx.open());
    Conn client(client_ctx.open());

    client.set_sni("localhost");
    client.set_session(client_session);
    assert(SSL_SESSION_is_resumable(client_session));

    double t, time_client_one = 0, time_server_one = 0;

    t = get_time();
    client.connect();
    client.transfer_to(server);
    time_client_one += get_time() - t;

    t = get_time();
    server.accept();
    server.transfer_to(client);
    time_server_one += get_time() - t;

    t = get_time();
    client.connect();
    client.transfer_to(server);
    time_client_one += get_time() - t;

    t = get_time();
    server.accept();
    server.transfer_to(client);
    time_server_one += get_time() - t;

    assert(server.accept());
    assert(client.connect());
    assert(server.was_resumed());
    assert(client.was_resumed());
    server.ragged_close();
    client.ragged_close();

    client_latency.sample(time_client_one);
    server_latency.sample(time_server_one);
    time_client += time_client_one;
    time_server += time_server_one;
  }

  timings_out.client.store(time_client);
  timings_out.server.store(time_server);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
leaq 0x8b02(%rip), %rsi      # 0xe4b8
leaq -0x40(%rbp), %rdi
callq 0xb040
leaq 0x8af9(%rip), %rsi      # 0xe4bf
leaq -0x48(%rbp), %rdi
callq 0xb040
jmp 0x59d1
movq $0x0, -0x60(%rbp)
movq -0x60(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x5dfc
movq -0x10(%rbp), %rdi
callq 0x6500
movq %rax, -0xf0(%rbp)
jmp 0x59f9
movq -0xf0(%rbp), %rsi
leaq -0x98(%rbp), %rdi
callq 0x6520
jmp 0x5a0e
movq -0x18(%rbp), %rdi
callq 0x6500
movq %rax, -0xf8(%rbp)
jmp 0x5a20
movq -0xf8(%rbp), %rsi
leaq -0xd0(%rbp), %rdi
callq 0x6520
jmp 0x5a35
leaq 0x89bb(%rip), %rsi      # 0xe3f7
leaq -0xd0(%rbp), %rdi
callq 0xa9b0
jmp 0x5a4a
movq -0x20(%rbp), %rsi
leaq -0xd0(%rbp), %rdi
callq 0xbde0
jmp 0x5a5c
movq -0x20(%rbp), %rdi
callq 0x34b0
movl %eax, -0xfc(%rbp)
jmp 0x5a6d
movl -0xfc(%rbp), %eax
cmpl $0x0, %eax
je 0x5a7a
jmp 0x5ae9
leaq 0x8b9f(%rip), %rdi      # 0xe620
leaq 0x8757(%rip), %rsi      # 0xe1df
movl $0x244, %edx            # imm = 0x244
leaq 0x8c06(%rip), %rcx      # 0xe69a
callq 0x3210
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x5e4a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x5e41
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x5dee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x6770
jmp 0x5dee
movq $0x0, -0xe0(%rbp)
movq $0x0, -0xe8(%rbp)
callq 0x53f0
movsd %xmm0, -0xd8(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0xaa50
jmp 0x5b1a
leaq -0xd0(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x7b80
jmp 0x5b2f
callq 0x53f0
movaps %xmm0, %xmm1
movsd -0xd8(%rbp), %xmm0
subsd %xmm0, %xmm1
movsd -0xe0(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xe0(%rbp)
callq 0x53f0
movsd %xmm0, -0xd8(%rbp)
leaq -0x98(%rbp), %rdi
callq 0xaa10
jmp 0x5b72
leaq -0x98(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x7b80
jmp 0x5b87
callq 0x53f0
movaps %xmm0, %xmm1
movsd -0xd8(%rbp), %xmm0
subsd %xmm0, %xmm1
movsd -0xe8(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xe8(%rbp)
callq 0x53f0
movsd %xmm0, -0xd8(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0xaa50
jmp 0x5bca
leaq -0xd0(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x7b80
jmp 0x5bdf
callq 0x53f0
movaps %xmm0, %xmm1
movsd -0xd8(%rbp), %xmm0
subsd %xmm0, %xmm1
movsd -0xe0(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xe0(%rbp)
callq 0x53f0
movsd %xmm0, -0xd8(%rbp)
leaq -0x98(%rbp), %rdi
callq 0xaa10
jmp 0x5c22
leaq -0x98(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x7b80
jmp 0x5c37
callq 0x53f0
movaps %xmm0, %xmm1
movsd -0xd8(%rbp), %xmm0
subsd %xmm0, %xmm1
movsd -0xe8(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xe8(%rbp)
leaq -0x98(%rbp), %rdi
callq 0xaa10
movb %al, -0xfd(%rbp)
jmp 0x5c73
movb -0xfd(%rbp), %al
testb $0x1, %al
jne 0x5c7f
jmp 0x5c81
jmp 0x5ca0
leaq 0x883e(%rip), %rdi      # 0xe4c6
leaq 0x8550(%rip), %rsi      # 0xe1df
movl $0x25c, %edx            # imm = 0x25C
leaq 0x89ff(%rip), %rcx      # 0xe69a
callq 0x3210
leaq -0xd0(%rbp), %rdi
callq 0xaa50
movb %al, -0xfe(%rbp)
jmp 0x5cb4
movb -0xfe(%rbp), %al
testb $0x1, %al
jne 0x5cc0
jmp 0x5cc2
jmp 0x5ce1
leaq 0x885a(%rip), %rdi      # 0xe523
leaq 0x850f(%rip), %rsi      # 0xe1df
movl $0x25d, %edx            # imm = 0x25D
leaq 0x89be(%rip), %rcx      # 0xe69a
callq 0x3210
leaq -0x98(%rbp), %rdi
callq 0xb250
movb %al, -0xff(%rbp)
jmp 0x5cf5
movb -0xff(%rbp), %al
testb $0x1, %al
jne 0x5d01
jmp 0x5d03
jmp 0x5d22
leaq 0x882b(%rip), %rdi      # 0xe535
leaq 0x84ce(%rip), %rsi      # 0xe1df
movl $0x25e, %edx            # imm = 0x25E
leaq 0x897d(%rip), %rcx      # 0xe69a
callq 0x3210
leaq -0xd0(%rbp), %rdi
callq 0xb250
movb %al, -0x100(%rbp)
jmp 0x5d36
movb -0x100(%rbp), %al
testb $0x1, %al
jne 0x5d42
jmp 0x5d44
jmp 0x5d63
leaq 0x8800(%rip), %rdi      # 0xe54b
leaq 0x848d(%rip), %rsi      # 0xe1df
movl $0x25f, %edx            # imm = 0x25F
leaq 0x893c(%rip), %rcx      # 0xe69a
callq 0x3210
leaq -0x98(%rbp), %rdi
callq 0xbb40
jmp 0x5d71
leaq -0xd0(%rbp), %rdi
callq 0xbb40
jmp 0x5d7f
movsd -0xe0(%rbp), %xmm0
leaq -0x40(%rbp), %rdi
callq 0xb1f0
movsd -0xe8(%rbp), %xmm0
leaq -0x48(%rbp), %rdi
callq 0xb1f0
movsd -0xe0(%rbp), %xmm0
addsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0xe8(%rbp), %xmm0
addsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x6770
leaq -0x98(%rbp), %rdi
callq 0x6770
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x59d9
leaq -0x98(%rbp), %rdi
callq 0x6770
jmp 0x5e41
movq -0x8(%rbp), %rdi
movsd -0x30(%rbp), %xmm0
movl $0x5, %esi
callq 0x7d40
movq -0x8(%rbp), %rdi
addq $0x8, %rdi
movsd -0x38(%rbp), %xmm0
movl $0x5, %esi
callq 0x7d40
leaq -0x48(%rbp), %rdi
callq 0xb280
leaq -0x40(%rbp), %rdi
callq 0xb280
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
leaq -0x48(%rbp), %rdi
callq 0xb280
leaq -0x40(%rbp), %rdi
callq 0xb280
movq -0x50(%rbp), %rdi
callq 0x3590
nopl (%rax)