// File: /workspace/github_cpp_makefile_star2_O1/ctSkennerton[P]fxtract/util/uri.c
// Function: uri_parts
void
uri_parts(char const *request, URIREF *uri)
{
    char const  *ap, *cp = find(request, 1);   // brk ":/?#\0"
    memset(uri, 0, sizeof(URIREF));

    if (cp > request && cp[0] == ':' && cp[1] == '/' && cp[2] == '/') {
        uri->scheme = (MEMREF){request, cp - request};
        cp += 3;
    } else {
        cp = request;
    }

    if (cp[0] == '/' && cp[1] == '/') {
        // Do not use find(): auth may contain ':'
        // and password may contain anything except '@'
        //  and query or fragment may contain "@"??
        if ((ap = strchr(cp += 2, '@'))) { // BasicAuth
            uri->auth = (MEMREF){cp, ap - cp};
            cp = ap + 1;
        }
    }

    uri->host.ptr = cp;
    cp = find(cp, 1);   // brk ":/?#\0"
    if (!(uri->host.len = cp - uri->host.ptr))
        uri->host.ptr = NULL;

    if (*cp == ':') {
        uri->port.ptr = ++cp;
        cp = find(cp, 2);    // brk "/?#\0"
        uri->port.len = cp - uri->port.ptr;
    }

    if (*cp == '/') {
        uri->path.ptr = ++cp;
        cp = find(cp, 3);    // brk "#?\0"
        uri->path.len = cp - uri->path.ptr;
    }

    if (*cp == '?') {
        uri->query.ptr = ++cp;
        cp = find(cp, 4);    // brk "#\0"
        uri->query.len = cp - uri->query.ptr;
    }

    if (*cp == '#') {
        uri->fragment.len = strlen(uri->fragment.ptr = cp + 1);
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
leaq -0x1(%rdi), %rax
movq $-0x1, %rcx
leaq 0x14d7(%rip), %r15      # 0x61b0
movzbl 0x1(%rax), %edx
incq %rax
incq %rcx
cmpl $0x0, (%r15,%rdx,4)
jle 0x4cd9
xorps %xmm0, %xmm0
movups %xmm0, 0x60(%rbx)
movups %xmm0, 0x50(%rbx)
movups %xmm0, 0x40(%rbx)
movups %xmm0, 0x30(%rbx)
movups %xmm0, 0x20(%rbx)
movups %xmm0, 0x10(%rbx)
movups %xmm0, (%rbx)
cmpq %r14, %rax
jbe 0x4d2c
cmpb $0x3a, (%rax)
jne 0x4d2c
cmpb $0x2f, 0x1(%rax)
jne 0x4d2c
cmpb $0x2f, 0x2(%rax)
jne 0x4d2c
movq %r14, (%rbx)
movq %rcx, 0x8(%rbx)
addq $0x3, %rax
movq %rax, %r14
cmpb $0x2f, (%r14)
jne 0x4d63
cmpb $0x2f, 0x1(%r14)
jne 0x4d63
addq $0x2, %r14
movq %r14, %rdi
movl $0x40, %esi
callq 0x3090
testq %rax, %rax
je 0x4d63
movq %rax, %rcx
subq %r14, %rcx
movq %r14, 0x10(%rbx)
movq %rcx, 0x18(%rbx)
incq %rax
movq %rax, %r14
movq %r14, 0x20(%rbx)
movq %r14, %rax
movq %rax, %rdi
movzbl (%rax), %ecx
incq %rax
cmpl $0x0, (%r15,%rcx,4)
jle 0x4d6a
movq %rdi, %rcx
subq %r14, %rcx
movq %rcx, 0x28(%rbx)
jne 0x4d8e
movq $0x0, 0x20(%rbx)
cmpb $0x3a, (%rdi)
jne 0x4db7
movq %rax, 0x30(%rbx)
movq $-0x1, %rcx
movzbl 0x1(%rax,%rcx), %edx
incq %rcx
cmpl $0x2, (%r15,%rdx,4)
jl 0x4d9e
movq %rcx, 0x38(%rbx)
addq %rcx, %rax
movq %rax, %rdi
cmpb $0x2f, (%rdi)
jne 0x4de0
leaq 0x1(%rdi), %rax
movq %rax, 0x40(%rbx)
xorl %eax, %eax
movzbl 0x1(%rdi,%rax), %ecx
incq %rax
cmpl $0x3, (%r15,%rcx,4)
jl 0x4dc6
leaq -0x1(%rax), %rcx
movq %rcx, 0x48(%rbx)
addq %rax, %rdi
cmpb $0x3f, (%rdi)
jne 0x4e09
leaq 0x1(%rdi), %rax
movq %rax, 0x50(%rbx)
xorl %eax, %eax
movzbl 0x1(%rdi,%rax), %ecx
incq %rax
cmpl $0x4, (%r15,%rcx,4)
jl 0x4def
leaq -0x1(%rax), %rcx
movq %rcx, 0x58(%rbx)
addq %rax, %rdi
cmpb $0x23, (%rdi)
jne 0x4e1e
incq %rdi
movq %rdi, 0x60(%rbx)
callq 0x30a0
movq %rax, 0x68(%rbx)
popq %rbx
popq %r14
popq %r15
retq