// File: /workspace/github_cpp_makefile_star2_O1/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 0x20f91
movq (%r14), %rbp
xorl %r13d, %r13d
leaq 0x8(%rsp), %r15
movzbl (%rbp,%r13), %eax
cmpl $0xa, %eax
je 0x20f89
cmpl $0xd, %eax
je 0x20f89
movsbl %al, %esi
movq %r15, %rdi
callq 0xb540
incq %r13
cmpq %r13, %r12
jne 0x20f6e
leaq 0x136b8(%rip), %rsi     # 0x34650
leaq 0x8(%rsp), %rdi
movl $0x1, %ecx
xorl %edx, %edx
callq 0xbba0
cmpq $-0x1, %rax
je 0x2110c
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 0x137b8(%rip), %rsi     # 0x34792
callq 0x21414
leaq 0x48(%rsp), %rdi
movq %rax, (%rdi)
movq %rdx, 0x8(%rdi)
leaq 0x137a0(%rip), %rsi     # 0x34792
callq 0x213c9
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 0x1376f(%rip), %rdx     # 0x34792
leaq 0x28(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x21353
leaq 0x48(%rsp), %rdi
leaq 0x28(%rsp), %r14
movq %r14, %rsi
callq 0xb7d0
movq (%r14), %rdi
leaq 0x38(%rsp), %r15
cmpq %r15, %rdi
je 0x2105e
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 0x10322
leaq 0x88(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
addq %rsi, %rdx
leaq 0x78(%rsp), %rdi
callq 0xe53c
movl $0x40, %edi
callq 0xb5e0
movq %rax, %r14
leaq 0x28(%rsp), %rsi
leaq 0x78(%rsp), %rdx
movq %rax, %rdi
callq 0x20ecc
movq %r14, (%rbx)
movq 0x78(%rsp), %rdi
cmpq %r12, %rdi
je 0x210d8
movq 0x88(%rsp), %rsi
incq %rsi
callq 0xb600
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x210ef
movq 0x38(%rsp), %rsi
incq %rsi
callq 0xb600
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x21113
movq 0x58(%rsp), %rsi
incq %rsi
callq 0xb600
jmp 0x21113
movq $0x0, (%rbx)
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x2112f
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 0x21159
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r12, %rdi
je 0x21178
movq 0x88(%rsp), %rsi
incq %rsi
callq 0xb600
jmp 0x21178
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x21196
movq 0x38(%rsp), %rsi
incq %rsi
callq 0xb600
jmp 0x21196
jmp 0x21193
movq %rax, %rbx
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x211ba
movq 0x58(%rsp), %rsi
incq %rsi
callq 0xb600
jmp 0x211ba
jmp 0x211b7
jmp 0x211b7
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x211d6
movq 0x18(%rsp), %rsi
incq %rsi
callq 0xb600
movq %rbx, %rdi
callq 0xbbb0