// File: /workspace/github_cpp_makefile_star2_O1/kztomita[P]http-dump/./socket.h
// Function: bool read_line<sync_stream_wrapper>(sync_stream_wrapper&, boost::asio::basic_streambuf<std::allocator<char>>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
bool read_line(SyncReadStream& socket, boost::asio::streambuf& receive_buffer, std::string& line) {
  namespace asio = boost::asio;

  boost::system::error_code error;

  // receive_bufferにdelimiterより先のデータもまとめて読み込まれ場合がある。
  // この場合、sizeとreceive_buffer.size()が異ることがあるのでsizeの方を
  // 参照する必要がある。
  std::size_t size = asio::read_until(socket, receive_buffer, "\r\n", error);
  if (error && error != asio::error::eof) {
    throw std::runtime_error(error.message());
  }
  if (error == asio::error::eof) {
    return false;
  }

  const char* data = asio::buffer_cast<const char*>(receive_buffer.data());
  line.assign(data, size - 2);

  receive_buffer.consume(size);

  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x30, %rsp
movq %rdx, %r15
movq %rsi, %rbx
movq %rsp, %r12
movl $0x0, (%r12)
movb $0x0, 0x4(%r12)
leaq 0x22dc6(%rip), %rax     # 0x46270
movq %rax, 0x8(%r12)
leaq 0x10(%rsp), %rsi
movq %rbx, (%rsi)
leaq 0x10df0(%rip), %rcx     # 0x342ae
movl $0x2, %edx
movq %r12, %r8
xorl %r9d, %r9d
callq 0x2401b
movq %rax, %r14
cmpb $0x1, 0x4(%r12)
movabsq $-0x70502de1da3a1f65, %r12 # imm = 0x8FAFD21E25C5E09B
jne 0x23552
movq 0x2569e(%rip), %rax     # 0x48b88
cmpq %r12, %rax
je 0x23514
movabsq $-0x4d54ee85da8120f3, %rcx # imm = 0xB2AB117A257EDF0D
cmpq %rcx, %rax
je 0x23514
movq 0x2567b(%rip), %rax     # 0x48b80
leaq 0x25674(%rip), %rdi     # 0x48b80
movl $0x2, %esi
callq *0x30(%rax)
cmpl $0x2, (%rsp)
jne 0x2361a
movq 0x8(%rsp), %rax
movq 0x2565e(%rip), %rcx     # 0x48b88
leaq 0x2564f(%rip), %rdx     # 0x48b80
xorl %esi, %esi
cmpq %rdx, %rax
setne %sil
xorl %edx, %edx
cmpq %rcx, 0x8(%rax)
setne %dl
testq %rcx, %rcx
cmovel %esi, %edx
cmpb $0x1, %dl
je 0x2361a
movq 0x2562f(%rip), %rax     # 0x48b88
cmpq %r12, %rax
je 0x23583
movabsq $-0x4d54ee85da8120f3, %rcx # imm = 0xB2AB117A257EDF0D
cmpq %rcx, %rax
je 0x23583
movq 0x2560c(%rip), %rax     # 0x48b80
leaq 0x25605(%rip), %rdi     # 0x48b80
movl $0x2, %esi
callq *0x30(%rax)
cmpl $0x2, (%rsp)
jne 0x235b7
movq 0x8(%rsp), %rax
movq 0x255f3(%rip), %rcx     # 0x48b88
leaq 0x255e4(%rip), %rdx     # 0x48b80
xorl %esi, %esi
cmpq %rdx, %rax
sete %sil
xorl %ebp, %ebp
cmpq %rcx, 0x8(%rax)
sete %bpl
testq %rcx, %rcx
cmovel %esi, %ebp
jmp 0x235b9
xorl %ebp, %ebp
testb %bpl, %bpl
jne 0x23607
movq 0x10(%rbx), %rcx
leaq -0x2(%r14), %r8
movq 0x8(%r15), %rdx
movq %r15, %rdi
xorl %esi, %esi
callq 0xba50
movq 0x28(%rbx), %rax
cmpq %rax, 0x18(%rbx)
jae 0x235ea
movq 0x48(%rbx), %rcx
movq %rcx, 0x8(%rbx)
movq %rax, 0x18(%rbx)
movq 0x10(%rbx), %rcx
leaq (%rcx,%r14), %rdx
movl %eax, %esi
subl %ecx, %esi
cmpq %rax, %rdx
cmovbeq %r14, %rsi
movslq %esi, %rax
addq %rcx, %rax
movq %rax, 0x10(%rbx)
xorb $0x1, %bpl
movl %ebp, %eax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0xb300
movq %rax, %rbx
movq 0x8(%rsp), %rsi
movl (%rsp), %edx
movq (%rsi), %rax
leaq 0x10(%rsp), %rdi
callq *0x20(%rax)
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0xbaa0
xorl %ebp, %ebp
movq 0x2499d(%rip), %rsi     # 0x47ff0
movq 0x248f6(%rip), %rdx     # 0x47f50
movq %rbx, %rdi
callq 0xbb60
movq %rax, %r14
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x23688
movq 0x20(%rsp), %rsi
incq %rsi
callq 0xb600
jmp 0x23688
movq %rax, %r14
movb $0x1, %bpl
testb %bpl, %bpl
je 0x23695
movq %rbx, %rdi
callq 0xb4b0
movq %r14, %rdi
callq 0xbbb0