// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x2300, %rsp           # imm = 0x2300
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movb $0x0, (%rax)
movq -0x28(%rbp), %rdi
leaq -0x1294(%rbp), %rsi
xorl %edx, %edx
callq 0x1a40
cmpl $-0x1, %eax
je 0x1ee5
movq -0x20(%rbp), %rdi
leaq -0x95e(%rbp), %rsi
movl $0x1, %edx
callq 0x1a40
cmpl $-0x1, %eax
je 0x1ee5
cmpb $0x0, -0x92e(%rbp)
jne 0x1ef1
cmpb $0x0, -0x1264(%rbp)
jne 0x1ef1
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x21db
movq -0x20(%rbp), %rdi
leaq 0x1689(%rip), %rsi      # 0x3585
movl $0x2, %edx
callq 0x1050
cmpl $0x0, %eax
jne 0x1f36
leaq -0x95e(%rbp), %rax
addq $0x30, %rax
movq %rax, -0x22a8(%rbp)
leaq -0x95e(%rbp), %rax
addq $0x930, %rax            # imm = 0x930
movq %rax, -0x22b8(%rbp)
jmp 0x1fb7
movsbl -0x92e(%rbp), %eax
cmpl $0x0, %eax
je 0x1f56
leaq -0x95e(%rbp), %rax
addq $0x30, %rax
movq %rax, -0x22d0(%rbp)
jmp 0x1f68
leaq -0x1294(%rbp), %rax
addq $0x30, %rax
movq %rax, -0x22d0(%rbp)
movq -0x22d0(%rbp), %rax
movq %rax, -0x22a8(%rbp)
movsbl -0x2e(%rbp), %eax
cmpl $0x0, %eax
je 0x1f95
leaq -0x95e(%rbp), %rax
addq $0x930, %rax            # imm = 0x930
movq %rax, -0x22d8(%rbp)
jmp 0x1fa9
leaq -0x1294(%rbp), %rax
addq $0x930, %rax            # imm = 0x930
movq %rax, -0x22d8(%rbp)
movq -0x22d8(%rbp), %rax
movq %rax, -0x22b8(%rbp)
leaq -0x22a0(%rbp), %rax
movq %rax, -0x22e0(%rbp)
movsbl -0x95e(%rbp), %eax
cmpl $0x0, %eax
je 0x1fe1
leaq -0x95e(%rbp), %rax
movq %rax, -0x22e8(%rbp)
jmp 0x201b
movsbl -0x1294(%rbp), %eax
cmpl $0x0, %eax
je 0x1ffd
leaq -0x1294(%rbp), %rax
movq %rax, -0x22f0(%rbp)
jmp 0x200d
leaq 0x1593(%rip), %rax      # 0x3597
movq %rax, -0x22f0(%rbp)
jmp 0x200d
movq -0x22f0(%rbp), %rax
movq %rax, -0x22e8(%rbp)
movq -0x22e0(%rbp), %rdi
movq -0x22e8(%rbp), %rcx
movq -0x22a8(%rbp), %r8
movq -0x22b8(%rbp), %rax
movsbl (%rax), %edx
leaq 0x1429(%rip), %r9       # 0x346a
leaq 0x1554(%rip), %rax      # 0x359c
cmpl $0x0, %edx
cmovneq %rax, %r9
movq -0x22b8(%rbp), %rax
movl $0x1000, %esi           # imm = 0x1000
leaq 0x1529(%rip), %rdx      # 0x358b
movq %rax, (%rsp)
movb $0x0, %al
callq 0x10a0
movl %eax, -0x22c0(%rbp)
cmpl $0x0, -0x22c0(%rbp)
jl 0x208b
movslq -0x22c0(%rbp), %rax
cmpq $0x1000, %rax           # imm = 0x1000
jb 0x2097
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x21db
cmpb $0x0, -0x92e(%rbp)
jne 0x2194
movsbl -0x82e(%rbp), %eax
cmpl $0x2f, %eax
je 0x2194
cmpb $0x0, -0x82e(%rbp)
je 0x2160
leaq -0x1294(%rbp), %rdi
addq $0x130, %rdi            # imm = 0x130
movl $0x2f, %esi
callq 0x10b0
movq %rax, -0x22b0(%rbp)
cmpq $0x0, %rax
je 0x215e
movq -0x22b0(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x22b0(%rbp)
movsbl 0x1(%rax), %eax
movl %eax, -0x22bc(%rbp)
movq -0x22b0(%rbp), %rax
movb $0x0, (%rax)
leaq -0x22a0(%rbp), %rdi
leaq -0x1294(%rbp), %rsi
addq $0x130, %rsi            # imm = 0x130
movl $0x1000, %edx           # imm = 0x1000
callq 0x2730
movq %rax, -0x22c8(%rbp)
movl -0x22bc(%rbp), %eax
movb %al, %cl
movq -0x22b0(%rbp), %rax
movb %cl, (%rax)
cmpq $0x1000, -0x22c8(%rbp) # imm = 0x1000
jb 0x215c
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x21db
jmp 0x215e
jmp 0x2192
leaq -0x22a0(%rbp), %rdi
leaq -0x1294(%rbp), %rsi
addq $0x130, %rsi            # imm = 0x130
movl $0x1000, %edx           # imm = 0x1000
callq 0x2730
cmpq $0x1000, %rax           # imm = 0x1000
jb 0x2190
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x21db
jmp 0x2192
jmp 0x2194
leaq -0x22a0(%rbp), %rdi
leaq -0x95e(%rbp), %rsi
addq $0x130, %rsi            # imm = 0x130
movl $0x1000, %edx           # imm = 0x1000
callq 0x2730
cmpq $0x1000, %rax           # imm = 0x1000
jb 0x21c4
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x21db
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x22a0(%rbp), %rdx
callq 0x21f0
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x2300, %rsp           # imm = 0x2300
popq %rbp
retq
nopw (%rax,%rax)