// File: /workspace/github_cpp_makefile_star2_O3/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 0x1597(%rip), %r15      # 0x61b0
movzbl 0x1(%rax), %edx
incq %rax
incq %rcx
cmpl $0x0, (%r15,%rdx,4)
jle 0x4c19
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 0x4c6c
cmpb $0x3a, (%rax)
jne 0x4c6c
cmpb $0x2f, 0x1(%rax)
jne 0x4c6c
cmpb $0x2f, 0x2(%rax)
jne 0x4c6c
movq %r14, (%rbx)
movq %rcx, 0x8(%rbx)
addq $0x3, %rax
movq %rax, %r14
cmpb $0x2f, (%r14)
jne 0x4ca3
cmpb $0x2f, 0x1(%r14)
jne 0x4ca3
addq $0x2, %r14
movq %r14, %rdi
movl $0x40, %esi
callq 0x3090
testq %rax, %rax
je 0x4ca3
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 0x4caa
movq %rdi, %rcx
subq %r14, %rcx
movq %rcx, 0x28(%rbx)
jne 0x4cce
movq $0x0, 0x20(%rbx)
movb (%rdi), %cl
cmpb $0x3a, %cl
jne 0x4cfa
movq %rax, 0x30(%rbx)
movq $-0x1, %rcx
movzbl 0x1(%rax,%rcx), %edx
incq %rcx
cmpl $0x2, (%r15,%rdx,4)
jl 0x4ce0
movq %rcx, 0x38(%rbx)
leaq (%rax,%rcx), %rdi
movb (%rax,%rcx), %cl
cmpb $0x2f, %cl
jne 0x4d25
leaq 0x1(%rdi), %rax
movq %rax, 0x40(%rbx)
movq $-0x1, %rax
movzbl 0x1(%rdi), %ecx
incq %rdi
incq %rax
cmpl $0x3, (%r15,%rcx,4)
jl 0x4d0e
movq %rax, 0x48(%rbx)
movb (%rdi), %cl
cmpb $0x3f, %cl
jne 0x4d50
leaq 0x1(%rdi), %rax
movq %rax, 0x50(%rbx)
movq $-0x1, %rax
movzbl 0x1(%rdi), %ecx
incq %rdi
incq %rax
cmpl $0x4, (%r15,%rcx,4)
jl 0x4d39
movq %rax, 0x58(%rbx)
movb (%rdi), %cl
cmpb $0x23, %cl
jne 0x4d65
incq %rdi
movq %rdi, 0x60(%rbx)
callq 0x30a0
movq %rax, 0x68(%rbx)
popq %rbx
popq %r14
popq %r15
retq
nop