// File: tenup-coin[P]seeder/netbase.cpp
// Function: CNetAddr::GetGroup() const
std::vector<unsigned char> CNetAddr::GetGroup() const
{
    std::vector<unsigned char> vchRet;
    int nClass = NET_IPV6;
    int nStartByte = 0;
    int nBits = 16;

    // all local addresses belong to the same group
    if (IsLocal())
    {
        nClass = 255;
        nBits = 0;
    }

    // all unroutable addresses belong to the same group
    if (!IsRoutable())
    {
        nClass = NET_UNROUTABLE;
        nBits = 0;
    }
    // for IPv4 addresses, '1' + the 16 higher-order bits of the IP
    // includes mapped IPv4, SIIT translated IPv4, and the well-known prefix
    else if (IsIPv4() || IsRFC6145() || IsRFC6052())
    {
        nClass = NET_IPV4;
        nStartByte = 12;
    }
    // for 6to4 tunnelled addresses, use the encapsulated IPv4 address
    else if (IsRFC3964())
    {
        nClass = NET_IPV4;
        nStartByte = 2;
    }
    // for Teredo-tunnelled IPv6 addresses, use the encapsulated IPv4 address
    else if (IsRFC4380())
    {
        vchRet.push_back(NET_IPV4);
        vchRet.push_back(GetByte(3) ^ 0xFF);
        vchRet.push_back(GetByte(2) ^ 0xFF);
        return vchRet;
    }
    else if (IsTor())
    {
        nClass = NET_TOR;
        nStartByte = 6;
        nBits = 4;
    }
    else if (IsI2P())
    {
        nClass = NET_I2P;
        nStartByte = 6;
        nBits = 4;
    }
    // for he.net, use /36 groups
    else if (GetByte(15) == 0x20 && GetByte(14) == 0x11 && GetByte(13) == 0x04 && GetByte(12) == 0x70)
        nBits = 36;
    // for the rest of the IPv6 network, use /32 groups
    else
        nBits = 32;

    vchRet.push_back(nClass);
    while (nBits >= 8)
    {
        vchRet.push_back(GetByte(15 - nStartByte));
        nStartByte++;
        nBits -= 8;
    }
    if (nBits > 0)
        vchRet.push_back(GetByte(15 - nStartByte) | ((1 << nBits) - 1));

    return vchRet;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x58(%rbp)
movq %rdi, %rax
movq %rax, -0x50(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x48(%rbp)
movb $0x0, -0x11(%rbp)
callq 0x15600
movq -0x48(%rbp), %rdi
movl $0x2, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x10, -0x20(%rbp)
callq 0x13a40
testb $0x1, %al
jne 0x13fb0
jmp 0x13fbe
movl $0xff, -0x18(%rbp)
movl $0x0, -0x20(%rbp)
movq -0x48(%rbp), %rdi
callq 0x13b40
testb $0x1, %al
jne 0x13fde
movl $0x0, -0x18(%rbp)
movl $0x0, -0x20(%rbp)
jmp 0x14186
movq -0x48(%rbp), %rdi
callq 0x134f0
testb $0x1, %al
jne 0x14007
movq -0x48(%rbp), %rdi
callq 0x13980
testb $0x1, %al
jne 0x14007
movq -0x48(%rbp), %rdi
callq 0x13870
testb $0x1, %al
jne 0x14007
jmp 0x1401a
movl $0x1, -0x18(%rbp)
movl $0xc, -0x1c(%rbp)
jmp 0x14184
movq -0x48(%rbp), %rdi
callq 0x13820
testb $0x1, %al
jne 0x14029
jmp 0x1403c
movl $0x1, -0x18(%rbp)
movl $0x2, -0x1c(%rbp)
jmp 0x14182
movq -0x48(%rbp), %rdi
callq 0x138a0
testb $0x1, %al
jne 0x1404e
jmp 0x140cf
movq -0x58(%rbp), %rdi
movb $0x1, -0x21(%rbp)
leaq -0x21(%rbp), %rsi
callq 0x15620
jmp 0x14061
movq -0x48(%rbp), %rdi
movl $0x3, %esi
callq 0x134d0
movq -0x58(%rbp), %rdi
notb %al
movb %al, -0x35(%rbp)
leaq -0x35(%rbp), %rsi
callq 0x15620
jmp 0x14083
movq -0x48(%rbp), %rdi
movl $0x2, %esi
callq 0x134d0
movq -0x58(%rbp), %rdi
notb %al
movb %al, -0x36(%rbp)
leaq -0x36(%rbp), %rsi
callq 0x15620
jmp 0x140a5
movb $0x1, -0x11(%rbp)
movl $0x1, -0x3c(%rbp)
jmp 0x14224
movq -0x58(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
callq 0x15550
jmp 0x1423d
movq -0x48(%rbp), %rdi
callq 0x13580
testb $0x1, %al
jne 0x140de
jmp 0x140f8
movl $0x3, -0x18(%rbp)
movl $0x6, -0x1c(%rbp)
movl $0x4, -0x20(%rbp)
jmp 0x1417e
movq -0x48(%rbp), %rdi
callq 0x135b0
testb $0x1, %al
jne 0x14107
jmp 0x1411e
movl $0x4, -0x18(%rbp)
movl $0x6, -0x1c(%rbp)
movl $0x4, -0x20(%rbp)
jmp 0x1417c
movq -0x48(%rbp), %rdi
movl $0xf, %esi
callq 0x134d0
cmpl $0x20, %eax
jne 0x14173
movq -0x48(%rbp), %rdi
movl $0xe, %esi
callq 0x134d0
cmpl $0x11, %eax
jne 0x14173
movq -0x48(%rbp), %rdi
movl $0xd, %esi
callq 0x134d0
cmpl $0x4, %eax
jne 0x14173
movq -0x48(%rbp), %rdi
movl $0xc, %esi
callq 0x134d0
cmpl $0x70, %eax
jne 0x14173
movl $0x24, -0x20(%rbp)
jmp 0x1417a
movl $0x20, -0x20(%rbp)
jmp 0x1417c
jmp 0x1417e
jmp 0x14180
jmp 0x14182
jmp 0x14184
jmp 0x14186
movq -0x58(%rbp), %rdi
movb -0x18(%rbp), %al
movb %al, -0x3d(%rbp)
leaq -0x3d(%rbp), %rsi
callq 0x15620
jmp 0x1419b
jmp 0x1419d
cmpl $0x8, -0x20(%rbp)
jl 0x141dc
movq -0x48(%rbp), %rdi
movl -0x1c(%rbp), %eax
movl $0xf, %esi
subl %eax, %esi
callq 0x134d0
movq -0x58(%rbp), %rdi
movb %al, -0x3e(%rbp)
leaq -0x3e(%rbp), %rsi
callq 0x15620
jmp 0x141c8
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movl -0x20(%rbp), %eax
subl $0x8, %eax
movl %eax, -0x20(%rbp)
jmp 0x1419d
cmpl $0x0, -0x20(%rbp)
jle 0x14219
movq -0x48(%rbp), %rdi
movl -0x1c(%rbp), %eax
movl $0xf, %esi
subl %eax, %esi
callq 0x134d0
movq -0x58(%rbp), %rdi
movb -0x20(%rbp), %cl
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
decl %ecx
orl %ecx, %eax
movb %al, -0x3f(%rbp)
leaq -0x3f(%rbp), %rsi
callq 0x15620
jmp 0x14217
jmp 0x14219
movb $0x1, -0x11(%rbp)
movl $0x1, -0x3c(%rbp)
testb $0x1, -0x11(%rbp)
jne 0x14233
movq -0x58(%rbp), %rdi
callq 0x15550
movq -0x50(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
movq -0x30(%rbp), %rdi
callq 0x47f0
nopw %cs:(%rax,%rax)