// File: ctz[P]openssl-bench/bench.cc
// Function: test_memory(Context&, Context&, unsigned long)
static void test_memory(Context &server_ctx, Context &client_ctx,
                        size_t session_count) {
  std::vector<Conn> servers;
  std::vector<Conn> clients;

  session_count /= 2;

  servers.reserve(session_count);
  clients.reserve(session_count);

  for (size_t i = 0; i < session_count; i++) {
    servers.push_back(std::move(server_ctx.open()));
    clients.push_back(std::move(client_ctx.open()));
    clients.back().set_sni("localhost");
  }

  for (size_t s = 0; s < 5; s++) {
    for (size_t i = 0; i < session_count; i++) {
      do_handshake_step(clients[i], servers[i]);
    }
  }

  for (size_t i = 0; i < session_count; i++) {
    uint8_t buf[1024] = {0};
    clients[i].write(buf, sizeof buf);
  }

  for (size_t i = 0; i < session_count; i++) {
    clients[i].transfer_to(servers[i]);
    uint8_t buf[1024];
    servers[i].read(buf, sizeof buf);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x950, %rsp            # imm = 0x950
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
leaq -0x30(%rbp), %rdi
movq %rdi, -0x918(%rbp)
callq 0xc550
leaq -0x48(%rbp), %rdi
callq 0xc550
movq -0x918(%rbp), %rdi
movq -0x18(%rbp), %rax
shrq %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rsi
callq 0xc570
jmp 0x49bd
movq -0x18(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0xc570
jmp 0x49cc
movq $0x0, -0x60(%rbp)
movq -0x60(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x4b00
movq -0x8(%rbp), %rdi
callq 0x6500
movq %rax, -0x920(%rbp)
jmp 0x49f4
movq -0x920(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rsi
leaq -0x98(%rbp), %rdi
callq 0x6520
jmp 0x4a17
leaq -0x30(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0xc690
jmp 0x4a29
leaq -0x98(%rbp), %rdi
callq 0x6770
movq -0x10(%rbp), %rdi
callq 0x6500
movq %rax, -0x928(%rbp)
jmp 0x4a47
movq -0x928(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0xe0(%rbp), %rsi
leaq -0xd8(%rbp), %rdi
callq 0x6520
jmp 0x4a6a
leaq -0x48(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0xc690
jmp 0x4a7c
leaq -0xd8(%rbp), %rdi
callq 0x6770
leaq -0x48(%rbp), %rdi
callq 0xc6c0
movq %rax, %rdi
leaq 0x995c(%rip), %rsi      # 0xe3f7
callq 0xa9b0
jmp 0x4aa2
jmp 0x4aa4
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x49d4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x4cb5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x6770
jmp 0x4cb5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x6770
jmp 0x4cb5
movq $0x0, -0xe8(%rbp)
cmpq $0x5, -0xe8(%rbp)
jae 0x4b94
movq $0x0, -0xf0(%rbp)
movq -0xf0(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x4b7b
movq -0xf0(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0xc700
movq %rax, -0x930(%rbp)
movq -0xf0(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0xc700
movq -0x930(%rbp), %rdi
movq %rax, %rsi
callq 0x5490
jmp 0x4b65
jmp 0x4b67
movq -0xf0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xf0(%rbp)
jmp 0x4b20
jmp 0x4b7d
movq -0xe8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xe8(%rbp)
jmp 0x4b0b
movq $0x0, -0xf8(%rbp)
movq -0xf8(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x4c0b
leaq -0x500(%rbp), %rdi
movq %rdi, -0x940(%rbp)
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
movq %rdx, -0x938(%rbp)
callq 0x31d0
movq -0xf8(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0xc700
movq -0x940(%rbp), %rsi
movq -0x938(%rbp), %rdx
movq %rax, %rdi
callq 0x7af0
jmp 0x4bf5
jmp 0x4bf7
movq -0xf8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xf8(%rbp)
jmp 0x4b9f
movq $0x0, -0x508(%rbp)
movq -0x508(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x4c9a
movq -0x508(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0xc700
movq %rax, -0x948(%rbp)
movq -0x508(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0xc700
movq -0x948(%rbp), %rdi
movq %rax, %rsi
callq 0x7b80
jmp 0x4c5b
movq -0x508(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0xc700
movq %rax, %rdi
leaq -0x910(%rbp), %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x7cb0
jmp 0x4c81
jmp 0x4c83
movq -0x508(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x508(%rbp)
jmp 0x4c16
leaq -0x48(%rbp), %rdi
callq 0xc720
leaq -0x30(%rbp), %rdi
callq 0xc720
addq $0x950, %rsp            # imm = 0x950
popq %rbp
retq
leaq -0x48(%rbp), %rdi
callq 0xc720
leaq -0x30(%rbp), %rdi
callq 0xc720
movq -0x50(%rbp), %rdi
callq 0x3590