// File: /workspace/github_c_makefile_star2_O0/dropletzhu[P]msuite/pim_sender.c
// Function: make_pim_register
int make_pim_register()
{
	struct ip *iph;
	struct _SPimRegHdr *pim_reg_header;
	struct ip *mcast_iph;
	struct udphdr *mcast_udphdr;
	char *header = datagram;

	if( has_local_source ) {
		iph = (struct ip*)(header);
		iph->ip_hl = 5;
		iph->ip_v = 4;
		iph->ip_tos = 0;
		iph->ip_len = htons(length);
		iph->ip_id = htonl(random());
		iph->ip_off = 0;
		iph->ip_ttl = 255;
		iph->ip_p = IPPROTO_PIM;
		iph->ip_sum = 0;
		iph->ip_src.s_addr = inet_addr (local_source);
		iph->ip_dst.s_addr = inet_addr (rp);

		header += sizeof(struct ip);
	}

	pim_reg_header = (struct _SPimRegHdr*)(header); 
	pim_reg_header->msgtpe = PIMSM_REGISTER_MSG;
	pim_reg_header->pimver = 2;
	pim_reg_header->u2Checksum = csum((unsigned short*)pim_reg_header,sizeof(struct _SPimRegHdr)>>1);
	header += sizeof(struct _SPimRegHdr);

	mcast_iph = (struct ip*)(header);
	mcast_iph->ip_hl = 5;
	mcast_iph->ip_v = 4;
	mcast_iph->ip_tos = 0;
	if( has_local_source ) {
		mcast_iph->ip_len = htons(length - sizeof(struct ip) - sizeof(struct _SPimRegHdr));
	} else {
		mcast_iph->ip_len = htons(length - sizeof(struct _SPimRegHdr));
	}
	mcast_iph->ip_id = htonl(random());
	mcast_iph->ip_off = 0;
	mcast_iph->ip_ttl = 255;
	mcast_iph->ip_p = IPPROTO_UDP;
	mcast_iph->ip_sum = 0;
	mcast_iph->ip_src.s_addr = inet_addr (mcast_source);
	mcast_iph->ip_dst.s_addr = inet_addr (mcast_group);
	header += sizeof(struct ip);

	mcast_udphdr = (struct udphdr*)(header);
	mcast_udphdr->source = htons(mcast_port);
	mcast_udphdr->dest = htons(mcast_port);
	if( has_local_source ) {
		mcast_udphdr->len = htons(length - sizeof(struct ip) - sizeof(struct _SPimRegHdr) - sizeof(struct ip));
	} else {
		mcast_udphdr->len = htons(length - sizeof(struct _SPimRegHdr) - sizeof(struct ip));
	}
	mcast_udphdr->check = csum((unsigned short*)(((int*)mcast_udphdr)-2), strlen(((char*)mcast_udphdr)-1)>>1);

	if( has_local_source ) {
		mcast_iph->ip_sum = csum ((unsigned short*)mcast_iph, (length - sizeof(struct ip) - sizeof(struct _SPimRegHdr))>>1);
	} else {
		mcast_iph->ip_sum = csum ((unsigned short*)mcast_iph, (length - sizeof(struct _SPimRegHdr))>>1);
	}

	if( has_local_source ) {
		iph->ip_sum = csum((unsigned short*)iph, length>>1);
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
leaq 0x2ca1(%rip), %rax      # 0x40d0
movq %rax, -0x28(%rbp)
cmpl $0x0, 0x2c8a(%rip)      # 0x40c4
je 0x14f6
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
movb (%rax), %cl
andb $-0x10, %cl
orb $0x5, %cl
movb %cl, (%rax)
movq -0x8(%rbp), %rax
movb (%rax), %cl
andb $0xf, %cl
orb $0x40, %cl
movb %cl, (%rax)
movq -0x8(%rbp), %rax
movb $0x0, 0x1(%rax)
movl 0x2c2e(%rip), %eax      # 0x40a0
movzwl %ax, %edi
callq 0x1060
movw %ax, %cx
movq -0x8(%rbp), %rax
movw %cx, 0x2(%rax)
callq 0x10c0
movl %eax, %edi
callq 0x1080
movw %ax, %cx
movq -0x8(%rbp), %rax
movw %cx, 0x4(%rax)
movq -0x8(%rbp), %rax
movw $0x0, 0x6(%rax)
movq -0x8(%rbp), %rax
movb $-0x1, 0x8(%rax)
movq -0x8(%rbp), %rax
movb $0x67, 0x9(%rax)
movq -0x8(%rbp), %rax
movw $0x0, 0xa(%rax)
leaq 0x12c09(%rip), %rdi     # 0x140d0
callq 0x10b0
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0xc(%rax)
leaq 0x12c04(%rip), %rdi     # 0x140e0
callq 0x10b0
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x28(%rbp), %rax
addq $0x14, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movb (%rax), %cl
andb $-0x10, %cl
orb $0x1, %cl
movb %cl, (%rax)
movq -0x10(%rbp), %rax
movb (%rax), %cl
andb $0xf, %cl
orb $0x20, %cl
movb %cl, (%rax)
movq -0x10(%rbp), %rdi
movl $0x4, %esi
callq 0x1220
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x2(%rax)
movq -0x28(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movb (%rax), %cl
andb $-0x10, %cl
orb $0x5, %cl
movb %cl, (%rax)
movq -0x18(%rbp), %rax
movb (%rax), %cl
andb $0xf, %cl
orb $0x40, %cl
movb %cl, (%rax)
movq -0x18(%rbp), %rax
movb $0x0, 0x1(%rax)
cmpl $0x0, 0x2b52(%rip)      # 0x40c4
je 0x1598
movslq 0x2b25(%rip), %rax      # 0x40a0
subq $0x14, %rax
subq $0x8, %rax
movzwl %ax, %edi
callq 0x1060
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0x2(%rax)
jmp 0x15b6
movslq 0x2b01(%rip), %rax      # 0x40a0
subq $0x8, %rax
movzwl %ax, %edi
callq 0x1060
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0x2(%rax)
callq 0x10c0
movl %eax, %edi
callq 0x1080
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0x4(%rax)
movq -0x18(%rbp), %rax
movw $0x0, 0x6(%rax)
movq -0x18(%rbp), %rax
movb $-0x1, 0x8(%rax)
movq -0x18(%rbp), %rax
movb $0x11, 0x9(%rax)
movq -0x18(%rbp), %rax
movw $0x0, 0xa(%rax)
leaq 0x12af8(%rip), %rdi     # 0x140f0
callq 0x10b0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0xc(%rax)
leaq 0x12af3(%rip), %rdi     # 0x14100
callq 0x10b0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x28(%rbp), %rax
addq $0x14, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x20(%rbp)
movl 0x12adb(%rip), %eax     # 0x14110
movzwl %ax, %edi
callq 0x1060
movw %ax, %cx
movq -0x20(%rbp), %rax
movw %cx, (%rax)
movl 0x12ac3(%rip), %eax     # 0x14110
movzwl %ax, %edi
callq 0x1060
movw %ax, %cx
movq -0x20(%rbp), %rax
movw %cx, 0x2(%rax)
cmpl $0x0, 0x2a5d(%rip)      # 0x40c4
je 0x1691
movslq 0x2a30(%rip), %rax      # 0x40a0
subq $0x14, %rax
subq $0x8, %rax
subq $0x14, %rax
movzwl %ax, %edi
callq 0x1060
movw %ax, %cx
movq -0x20(%rbp), %rax
movw %cx, 0x4(%rax)
jmp 0x16b3
movslq 0x2a08(%rip), %rax      # 0x40a0
subq $0x8, %rax
subq $0x14, %rax
movzwl %ax, %edi
callq 0x1060
movw %ax, %cx
movq -0x20(%rbp), %rax
movw %cx, 0x4(%rax)
movq -0x20(%rbp), %rax
addq $-0x8, %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rdi
addq $-0x1, %rdi
callq 0x1050
movq -0x30(%rbp), %rdi
shrq %rax
movl %eax, %esi
callq 0x1220
movw %ax, %cx
movq -0x20(%rbp), %rax
movw %cx, 0x6(%rax)
cmpl $0x0, 0x29d8(%rip)      # 0x40c4
je 0x1718
movq -0x18(%rbp), %rdi
movslq 0x29a7(%rip), %rax      # 0x40a0
subq $0x14, %rax
subq $0x8, %rax
shrq %rax
movl %eax, %esi
callq 0x1220
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0xa(%rax)
jmp 0x173c
movq -0x18(%rbp), %rdi
movslq 0x297d(%rip), %rax      # 0x40a0
subq $0x8, %rax
shrq %rax
movl %eax, %esi
callq 0x1220
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0xa(%rax)
cmpl $0x0, 0x2981(%rip)      # 0x40c4
je 0x1761
movq -0x8(%rbp), %rdi
movl 0x2951(%rip), %esi      # 0x40a0
sarl %esi
callq 0x1220
movw %ax, %cx
movq -0x8(%rbp), %rax
movw %cx, 0xa(%rax)
xorl %eax, %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)