// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xe0, %rsp
movb %sil, %al
movq 0x30(%rbp), %rsi
movl 0x28(%rbp), %esi
movl 0x20(%rbp), %esi
movl 0x18(%rbp), %esi
movl 0x10(%rbp), %esi
movq %rdi, -0x10(%rbp)
movb %al, -0x11(%rbp)
movl %edx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movq -0x10(%rbp), %rdi
callq 0xb250
movl %eax, -0xb8(%rbp)
cmpl $-0x1, -0xb8(%rbp)
jne 0xb6a7
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xb85c
movl -0xb8(%rbp), %edi
movq -0x10(%rbp), %rsi
movb -0x11(%rbp), %cl
movl 0x18(%rbp), %r8d
movl 0x10(%rbp), %r9d
movl 0x20(%rbp), %r10d
movl 0x28(%rbp), %eax
xorl %edx, %edx
movzbl %cl, %ecx
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
movl $0x1, 0x10(%rsp)
callq 0xb2b0
cmpl $-0x1, %eax
jne 0xb6ee
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xb85c
cmpl $0x0, -0x18(%rbp)
je 0xb7af
movl -0x2c(%rbp), %eax
movl %eax, -0xbc(%rbp)
subl $0x2, %eax
jb 0xb718
jmp 0xb708
movl -0xbc(%rbp), %eax
subl $0x2, %eax
je 0xb78a
jmp 0xb7ad
movq -0x10(%rbp), %rdi
movl -0xb8(%rbp), %edx
movl $0x1, %esi
movzbl -0x11(%rbp), %ecx
callq 0xacf0
cmpl $-0x1, %eax
jne 0xb741
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xb85c
movq -0x10(%rbp), %rdi
movl -0xb8(%rbp), %esi
movl -0x1c(%rbp), %edx
callq 0xa990
cmpl $-0x1, %eax
jne 0xb764
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xb85c
movq -0x10(%rbp), %rdi
movl -0xb8(%rbp), %esi
movq -0x28(%rbp), %rdx
callq 0xa830
cmpl $-0x1, %eax
jne 0xb788
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xb85c
jmp 0xb7ad
movl -0xb8(%rbp), %edi
movl $0x1, %esi
callq 0xa720
cmpl $-0x1, %eax
jne 0xb7ab
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xb85c
jmp 0xb7ad
jmp 0xb7af
movq -0x10(%rbp), %rsi
leaq -0xb0(%rbp), %rdi
callq 0x2bd0
cmpq $0x0, 0x30(%rbp)
je 0xb7d9
movq 0x30(%rbp), %rax
leaq -0xb0(%rbp), %rdi
movzwl (%rax), %esi
callq 0x3220
movl -0xb8(%rbp), %esi
leaq -0xb0(%rbp), %rdi
callq 0xaed0
cmpl $-0x1, %eax
jne 0xb7f9
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xb85c
cmpq $0x0, 0x30(%rbp)
je 0xb853
movq 0x30(%rbp), %rax
movzwl (%rax), %eax
cmpl $0x0, %eax
jne 0xb853
movl $0x80, -0xb4(%rbp)
movl -0xb8(%rbp), %edi
leaq -0xb0(%rbp), %rsi
leaq -0xb4(%rbp), %rdx
callq 0x22e0
cmpl $-0x1, %eax
jne 0xb83d
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xb85c
leaq -0xb0(%rbp), %rdi
callq 0x31a0
movw %ax, %cx
movq 0x30(%rbp), %rax
movw %cx, (%rax)
movl -0xb8(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xe0, %rsp
popq %rbp
retq
nopl (%rax,%rax)