// File: kztomita[P]http-dump/url.cc
// Function: parse_url(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
url_components parse_url(const std::string& url) {
  std::smatch m;
  if (!std::regex_search(url, m, std::regex(R"((^[a-z][a-z0-9+.-]*)://([^ /]+?)(?::(\d+))?(/[\S]*)?$)"))) {
    throw std::invalid_argument("invalid url.");
  }

  url_components c;
  c.scheme = m[1].str();
  c.host = m[2].str();

  if (m[3].matched) {
    c.port = static_cast<unsigned int>(std::stoi(m[3].str()));
  }

  if (m[4].matched) {
    c.path_and_query = m[4].str();
  } else {
    c.path_and_query = "/";
  }

  return c;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movq %rdi, -0x108(%rbp)
movq %rdi, %rax
movq %rax, -0x100(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x24b60
movq -0x10(%rbp), %rax
movq %rax, -0xf8(%rbp)
leaq 0x4faa5(%rip), %rsi     # 0x742b4
leaq -0x50(%rbp), %rdi
movl $0x10, %edx
callq 0x24c00
jmp 0x2481f
movq -0xf8(%rbp), %rdi
leaq -0x30(%rbp), %rsi
leaq -0x50(%rbp), %rdx
xorl %ecx, %ecx
callq 0x24ba0
movb %al, -0x109(%rbp)
jmp 0x2483d
movb -0x109(%rbp), %al
xorb $-0x1, %al
movb %al, -0x10a(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x24ca0
movb -0x10a(%rbp), %al
testb $0x1, %al
jne 0x24863
jmp 0x248ef
movl $0x10, %edi
callq 0xd580
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x118(%rbp)
leaq 0x4fa69(%rip), %rsi     # 0x742ea
callq 0xd2e0
jmp 0x24888
movq -0x118(%rbp), %rdi
movq 0x88692(%rip), %rsi     # 0xacf28
movq 0x88683(%rip), %rdx     # 0xacf20
callq 0xd970
jmp 0x24b5c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x24b4a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x24ca0
jmp 0x24b4a
movq -0x118(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
callq 0xdc70
jmp 0x24b4a
movq -0x108(%rbp), %rdi
movb $0x0, -0x5d(%rbp)
callq 0x24cd0
leaq -0x30(%rbp), %rdi
movl $0x1, %esi
callq 0x24d20
movq %rax, -0x120(%rbp)
jmp 0x24916
movq -0x120(%rbp), %rsi
leaq -0x80(%rbp), %rdi
callq 0x24d90
jmp 0x24928
movq -0x108(%rbp), %rdi
leaq -0x80(%rbp), %rsi
movq %rsi, -0x130(%rbp)
callq 0xd790
movq -0x130(%rbp), %rdi
callq 0xdac0
leaq -0x30(%rbp), %rdi
movl $0x2, %esi
callq 0x24d20
movq %rax, -0x128(%rbp)
jmp 0x24962
movq -0x128(%rbp), %rsi
leaq -0xa0(%rbp), %rdi
callq 0x24d90
jmp 0x24977
movq -0x108(%rbp), %rdi
addq $0x20, %rdi
leaq -0xa0(%rbp), %rsi
movq %rsi, -0x140(%rbp)
callq 0xd790
movq -0x140(%rbp), %rdi
callq 0xdac0
leaq -0x30(%rbp), %rdi
movl $0x3, %esi
callq 0x24d20
movq %rax, -0x138(%rbp)
jmp 0x249b8
movq -0x138(%rbp), %rax
testb $0x1, 0x10(%rax)
je 0x24a7f
leaq -0x30(%rbp), %rdi
movl $0x3, %esi
callq 0x24d20
movq %rax, -0x148(%rbp)
jmp 0x249e0
movq -0x148(%rbp), %rsi
leaq -0xd0(%rbp), %rdi
callq 0x24d90
jmp 0x249f5
xorl %eax, %eax
movl %eax, %esi
leaq -0xd0(%rbp), %rdi
movl $0xa, %edx
callq 0x24e50
movl %eax, -0x14c(%rbp)
jmp 0x24a12
movl -0x14c(%rbp), %eax
movl %eax, -0xac(%rbp)
leaq -0xa8(%rbp), %rdi
leaq -0xac(%rbp), %rsi
callq 0x24e90
movq -0x108(%rbp), %rax
movq -0xa8(%rbp), %rcx
movq %rcx, 0x40(%rax)
leaq -0xd0(%rbp), %rdi
callq 0xdac0
jmp 0x24a7f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x24b3e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0xdac0
jmp 0x24b3e
leaq -0x30(%rbp), %rdi
movl $0x4, %esi
callq 0x24d20
movq %rax, -0x158(%rbp)
jmp 0x24a96
movq -0x158(%rbp), %rax
testb $0x1, 0x10(%rax)
je 0x24af4
leaq -0x30(%rbp), %rdi
movl $0x4, %esi
callq 0x24d20
movq %rax, -0x160(%rbp)
jmp 0x24aba
movq -0x160(%rbp), %rsi
leaq -0xf0(%rbp), %rdi
callq 0x24d90
jmp 0x24acf
movq -0x108(%rbp), %rdi
addq $0x48, %rdi
leaq -0xf0(%rbp), %rsi
callq 0xd790
leaq -0xf0(%rbp), %rdi
callq 0xdac0
jmp 0x24b0f
movq -0x108(%rbp), %rdi
addq $0x48, %rdi
leaq 0x4f7f1(%rip), %rsi     # 0x742f7
callq 0xd5c0
jmp 0x24b0d
jmp 0x24b0f
movb $0x1, -0x5d(%rbp)
testb $0x1, -0x5d(%rbp)
jne 0x24b25
movq -0x108(%rbp), %rdi
callq 0x11220
leaq -0x30(%rbp), %rdi
callq 0x24ec0
movq -0x100(%rbp), %rax
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
movq -0x108(%rbp), %rdi
callq 0x11220
leaq -0x30(%rbp), %rdi
callq 0x24ec0
movq -0x58(%rbp), %rdi
callq 0xd990
nopl (%rax)