// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]kivaloo/liball/../libcperciva/util/sock.c
// Function: sock_listener
int
sock_listener(const struct sock_addr * sa)
{
	int s;
	int val = 1;

	/* Create a socket. */
	if ((s = socket(sa->ai_family, sa->ai_socktype, 0)) == -1) {
		warnp("socket(%d, %d)", sa->ai_family, sa->ai_socktype);
		goto err0;
	}

	/* Attempt to set SO_REUSEADDR. */
	if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val))) {
		/* ENOPROTOOPT is ok. */
		if (errno != ENOPROTOOPT) {
			warnp("setsockopt(SO_REUSEADDR)");
			goto err1;
		}
	}

	/* Bind the socket. */
	if (bind(s, sa->name, sa->namelen)) {
		warnp("Error binding socket");
		goto err1;
	}

	/* Mark the socket as listening. */
	if (listen(s, 10)) {
		warnp("Error marking socket as listening");
		goto err1;
	}

	/* Mark the socket as non-blocking. */
	if (fcntl(s, F_SETFL, O_NONBLOCK) == -1) {
		warnp("Error marking socket as non-blocking");
		goto err1;
	}

	/* Success! */
	return (s);

err1:
	if (close(s))
		warnp("close");
err0:
	/* Failure! */
	return (-1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movl $0x1, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %edi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %esi
xorl %edx, %edx
callq 0x2380
movl %eax, -0x14(%rbp)
cmpl $-0x1, %eax
jne 0x5655
jmp 0x5601
callq 0x20a0
cmpl $0x0, (%rax)
je 0x5633
movq -0x10(%rbp), %rax
movl (%rax), %esi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
leaq 0x4ed3(%rip), %rdi      # 0xa4f2
movb $0x0, %al
callq 0x65c0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x564e
movq -0x10(%rbp), %rax
movl (%rax), %esi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
leaq 0x4eab(%rip), %rdi      # 0xa4f2
movb $0x0, %al
callq 0x6810
jmp 0x5650
jmp 0x5803
movl -0x14(%rbp), %edi
movl $0x1, %esi
movl $0x2, %edx
leaq -0x18(%rbp), %rcx
movl $0x4, %r8d
callq 0x20e0
cmpl $0x0, %eax
je 0x56be
callq 0x20a0
cmpl $0x5c, (%rax)
je 0x56bc
jmp 0x5682
callq 0x20a0
cmpl $0x0, (%rax)
je 0x56a7
leaq 0x4e6e(%rip), %rdi      # 0xa501
movb $0x0, %al
callq 0x65c0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x56b5
leaq 0x4e53(%rip), %rdi      # 0xa501
movb $0x0, %al
callq 0x6810
jmp 0x56b7
jmp 0x57bb
jmp 0x56be
movl -0x14(%rbp), %edi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x10(%rbp), %rax
movl 0x10(%rax), %edx
callq 0x22b0
cmpl $0x0, %eax
je 0x5716
jmp 0x56dc
callq 0x20a0
cmpl $0x0, (%rax)
je 0x5701
leaq 0x4e2d(%rip), %rdi      # 0xa51a
movb $0x0, %al
callq 0x65c0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x570f
leaq 0x4e12(%rip), %rdi      # 0xa51a
movb $0x0, %al
callq 0x6810
jmp 0x5711
jmp 0x57bb
movl -0x14(%rbp), %edi
movl $0xa, %esi
callq 0x2270
cmpl $0x0, %eax
je 0x5761
jmp 0x572a
callq 0x20a0
cmpl $0x0, (%rax)
je 0x574f
leaq 0x4df4(%rip), %rdi      # 0xa52f
movb $0x0, %al
callq 0x65c0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x575d
leaq 0x4dd9(%rip), %rdi      # 0xa52f
movb $0x0, %al
callq 0x6810
jmp 0x575f
jmp 0x57bb
movl -0x14(%rbp), %edi
movl $0x4, %esi
movl $0x800, %edx            # imm = 0x800
movb $0x0, %al
callq 0x20f0
cmpl $-0x1, %eax
jne 0x57b3
jmp 0x577c
callq 0x20a0
cmpl $0x0, (%rax)
je 0x57a1
leaq 0x4dc4(%rip), %rdi      # 0xa551
movb $0x0, %al
callq 0x65c0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x57af
leaq 0x4da9(%rip), %rdi      # 0xa551
movb $0x0, %al
callq 0x6810
jmp 0x57b1
jmp 0x57bb
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x580a
movl -0x14(%rbp), %edi
callq 0x21a0
cmpl $0x0, %eax
je 0x5801
jmp 0x57ca
callq 0x20a0
cmpl $0x0, (%rax)
je 0x57ef
leaq 0x4d9b(%rip), %rdi      # 0xa576
movb $0x0, %al
callq 0x65c0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x57fd
leaq 0x4d80(%rip), %rdi      # 0xa576
movb $0x0, %al
callq 0x6810
jmp 0x57ff
jmp 0x5801
jmp 0x5803
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)