// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %rcx, %rbx
movq %rdx, %r14
movq %rdi, 0x80(%rsp)
movq (%rsi), %r12
leaq 0x80(%rsp), %r15
movq 0x28(%r12), %rcx
xorl %ebp, %ebp
movq 0x10(%r12), %rax
movq %rax, 0x70(%rsp)
movq %r15, %rdx
subq %rax, %rcx
movq %rcx, 0x78(%rsp)
je 0xb66a
leaq 0x70(%rsp), %rdx
movq %rax, 0x88(%rsp)
movq %rcx, 0x90(%rsp)
andq $0x0, 0x98(%rsp)
leaq 0x70(%rsp), %r13
movq %r13, 0xa0(%rsp)
movq %rdx, 0xa8(%rsp)
movq %r15, 0xb0(%rsp)
andq $0x0, 0xb8(%rsp)
leaq 0x88(%rsp), %rdi
movq %rbp, %rsi
callq 0xb9be
xorps %xmm0, %xmm0
movaps %xmm0, 0xd0(%rsp)
andq $0x0, 0xe0(%rsp)
movq 0x78(%rsp), %rbp
movq %r13, 0xe8(%rsp)
movq %r15, 0xf0(%rsp)
movq %r15, 0xf8(%rsp)
movq %rbp, 0x100(%rsp)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
movq 0x100(%rsp), %rax
movq %rax, 0x68(%rsp)
movaps 0xd0(%rsp), %xmm0
movaps 0xe0(%rsp), %xmm1
movaps 0xf0(%rsp), %xmm2
movups %xmm2, 0x58(%rsp)
movups %xmm1, 0x48(%rsp)
movups %xmm0, 0x38(%rsp)
movq 0xb8(%rsp), %rax
movq %rax, 0x30(%rsp)
movups 0x88(%rsp), %xmm0
movups 0x98(%rsp), %xmm1
movups 0xa8(%rsp), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq 0x108(%rsp), %rdi
callq 0xb86c
movq 0x138(%rsp), %r13
cmpq %rbp, %r13
je 0xb78e
cmpb $0x1, 0x140(%rsp)
je 0xb847
movq %r13, %rbp
movq 0x28(%r12), %rcx
movq 0x40(%r12), %rax
subq 0x10(%r12), %rcx
subq %rcx, %rax
je 0xb837
movq 0x58(%r12), %rsi
addq 0x48(%r12), %rcx
subq %rcx, %rsi
cmpq $0x201, %rsi            # imm = 0x201
jae 0xb7c1
movl $0x200, %esi            # imm = 0x200
cmpq %rsi, %rax
cmovbq %rax, %rsi
movl $0x10000, %eax          # imm = 0x10000
cmpq %rax, %rsi
jb 0xb7d7
movl $0x10000, %esi          # imm = 0x10000
movq %r12, %rdi
callq 0xbe26
movq %rax, 0xc0(%rsp)
movq %rdx, 0xc8(%rsp)
movq 0x80(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
movq %rbx, %rdx
callq 0xb9a2
movq 0x28(%r12), %rcx
movq 0x30(%r12), %rdx
subq %rcx, %rdx
cmpq %rax, %rdx
jb 0xb81c
movq %rax, %rdx
movslq %edx, %rax
addq %rax, %rcx
movq %rcx, 0x28(%r12)
movq %rcx, 0x18(%r12)
cmpl $0x0, (%rbx)
je 0xb64e
jmp 0xb842
pushq $0x3
popq %rsi
movq %rbx, %rdi
callq 0xa7f8
xorl %r13d, %r13d
jmp 0xb857
callq 0x5210
andl $0x0, (%rbx)
movq %rax, 0x8(%rbx)
addq 0x8(%r14), %r13
movq %r13, %rax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq