// File: /workspace/github_cpp_makefile_star2_O3/kztomita[P]http-dump/http_header.cc
// Function: create_http_header_from_header_line_or_null(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
http_header_ptr create_http_header_from_header_line_or_null(const std::string& line) {
  // 改行コード削除
  std::string stripped;
  std::copy_if(line.begin(), line.end(), std::back_inserter(stripped),
               [](char c){return c != '\r' && c != '\n' ;});

  auto pos = stripped.find(":");
  if (pos == std::string::npos) {
    return http_header_ptr();      // null
  }

  auto stripped_view = std::string_view(stripped);

  auto name = std::string_view(stripped_view.substr(0, pos));
  name = string_util::trim(name, " ");

  auto value = line.substr(pos + 1, stripped_view.size() - pos - 1);
  value = string_util::trim(value, " ");

  return std::make_unique<http_header>(std::string(name), std::string(value));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x8(%rsi), %r12
testq %r12, %r12
je 0x20e5d
movq (%r14), %rbp
xorl %r13d, %r13d
leaq 0x8(%rsp), %r15
movzbl (%rbp,%r13), %eax
cmpl $0xa, %eax
je 0x20e55
cmpl $0xd, %eax
je 0x20e55
movsbl %al, %esi
movq %r15, %rdi
callq 0xb540
incq %r13
cmpq %r13, %r12
jne 0x20e3a
leaq 0x127ec(%rip), %rsi     # 0x33650
leaq 0x8(%rsp), %rdi
movl $0x1, %ecx
xorl %edx, %edx
callq 0xbba0
cmpq $-0x1, %rax
je 0x20fd8
movq %rax, %r12
movq 0x10(%rsp), %r15
cmpq %rax, %r15
cmovbq %r15, %rax
movq 0x8(%rsp), %rcx
leaq 0x68(%rsp), %rdi
movq %rax, (%rdi)
movq %rcx, 0x8(%rdi)
leaq 0x128ec(%rip), %rsi     # 0x33792
callq 0x212cd
leaq 0x48(%rsp), %rdi
movq %rax, (%rdi)
movq %rdx, 0x8(%rdi)
leaq 0x128d4(%rip), %rsi     # 0x33792
callq 0x21282
movq %rax, 0x68(%rsp)
movq %rdx, 0x70(%rsp)
leaq 0x1(%r12), %rdx
notq %r12
addq %r12, %r15
leaq 0x48(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rcx
callq 0xb660
leaq 0x128a3(%rip), %rdx     # 0x33792
leaq 0x28(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x2120c
leaq 0x48(%rsp), %rdi
leaq 0x28(%rsp), %r14
movq %r14, %rsi
callq 0xb7d0
movq (%r14), %rdi
leaq 0x38(%rsp), %r15
cmpq %r15, %rdi
je 0x20f2a
movq 0x38(%rsp), %rsi
incq %rsi
callq 0xb600
movq 0x70(%rsp), %rsi
leaq 0x28(%rsp), %rdi
movq %r15, (%rdi)
movq 0x68(%rsp), %rdx
addq %rsi, %rdx
callq 0x1025a
leaq 0x88(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
addq %rsi, %rdx
leaq 0x78(%rsp), %rdi
callq 0xe500
movl $0x40, %edi
callq 0xb5e0
movq %rax, %r14
leaq 0x28(%rsp), %rsi
leaq 0x78(%rsp), %rdx
movq %rax, %rdi
callq 0x20d98
movq %r14, (%rbx)
movq 0x78(%rsp), %rdi
cmpq %r12, %rdi
je 0x20fa4
movq 0x88(%rsp), %rsi
incq %rsi
callq 0xb600
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x20fbb
movq 0x38(%rsp), %rsi
incq %rsi
callq 0xb600
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x20fdf
movq 0x58(%rsp), %rsi
incq %rsi
callq 0xb600
jmp 0x20fdf
movq $0x0, (%rbx)
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x20ffb
movq 0x18(%rsp), %rsi
incq %rsi
callq 0xb600
movq %rbx, %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movl $0x40, %esi
movq %r14, %rdi
callq 0xb600
jmp 0x21025
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r12, %rdi
je 0x21044
movq 0x88(%rsp), %rsi
incq %rsi
callq 0xb600
jmp 0x21044
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x21062
movq 0x38(%rsp), %rsi
incq %rsi
callq 0xb600
jmp 0x21062
jmp 0x2105f
movq %rax, %rbx
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x21086
movq 0x58(%rsp), %rsi
incq %rsi
callq 0xb600
jmp 0x21086
jmp 0x21083
jmp 0x21083
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x210a2
movq 0x18(%rsp), %rsi
incq %rsi
callq 0xb600
movq %rbx, %rdi
callq 0xbbb0