// File: /workspace/github_cpp_makefile_star2_O3/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 0x2205e(%rip), %rax     # 0x45310
movq %rax, 0x8(%r12)
leaq 0x10(%rsp), %rsi
movq %rbx, (%rsi)
leaq 0xffe8(%rip), %rcx      # 0x332ae
movl $0x2, %edx
movq %r12, %r8
xorl %r9d, %r9d
callq 0x23e25
movq %rax, %r14
movq 0x248a8(%rip), %rax     # 0x47b88
cmpb $0x1, 0x4(%r12)
movabsq $-0x70502de1da3a1f65, %r12 # imm = 0x8FAFD21E25C5E09B
jne 0x2335a
cmpq %r12, %rax
je 0x2331c
movabsq $-0x4d54ee85da8120f3, %rcx # imm = 0xB2AB117A257EDF0D
cmpq %rcx, %rax
je 0x2331c
movq 0x24873(%rip), %rax     # 0x47b80
leaq 0x2486c(%rip), %rdi     # 0x47b80
movl $0x2, %esi
callq *0x30(%rax)
cmpl $0x2, (%rsp)
jne 0x23415
movq 0x8(%rsp), %rcx
movq 0x24856(%rip), %rax     # 0x47b88
leaq 0x24847(%rip), %rdx     # 0x47b80
xorl %esi, %esi
cmpq %rdx, %rcx
setne %sil
xorl %edx, %edx
cmpq %rax, 0x8(%rcx)
setne %dl
testq %rax, %rax
cmovel %esi, %edx
cmpb $0x1, %dl
je 0x23415
cmpq %r12, %rax
je 0x23384
movabsq $-0x4d54ee85da8120f3, %rcx # imm = 0xB2AB117A257EDF0D
cmpq %rcx, %rax
je 0x23384
movq 0x2480b(%rip), %rax     # 0x47b80
leaq 0x24804(%rip), %rdi     # 0x47b80
movl $0x2, %esi
callq *0x30(%rax)
cmpl $0x2, (%rsp)
jne 0x233bd
movq 0x8(%rsp), %rax
movq 0x247f2(%rip), %rcx     # 0x47b88
leaq 0x247e3(%rip), %rdx     # 0x47b80
xorl %esi, %esi
cmpq %rdx, %rax
sete %sil
xorl %edx, %edx
cmpq %rcx, 0x8(%rax)
sete %dl
testq %rcx, %rcx
cmovel %esi, %edx
testb %dl, %dl
je 0x233bd
xorl %eax, %eax
jmp 0x23408
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 0x233e9
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)
movb $0x1, %al
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 0x23b9a(%rip), %rsi     # 0x46fe8
movq 0x23af3(%rip), %rdx     # 0x46f48
movq %rbx, %rdi
callq 0xbb60
movq %rax, %r14
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2347b
movq 0x20(%rsp), %rsi
incq %rsi
callq 0xb600
testb %bpl, %bpl
jne 0x23485
jmp 0x2348d
movq %rax, %r14
movq %rbx, %rdi
callq 0xb4b0
movq %r14, %rdi
callq 0xbbb0