// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x101d0, %rsp          # imm = 0x101D0
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x100, -0x1006c(%rbp)  # imm = 0x100
cmpl $0x1, -0x8(%rbp)
jg 0x137a
callq 0x1230
movl $0x0, -0x4(%rbp)
jmp 0x16bb
jmp 0x137c
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq 0xde6(%rip), %rdx       # 0x2170
callq 0x10f0
movl %eax, -0x2c(%rbp)
cmpl $-0x1, %eax
je 0x148a
movl -0x2c(%rbp), %eax
addl $-0x67, %eax
movl %eax, %ecx
movq %rcx, -0x101c8(%rbp)
subl $0xc, %eax
ja 0x1474
movq -0x101c8(%rbp), %rax
leaq 0xc43(%rip), %rcx       # 0x2004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x10050(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x1080
leaq -0x10050(%rbp), %rdi
movq 0x2bf5(%rip), %rax      # 0x3fe0
movq (%rax), %rsi
movl $0xf, %edx
callq 0x1030
jmp 0x1485
leaq -0x10060(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x1080
leaq -0x10060(%rbp), %rdi
movq 0x2bc2(%rip), %rax      # 0x3fe0
movq (%rax), %rsi
movl $0xf, %edx
callq 0x1030
jmp 0x1485
leaq -0x10066(%rbp), %rdi
xorl %esi, %esi
movl $0x6, %edx
callq 0x1080
leaq -0x10066(%rbp), %rdi
movq 0x2b92(%rip), %rax      # 0x3fe0
movq (%rax), %rsi
movl $0x5, %edx
callq 0x1030
jmp 0x1485
movq 0x2b7c(%rip), %rax      # 0x3fe0
movq (%rax), %rdi
callq 0x1100
movl %eax, -0x1006c(%rbp)
jmp 0x1485
callq 0x1230
movl $0x0, -0x4(%rbp)
jmp 0x16bb
jmp 0x137c
movl $0x2, %esi
xorl %edx, %edx
movl %esi, %edi
callq 0x1120
movl %eax, -0x24(%rbp)
cmpl $0x0, %eax
jge 0x14b8
leaq 0xcd2(%rip), %rdi       # 0x2179
callq 0x10e0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x16bb
leaq -0x20(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x1080
movw $0x2, -0x20(%rbp)
leaq -0x10060(%rbp), %rdi
callq 0x1090
movl %eax, -0x1c(%rbp)
leaq -0x10066(%rbp), %rdi
callq 0x1100
movzwl %ax, %edi
callq 0x1060
movw %ax, -0x1e(%rbp)
movl -0x24(%rbp), %edi
leaq -0x20(%rbp), %rsi
movl $0x10, %edx
callq 0x10d0
cmpl $0x0, %eax
jge 0x1523
leaq 0xc6e(%rip), %rdi       # 0x2180
callq 0x10e0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x16bb
leaq -0x10060(%rbp), %rdi
callq 0x1090
movl %eax, -0x3c(%rbp)
leaq -0x10050(%rbp), %rdi
callq 0x1090
movl %eax, -0x38(%rbp)
movl -0x24(%rbp), %edi
xorl %esi, %esi
movl $0x23, %edx
leaq -0x3c(%rbp), %rcx
movl $0x8, %r8d
callq 0x1050
cmpl $0x0, %eax
jge 0x1577
leaq 0xc1f(%rip), %rdi       # 0x2185
callq 0x10e0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x16bb
leaq -0x2de(%rip), %rax      # 0x12a0
movq %rax, -0x10108(%rbp)
leaq -0x10108(%rbp), %rdi
addq $0x8, %rdi
callq 0x10a0
movl $0x0, -0x10080(%rbp)
movl $0x2, %edi
leaq -0x10108(%rbp), %rsi
leaq -0x101a0(%rbp), %rdx
callq 0x1040
movl $0x9, %edi
leaq -0x10108(%rbp), %rsi
leaq -0x101a0(%rbp), %rdx
callq 0x1040
movl $0xf, %edi
leaq -0x10108(%rbp), %rsi
leaq -0x101a0(%rbp), %rdx
callq 0x1040
leaq -0x10040(%rbp), %rdi
xorl %esi, %esi
movl $0xffff, %edx           # imm = 0xFFFF
callq 0x1080
movl $0x10, -0x34(%rbp)
movl -0x24(%rbp), %edi
leaq -0x10040(%rbp), %rsi
movslq -0x1006c(%rbp), %rdx
xorl %ecx, %ecx
leaq -0x20(%rbp), %r8
leaq -0x34(%rbp), %r9
callq 0x10c0
movl %eax, -0x28(%rbp)
cmpl $0x0, %eax
jge 0x163e
leaq 0xb60(%rip), %rdi       # 0x2190
callq 0x10e0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x16bb
movl 0x2a7c(%rip), %esi      # 0x40c0
addl $0x1, %esi
movl %esi, 0x2a73(%rip)      # 0x40c0
leaq -0x10040(%rbp), %rdx
leaq 0xb3e(%rip), %rdi       # 0x2199
movb $0x0, %al
callq 0x1070
leaq -0x10040(%rbp), %rdi
leaq -0x101b0(%rbp), %rdx
leaq -0x101c0(%rbp), %rcx
leaq 0xb2e(%rip), %rsi       # 0x21ac
leaq -0x30(%rbp), %r8
movb $0x0, %al
callq 0x10b0
movl -0x30(%rbp), %eax
movl %eax, -0x101cc(%rbp)
leaq -0x101b0(%rbp), %rdi
callq 0x1100
movl -0x101cc(%rbp), %edx
andl $0xff, %eax
movslq %eax, %rcx
leaq 0x2a1d(%rip), %rax      # 0x40d0
movl %edx, (%rax,%rcx,4)
jmp 0x15e7
movl -0x4(%rbp), %eax
addq $0x101d0, %rsp          # imm = 0x101D0
popq %rbp
retq