// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movq %rsi, %rdi
callq 0x93f2
movl %eax, %ebp
movq %r14, %rdi
callq 0x9450
xorl %ecx, %ecx
testb %al, %al
je 0x97c9
movl %ebp, %eax
xorb $0x1, %al
movzbl %al, %r12d
shll $0x4, %r12d
movl $0x9bff6400, %eax       # imm = 0x9BFF6400
movl 0x8(%r14), %ecx
leaq 0x63ff9c00(%rax), %rdx
xorq %rcx, %rdx
movl $0xc, %r13d
movb $0x1, %cl
orq (%r14), %rdx
je 0x97cf
movl 0x8(%r14), %edx
xorq $0xffff, %rdx           # imm = 0xFFFF
orq (%r14), %rdx
je 0x97cf
xorq (%r14), %rax
movl 0x8(%r14), %edx
orq %rax, %rdx
je 0x97cf
movb (%r14), %al
movb 0x1(%r14), %dl
xorb $0x20, %al
movl %edx, %esi
xorb $0x2, %sil
movl $0x2, %r13d
orb %al, %sil
je 0x97cf
movl %edx, %edi
xorb $0x1, %dil
orb %al, %dil
movb 0x2(%r14), %cl
movb 0x3(%r14), %sil
orb %cl, %dil
orb %sil, %dil
jne 0x9870
leaq 0x7(%rsp), %rsi
movb $0x1, (%rsi)
movq %rbx, %rdi
callq 0xa3d8
movb 0xc(%r14), %al
notb %al
leaq 0x6(%rsp), %rsi
movb %al, (%rsi)
movq %rbx, %rdi
callq 0xa3d8
movb 0xd(%r14), %al
notb %al
leaq 0x5(%rsp), %rsi
movb %al, (%rsi)
movq %rbx, %rdi
callq 0xa3d8
jmp 0x985e
xorl %r13d, %r13d
xorl %r12d, %r12d
leaq 0x4(%rsp), %rdx
movb %cl, (%rdx)
movq %rbx, %rdi
xorl %esi, %esi
callq 0xa7f8
cmpl $0x8, %r12d
jb 0x982d
movl %r13d, %ebp
leal -0x8(%r12), %eax
shrl $0x3, %eax
addl %eax, %r13d
incl %r13d
leaq 0x3(%rsp), %r15
movb (%r14,%rbp), %al
movb %al, 0x3(%rsp)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x9816
movb %al, (%rsi)
incq 0x8(%rbx)
jmp 0x9821
movq %rbx, %rdi
movq %r15, %rdx
callq 0xa7f8
incq %rbp
addl $-0x8, %r12d
cmpq %rbp, %r13
jne 0x97fc
testl %r12d, %r12d
je 0x985e
movl %r13d, %eax
movb (%r14,%rax), %al
orb $0xf, %al
movb %al, 0x2(%rsp)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x9851
movb %al, (%rsi)
incq 0x8(%rbx)
jmp 0x985e
leaq 0x2(%rsp), %rdx
movq %rbx, %rdi
callq 0xa7f8
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x7ed887fd, %edi       # imm = 0x7ED887FD
xorl (%r14), %edi
movzwl 0x4(%r14), %r8d
xorl $0x43eb, %r8d           # imm = 0x43EB
movl $0x4, %r12d
movl $0x6, %r13d
orl %edi, %r8d
je 0x98dd
movl $0x4ddb60fd, %edi       # imm = 0x4DDB60FD
xorl (%r14), %edi
movzwl 0x4(%r14), %r8d
xorl $0xb5dd, %r8d           # imm = 0xB5DD
orl %edi, %r8d
je 0x98e4
xorb $0x11, %dl
orb %dl, %al
xorb $0x4, %cl
orb %al, %cl
xorb $0x70, %sil
xorl %eax, %eax
orb %cl, %sil
sete %al
leal 0x20(,%rax,4), %r12d
negb %bpl
orb $0x2, %bpl
movl %ebp, %ecx
xorl %r13d, %r13d
jmp 0x97cf
movb $0x3, %cl
jmp 0x97cf
movb $0x4, %cl
jmp 0x97cf
jmp 0x98f5
jmp 0x98f5
jmp 0x98f5
jmp 0x98f5
jmp 0x98f5
movq %rax, %r14
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x9905
callq 0x33d0
movq %r14, %rdi
callq 0x3650
nop