// File: hugosantos[P]dbeacon/dbeacon.cpp
// Function: CountSSMJoin(address const&, address const&)
static void CountSSMJoin(const address &group, const address &source) {
	address source_addr;
	char tmp[64], tmp2[64], tmp3[64];
	
	source_addr.set_family(source.family());
	source_addr.copy_address(source);
	source_addr.set_port(0);
	GroupMap::iterator g = groupMap.find(group);
	if (g == groupMap.end()) {
		if (verbose) 
			info("Registering SSM group %s", group.to_string(tmp, sizeof(tmp)));
		g = groupMap.insert(std::make_pair(group, SourceMap())).first;
	}
	SourceMap::iterator s = g->second.find(source_addr);
	if (s == g->second.end()) {
		if (verbose)
			info("Joining (%s, %s)", source_addr.to_string(tmp, sizeof(tmp)),
			     group.to_string(tmp2, sizeof(tmp2)));
		if (SSMJoin(ssmMcastSock, group, source_addr) < 0) {
			if (verbose)
				info("Join failed, reason: %s", strerror(errno));
			return;
		} else {
			s = g->second.insert(std::make_pair(source_addr, SourceSet())).first;
		}
	} 
	SourceSet::iterator ss = s->second.find(source);
	if (ss == s->second.end()) {
		if (verbose)
			info("Adding beacon %s to (%s, %s)", source.to_string(tmp, sizeof(tmp)),
			     source_addr.to_string(tmp2, sizeof(tmp2)),
			     group.to_string(tmp3, sizeof(tmp3)));
		s->second.insert(source);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x400, %rsp            # imm = 0x400
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x17b40
movq -0x10(%rbp), %rdi
callq 0x170e0
movl %eax, %esi
leaq -0x90(%rbp), %rdi
callq 0x17900
movq -0x10(%rbp), %rsi
leaq -0x90(%rbp), %rdi
callq 0x18440
leaq -0x90(%rbp), %rdi
xorl %esi, %esi
callq 0x18000
movq -0x8(%rbp), %rsi
leaq 0x22b21(%rip), %rdi     # 0x29950
callq 0x107c0
movq %rax, -0x158(%rbp)
leaq 0x22b0e(%rip), %rdi     # 0x29950
callq 0x10820
movq %rax, -0x160(%rbp)
leaq -0x158(%rbp), %rdi
leaq -0x160(%rbp), %rsi
callq 0x107f0
testb $0x1, %al
jne 0x6e6a
jmp 0x6fb1
cmpl $0x0, 0x22777(%rip)     # 0x295e8
je 0x6e9e
movq -0x8(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
movl $0x40, %edx
movl $0x1, %ecx
callq 0x18100
movq %rax, %rsi
leaq 0x1561f(%rip), %rdi     # 0x1c4b6
movb $0x0, %al
callq 0x51b0
movq -0x8(%rbp), %rax
movq %rax, -0x3b0(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x230(%rbp)
movaps %xmm0, -0x240(%rbp)
movaps %xmm0, -0x250(%rbp)
leaq -0x250(%rbp), %rdi
movq %rdi, -0x3a8(%rbp)
callq 0x108d0
movq -0x3b0(%rbp), %rsi
movq -0x3a8(%rbp), %rdx
leaq -0x220(%rbp), %rdi
callq 0x10890
jmp 0x6ef0
leaq 0x22a59(%rip), %rdi     # 0x29950
leaq -0x220(%rbp), %rsi
callq 0x10850
movb %dl, -0x3b9(%rbp)
movq %rax, -0x3b8(%rbp)
jmp 0x6f12
movb -0x3b9(%rbp), %al
movq -0x3b8(%rbp), %rcx
movq %rcx, -0x270(%rbp)
movb %al, -0x268(%rbp)
movq -0x270(%rbp), %rax
movq %rax, -0x170(%rbp)
movb -0x268(%rbp), %al
movb %al, -0x168(%rbp)
movq -0x170(%rbp), %rax
movq %rax, -0x158(%rbp)
leaq -0x220(%rbp), %rdi
callq 0x108f0
leaq -0x250(%rbp), %rdi
callq 0xffe0
jmp 0x6fb1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x258(%rbp)
movl %eax, -0x25c(%rbp)
jmp 0x6fa0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x258(%rbp)
movl %eax, -0x25c(%rbp)
leaq -0x220(%rbp), %rdi
callq 0x108f0
leaq -0x250(%rbp), %rdi
callq 0xffe0
jmp 0x72fe
leaq -0x158(%rbp), %rdi
callq 0x10920
movq %rax, %rdi
addq $0x80, %rdi
leaq -0x90(%rbp), %rsi
callq 0x10940
movq %rax, -0x278(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x10920
movq %rax, %rdi
addq $0x80, %rdi
callq 0x109a0
movq %rax, -0x280(%rbp)
leaq -0x278(%rbp), %rdi
leaq -0x280(%rbp), %rsi
callq 0x10970
testb $0x1, %al
jne 0x7018
jmp 0x71de
cmpl $0x0, 0x225c9(%rip)     # 0x295e8
je 0x7077
leaq -0xd0(%rbp), %rsi
leaq -0x90(%rbp), %rdi
movl $0x40, %edx
movl $0x1, %ecx
callq 0x18100
movq %rax, -0x3c8(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x110(%rbp), %rsi
movl $0x40, %edx
movl $0x1, %ecx
callq 0x18100
movq -0x3c8(%rbp), %rsi
movq %rax, %rdx
leaq 0x1545f(%rip), %rdi     # 0x1c4cf
movb $0x0, %al
callq 0x51b0
movl 0x2288b(%rip), %edi     # 0x29908
movq -0x8(%rbp), %rsi
leaq -0x90(%rbp), %rdx
callq 0x17150
cmpl $0x0, %eax
jge 0x70bd
cmpl $0x0, 0x2254f(%rip)     # 0x295e8
je 0x70b8
callq 0x4040
movl (%rax), %edi
callq 0x4170
movq %rax, %rsi
leaq 0x1542f(%rip), %rdi     # 0x1c4e0
movb $0x0, %al
callq 0x51b0
jmp 0x72f5
leaq -0x158(%rbp), %rdi
callq 0x10920
subq $-0x80, %rax
movq %rax, -0x3d8(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x350(%rbp)
movaps %xmm0, -0x360(%rbp)
movaps %xmm0, -0x370(%rbp)
leaq -0x370(%rbp), %rdi
movq %rdi, -0x3d0(%rbp)
callq 0x10a50
movq -0x3d0(%rbp), %rdx
leaq -0x340(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x10a10
jmp 0x711b
movq -0x3d8(%rbp), %rdi
leaq -0x340(%rbp), %rsi
callq 0x109d0
movb %dl, -0x3e1(%rbp)
movq %rax, -0x3e0(%rbp)
jmp 0x713d
movb -0x3e1(%rbp), %al
movq -0x3e0(%rbp), %rcx
movq %rcx, -0x380(%rbp)
movb %al, -0x378(%rbp)
movq -0x380(%rbp), %rax
movq %rax, -0x290(%rbp)
movb -0x378(%rbp), %al
movb %al, -0x288(%rbp)
movq -0x290(%rbp), %rax
movq %rax, -0x278(%rbp)
leaq -0x340(%rbp), %rdi
callq 0x10a70
leaq -0x370(%rbp), %rdi
callq 0x102a0
jmp 0x71dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x258(%rbp)
movl %eax, -0x25c(%rbp)
jmp 0x71cb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x258(%rbp)
movl %eax, -0x25c(%rbp)
leaq -0x340(%rbp), %rdi
callq 0x10a70
leaq -0x370(%rbp), %rdi
callq 0x102a0
jmp 0x72fe
jmp 0x71de
leaq -0x278(%rbp), %rdi
callq 0x10aa0
movq %rax, %rdi
addq $0x80, %rdi
movq -0x10(%rbp), %rsi
callq 0x10ac0
movq %rax, -0x388(%rbp)
leaq -0x278(%rbp), %rdi
callq 0x10aa0
movq %rax, %rdi
addq $0x80, %rdi
callq 0x10b30
movq %rax, -0x390(%rbp)
leaq -0x388(%rbp), %rdi
leaq -0x390(%rbp), %rsi
callq 0x10b00
testb $0x1, %al
jne 0x7242
jmp 0x72f5
cmpl $0x0, 0x2239f(%rip)     # 0x295e8
je 0x72c9
movq -0x10(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
movl $0x40, %edx
movl $0x1, %ecx
callq 0x18100
movq %rax, -0x3f8(%rbp)
leaq -0x110(%rbp), %rsi
leaq -0x90(%rbp), %rdi
movl $0x40, %edx
movl $0x1, %ecx
callq 0x18100
movq %rax, -0x3f0(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x150(%rbp), %rsi
movl $0x40, %edx
movl $0x1, %ecx
callq 0x18100
movq -0x3f8(%rbp), %rsi
movq -0x3f0(%rbp), %rdx
movq %rax, %rcx
leaq 0x15236(%rip), %rdi     # 0x1c4f8
movb $0x0, %al
callq 0x51b0
leaq -0x278(%rbp), %rdi
callq 0x10aa0
movq %rax, %rdi
addq $0x80, %rdi
movq -0x10(%rbp), %rsi
callq 0x10b60
movq %rax, -0x3a0(%rbp)
movb %dl, -0x398(%rbp)
addq $0x400, %rsp            # imm = 0x400
popq %rbp
retq
movq -0x258(%rbp), %rdi
callq 0x46f0
nopw (%rax,%rax)