// File: nurseiit[P]cpp-server/./include/asio/impl/read_until.hpp
// Function: unsigned long asio::read_until<asio::basic_stream_socket<asio::ip::tcp, asio::executor>, asio::basic_streambuf_ref<std::allocator<char>>>(asio::basic_stream_socket<asio::ip::tcp, asio::executor>&, asio::basic_streambuf_ref<std::allocator<char>>&&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::error_code&, std::enable_if<is_dynamic_buffer_v1<std::decay<asio::basic_streambuf_ref<std::allocator<char>>>::type>::value && !is_dynamic_buffer_v2<std::decay<asio::basic_streambuf_ref<std::allocator<char>>>::type>::value, void>::type*)
std::size_t read_until(SyncReadStream& s,
    ASIO_MOVE_ARG(DynamicBuffer_v1) buffers,
    ASIO_STRING_VIEW_PARAM delim, asio::error_code& ec,
    typename enable_if<
      is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
        && !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
    >::type*)
{
  typename decay<DynamicBuffer_v1>::type b(
      ASIO_MOVE_CAST(DynamicBuffer_v1)(buffers));

  std::size_t search_position = 0;
  for (;;)
  {
    // Determine the range of the data to be searched.
    typedef typename DynamicBuffer_v1::const_buffers_type buffers_type;
    typedef buffers_iterator<buffers_type> iterator;
    buffers_type data_buffers = b.data();
    iterator begin = iterator::begin(data_buffers);
    iterator start_pos = begin + search_position;
    iterator end = iterator::end(data_buffers);

    // Look for a match.
    std::pair<iterator, bool> result = detail::partial_search(
        start_pos, end, delim.begin(), delim.end());
    if (result.first != end)
    {
      if (result.second)
      {
        // Full match. We're done.
        ec = asio::error_code();
        return result.first - begin + delim.length();
      }
      else
      {
        // Partial match. Next search needs to start from beginning of match.
        search_position = result.first - begin;
      }
    }
    else
    {
      // No match. Next search can start with the new data.
      search_position = end - begin;
    }

    // Check if buffer is full.
    if (b.size() == b.max_size())
    {
      ec = error::not_found;
      return 0;
    }

    // Need more data.
    std::size_t bytes_to_read = std::min<std::size_t>(
          std::max<std::size_t>(512, b.capacity() - b.size()),
          std::min<std::size_t>(65536, b.max_size() - b.size()));
    b.commit(s.read_some(b.prepare(bytes_to_read), ec));
    if (ec)
      return 0;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2b0, %rsp            # imm = 0x2B0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq -0x18(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x15510
movq $0x0, -0x40(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x15590
movq %rax, -0x50(%rbp)
movq %rdx, -0x48(%rbp)
leaq -0x88(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x16500
movq -0x40(%rbp), %rdx
leaq -0xc0(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x165b0
leaq -0xf8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x165f0
leaq -0x170(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
movl $0x38, %edx
callq 0x5310
leaq -0x1a8(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
movl $0x38, %edx
callq 0x5310
movq -0x20(%rbp), %rdi
callq 0x5370
movq %rax, -0x1b0(%rbp)
movq -0x20(%rbp), %rdi
callq 0x56f0
movq %rax, -0x1b8(%rbp)
movq -0x1b0(%rbp), %rsi
movq -0x1b8(%rbp), %rdx
movq -0x178(%rbp), %rcx
movq %rsp, %rax
movq %rax, -0x208(%rbp)
movq %rcx, 0x68(%rax)
movups -0x1a8(%rbp), %xmm0
movups -0x198(%rbp), %xmm1
movups -0x188(%rbp), %xmm2
movups %xmm2, 0x58(%rax)
movups %xmm1, 0x48(%rax)
movups %xmm0, 0x38(%rax)
movq -0x140(%rbp), %rcx
movq %rcx, 0x30(%rax)
movups -0x170(%rbp), %xmm0
movups -0x160(%rbp), %xmm1
movups -0x150(%rbp), %xmm2
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
leaq -0x138(%rbp), %rdi
callq 0x166a0
leaq -0x138(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x16830
testb $0x1, %al
jne 0x162f3
jmp 0x16373
testb $0x1, -0x100(%rbp)
je 0x1635a
leaq -0x1c8(%rbp), %rdi
callq 0x6f10
movq -0x28(%rbp), %rax
movq -0x1c8(%rbp), %rcx
movq %rcx, (%rax)
movq -0x1c0(%rbp), %rcx
movq %rcx, 0x8(%rax)
leaq -0x138(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x16860
movq %rax, -0x210(%rbp)
movq -0x20(%rbp), %rdi
callq 0x5590
movq %rax, %rcx
movq -0x210(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x8(%rbp)
jmp 0x164ed
leaq -0x138(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x16860
movq %rax, -0x40(%rbp)
jmp 0x1638a
leaq -0xf8(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x16860
movq %rax, -0x40(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x16890
movq %rax, -0x218(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x168b0
movq %rax, %rcx
movq -0x218(%rbp), %rax
cmpq %rcx, %rax
jne 0x163cd
movq -0x28(%rbp), %rdi
movl $0x3, %esi
callq 0x13ab0
movq $0x0, -0x8(%rbp)
jmp 0x164ed
movq $0x200, -0x1d8(%rbp) # imm = 0x200
leaq -0x38(%rbp), %rdi
callq 0x168d0
movq %rax, -0x238(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x16890
movq %rax, %rcx
movq -0x238(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x1e0(%rbp)
leaq -0x1d8(%rbp), %rdi
leaq -0x1e0(%rbp), %rsi
callq 0xbb90
movq %rax, -0x228(%rbp)
movq $0x10000, -0x1e8(%rbp) # imm = 0x10000
leaq -0x38(%rbp), %rdi
callq 0x168b0
movq %rax, -0x230(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x16890
movq %rax, %rcx
movq -0x230(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x1f0(%rbp)
leaq -0x1e8(%rbp), %rdi
leaq -0x1f0(%rbp), %rsi
callq 0xc110
movq -0x228(%rbp), %rdi
movq %rax, %rsi
callq 0xc110
movq (%rax), %rax
movq %rax, -0x1d0(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x220(%rbp)
movq -0x1d0(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x16970
movq -0x220(%rbp), %rdi
movq %rax, -0x200(%rbp)
movq %rdx, -0x1f8(%rbp)
movq -0x28(%rbp), %rdx
leaq -0x200(%rbp), %rsi
callq 0x16920
movq %rax, %rsi
leaq -0x38(%rbp), %rdi
callq 0x168f0
movq -0x28(%rbp), %rdi
callq 0x8260
testb $0x1, %al
jne 0x164de
jmp 0x164e8
movq $0x0, -0x8(%rbp)
jmp 0x164ed
jmp 0x161c4
movq -0x8(%rbp), %rax
addq $0x2b0, %rsp            # imm = 0x2B0
popq %rbp
retq
nopw (%rax,%rax)