// File: /workspace/github_c_makefile_star2_O2/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 0x43fd
movl %eax, %ebx
testq %r15, %r15
je 0x43a2
pushq $0x1
popq %rsi
pushq $0x2
popq %rdx
leaq 0x4(%rsp), %rcx
pushq $0x4
popq %r8
movl %ebx, %edi
callq 0x20e0
testl %eax, %eax
je 0x438a
callq 0x2090
movq %rax, %r12
movl (%rax), %eax
testl %eax, %eax
je 0x4471
cmpl $0x5c, %eax
jne 0x447a
movq 0x8(%r15), %rsi
movl 0x10(%r15), %edx
movl %ebx, %edi
callq 0x2290
cmpl $-0x1, %eax
je 0x4450
pushq $0x4
popq %rsi
movl %ebx, %edi
movl $0x800, %edx            # imm = 0x800
xorl %eax, %eax
callq 0x20f0
cmpl $-0x1, %eax
je 0x4424
movq 0x8(%r14), %rsi
movl 0x10(%r14), %edx
movl %ebx, %edi
callq 0x22d0
cmpl $-0x1, %eax
jne 0x44ec
callq 0x2090
movq %rax, %r14
movl (%rax), %eax
testl %eax, %eax
je 0x44a1
cmpl $0x4, %eax
je 0x44ec
cmpl $0x73, %eax
je 0x44ec
leaq 0x3140(%rip), %rdi      # 0x753b
jmp 0x4464
callq 0x2090
cmpl $0x0, (%rax)
movl (%r14), %esi
movl 0x4(%r14), %edx
je 0x443a
movq %rax, %rbx
leaq 0x308f(%rip), %rdi      # 0x74a7
xorl %eax, %eax
callq 0x4919
andl $0x0, (%rbx)
jmp 0x4448
callq 0x2090
cmpl $0x0, (%rax)
je 0x448f
movq %rax, %r14
leaq 0x312f(%rip), %rdi      # 0x7567
jmp 0x4464
leaq 0x3066(%rip), %rdi      # 0x74a7
xorl %eax, %eax
callq 0x4aa8
pushq $-0x1
popq %rbx
jmp 0x44ec
callq 0x2090
cmpl $0x0, (%rax)
je 0x4498
movq %rax, %r14
leaq 0x306b(%rip), %rdi      # 0x74cf
xorl %eax, %eax
callq 0x4919
andl $0x0, (%r14)
jmp 0x44af
leaq 0x303e(%rip), %rdi      # 0x74b6
jmp 0x44a8
leaq 0x3035(%rip), %rdi      # 0x74b6
xorl %eax, %eax
callq 0x4919
andl $0x0, (%r12)
jmp 0x44af
leaq 0x30d1(%rip), %rdi      # 0x7567
jmp 0x44a8
leaq 0x3030(%rip), %rdi      # 0x74cf
jmp 0x44a8
leaq 0x3093(%rip), %rdi      # 0x753b
xorl %eax, %eax
callq 0x4aa8
movl %ebx, %edi
callq 0x2180
pushq $-0x1
popq %rbx
testl %eax, %eax
je 0x44ec
callq 0x2090
cmpl $0x0, (%rax)
je 0x44de
movq %rax, %r14
leaq 0x305a(%rip), %rdi      # 0x752b
xorl %eax, %eax
callq 0x4919
andl $0x0, (%r14)
jmp 0x44ec
leaq 0x3046(%rip), %rdi      # 0x752b
xorl %eax, %eax
callq 0x4aa8
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
nop