// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x10270, %rsp          # imm = 0x10270
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x100, -0x100d8(%rbp)  # imm = 0x100
cmpl $0x1, -0x8(%rbp)
jg 0x138a
callq 0x1240
movl $0x0, -0x4(%rbp)
jmp 0x171e
jmp 0x138c
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq 0xdfe(%rip), %rdx       # 0x2198
callq 0x1100
movl %eax, -0x38(%rbp)
cmpl $-0x1, %eax
je 0x14cd
movl -0x38(%rbp), %eax
addl $-0x67, %eax
movl %eax, %ecx
movq %rcx, -0x10268(%rbp)
subl $0xc, %eax
ja 0x14b7
movq -0x10268(%rbp), %rax
leaq 0xc33(%rip), %rcx       # 0x2004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x10090(%rbp), %rdi
xorl %esi, %esi
movl $0x28, %edx
callq 0x1080
leaq -0x10090(%rbp), %rdi
movq 0x2be5(%rip), %rax      # 0x3fe0
movq (%rax), %rsi
movl $0x27, %edx
callq 0x1030
jmp 0x14c8
leaq -0x100d0(%rbp), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x1080
leaq -0x100d0(%rbp), %rdi
movq 0x2bb2(%rip), %rax      # 0x3fe0
movq (%rax), %rsi
movl $0x9, %edx
callq 0x1030
jmp 0x14c8
leaq -0x100c0(%rbp), %rdi
xorl %esi, %esi
movl $0x28, %edx
callq 0x1080
leaq -0x100c0(%rbp), %rdi
movq 0x2b7f(%rip), %rax      # 0x3fe0
movq (%rax), %rsi
movl $0x27, %edx
callq 0x1030
jmp 0x14c8
leaq -0x100c6(%rbp), %rdi
xorl %esi, %esi
movl $0x6, %edx
callq 0x1080
leaq -0x100c6(%rbp), %rdi
movq 0x2b4f(%rip), %rax      # 0x3fe0
movq (%rax), %rsi
movl $0x5, %edx
callq 0x1030
jmp 0x14c8
movq 0x2b39(%rip), %rax      # 0x3fe0
movq (%rax), %rdi
callq 0x1110
movl %eax, -0x100d8(%rbp)
jmp 0x14c8
callq 0x1240
movl $0x0, -0x4(%rbp)
jmp 0x171e
jmp 0x138c
movl $0xa, %edi
movl $0x2, %esi
xorl %edx, %edx
callq 0x1130
movl %eax, -0x30(%rbp)
cmpl $0x0, %eax
jge 0x14fe
leaq 0xcb6(%rip), %rdi       # 0x21a3
callq 0x10f0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x171e
leaq -0x2c(%rbp), %rdi
xorl %esi, %esi
movl $0x1c, %edx
callq 0x1080
movw $0xa, -0x2c(%rbp)
leaq -0x100c0(%rbp), %rsi
leaq -0x2c(%rbp), %rdx
addq $0x8, %rdx
movl $0xa, %edi
callq 0x10b0
leaq -0x100c6(%rbp), %rdi
callq 0x1110
movzwl %ax, %edi
callq 0x1060
movw %ax, -0x2a(%rbp)
movl -0x30(%rbp), %edi
leaq -0x2c(%rbp), %rsi
movl $0x1c, %edx
callq 0x10e0
cmpl $0x0, %eax
jge 0x1573
leaq 0xc48(%rip), %rdi       # 0x21aa
callq 0x10f0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x171e
leaq -0x100c0(%rbp), %rsi
leaq -0x54(%rbp), %rdx
movl $0xa, %edi
callq 0x10b0
leaq -0x100d0(%rbp), %rdi
callq 0x10a0
movl %eax, -0x100d4(%rbp)
movl -0x100d4(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x30(%rbp), %edi
movl $0x29, %esi
movl $0x14, %r8d
leaq -0x54(%rbp), %rcx
movl %r8d, %edx
callq 0x1050
cmpl $0x0, %eax
jge 0x15da
leaq 0xbe6(%rip), %rdi       # 0x21af
callq 0x10f0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x171e
leaq -0x331(%rip), %rax      # 0x12b0
movq %rax, -0x10170(%rbp)
leaq -0x10170(%rbp), %rdi
addq $0x8, %rdi
callq 0x1090
movl $0x0, -0x100e8(%rbp)
movl $0x2, %edi
leaq -0x10170(%rbp), %rsi
leaq -0x10208(%rbp), %rdx
callq 0x1040
movl $0x9, %edi
leaq -0x10170(%rbp), %rsi
leaq -0x10208(%rbp), %rdx
callq 0x1040
movl $0xf, %edi
leaq -0x10170(%rbp), %rsi
leaq -0x10208(%rbp), %rdx
callq 0x1040
leaq -0x10060(%rbp), %rdi
xorl %esi, %esi
movl $0xffff, %edx           # imm = 0xFFFF
callq 0x1080
movl $0x1c, -0x40(%rbp)
movl -0x30(%rbp), %edi
leaq -0x10060(%rbp), %rsi
movslq -0x100d8(%rbp), %rdx
xorl %ecx, %ecx
leaq -0x2c(%rbp), %r8
leaq -0x40(%rbp), %r9
callq 0x10d0
movl %eax, -0x34(%rbp)
cmpl $0x0, %eax
jge 0x16a1
leaq 0xb2b(%rip), %rdi       # 0x21be
callq 0x10f0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x171e
movl 0x2a19(%rip), %esi      # 0x40c0
addl $0x1, %esi
movl %esi, 0x2a10(%rip)      # 0x40c0
leaq -0x10060(%rbp), %rdx
leaq 0xb09(%rip), %rdi       # 0x21c7
movb $0x0, %al
callq 0x1070
leaq -0x10060(%rbp), %rdi
leaq -0x10230(%rbp), %rdx
leaq -0x10260(%rbp), %rcx
leaq 0xaf9(%rip), %rsi       # 0x21da
leaq -0x3c(%rbp), %r8
movb $0x0, %al
callq 0x10c0
movl -0x3c(%rbp), %eax
movl %eax, -0x1026c(%rbp)
leaq -0x10230(%rbp), %rdi
callq 0x1110
movl -0x1026c(%rbp), %edx
andl $0xff, %eax
movslq %eax, %rcx
leaq 0x29ba(%rip), %rax      # 0x40d0
movl %edx, (%rax,%rcx,4)
jmp 0x164a
movl -0x4(%rbp), %eax
addq $0x10270, %rsp          # imm = 0x10270
popq %rbp
retq