// File: /workspace/github_c_makefile_star2_O2/jfriesse[P]omping/sockfunc.c
// Function: sf_create_unicast_socket
int
sf_create_unicast_socket(const struct sockaddr *local_addr, uint8_t ttl, int mcast_send,
    int allow_mcast_loop, const char *local_ifname, enum sf_transport_method transport_method,
    int receive_timestamp, int force_recvttl, int sndbuf_size, int rcvbuf_size,
    uint16_t *bind_port)
{
	struct sockaddr_storage bind_addr;
	socklen_t bind_addr_len;
	int sock;

	sock = sf_create_udp_socket(local_addr);
	if (sock == -1) {
		return (-1);
	}

	if (sf_set_socket_common_options(sock, local_addr, SF_CT_UNI, ttl, force_recvttl,
	    receive_timestamp, sndbuf_size, rcvbuf_size, 1) == -1) {
		return (-1);
	}

	if (mcast_send) {
		switch (transport_method) {
		case SF_TM_ASM:
		case SF_TM_SSM:
			if (sfset_ttl(local_addr, SF_CT_MULTI, sock, ttl) == -1) {
				return (-1);
			}

			if (sfset_mcast_loop(local_addr, sock, allow_mcast_loop) == -1) {
				return (-1);
			}

			if (sfset_mcast_if(local_addr, sock, local_ifname) == -1) {
				return (-1);
			}
			break;
		case SF_TM_IPBC:
			if (sfset_broadcast(sock, 1) == -1) {
				return (-1);
			}
			break;
		}
	}

	af_copy_sa_to_sas(&bind_addr, local_addr);

	if (bind_port != NULL) {
		af_sa_set_port(AF_CAST_SA(&bind_addr), *bind_port);
	}

	if (sf_bind_socket(AF_CAST_SA(&bind_addr), sock) == -1) {
		return (-1);
	}

	if (bind_port != NULL && *bind_port == 0) {
		bind_addr_len = sizeof(bind_addr);

		if (getsockname(sock, AF_CAST_SA(&bind_addr), &bind_addr_len) == -1) {
			return (-1);
		}

		*bind_port = af_sa_port(AF_CAST_SA(&bind_addr));
	}

	return (sock);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movl %r9d, %r12d
movq %r8, 0x8(%rsp)
movl %ecx, %ebp
movl %edx, %r13d
movl %esi, %r15d
movq %rdi, %r14
callq 0x7c8c
movl %eax, %ebx
pushq $-0x1
popq %rax
cmpl $-0x1, %ebx
je 0x80c2
movl 0xe8(%rsp), %eax
movl 0xe0(%rsp), %r10d
movl 0xd8(%rsp), %r8d
movl 0xd0(%rsp), %r9d
movzbl %r15b, %r15d
movl %ebx, %edi
movq %r14, %rsi
xorl %edx, %edx
movl %r15d, %ecx
pushq %rax
pushq %r10
callq 0x7cc2
popq %rcx
popq %rdx
cmpl $-0x1, %eax
je 0x80bf
testl %r13d, %r13d
je 0x8038
cmpl $0x2, %r12d
jae 0x8023
pushq $0x1
popq %rsi
movq %r14, %rdi
movl %ebx, %edx
movl %r15d, %ecx
callq 0x7946
cmpl $-0x1, %eax
je 0x80bf
movq %r14, %rdi
movl %ebx, %esi
movl %ebp, %edx
callq 0x76f1
cmpl $-0x1, %eax
je 0x80bf
movq %r14, %rdi
movl %ebx, %esi
movq 0x8(%rsp), %rdx
callq 0x75f2
jmp 0x802f
jne 0x8038
pushq $0x1
popq %rsi
movl %ebx, %edi
callq 0x754f
cmpl $-0x1, %eax
je 0x80bf
movq 0xf0(%rsp), %r15
leaq 0x18(%rsp), %rdi
movq %r14, %rsi
callq 0x27bc
testq %r15, %r15
je 0x8060
movzwl (%r15), %esi
leaq 0x18(%rsp), %rdi
callq 0x2bec
testq %r15, %r15
sete %bpl
leaq 0x18(%rsp), %rdi
movl %ebx, %esi
callq 0x7a90
movl %eax, %ecx
cmpl $-0x1, %eax
sete %dl
movl %ebx, %eax
cmovel %ecx, %eax
orb %bpl, %dl
jne 0x80c2
cmpw $0x0, (%r15)
jne 0x80bb
leaq 0x14(%rsp), %rdx
movl $0x80, (%rdx)
leaq 0x18(%rsp), %rsi
movl %ebx, %edi
callq 0x22e0
movl %eax, %ecx
pushq $-0x1
popq %rax
cmpl $-0x1, %ecx
je 0x80c2
leaq 0x18(%rsp), %rdi
callq 0x2bae
movw %ax, (%r15)
movl %ebx, %eax
jmp 0x80c2
pushq $-0x1
popq %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq