// File: /workspace/github_c_makefile_star2_O3/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 0x49af
movl %eax, %ebx
testq %r15, %r15
je 0x4952
leaq 0x4(%rsp), %rcx
movl %ebx, %edi
movl $0x1, %esi
movl $0x2, %edx
movl $0x4, %r8d
callq 0x20e0
testl %eax, %eax
je 0x493a
callq 0x2090
movq %rax, %r12
movl (%rax), %eax
testl %eax, %eax
je 0x4a2b
cmpl $0x5c, %eax
jne 0x4a34
movq 0x8(%r15), %rsi
movl 0x10(%r15), %edx
movl %ebx, %edi
callq 0x2290
cmpl $-0x1, %eax
je 0x4a07
movl %ebx, %edi
movl $0x4, %esi
movl $0x800, %edx            # imm = 0x800
xorl %eax, %eax
callq 0x20f0
cmpl $-0x1, %eax
je 0x49d9
movq 0x8(%r14), %rsi
movl 0x10(%r14), %edx
movl %ebx, %edi
callq 0x22d0
cmpl $-0x1, %eax
jne 0x4aae
callq 0x2090
movq %rax, %r14
movl (%rax), %eax
testl %eax, %eax
je 0x4a5e
cmpl $0x4, %eax
je 0x4aae
cmpl $0x73, %eax
je 0x4aae
leaq 0x2b8e(%rip), %rdi      # 0x753b
jmp 0x4a1b
callq 0x2090
cmpl $0x0, (%rax)
movl (%r14), %esi
movl 0x4(%r14), %edx
je 0x49ef
movq %rax, %rbx
leaq 0x2add(%rip), %rdi      # 0x74a7
xorl %eax, %eax
callq 0x4ef8
movl $0x0, (%rbx)
jmp 0x49fd
callq 0x2090
cmpl $0x0, (%rax)
je 0x4a4c
movq %rax, %r14
leaq 0x2b7a(%rip), %rdi      # 0x7567
jmp 0x4a1b
leaq 0x2ab1(%rip), %rdi      # 0x74a7
xorl %eax, %eax
callq 0x5017
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x4aae
callq 0x2090
cmpl $0x0, (%rax)
je 0x4a55
movq %rax, %r14
leaq 0x2ab4(%rip), %rdi      # 0x74cf
xorl %eax, %eax
callq 0x4ef8
movl $0x0, (%r14)
jmp 0x4a6c
leaq 0x2a84(%rip), %rdi      # 0x74b6
jmp 0x4a65
leaq 0x2a7b(%rip), %rdi      # 0x74b6
xorl %eax, %eax
callq 0x4ef8
movl $0x0, (%r12)
jmp 0x4a6c
leaq 0x2b14(%rip), %rdi      # 0x7567
jmp 0x4a65
leaq 0x2a73(%rip), %rdi      # 0x74cf
jmp 0x4a65
leaq 0x2ad6(%rip), %rdi      # 0x753b
xorl %eax, %eax
callq 0x5017
movl %ebx, %edi
callq 0x2180
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testl %eax, %eax
je 0x4aae
callq 0x2090
cmpl $0x0, (%rax)
je 0x4aa0
movq %rax, %r14
leaq 0x2a9b(%rip), %rdi      # 0x752b
xorl %eax, %eax
callq 0x4ef8
movl $0x0, (%r14)
jmp 0x4aae
leaq 0x2a84(%rip), %rdi      # 0x752b
xorl %eax, %eax
callq 0x5017
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq