// File: /workspace/github_c_makefile_star2_O3/dxwc[P]sfeed/util.c
// Function: absuri
int
absuri(char *buf, size_t bufsiz, const char *link, const char *base)
{
	struct uri ulink, ubase;
	char tmp[4096], *host, *p, *port;
	int c, r;
	size_t i;

	buf[0] = '\0';
	if (parseuri(base, &ubase, 0) == -1 ||
	    parseuri(link, &ulink, 1) == -1 ||
	    (!ulink.host[0] && !ubase.host[0]))
		return -1;

	if (!strncmp(link, "//", 2)) {
		host = ulink.host;
		port = ulink.port;
	} else {
		host = ulink.host[0] ? ulink.host : ubase.host;
		port = ulink.port[0] ? ulink.port : ubase.port;
	}
	r = snprintf(tmp, sizeof(tmp), "%s://%s%s%s",
		ulink.proto[0] ?
			ulink.proto :
			(ubase.proto[0] ? ubase.proto : "http"),
		host,
		port[0] ? ":" : "",
		port);
	if (r < 0 || (size_t)r >= sizeof(tmp))
		return -1; /* error or truncation */

	/* relative to root */
	if (!ulink.host[0] && ulink.path[0] != '/') {
		/* relative to base url path */
		if (ulink.path[0]) {
			if ((p = strrchr(ubase.path, '/'))) {
				/* temporary null-terminate */
				c = *(++p);
				*p = '\0';
				i = strlcat(tmp, ubase.path, sizeof(tmp));
				*p = c; /* restore */
				if (i >= sizeof(tmp))
					return -1;
			}
		} else if (strlcat(tmp, ubase.path, sizeof(tmp)) >=
		           sizeof(tmp)) {
			return -1;
		}
	}
	if (strlcat(tmp, ulink.path, sizeof(tmp)) >= sizeof(tmp))
		return -1;

	return encodeuri(buf, bufsiz, tmp);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2288, %rsp           # imm = 0x2288
movq %rdx, %rbp
movq %rsi, %r15
movq %rdi, %r14
movb $0x0, (%rdi)
leaq 0x94a(%rsp), %r13
movq %rcx, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x1928
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $-0x1, %eax
je 0x1dd9
leaq 0x14(%rsp), %r12
movq %rbp, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0x1928
cmpl $-0x1, %eax
je 0x1dd9
movb 0x44(%rsp), %al
movb 0x97a(%rsp), %cl
orb %al, %cl
je 0x1dd9
leaq 0x44(%rsp), %r8
cmpb $0x2f, (%rbp)
jne 0x1c2e
cmpb $0x2f, 0x1(%rbp)
jne 0x1c2e
leaq 0x944(%rsp), %rax
jmp 0x1c54
leaq 0x97a(%rsp), %rcx
testb %al, %al
cmoveq %rcx, %r8
movl $0x930, %eax            # imm = 0x930
leaq (%r12,%rax), %rcx
addq %r13, %rax
cmpb $0x0, 0x944(%rsp)
cmovneq %rcx, %rax
cmpb $0x0, 0x94a(%rsp)
leaq 0x18ec(%rip), %rcx      # 0x354f
cmoveq %rcx, %r13
cmpb $0x0, 0x14(%rsp)
cmoveq %r13, %r12
cmpb $0x0, (%rax)
leaq 0x180c(%rip), %rcx      # 0x3486
leaq 0x18d3(%rip), %r9       # 0x3554
cmoveq %rcx, %r9
movq %rax, (%rsp)
leaq 0x18b3(%rip), %rdx      # 0x3543
leaq 0x1280(%rsp), %rdi
movl $0x1000, %esi           # imm = 0x1000
movq %r12, %rcx
xorl %eax, %eax
callq 0x1090
cmpl $0xfff, %eax            # imm = 0xFFF
ja 0x1dd9
cmpb $0x0, 0x44(%rsp)
sete %cl
movb 0x144(%rsp), %al
cmpb $0x2f, %al
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x1d36
leaq 0xa7a(%rsp), %r12
testb %al, %al
je 0x1d15
movq %r12, %rdi
movl $0x2f, %esi
callq 0x10a0
testq %rax, %rax
je 0x1d36
movq %rax, %r13
movb 0x1(%rax), %bl
movb $0x0, 0x1(%rax)
leaq 0x1280(%rsp), %rdi
movl $0x1000, %edx           # imm = 0x1000
movq %r12, %rsi
callq 0x2134
movb %bl, 0x1(%r13)
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x1d2a
leaq 0x1280(%rsp), %rdi
movl $0x1000, %edx           # imm = 0x1000
movq %r12, %rsi
callq 0x2134
cmpq $0xfff, %rax            # imm = 0xFFF
ja 0x1dd9
leaq 0x144(%rsp), %rsi
leaq 0x1280(%rsp), %r12
movl $0x1000, %edx           # imm = 0x1000
movq %r12, %rdi
callq 0x2134
cmpq $0xfff, %rax            # imm = 0xFFF
ja 0x1dd9
xorl %r13d, %r13d
leaq 0x1812(%rip), %rbp      # 0x3577
movzbl (%r12), %ebx
cmpl $0x20, %ebx
je 0x1d93
testl %ebx, %ebx
je 0x1dc8
testb %bl, %bl
js 0x1d93
callq 0x11c0
movq (%rax), %rax
testb $0x2, (%rax,%rbx,2)
jne 0x1d93
cmpq %r15, %r13
jae 0x1dc1
movb %bl, (%r14,%r13)
incq %r13
jmp 0x1dbc
leaq 0x3(%r13), %rax
cmpq %r15, %rax
jae 0x1dc1
movb $0x25, (%r14,%r13)
movl %ebx, %ecx
shrl $0x4, %ecx
movb (%rcx,%rbp), %cl
movb %cl, 0x1(%r14,%r13)
andl $0xf, %ebx
movb (%rbx,%rbp), %cl
movb %cl, 0x2(%r14,%r13)
movq %rax, %r13
incq %r12
jmp 0x1d65
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x1dd9
cmpq %r15, %r13
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jae 0x1dd9
movb $0x0, (%r14,%r13)
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x2288, %rsp           # imm = 0x2288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq