// File: /workspace/github_c_makefile_star2_O0/dropletzhu[P]msuite/msender6.c
// Function: main
int
main (int argc, char *argv[])
{
	struct sockaddr_in6 addr;
	int fd, ch, i = 1;
	int hops = 1;
	char msgbuf[BUF_LEN], source[IP_LEN], group[IP_LEN], port[PORT_LEN];
	char ifname[NAME_LEN];
	unsigned int ifindex = 0;
	int length = 256;
	int count = 0;

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

	while ((ch = getopt (argc, argv, "s:i:g:p:h:l:c:")) != -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 'h':
			hops = atoi (optarg);
			break;
		case 'l':
			length = atoi(optarg);
			break;
		case 'c':
			count = atoi(optarg);
			break;
		default:
			usage();
			return 0;
		}
	}

	fd = socket (AF_INET6, SOCK_DGRAM, 0 );

	if (fd < 0)
	{
		perror ("socket");
		return -1;
	}

	ifindex = if_nametoindex(ifname);

	/* 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));

	if (setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_IF, &ifindex,
		 sizeof (ifindex)))
	{
		perror ("setsockopt if");
		return -1;
	}

	if (setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &hops, sizeof (hops)))
	{
		perror ("setsockopt hops");
		return -1;
	}

	/* now just sendto() our destination! */
	while (1)
	{
		if ( count && ( i > count ) ) {
			break;
		}
		memset(msgbuf,0,BUF_LEN);

		snprintf(msgbuf,length,"Sender %s->%s <>%d", source, group, i++);

		if (sendto(fd, msgbuf, length, 0, (struct sockaddr *) &addr, 
					sizeof (addr)) < 0)
		{
			perror ("sendto");
			return -1;
		}
		else
		{
			printf ("%s\n",msgbuf);
		}
		sleep (1);
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100d0, %rsp          # imm = 0x100D0
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x1, -0x38(%rbp)
movl $0x1, -0x3c(%rbp)
movl $0x0, -0x100b4(%rbp)
movl $0x100, -0x100b8(%rbp)  # imm = 0x100
movl $0x0, -0x100bc(%rbp)
cmpl $0x1, -0x8(%rbp)
jg 0x12fc
callq 0x1210
movl $0x0, -0x4(%rbp)
jmp 0x163a
jmp 0x12fe
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq 0xe9d(%rip), %rdx       # 0x21a9
callq 0x10d0
movl %eax, -0x34(%rbp)
cmpl $-0x1, %eax
je 0x146d
movl -0x34(%rbp), %eax
addl $-0x63, %eax
movl %eax, %ecx
movq %rcx, -0x100c8(%rbp)
subl $0x10, %eax
ja 0x1457
movq -0x100c8(%rbp), %rax
leaq 0xcc1(%rip), %rcx       # 0x2004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x10070(%rbp), %rdi
xorl %esi, %esi
movl $0x28, %edx
callq 0x1080
leaq -0x10070(%rbp), %rdi
movq 0x2c73(%rip), %rax      # 0x3fe0
movq (%rax), %rsi
movl $0x27, %edx
callq 0x1030
jmp 0x1468
leaq -0x100b0(%rbp), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x1080
leaq -0x100b0(%rbp), %rdi
movq 0x2c40(%rip), %rax      # 0x3fe0
movq (%rax), %rsi
movl $0x9, %edx
callq 0x1030
jmp 0x1468
leaq -0x100a0(%rbp), %rdi
xorl %esi, %esi
movl $0x28, %edx
callq 0x1080
leaq -0x100a0(%rbp), %rdi
movq 0x2c0d(%rip), %rax      # 0x3fe0
movq (%rax), %rsi
movl $0x27, %edx
callq 0x1030
jmp 0x1468
leaq -0x100a6(%rbp), %rdi
xorl %esi, %esi
movl $0x6, %edx
callq 0x1080
leaq -0x100a6(%rbp), %rdi
movq 0x2bda(%rip), %rax      # 0x3fe0
movq (%rax), %rsi
movl $0x5, %edx
callq 0x1030
jmp 0x1468
movq 0x2bc4(%rip), %rax      # 0x3fe0
movq (%rax), %rdi
callq 0x10e0
movl %eax, -0x3c(%rbp)
jmp 0x1468
movq 0x2bb0(%rip), %rax      # 0x3fe0
movq (%rax), %rdi
callq 0x10e0
movl %eax, -0x100b8(%rbp)
jmp 0x1468
movq 0x2b99(%rip), %rax      # 0x3fe0
movq (%rax), %rdi
callq 0x10e0
movl %eax, -0x100bc(%rbp)
jmp 0x1468
callq 0x1210
movl $0x0, -0x4(%rbp)
jmp 0x163a
jmp 0x12fe
movl $0xa, %edi
movl $0x2, %esi
xorl %edx, %edx
callq 0x1100
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
jge 0x149f
leaq 0xd2a(%rip), %rdi       # 0x21b8
callq 0x10c0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x163a
leaq -0x100b0(%rbp), %rdi
callq 0x10a0
movl %eax, -0x100b4(%rbp)
leaq -0x2c(%rbp), %rdi
xorl %esi, %esi
movl $0x1c, %edx
callq 0x1080
movw $0xa, -0x2c(%rbp)
leaq -0x100a0(%rbp), %rsi
leaq -0x2c(%rbp), %rdx
addq $0x8, %rdx
movl $0xa, %edi
callq 0x10b0
leaq -0x100a6(%rbp), %rdi
callq 0x10e0
movzwl %ax, %edi
callq 0x1050
movw %ax, -0x2a(%rbp)
movl -0x30(%rbp), %edi
movl $0x29, %esi
movl $0x11, %edx
leaq -0x100b4(%rbp), %rcx
movl $0x4, %r8d
callq 0x1040
cmpl $0x0, %eax
je 0x1534
leaq 0xc9c(%rip), %rdi       # 0x21bf
callq 0x10c0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x163a
movl -0x30(%rbp), %edi
movl $0x29, %esi
movl $0x12, %edx
leaq -0x3c(%rbp), %rcx
movl $0x4, %r8d
callq 0x1040
cmpl $0x0, %eax
je 0x156d
leaq 0xc71(%rip), %rdi       # 0x21cd
callq 0x10c0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x163a
jmp 0x156f
cmpl $0x0, -0x100bc(%rbp)
je 0x1588
movl -0x38(%rbp), %eax
cmpl -0x100bc(%rbp), %eax
jle 0x1588
jmp 0x1633
leaq -0x10040(%rbp), %rdi
xorl %esi, %esi
movl $0xffff, %edx           # imm = 0xFFFF
callq 0x1080
leaq -0x10040(%rbp), %rdi
movslq -0x100b8(%rbp), %rsi
leaq -0x10070(%rbp), %rcx
leaq -0x100a0(%rbp), %r8
movl -0x38(%rbp), %r9d
movl %r9d, %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
leaq 0xc12(%rip), %rdx       # 0x21dd
movb $0x0, %al
callq 0x1070
movl -0x30(%rbp), %edi
leaq -0x10040(%rbp), %rsi
movslq -0x100b8(%rbp), %rdx
xorl %ecx, %ecx
leaq -0x2c(%rbp), %r8
movl $0x1c, %r9d
callq 0x1090
cmpq $0x0, %rax
jge 0x160f
leaq 0xbef(%rip), %rdi       # 0x21f0
callq 0x10c0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x163a
leaq -0x10040(%rbp), %rsi
leaq 0xb84(%rip), %rdi       # 0x21a1
movb $0x0, %al
callq 0x1060
movl $0x1, %edi
callq 0x10f0
jmp 0x156f
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x100d0, %rsp          # imm = 0x100D0
popq %rbp
retq