// File: /workspace/github_c_makefile_star2_O0/jfriesse[P]omping/sockfunc.c
// Function: sf_mcast_join_asm_group
int
sf_mcast_join_asm_group(const struct sockaddr *mcast_addr, const struct sockaddr *local_addr,
    const char *local_ifname, int sock)
{
	struct ip_mreq mreq4;
	struct ipv6_mreq mreq6;
	int iface_index;

	switch (mcast_addr->sa_family) {
	case 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;
		if (setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq4, sizeof(mreq4)) == -1) {
			DEBUG_PRINTF("setsockopt IP_ADD_MEMBERSHIP failed");

			return (-1);
		}
		break;
	case 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(&mreq6, 0, sizeof(mreq6));

		mreq6.ipv6mr_multiaddr = ((struct sockaddr_in6 *)mcast_addr)->sin6_addr;
		mreq6.ipv6mr_interface = iface_index;
		if (setsockopt(sock, IPPROTO_IPV6, IPV6_JOIN_GROUP, &mreq6, sizeof(mreq6)) == -1) {
			DEBUG_PRINTF("setsockopt IPV6_JOIN_GROUP failed");

			return (-1);
		}
		break;
	default:
		DEBUG_PRINTF("Unknown sockaddr family");
		errx(1, "Unknown sockaddr family");
	}

	return (0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq -0x10(%rbp), %rax
movzwl (%rax), %eax
movl %eax, -0x48(%rbp)
subl $0x2, %eax
je 0xb465
jmp 0xb458
movl -0x48(%rbp), %eax
subl $0xa, %eax
je 0xb4d7
jmp 0xb58b
leaq -0x2c(%rbp), %rdi
xorl %esi, %esi
movl $0x8, %edx
callq 0x2150
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x2c(%rbp)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x28(%rbp)
movl -0x24(%rbp), %edi
xorl %esi, %esi
movl $0x23, %edx
leaq -0x2c(%rbp), %rcx
movl $0x8, %r8d
callq 0x20a0
cmpl $-0x1, %eax
jne 0xb4d2
leaq 0x460c(%rip), %rdi      # 0xfaba
movl $0x157, %esi            # imm = 0x157
movl $0x2, %edx
leaq 0x463c(%rip), %rcx      # 0xfafb
movb $0x0, %al
callq 0x5dc0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xb5c4
jmp 0xb5bd
movq -0x20(%rbp), %rdi
callq 0x21e0
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
jne 0xb518
movq -0x20(%rbp), %r8
leaq 0x45c6(%rip), %rdi      # 0xfaba
movl $0x160, %esi            # imm = 0x160
movl $0x2, %edx
leaq 0x43ee(%rip), %rcx      # 0xf8f3
movb $0x0, %al
callq 0x5dc0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xb5c4
leaq -0x40(%rbp), %rdi
xorl %esi, %esi
movl $0x14, %edx
callq 0x2150
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rcx
movq %rcx, -0x40(%rbp)
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x24(%rbp), %edi
movl $0x29, %esi
movl $0x14, %r8d
leaq -0x40(%rbp), %rcx
movl %r8d, %edx
callq 0x20a0
cmpl $-0x1, %eax
jne 0xb589
leaq 0x4552(%rip), %rdi      # 0xfaba
movl $0x169, %esi            # imm = 0x169
movl $0x2, %edx
leaq 0x45a6(%rip), %rcx      # 0xfb1f
movb $0x0, %al
callq 0x5dc0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xb5c4
jmp 0xb5bd
leaq 0x4528(%rip), %rdi      # 0xfaba
movl $0x16f, %esi            # imm = 0x16F
movl $0x2, %edx
leaq 0x2b1e(%rip), %rcx      # 0xe0c1
movb $0x0, %al
callq 0x5dc0
movl $0x1, %edi
leaq 0x2b0b(%rip), %rsi      # 0xe0c1
movb $0x0, %al
callq 0x20d0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)