// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]spiped/liball/../libcperciva/network/network_connect.c
// Function: tryconnect
static int
tryconnect(struct connect_cookie * C)
{

	/* Try addresses until we find one which doesn't fail immediately. */
	for (; C->sas[0] != NULL; C->sas++) {
		/* Can we try to connect to this address? */
		if ((C->s = sock_connect_bind_nb(C->sas[0], C->sa_b)) != -1)
			break;
	}

	/* Did we run out of addresses to try? */
	if (C->sas[0] == NULL)
		goto failed;

	/* If we've been asked to have a timeout, set one. */
	if (C->timeo_enabled) {
		if ((C->cookie_timeo = events_timer_register(callback_timeo,
		    C, &C->timeo)) == NULL)
			goto err1;
	} else {
		C->cookie_timeo = NULL;
	}

	/* Wait until this socket connects or fails to do so. */
	if (events_network_register(callback_connect, C, C->s,
	    EVENTS_NETWORK_OP_WRITE))
		goto err2;

	/* Success! */
	return (0);

failed:
	/* Schedule a callback. */
	if ((C->cookie_immediate =
	    events_immediate_register(docallback, C, 0)) == NULL)
		goto err1;

	/* Failure successfully handled. */
	return (0);

err2:
	if (C->cookie_timeo != NULL)
		events_timer_cancel(C->cookie_timeo);
err1:
	if ((C->s != -1) && close(C->s))
		warnp("close");
	free(C);

	/* Fatal error. */
	return (-1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
cmpq $0x0, (%rax)
je 0x4bd4
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x6e90
movq -0x10(%rbp), %rcx
movl %eax, 0x38(%rcx)
cmpl $-0x1, %eax
je 0x4bc0
jmp 0x4bd4
jmp 0x4bc2
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
addq $0x8, %rcx
movq %rcx, 0x10(%rax)
jmp 0x4b8c
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
cmpq $0x0, (%rax)
jne 0x4be4
jmp 0x4c56
movq -0x10(%rbp), %rax
cmpl $0x0, 0x3c(%rax)
je 0x4c1b
movq -0x10(%rbp), %rsi
movq -0x10(%rbp), %rdx
addq $0x20, %rdx
leaq 0x10f(%rip), %rdi       # 0x4d10
callq 0x43d0
movq -0x10(%rbp), %rcx
movq %rax, 0x40(%rcx)
cmpq $0x0, %rax
jne 0x4c19
jmp 0x4c9b
jmp 0x4c27
movq -0x10(%rbp), %rax
movq $0x0, 0x40(%rax)
movq -0x10(%rbp), %rsi
movq -0x10(%rbp), %rax
movl 0x38(%rax), %edx
leaq 0x117(%rip), %rdi       # 0x4d50
movl $0x1, %ecx
callq 0x35c0
cmpl $0x0, %eax
je 0x4c4a
jmp 0x4c81
movl $0x0, -0x4(%rbp)
jmp 0x4cff
movq -0x10(%rbp), %rsi
leaq 0x1df(%rip), %rdi       # 0x4e40
xorl %edx, %edx
callq 0x3020
movq -0x10(%rbp), %rcx
movq %rax, 0x30(%rcx)
cmpq $0x0, %rax
jne 0x4c78
jmp 0x4c9b
movl $0x0, -0x4(%rbp)
jmp 0x4cff
movq -0x10(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0x4c99
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rdi
callq 0x4610
jmp 0x4c9b
movq -0x10(%rbp), %rax
cmpl $-0x1, 0x38(%rax)
je 0x4cef
movq -0x10(%rbp), %rax
movl 0x38(%rax), %edi
callq 0x2190
cmpl $0x0, %eax
je 0x4cef
jmp 0x4cb8
callq 0x20a0
cmpl $0x0, (%rax)
je 0x4cdd
leaq 0x5790(%rip), %rdi      # 0xa459
movb $0x0, %al
callq 0x7a60
callq 0x20a0
movl $0x0, (%rax)
jmp 0x4ceb
leaq 0x5775(%rip), %rdi      # 0xa459
movb $0x0, %al
callq 0x7cb0
jmp 0x4ced
jmp 0x4cef
movq -0x10(%rbp), %rdi
callq 0x2040
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax,%rax)