// File: /workspace/github_c_makefile_star2_O2/dropletzhu[P]msuite/mlistener6.c
// Function: main
int
main (int argc, char *argv[])
{
	struct sockaddr_in6 addr;
	int fd, nbytes, ch, i;
	unsigned int addrlen;
	struct ipv6_mreq mreq;
	char msgbuf[BUF_LEN], source[IP_LEN], group[IP_LEN], port[PORT_LEN];
	char ifname[NAME_LEN];
	unsigned int ifindex;
	int length = 256;
	struct sigaction new_action, old_action;
	char s_source[IP_LEN], s_group[IP_LEN];

	if (argc <= 1)
	{
		usage();
		return 0;
	}

	while ((ch = getopt (argc, argv, "s:i:g:p:l:")) != -1)
	{
		switch (ch)
		{
		case 's':
			memset (source, 0, IP_LEN);
			strncpy (source, optarg, IP_LEN - 1);
			break;
		case 'i':
			memset (ifname, 0, NAME_LEN);
			strncpy (ifname, optarg, NAME_LEN - 1);
			break;
		case 'g':
			memset (group, 0, IP_LEN);
			strncpy (group, optarg, IP_LEN - 1);
			break;
		case 'p':
			memset (port, 0, PORT_LEN);
			strncpy (port, optarg, PORT_LEN - 1);
			break;
		case 'l':
			length = atoi(optarg);
			break;
		default:
			usage();
			return 0;
		}
	}

	/* create what looks like an ordinary UDP socket */
	if ((fd = socket (AF_INET6, SOCK_DGRAM, 0)) < 0)
	{
		perror ("socket");
		return -1;
	}

	/* set up destination address */
	memset (&addr, 0, sizeof (addr));
	addr.sin6_family = AF_INET6;
	inet_pton(AF_INET6, group, &(addr.sin6_addr));
	addr.sin6_port = htons (atoi (port));

	/* bind to receive address */
	if (bind (fd, (struct sockaddr *) &addr, sizeof (addr)) < 0)
	{
		perror ("bind");
		return -1;
	}

	/* use setsockopt() to request that the kernel join a multicast group */
	inet_pton(AF_INET6, group, &(mreq.ipv6mr_multiaddr));
	ifindex = if_nametoindex(ifname);
	mreq.ipv6mr_interface = ifindex;

	if (setsockopt (fd, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, &mreq, sizeof (mreq)) < 0)
	{
		perror ("setsockopt add");
		return -1;
	}

	new_action.sa_handler = term_handler;
	sigemptyset(&new_action.sa_mask);
	new_action.sa_flags = 0;
	sigaction(SIGINT, &new_action, &old_action);
	sigaction(SIGKILL, &new_action, &old_action);
	sigaction(SIGTERM, &new_action, &old_action);

	while (1)
	{
		memset(msgbuf, 0, BUF_LEN);

		addrlen = sizeof (addr);
		if ((nbytes = recvfrom (fd, msgbuf, length, 0, (struct sockaddr *) &addr, &addrlen)) < 0)
		{
			perror ("recvfrom");
			return -1;
		}
		printf ("Receiver %d -- %s\n", ++l_count, msgbuf);
		sscanf (msgbuf,"Sender %[0-9.]->%[0-9.] <> %d",s_source,s_group,&i);
		s_count[atoi(s_source) & 0xFF] = i;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10228, %rsp          # imm = 0x10228
cmpl $0x2, %edi
jl 0x13e8
movq %rsi, %r14
movl %edi, %ebp
movl $0x100, 0xc(%rsp)       # imm = 0x100
leaq 0xd3d(%rip), %r15       # 0x2072
leaq 0xcc8(%rip), %r12       # 0x2004
movq 0x2c9d(%rip), %r13      # 0x3fe0
pushq $0x5
popq %rbx
movl %ebp, %edi
movq %r14, %rsi
movq %r15, %rdx
callq 0x1100
leal -0x67(%rax), %ecx
cmpl $0x9, %ecx
ja 0x138a
movslq (%r12,%rcx,4), %rax
addq %r12, %rax
jmpq *%rax
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
andq $0x0, 0x50(%rsp)
movq (%r13), %rsi
leaq 0x30(%rsp), %rdi
pushq $0x27
popq %rdx
callq 0x1030
jmp 0x1346
cmpl $0x73, %eax
je 0x1346
jmp 0x13e3
andw $0x0, 0x14(%rsp)
andl $0x0, 0x10(%rsp)
movq (%r13), %rsi
leaq 0x10(%rsp), %rdi
movq %rbx, %rdx
callq 0x1030
jmp 0x1346
andw $0x0, 0x28(%rsp)
andq $0x0, 0x20(%rsp)
movq (%r13), %rsi
leaq 0x20(%rsp), %rdi
pushq $0x9
popq %rdx
callq 0x1030
jmp 0x1346
movq (%r13), %rdi
callq 0x1110
movl %eax, 0xc(%rsp)
jmp 0x1346
cmpl $-0x1, %eax
je 0x1401
callq 0x123c
xorl %eax, %eax
addq $0x10228, %rsp          # imm = 0x10228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0xa
popq %rdi
pushq $0x2
popq %rsi
xorl %edx, %edx
callq 0x1130
testl %eax, %eax
jns 0x141e
leaq 0xc64(%rip), %rdi       # 0x207d
jmp 0x15cd
movl %eax, %r13d
xorps %xmm0, %xmm0
leaq 0x68(%rsp), %rbx
movaps %xmm0, -0x8(%rbx)
movups %xmm0, 0x4(%rbx)
movw $0xa, -0x8(%rbx)
pushq $0xa
popq %rdi
leaq 0x30(%rsp), %rsi
movq %rbx, %rdx
callq 0x10b0
leaq 0x10(%rsp), %rdi
callq 0x1110
rolw $0x8, %ax
movw %ax, -0x6(%rbx)
leaq 0x60(%rsp), %rsi
pushq $0x1c
popq %rdx
movl %r13d, %edi
callq 0x10e0
testl %eax, %eax
jns 0x1479
leaq 0xc10(%rip), %rdi       # 0x2084
jmp 0x15cd
pushq $0xa
popq %rdi
leaq 0x30(%rsp), %rsi
leaq 0x7c(%rsp), %rbx
movq %rbx, %rdx
callq 0x10b0
leaq 0x20(%rsp), %rdi
callq 0x10a0
movl %eax, 0x10(%rbx)
pushq $0x29
popq %rsi
pushq $0x14
popq %rdx
movl %r13d, %edi
movq %rbx, %rcx
movl %edx, %r8d
callq 0x1060
testl %eax, %eax
jns 0x14bf
leaq 0xbcf(%rip), %rdi       # 0x2089
jmp 0x15cd
leaq -0x22b(%rip), %rax      # 0x129b
leaq 0xf8(%rsp), %rbx
movq %rax, -0x8(%rbx)
movq %rbx, %rdi
callq 0x1090
andl $0x0, 0x80(%rbx)
pushq $0x2
popq %rdi
leaq 0xf0(%rsp), %rbx
leaq 0x188(%rsp), %r14
movq %rbx, %rsi
movq %r14, %rdx
callq 0x1050
pushq $0x9
popq %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x1050
pushq $0xf
popq %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x1050
movslq 0xc(%rsp), %rbx
leaq 0x220(%rsp), %r14
leaq 0xc0(%rsp), %r15
leaq 0x2b99(%rip), %rbp      # 0x40d0
movl $0xffff, %edx           # imm = 0xFFFF
movq %r14, %rdi
xorl %esi, %esi
callq 0x1080
movl $0x1c, 0x18(%rsp)
movl %r13d, %edi
movq %r14, %rsi
movq %rbx, %rdx
xorl %ecx, %ecx
leaq 0x60(%rsp), %r8
leaq 0x18(%rsp), %r9
callq 0x10d0
testl %eax, %eax
js 0x15c6
movl 0x2b4e(%rip), %esi      # 0x40c0
incl %esi
movl %esi, 0x2b46(%rip)      # 0x40c0
leaq 0xb20(%rip), %rdi       # 0x20a1
movq %r14, %rdx
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
leaq 0xb1f(%rip), %rsi       # 0x20b4
movq %r15, %rdx
leaq 0x90(%rsp), %rcx
leaq 0x1c(%rsp), %r8
xorl %eax, %eax
callq 0x10c0
movl 0x1c(%rsp), %r12d
movq %r15, %rdi
callq 0x1110
movzbl %al, %eax
movl %r12d, (%rbp,%rax,4)
jmp 0x1537
leaq 0xacb(%rip), %rdi       # 0x2098
callq 0x10f0
pushq $-0x1
popq %rax
jmp 0x13ef