// File: mh0fm4[P]SCDC/src/components/common/common.cc
// Function: split_uri(char const*, long long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*)
void split_uri(const char *uri, scdcint_t uri_size, string *scheme, string *authority, string *path)
{
  string s = (uri_size < 0)?string(uri):string(uri, uri_size);

  SCDC_TRACE("split_uri: '" << s << "'");

  if (scheme) *scheme = "";
  if (authority) *authority = "";
  if (path) *path = "";

  size_t offset = 0, p;

  /* if there is a (first) ':', then ... */
  p = s.find(":", offset);
  if (p != string::npos)
  {
    /* ... all up to the ':' is the scheme */
    if (scheme) *scheme = s.substr(offset, p - offset);
    offset = p + 1;
  }

  /* if there is a '//' following, then ... */
  if (s.substr(offset, 2) == "//")
  {
    offset += 2;

    /* ... if there is a '/', then ... */
    p = s.find("/", offset);
    if (p != string::npos)
    {
      /* ... all up to the '/' is the authority */
      if (authority) *authority = s.substr(offset, p - offset);
      offset = p + 1;

    } else
    {
      /* ... all remaining is the authority */
      if (authority) *authority = s.substr(offset);
      offset = string::npos;
    }

  } else
  {
    /* ... if there is an immediate '/', then skip it (because it marks the beginning of the path) */
    p = s.find("/", offset);
    if (p == offset) ++offset;
  }

  /* if there is something left, then this is the path */
  if (offset != string::npos)
  {
    if (path) *path = s.substr(offset);
  }

  SCDC_TRACE("split_uri: scheme: '" << ((scheme)?*scheme:"") << "', authority: '" << ((authority)?*authority:"") << "', path: '" << ((path)?*path:"") << "'");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x10(%rbp), %rax
movb $0x0, -0x4a(%rbp)
movb $0x0, -0x5e(%rbp)
cmpq $0x0, %rax
jge 0x2a7cb
movq -0x8(%rbp), %rax
movq %rax, -0x120(%rbp)
leaq -0x49(%rbp), %rdi
movq %rdi, -0x118(%rbp)
callq 0xcbc0
movq -0x120(%rbp), %rsi
movq -0x118(%rbp), %rdx
movb $0x1, -0x4a(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x27820
jmp 0x2a7c9
jmp 0x2a817
movq -0x8(%rbp), %rax
movq %rax, -0x138(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x130(%rbp)
leaq -0x5d(%rbp), %rdi
movq %rdi, -0x128(%rbp)
callq 0xcbc0
movq -0x138(%rbp), %rsi
movq -0x130(%rbp), %rdx
movq -0x128(%rbp), %rcx
movb $0x1, -0x5e(%rbp)
leaq -0x48(%rbp), %rdi
callq 0xc7a0
jmp 0x2a815
jmp 0x2a817
testb $0x1, -0x5e(%rbp)
jne 0x2a81f
jmp 0x2a828
leaq -0x5d(%rbp), %rdi
callq 0xc730
testb $0x1, -0x4a(%rbp)
jne 0x2a830
jmp 0x2a839
leaq -0x49(%rbp), %rdi
callq 0xc730
jmp 0x2a83b
jmp 0x2a83d
jmp 0x2a83f
cmpq $0x0, -0x18(%rbp)
je 0x2a8ae
movq -0x18(%rbp), %rdi
leaq 0x7bd53(%rip), %rsi     # 0xa65a4
callq 0xc920
jmp 0x2a858
jmp 0x2a8ae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x2a887
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
testb $0x1, -0x5e(%rbp)
jne 0x2a87c
jmp 0x2a885
leaq -0x5d(%rbp), %rdi
callq 0xc730
jmp 0x2a887
testb $0x1, -0x4a(%rbp)
jne 0x2a88f
jmp 0x2a898
leaq -0x49(%rbp), %rdi
callq 0xc730
jmp 0x2ab24
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x2ab1b
cmpq $0x0, -0x20(%rbp)
je 0x2a8c9
movq -0x20(%rbp), %rdi
leaq 0x7bce4(%rip), %rsi     # 0xa65a4
callq 0xc920
jmp 0x2a8c7
jmp 0x2a8c9
cmpq $0x0, -0x28(%rbp)
je 0x2a8e4
movq -0x28(%rbp), %rdi
leaq 0x7bcc9(%rip), %rsi     # 0xa65a4
callq 0xc920
jmp 0x2a8e2
jmp 0x2a8e4
movq $0x0, -0x68(%rbp)
movq -0x68(%rbp), %rdx
leaq -0x48(%rbp), %rdi
leaq 0x7ba69(%rip), %rsi     # 0xa6364
callq 0xccf0
movq %rax, -0x70(%rbp)
cmpq $-0x1, -0x70(%rbp)
je 0x2a957
cmpq $0x0, -0x18(%rbp)
je 0x2a94b
movq -0x68(%rbp), %rdx
movq -0x70(%rbp), %rcx
subq %rdx, %rcx
leaq -0x90(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0xc6b0
jmp 0x2a92f
movq -0x18(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0xc850
leaq -0x90(%rbp), %rdi
callq 0xc3e0
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdx
leaq -0xb0(%rbp), %rdi
leaq -0x48(%rbp), %rsi
movl $0x2, %ecx
callq 0xc6b0
jmp 0x2a972
leaq 0x7b9f3(%rip), %rsi     # 0xa636c
leaq -0xb0(%rbp), %rdi
callq 0x25b80
movb %al, -0x139(%rbp)
jmp 0x2a98d
leaq -0xb0(%rbp), %rdi
callq 0xc3e0
movb -0x139(%rbp), %al
testb $0x1, %al
jne 0x2a9a8
jmp 0x2aa8a
movq -0x68(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdx
leaq -0x48(%rbp), %rdi
leaq 0x7b9aa(%rip), %rsi     # 0xa636d
callq 0xccf0
movq %rax, -0x70(%rbp)
cmpq $-0x1, -0x70(%rbp)
je 0x2aa40
cmpq $0x0, -0x20(%rbp)
je 0x2aa32
movq -0x68(%rbp), %rdx
movq -0x70(%rbp), %rcx
subq %rdx, %rcx
leaq -0xd0(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0xc6b0
jmp 0x2a9f7
movq -0x20(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0xc850
leaq -0xd0(%rbp), %rdi
callq 0xc3e0
jmp 0x2aa32
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0xc3e0
jmp 0x2ab1b
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
jmp 0x2aa88
cmpq $0x0, -0x20(%rbp)
je 0x2aa80
movq -0x68(%rbp), %rdx
leaq -0xf0(%rbp), %rdi
leaq -0x48(%rbp), %rsi
movq $-0x1, %rcx
callq 0xc6b0
jmp 0x2aa64
movq -0x20(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0xc850
leaq -0xf0(%rbp), %rdi
callq 0xc3e0
movq $-0x1, -0x68(%rbp)
jmp 0x2aaba
movq -0x68(%rbp), %rdx
leaq -0x48(%rbp), %rdi
leaq 0x7b8d4(%rip), %rsi     # 0xa636d
callq 0xccf0
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
cmpq -0x68(%rbp), %rax
jne 0x2aab8
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
jmp 0x2aaba
cmpq $-0x1, -0x68(%rbp)
je 0x2ab03
cmpq $0x0, -0x28(%rbp)
je 0x2ab01
movq -0x68(%rbp), %rdx
leaq -0x110(%rbp), %rdi
leaq -0x48(%rbp), %rsi
movq $-0x1, %rcx
callq 0xc6b0
jmp 0x2aae5
movq -0x28(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0xc850
leaq -0x110(%rbp), %rdi
callq 0xc3e0
jmp 0x2ab03
jmp 0x2ab05
jmp 0x2ab07
jmp 0x2ab09
leaq -0x48(%rbp), %rdi
callq 0xc3e0
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
leaq -0x48(%rbp), %rdi
callq 0xc3e0
movq -0x58(%rbp), %rdi
callq 0xcba0
nopl (%rax)