// File: /workspace/github_cpp_makefile_star2_O1/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 $0xf8, %rsp
movq %rcx, 0x8(%rsp)
movq %rdx, 0x18(%rsp)
movq %rdi, 0x70(%rsp)
movq (%rsi), %r15
xorl %r14d, %r14d
movq %r15, 0x10(%rsp)
movq %rax, 0x78(%rsp)
movq 0x10(%r15), %rax
movq 0x28(%r15), %rcx
movq %rax, 0x20(%rsp)
subq %rax, %rcx
leaq 0x20(%rsp), %rdi
movq %rdi, %rdx
leaq 0x30(%rsp), %rsi
cmoveq %rsi, %rdx
movq %rcx, 0x28(%rsp)
movq %rax, 0x88(%rsp)
movq %rcx, 0x90(%rsp)
xorl %eax, %eax
movq %rax, 0x98(%rsp)
movq %rdi, 0xa0(%rsp)
movq %rdx, 0xa8(%rsp)
movq %rsi, 0xb0(%rsp)
movq %rax, 0xb8(%rsp)
leaq 0x88(%rsp), %rdi
movq %r14, 0x80(%rsp)
movq %r14, %rsi
callq 0xd2a2
movq 0x28(%rsp), %r15
movq 0xb8(%rsp), %rax
movq %rax, 0x60(%rsp)
movups 0x88(%rsp), %xmm0
movups 0x98(%rsp), %xmm1
movups 0xa8(%rsp), %xmm2
movaps %xmm2, 0x50(%rsp)
movaps %xmm1, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
cmpq %r15, %rax
je 0xd158
movq 0x18(%rsp), %rax
movq (%rax), %rbp
movq 0x8(%rax), %r12
testq %r12, %r12
sete %bl
xorl %r14d, %r14d
movq 0x60(%rsp), %rax
movq %rax, 0xf0(%rsp)
movaps 0x30(%rsp), %xmm0
movaps 0x40(%rsp), %xmm1
movaps 0x50(%rsp), %xmm2
movaps %xmm2, 0xe0(%rsp)
movaps %xmm1, 0xd0(%rsp)
movaps %xmm0, 0xc0(%rsp)
testq %r12, %r12
je 0xd287
xorl %r13d, %r13d
cmpq %r15, 0xf0(%rsp)
je 0xd130
movq 0xc0(%rsp), %rax
movq 0xd0(%rsp), %rcx
movb (%rax,%rcx), %al
cmpb (%rbp,%r13), %al
jne 0xd135
leaq 0xc0(%rsp), %rdi
callq 0xd434
incq %r13
cmpq %r13, %r12
jne 0xd0f5
jmp 0xd150
testq %r13, %r13
jne 0xd152
leaq 0x30(%rsp), %rdi
callq 0xd434
cmpq %r15, 0x60(%rsp)
sete %r14b
jne 0xd0b5
jmp 0xd158
movb $0x1, %bl
testb $0x1, %r14b
je 0xd15f
xorl %ebx, %ebx
movq %r15, %r14
jmp 0xd164
movq 0x60(%rsp), %r14
cmpq %r15, %r14
sete %al
xorb $0x1, %bl
orb %al, %bl
jne 0xd1a5
callq 0x51d0
movq 0x8(%rsp), %rcx
movl $0x0, (%rcx)
movq %rax, 0x8(%rcx)
movq 0x18(%rsp), %rax
addq 0x8(%rax), %r14
xorl %edx, %edx
movq %r14, %rax
movq 0x10(%rsp), %r15
movq 0x80(%rsp), %r14
jmp 0xd27d
movq 0x10(%rsp), %r15
movq 0x28(%r15), %rcx
movq 0x40(%r15), %rax
subq 0x10(%r15), %rcx
subq %rcx, %rax
jne 0xd1d3
movq 0x8(%rsp), %rdi
movl $0x3, %esi
callq 0xc2aa
xorl %edx, %edx
xorl %eax, %eax
jmp 0xd27d
movq 0x58(%r15), %rbp
addq 0x48(%r15), %rcx
subq %rcx, %rbp
cmpq $0x201, %rbp            # imm = 0x201
movl $0x200, %ecx            # imm = 0x200
cmovbq %rcx, %rbp
cmpq %rbp, %rax
cmovbq %rax, %rbp
movl $0x10000, %eax          # imm = 0x10000
cmpq %rax, %rbp
cmovaeq %rax, %rbp
movq %r15, %rdi
movq %rbp, %rsi
callq 0x8ac0
movq 0x28(%r15), %rax
movq %rax, 0x30(%rsp)
movq %rbp, 0x38(%rsp)
movq %rbp, 0x40(%rsp)
movq 0x70(%rsp), %rax
movl 0x8(%rax), %edi
movzbl 0xc(%rax), %esi
movq 0x8(%rsp), %rbx
movq %rbx, (%rsp)
movl $0x1, %ecx
leaq 0x30(%rsp), %rdx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xd4a4
movq 0x28(%r15), %rcx
movq 0x30(%r15), %rdx
subq %rcx, %rdx
cmpq %rax, %rdx
cmovaeq %rax, %rdx
movslq %edx, %rax
addq %rcx, %rax
movq %rax, 0x28(%r15)
movq %rax, 0x18(%r15)
cmpl $0x0, (%rbx)
sete %dl
movl $0x0, %ecx
movq 0x78(%rsp), %rax
cmovneq %rcx, %rax
testb %dl, %dl
jne 0xcfe1
jmp 0xd28f
xorl %r14d, %r14d
jmp 0xd152
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop