// File: /workspace/github_c_makefile_star2_O3/dropletzhu[P]msuite/mlistener.c
// Function: main
int
main (int argc, char *argv[])
{
	struct sockaddr_in addr;
	int fd, nbytes, ch, i;
	unsigned int addrlen;
	struct ip_mreq mreq;
	char msgbuf[BUF_LEN], source[IP_LEN], group[IP_LEN], port[PORT_LEN];
	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:g:p:l:")) != -1)
	{
		switch (ch)
		{
		case 's':
			memset (source, 0, IP_LEN);
			strncpy (source, optarg, IP_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_INET, SOCK_DGRAM, 0)) < 0)
	{
		perror ("socket");
		return -1;
	}

	/* set up destination address */
	memset (&addr, 0, sizeof (addr));
	addr.sin_family = AF_INET;
	addr.sin_addr.s_addr = inet_addr (group);
	addr.sin_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 */
	mreq.imr_multiaddr.s_addr = inet_addr (group);
	mreq.imr_interface.s_addr = inet_addr (source);

	if (setsockopt (fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof (mreq)) < 0)
	{
		perror ("setsockopt");
		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 $0x101b8, %rsp          # imm = 0x101B8
cmpl $0x2, %edi
jl 0x13c1
movq %rsi, %rbx
movl %edi, %r14d
movl $0x100, 0xc(%rsp)       # imm = 0x100
leaq 0xd4e(%rip), %r15       # 0x2066
movq 0x2cc1(%rip), %r12      # 0x3fe0
leaq 0x14(%rsp), %r13
leaq 0x30(%rsp), %rbp
movl %r14d, %edi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x10f0
cmpl $0x6f, %eax
jle 0x1361
cmpl $0x70, %eax
je 0x1383
cmpl $0x73, %eax
jne 0x13c1
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq (%r12), %rsi
movl $0xf, %edx
movq %rbp, %rdi
callq 0x1030
jmp 0x1329
cmpl $0x67, %eax
jne 0x13a5
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq (%r12), %rsi
movl $0xf, %edx
leaq 0x20(%rsp), %rdi
callq 0x1030
jmp 0x1329
movw $0x0, 0x18(%rsp)
movl $0x0, 0x14(%rsp)
movq (%r12), %rsi
movl $0x5, %edx
movq %r13, %rdi
callq 0x1030
jmp 0x1329
cmpl $0x6c, %eax
jne 0x13bc
movq (%r12), %rdi
callq 0x1100
movl %eax, 0xc(%rsp)
jmp 0x1329
cmpl $-0x1, %eax
je 0x13da
callq 0x122c
xorl %eax, %eax
addq $0x101b8, %rsp          # imm = 0x101B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x2, %edi
movl $0x2, %esi
xorl %edx, %edx
callq 0x1120
testl %eax, %eax
jns 0x13fb
leaq 0xc79(%rip), %rdi       # 0x206f
jmp 0x15e7
movl %eax, %r13d
leaq 0x48(%rsp), %rbx
movq $0x0, 0x8(%rbx)
movw $0x2, (%rbx)
leaq 0x20(%rsp), %rdi
callq 0x1090
movl %eax, 0x4(%rbx)
leaq 0x14(%rsp), %rdi
callq 0x1100
rolw $0x8, %ax
movw %ax, 0x2(%rbx)
movl %r13d, %edi
movq %rbx, %rsi
movl $0x10, %edx
callq 0x10d0
testl %eax, %eax
jns 0x144f
leaq 0xc2c(%rip), %rdi       # 0x2076
jmp 0x15e7
leaq 0x20(%rsp), %rdi
callq 0x1090
leaq 0x58(%rsp), %rbx
movl %eax, (%rbx)
leaq 0x30(%rsp), %rdi
callq 0x1090
movl %eax, 0x4(%rbx)
movl %r13d, %edi
xorl %esi, %esi
movl $0x23, %edx
movq %rbx, %rcx
movl $0x8, %r8d
callq 0x1060
testl %eax, %eax
jns 0x1495
leaq 0xbeb(%rip), %rdi       # 0x207b
jmp 0x15e7
leaq -0x21d(%rip), %rax      # 0x127f
leaq 0x88(%rsp), %rbx
movq %rax, -0x8(%rbx)
movq %rbx, %rdi
callq 0x10a0
movl $0x0, 0x80(%rbx)
leaq 0x80(%rsp), %rbx
leaq 0x118(%rsp), %r14
movl $0x2, %edi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x1050
movl $0x9, %edi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x1050
movl $0xf, %edi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x1050
movslq 0xc(%rsp), %r14
leaq 0x1b0(%rsp), %rbx
movl $0xffff, %edx           # imm = 0xFFFF
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1080
leaq 0x10(%rsp), %r9
movl $0x10, (%r9)
leaq 0x48(%rsp), %r8
movl %r13d, %edi
movq %rbx, %rsi
movq %r14, %rdx
xorl %ecx, %ecx
callq 0x10c0
testl %eax, %eax
js 0x15e0
leaq 0x1b0(%rsp), %r12
leaq 0x70(%rsp), %rbp
leaq 0x10(%rsp), %rbx
movl 0x2b69(%rip), %esi      # 0x40c0
incl %esi
movl %esi, 0x2b61(%rip)      # 0x40c0
leaq 0xb29(%rip), %rdi       # 0x208f
movq %r12, %rdx
xorl %eax, %eax
callq 0x1070
movq %r12, %rdi
leaq 0xb28(%rip), %rsi       # 0x20a2
movq %rbp, %rdx
leaq 0x60(%rsp), %rcx
leaq 0x1c(%rsp), %r8
xorl %eax, %eax
callq 0x10b0
movl 0x1c(%rsp), %r15d
movq %rbp, %rdi
callq 0x1100
movzbl %al, %eax
leaq 0x2b2b(%rip), %rcx      # 0x40d0
movl %r15d, (%rcx,%rax,4)
movl $0xffff, %edx           # imm = 0xFFFF
movq %r12, %rdi
xorl %esi, %esi
callq 0x1080
movl $0x10, 0x10(%rsp)
movl %r13d, %edi
movq %r12, %rsi
movq %r14, %rdx
xorl %ecx, %ecx
leaq 0x48(%rsp), %r8
movq %rbx, %r9
callq 0x10c0
testl %eax, %eax
jns 0x1551
leaq 0xa9f(%rip), %rdi       # 0x2086
callq 0x10e0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x13c8