// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x1, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %edi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %esi
xorl %edx, %edx
callq 0x2380
movl %eax, -0x1c(%rbp)
cmpl $-0x1, %eax
jne 0x5a69
jmp 0x5a15
callq 0x20a0
cmpl $0x0, (%rax)
je 0x5a47
movq -0x10(%rbp), %rax
movl (%rax), %esi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
leaq 0x4abf(%rip), %rdi      # 0xa4f2
movb $0x0, %al
callq 0x65c0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x5a62
movq -0x10(%rbp), %rax
movl (%rax), %esi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
leaq 0x4a97(%rip), %rdi      # 0xa4f2
movb $0x0, %al
callq 0x6810
jmp 0x5a64
jmp 0x5c42
cmpq $0x0, -0x18(%rbp)
je 0x5b37
movl -0x1c(%rbp), %edi
movl $0x1, %esi
movl $0x2, %edx
leaq -0x20(%rbp), %rcx
movl $0x4, %r8d
callq 0x20e0
cmpl $0x0, %eax
je 0x5add
callq 0x20a0
cmpl $0x5c, (%rax)
je 0x5adb
jmp 0x5aa1
callq 0x20a0
cmpl $0x0, (%rax)
je 0x5ac6
leaq 0x4a4f(%rip), %rdi      # 0xa501
movb $0x0, %al
callq 0x65c0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x5ad4
leaq 0x4a34(%rip), %rdi      # 0xa501
movb $0x0, %al
callq 0x6810
jmp 0x5ad6
jmp 0x5bfa
jmp 0x5add
movl -0x1c(%rbp), %edi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x18(%rbp), %rax
movl 0x10(%rax), %edx
callq 0x22b0
cmpl $-0x1, %eax
jne 0x5b35
jmp 0x5afb
callq 0x20a0
cmpl $0x0, (%rax)
je 0x5b20
leaq 0x4a0e(%rip), %rdi      # 0xa51a
movb $0x0, %al
callq 0x65c0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x5b2e
leaq 0x49f3(%rip), %rdi      # 0xa51a
movb $0x0, %al
callq 0x6810
jmp 0x5b30
jmp 0x5bfa
jmp 0x5b37
movl -0x1c(%rbp), %edi
movl $0x4, %esi
movl $0x800, %edx            # imm = 0x800
movb $0x0, %al
callq 0x20f0
cmpl $-0x1, %eax
jne 0x5b89
jmp 0x5b52
callq 0x20a0
cmpl $0x0, (%rax)
je 0x5b77
leaq 0x4a4f(%rip), %rdi      # 0xa5b2
movb $0x0, %al
callq 0x65c0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x5b85
leaq 0x4a34(%rip), %rdi      # 0xa5b2
movb $0x0, %al
callq 0x6810
jmp 0x5b87
jmp 0x5bfa
movl -0x1c(%rbp), %edi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x10(%rbp), %rax
movl 0x10(%rax), %edx
callq 0x2300
cmpl $-0x1, %eax
jne 0x5bf2
callq 0x20a0
cmpl $0x73, (%rax)
je 0x5bf2
callq 0x20a0
cmpl $0x4, (%rax)
je 0x5bf2
jmp 0x5bbb
callq 0x20a0
cmpl $0x0, (%rax)
je 0x5be0
leaq 0x49ba(%rip), %rdi      # 0xa586
movb $0x0, %al
callq 0x65c0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x5bee
leaq 0x499f(%rip), %rdi      # 0xa586
movb $0x0, %al
callq 0x6810
jmp 0x5bf0
jmp 0x5bfa
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x5c49
movl -0x1c(%rbp), %edi
callq 0x21a0
cmpl $0x0, %eax
je 0x5c40
jmp 0x5c09
callq 0x20a0
cmpl $0x0, (%rax)
je 0x5c2e
leaq 0x495c(%rip), %rdi      # 0xa576
movb $0x0, %al
callq 0x65c0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x5c3c
leaq 0x4941(%rip), %rdi      # 0xa576
movb $0x0, %al
callq 0x6810
jmp 0x5c3e
jmp 0x5c40
jmp 0x5c42
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)