// File: /workspace/github_c_makefile_star2_O0/jfriesse[P]omping/sockfunc.c
// Function: sf_mcast_join_ssm_group
int
sf_mcast_join_ssm_group(const struct sockaddr *mcast_addr, const struct sockaddr *local_addr,
    const struct sockaddr *remote_addr, const char *local_ifname, int sock)
{
#ifdef IP_ADD_SOURCE_MEMBERSHIP
	struct ip_mreq_source mreq4;
#endif
#ifdef MCAST_JOIN_SOURCE_GROUP
	struct group_source_req greq;
	size_t addr_len;
	int iface_index;
	int ip_lv;
#endif

#ifdef IP_ADD_SOURCE_MEMBERSHIP
	if (mcast_addr->sa_family == AF_INET) {
		memset(&mreq4, 0, sizeof(mreq4));

		mreq4.imr_multiaddr = ((struct sockaddr_in *)mcast_addr)->sin_addr;
		mreq4.imr_interface = ((struct sockaddr_in *)local_addr)->sin_addr;
		mreq4.imr_sourceaddr = ((struct sockaddr_in *)remote_addr)->sin_addr;

		if (setsockopt(sock, IPPROTO_IP, IP_ADD_SOURCE_MEMBERSHIP, &mreq4,
		    sizeof(mreq4)) == -1) {
			DEBUG_PRINTF("setsockopt IP_ADD_SOURCE_MEMBERSHIP failed");

			return (-1);
		}

		return (0);
	}
#endif

#ifdef MCAST_JOIN_SOURCE_GROUP
	if (mcast_addr->sa_family == AF_INET || mcast_addr->sa_family == AF_INET6) {
		iface_index = if_nametoindex(local_ifname);
		if (iface_index == 0) {
			DEBUG_PRINTF("if_nametoindex cannot convert iface name %s to index",
			    local_ifname);

			return (-1);
		}

		memset(&greq, 0, sizeof(greq));

		switch (mcast_addr->sa_family) {
		case AF_INET:
			addr_len = sizeof(struct sockaddr_in);
			ip_lv = IPPROTO_IP;
			break;
		case AF_INET6:
			addr_len = sizeof(struct sockaddr_in6);
			ip_lv = IPPROTO_IPV6;
			break;
		default:
			DEBUG_PRINTF("Unknown sockaddr family");
			errx(1, "Unknown sockaddr family");
			/* NOTREACHED */
		}

		greq.gsr_interface = iface_index;
		memcpy(&greq.gsr_group, mcast_addr, addr_len);
		memcpy(&greq.gsr_source, remote_addr, addr_len);

		if (setsockopt(sock, ip_lv, MCAST_JOIN_SOURCE_GROUP, &greq, sizeof(greq)) == -1) {
			DEBUG_PRINTF("setsockopt MCAST_JOIN_SOURCE_GROUP failed");

			return (-1);
		}

		return (0);
	}
#endif
	DEBUG_PRINTF("Can't join to Source-Specific Multicast because of no compile time support");
	errx(1, "Can't join to Source-Specific Multicast because of no compile time support");
	/* NOTREACHED */

	return (-1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movzwl (%rax), %eax
cmpl $0x2, %eax
jne 0xb942
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
movl $0xc, %edx
callq 0x2150
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x30(%rbp)
movl -0x2c(%rbp), %edi
xorl %esi, %esi
movl $0x27, %edx
leaq -0x38(%rbp), %rcx
movl $0xc, %r8d
callq 0x20a0
cmpl $-0x1, %eax
jne 0xb936
leaq 0x41a8(%rip), %rdi      # 0xfaba
movl $0x194, %esi            # imm = 0x194
movl $0x2, %edx
leaq 0x421e(%rip), %rcx      # 0xfb41
movb $0x0, %al
callq 0x5dc0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xbb06
movl $0x0, -0x4(%rbp)
jmp 0xbb06
movq -0x10(%rbp), %rax
movzwl (%rax), %eax
cmpl $0x2, %eax
je 0xb95e
movq -0x10(%rbp), %rax
movzwl (%rax), %eax
cmpl $0xa, %eax
jne 0xbad4
movq -0x28(%rbp), %rdi
callq 0x21e0
movl %eax, -0x14c(%rbp)
cmpl $0x0, -0x14c(%rbp)
jne 0xb9a5
movq -0x28(%rbp), %r8
leaq 0x4139(%rip), %rdi      # 0xfaba
movl $0x1a2, %esi            # imm = 0x1A2
movl $0x2, %edx
leaq 0x3f61(%rip), %rcx      # 0xf8f3
movb $0x0, %al
callq 0x5dc0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xbb06
leaq -0x140(%rbp), %rdi
xorl %esi, %esi
movl $0x108, %edx            # imm = 0x108
callq 0x2150
movq -0x10(%rbp), %rax
movzwl (%rax), %eax
movl %eax, -0x154(%rbp)
subl $0x2, %eax
je 0xb9d9
jmp 0xb9cc
movl -0x154(%rbp), %eax
subl $0xa, %eax
je 0xb9f0
jmp 0xba07
movq $0x10, -0x148(%rbp)
movl $0x0, -0x150(%rbp)
jmp 0xba39
movq $0x1c, -0x148(%rbp)
movl $0x29, -0x150(%rbp)
jmp 0xba39
leaq 0x40ac(%rip), %rdi      # 0xfaba
movl $0x1b3, %esi            # imm = 0x1B3
movl $0x2, %edx
leaq 0x26a2(%rip), %rcx      # 0xe0c1
movb $0x0, %al
callq 0x5dc0
movl $0x1, %edi
leaq 0x268f(%rip), %rsi      # 0xe0c1
movb $0x0, %al
callq 0x20d0
movl -0x14c(%rbp), %eax
movl %eax, -0x140(%rbp)
leaq -0x140(%rbp), %rdi
addq $0x8, %rdi
movq -0x10(%rbp), %rsi
movq -0x148(%rbp), %rdx
callq 0x2200
leaq -0x140(%rbp), %rdi
addq $0x88, %rdi
movq -0x20(%rbp), %rsi
movq -0x148(%rbp), %rdx
callq 0x2200
movl -0x2c(%rbp), %edi
movl -0x150(%rbp), %esi
movl $0x2e, %edx
leaq -0x140(%rbp), %rcx
movl $0x108, %r8d            # imm = 0x108
callq 0x20a0
cmpl $-0x1, %eax
jne 0xbacb
leaq 0x4010(%rip), %rdi      # 0xfaba
movl $0x1bd, %esi            # imm = 0x1BD
movl $0x2, %edx
leaq 0x40b1(%rip), %rcx      # 0xfb6c
movb $0x0, %al
callq 0x5dc0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xbb06
movl $0x0, -0x4(%rbp)
jmp 0xbb06
leaq 0x3fdf(%rip), %rdi      # 0xfaba
movl $0x1c5, %esi            # imm = 0x1C5
movl $0x2, %edx
leaq 0x40aa(%rip), %rcx      # 0xfb96
movb $0x0, %al
callq 0x5dc0
movl $0x1, %edi
leaq 0x4097(%rip), %rsi      # 0xfb96
movb $0x0, %al
callq 0x20d0
movl -0x4(%rbp), %eax
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)