// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]kivaloo/liball/../libcperciva/util/sock.c
// Function: sock_connect_bind_nb
int
sock_connect_bind_nb(const struct sock_addr * sa,
    const struct sock_addr * sa_b)
{
	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;
	}

	/* Bind the socket to sa_b (if applicable). */
	if (sa_b) {
		/* 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 socket. */
		if ((bind(s, sa_b->name, sa_b->namelen)) == -1) {
			warnp("Error binding socket");
			goto err1;
		}
	}

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

	/* Attempt to connect. */
	if ((connect(s, sa->name, sa->namelen) == -1) &&
	    (errno != EINPROGRESS) &&
	    (errno != EINTR)) {
		warnp("connect");
		goto err1;
	}

	/* We have a connect(ed|ing) socket. */
	return (s);

err1:
	if (close(s))
		warnp("close");
err0:
	/* We failed to connect to this address. */
	return (-1);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %r14
movl $0x1, 0x4(%rsp)
movl (%rdi), %edi
movl 0x4(%r14), %esi
xorl %edx, %edx
callq 0x2360
cmpl $-0x1, %eax
je 0x4994
movl %eax, %ebx
testq %r15, %r15
je 0x4937
leaq 0x4(%rsp), %rcx
movl %ebx, %edi
movl $0x1, %esi
movl $0x2, %edx
movl $0x4, %r8d
callq 0x20e0
testl %eax, %eax
je 0x491f
callq 0x2090
movq %rax, %r12
movl (%rax), %eax
testl %eax, %eax
je 0x4a10
cmpl $0x5c, %eax
jne 0x4a19
movq 0x8(%r15), %rsi
movl 0x10(%r15), %edx
movl %ebx, %edi
callq 0x2290
cmpl $-0x1, %eax
je 0x49ec
movl %ebx, %edi
movl $0x4, %esi
movl $0x800, %edx            # imm = 0x800
xorl %eax, %eax
callq 0x20f0
cmpl $-0x1, %eax
je 0x49be
movq 0x8(%r14), %rsi
movl 0x10(%r14), %edx
movl %ebx, %edi
callq 0x22d0
cmpl $-0x1, %eax
jne 0x4a93
callq 0x2090
movq %rax, %r14
movl (%rax), %eax
testl %eax, %eax
je 0x4a43
cmpl $0x4, %eax
je 0x4a93
cmpl $0x73, %eax
je 0x4a93
leaq 0x2b91(%rip), %rdi      # 0x7523
jmp 0x4a00
callq 0x2090
cmpl $0x0, (%rax)
movl (%r14), %esi
movl 0x4(%r14), %edx
je 0x49d4
movq %rax, %rbx
leaq 0x2ae0(%rip), %rdi      # 0x748f
xorl %eax, %eax
callq 0x4ef0
movl $0x0, (%rbx)
jmp 0x49e2
callq 0x2090
cmpl $0x0, (%rax)
je 0x4a31
movq %rax, %r14
leaq 0x2b7d(%rip), %rdi      # 0x754f
jmp 0x4a00
leaq 0x2ab4(%rip), %rdi      # 0x748f
xorl %eax, %eax
callq 0x500f
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x4a93
callq 0x2090
cmpl $0x0, (%rax)
je 0x4a3a
movq %rax, %r14
leaq 0x2ab7(%rip), %rdi      # 0x74b7
xorl %eax, %eax
callq 0x4ef0
movl $0x0, (%r14)
jmp 0x4a51
leaq 0x2a87(%rip), %rdi      # 0x749e
jmp 0x4a4a
leaq 0x2a7e(%rip), %rdi      # 0x749e
xorl %eax, %eax
callq 0x4ef0
movl $0x0, (%r12)
jmp 0x4a51
leaq 0x2b17(%rip), %rdi      # 0x754f
jmp 0x4a4a
leaq 0x2a76(%rip), %rdi      # 0x74b7
jmp 0x4a4a
leaq 0x2ad9(%rip), %rdi      # 0x7523
xorl %eax, %eax
callq 0x500f
movl %ebx, %edi
callq 0x2180
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testl %eax, %eax
je 0x4a93
callq 0x2090
cmpl $0x0, (%rax)
je 0x4a85
movq %rax, %r14
leaq 0x2a9e(%rip), %rdi      # 0x7513
xorl %eax, %eax
callq 0x4ef0
movl $0x0, (%r14)
jmp 0x4a93
leaq 0x2a87(%rip), %rdi      # 0x7513
xorl %eax, %eax
callq 0x500f
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
nopl (%rax)