// File: /workspace/github_cpp_makefile_star2_O3/Manca[P]algorithms2/./assignment2.hpp
// Function: assignment2::clustering_big::run_algorithm(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void run_algorithm(const std::string& inputFile)
        {
            std::fstream file(inputFile, std::ios::in);
            if (file.is_open())
            {
                PROFILE("Read input Clustering Big (slower algo)")
                int n, bpn;
                file >> n >> bpn;

                std::string node;
                std::getline(file, node);
                HashMap mapa;

                const int MAX_NODES = (int)std::pow(2, bpn);
                DataStructures::UnionFind uf(MAX_NODES); // total number of elements (2^24)

                while (std::getline(file, node))
                {
                    node.erase(std::remove_if(node.begin(), node.end(), [](char x) {return std::isspace(x); }), end(node));
                    std::bitset<24> bit_node(node);
                    int nodeNumber = bit_node.to_ulong();

                    mapa[nodeNumber] = false;
                }
                file.close();
                PROFILE_STOP();

                // generate distances
                std::vector<int> distances_one = generateHammingDistances(bpn, 1);
                std::vector<int> distances_two = generateHammingDistances(bpn, 2);
                int num_edg_cost_one = 0;
                int num_edg_cost_two = 0;

                PROFILE("Clustering big (slower algo)")
                // iterate through the map and find the neighbors
                for (auto& el : mapa)
                {
                    el.second = true;           // we won't bother to add already seen edge to UnionFind

                    for (auto d : distances_one)
                    {
                        int res = el.first ^ d;
                        auto exists = mapa.find(res);
                        if (exists != mapa.end() && !exists->second) // if it's found but not yet seen!
                        {
                            // add to UF (there is an edge from current element to the one 1 Hamming distance away)
                            num_edg_cost_one++;
                            uf.Union(exists->first, el.first);
                        }
                    }
                    for (auto d : distances_two)
                    {
                        int res = el.first ^ d;
                        auto exists = mapa.find(res);
                        if (exists != mapa.end() && !exists->second)
                        {
                            // add node connected to current one 2 Hamming distances away
                            num_edg_cost_two++;
                            uf.Union(exists->first, el.first);
                        }
                    }
                }
                PROFILE_STOP();
                // from total number of nodes (all clusters)
                // subtract leaders (clusters with nodes that are at most 2 Hamming distances away from each other)
                // and duplicated nodes to get number of clusters that are at least 3 Hamming distances away from others
                size_t totalNumberClusters = n - (MAX_NODES - uf.count()) - (n - mapa.size());
                std::cout << "Edges 1 Hamming distance away: " << num_edg_cost_one << std::endl;
                std::cout << "Edges 2 Hamming distances away: " << num_edg_cost_two << std::endl;
                std::cout << "Number of clusters: " << totalNumberClusters << std::endl;
                assert(totalNumberClusters == 6118);
            }
        }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2e8, %rsp            # imm = 0x2E8
movq %rdi, %rsi
leaq 0xd8(%rsp), %rdi
movl $0x8, %edx
callq 0x2330
leaq 0x158(%rsp), %rdi
callq 0x20b0
testb %al, %al
je 0x4278
callq 0x88f8
movq %rax, %rbx
leaq 0x60(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xa71d(%rip), %rsi      # 0xe3ee
leaq 0xa73d(%rip), %rdx      # 0xe415
leaq 0x50(%rsp), %rdi
callq 0xbb78
leaq 0x50(%rsp), %rsi
movq %rbx, %rdi
callq 0x8942
movq 0x50(%rsp), %rdi
cmpq %r14, %rdi
je 0x3cfe
callq 0x21f0
leaq 0xd8(%rsp), %rbx
leaq 0x14(%rsp), %rsi
movq %rbx, %rdi
callq 0x2160
leaq 0xc(%rsp), %rsi
movq %rax, %rdi
callq 0x2160
leaq 0x28(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0xd8(%rsp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %edx
leaq 0xd8(%rsp), %rbx
leaq 0x18(%rsp), %rsi
movq %rbx, %rdi
callq 0x2370
leaq 0x80(%rsp), %rax
movq %rax, -0x30(%rax)
movq $0x1, -0x28(%rax)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%rax)
movl $0x3f800000, -0x10(%rax) # imm = 0x3F800000
movups %xmm0, -0x8(%rax)
movl 0xc(%rsp), %edi
movsd 0xa389(%rip), %xmm0     # 0xe120
callq 0x22c0
cvttsd2si %xmm0, %esi
leaq 0xc0(%rsp), %rdi
movl %esi, 0x10(%rsp)
callq 0x8ab6
leaq 0x18(%rsp), %r15
movq 0xd8(%rsp), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2370
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x3f45
movq 0x18(%rsp), %rbp
movq 0x20(%rsp), %rax
leaq (%rax,%rbp), %r13
movq %rax, %r14
sarq $0x2, %r14
movq %rbp, %r12
testq %r14, %r14
jle 0x3e61
andq $-0x4, %rax
movq %rax, %r12
addq %rbp, %r12
incq %r14
leaq 0x3(%rbp), %rbx
movsbl -0x3(%rbx), %edi
callq 0x2060
testl %eax, %eax
jne 0x3eb0
movsbl -0x2(%rbx), %edi
callq 0x2060
testl %eax, %eax
jne 0x3eb6
movsbl -0x1(%rbx), %edi
callq 0x2060
testl %eax, %eax
jne 0x3ebc
movsbl (%rbx), %edi
callq 0x2060
testl %eax, %eax
jne 0x3ebf
decq %r14
addq $0x4, %rbx
cmpq $0x1, %r14
jg 0x3e1d
movq %r13, %rax
subq %r12, %rax
cmpq $0x1, %rax
je 0x3e9b
cmpq $0x2, %rax
je 0x3e8a
cmpq $0x3, %rax
jne 0x3ef8
movsbl (%r12), %edi
callq 0x2060
testl %eax, %eax
jne 0x3eab
incq %r12
movsbl (%r12), %edi
callq 0x2060
testl %eax, %eax
jne 0x3eab
incq %r12
movsbl (%r12), %edi
callq 0x2060
testl %eax, %eax
cmoveq %r13, %r12
movq %r12, %rbx
jmp 0x3ebf
addq $-0x3, %rbx
jmp 0x3ebf
addq $-0x2, %rbx
jmp 0x3ebf
decq %rbx
cmpq %r13, %rbx
sete %al
leaq 0x1(%rbx), %r14
cmpq %r13, %r14
sete %cl
orb %al, %cl
jne 0x3efb
movb (%r14), %bpl
movsbl %bpl, %edi
callq 0x2060
testl %eax, %eax
jne 0x3ee9
movb %bpl, (%rbx)
incq %rbx
incq %r14
cmpq %r13, %r14
jne 0x3ed3
movq 0x18(%rsp), %rbp
jmp 0x3efb
movq %r13, %rbx
movq %rbx, %rax
subq %rbp, %rax
movq %rax, 0x20(%rsp)
movb $0x0, (%rbx)
leaq 0x88(%rsp), %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x8c1a
movl 0x88(%rsp), %eax
movl %eax, 0x38(%rsp)
leaq 0x50(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0xbda0
leaq 0xd8(%rsp), %rbx
movb $0x0, (%rax)
jmp 0x3db6
leaq 0xd8(%rsp), %rdi
callq 0x2050
callq 0x88f8
movq %rax, %rdi
callq 0x898c
movl 0xc(%rsp), %esi
leaq 0x38(%rsp), %rdi
movl $0x1, %edx
callq 0x3b87
movl 0xc(%rsp), %esi
leaq 0xa8(%rsp), %rdi
movl $0x2, %edx
callq 0x3b87
callq 0x88f8
movq %rax, %r14
leaq 0x98(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xa473(%rip), %rsi      # 0xe416
leaq 0xa488(%rip), %rdx      # 0xe432
leaq 0x88(%rsp), %rdi
callq 0xbb78
leaq 0x88(%rsp), %rsi
movq %r14, %rdi
callq 0x8942
movq 0x88(%rsp), %rdi
cmpq %r15, %rdi
je 0x3fd9
callq 0x21f0
movq 0x60(%rsp), %r12
testq %r12, %r12
je 0x40fc
xorl %r14d, %r14d
leaq 0xc0(%rsp), %r15
xorl %ebp, %ebp
movb $0x1, 0xc(%r12)
movq 0x38(%rsp), %rbx
movq 0x40(%rsp), %r13
cmpq %r13, %rbx
je 0x4071
movl 0x8(%r12), %ecx
movl (%rbx), %esi
xorl %ecx, %esi
movslq %esi, %rax
movq 0x50(%rsp), %r8
movq 0x58(%rsp), %r9
xorl %edx, %edx
divq %r9
movq (%r8,%rdx,8), %rax
testq %rax, %rax
je 0x406b
movq %rdx, %rdi
movq (%rax), %r10
cmpl 0x8(%r10), %esi
je 0x4057
movq (%r10), %r10
testq %r10, %r10
je 0x406b
movslq 0x8(%r10), %r8
movq %r8, %rax
xorl %edx, %edx
divq %r9
cmpq %rdi, %rdx
jne 0x406b
cmpl %r8d, %esi
jne 0x4039
cmpb $0x0, 0xc(%r10)
jne 0x406b
incl %r14d
movq %r15, %rdi
movl %ecx, %edx
callq 0x8bb0
addq $0x4, %rbx
jmp 0x4004
movq 0xa8(%rsp), %rbx
movq 0xb0(%rsp), %r13
cmpq %r13, %rbx
je 0x40ed
movl 0x8(%r12), %ecx
movl (%rbx), %esi
xorl %ecx, %esi
movslq %esi, %rax
movq 0x50(%rsp), %r8
movq 0x58(%rsp), %r9
xorl %edx, %edx
divq %r9
movq (%r8,%rdx,8), %rax
testq %rax, %rax
je 0x40e7
movq %rdx, %rdi
movq (%rax), %r10
cmpl 0x8(%r10), %esi
je 0x40d4
movq (%r10), %r10
testq %r10, %r10
je 0x40e7
movslq 0x8(%r10), %r8
movq %r8, %rax
xorl %edx, %edx
divq %r9
cmpq %rdi, %rdx
jne 0x40e7
cmpl %r8d, %esi
jne 0x40b6
cmpb $0x0, 0xc(%r10)
jne 0x40e7
incl %ebp
movq %r15, %rdi
movl %ecx, %edx
callq 0x8bb0
addq $0x4, %rbx
jmp 0x4081
movq (%r12), %r12
testq %r12, %r12
jne 0x3ff4
jmp 0x4101
xorl %ebp, %ebp
xorl %r14d, %r14d
callq 0x88f8
movq %rax, %rdi
callq 0x898c
movslq 0x14(%rsp), %r15
movl %r15d, %r12d
subl 0x10(%rsp), %r12d
addl 0xd0(%rsp), %r12d
movq 0x68(%rsp), %rbx
movq 0x10ea9(%rip), %rdi     # 0x14fd8
leaq 0xa2fd(%rip), %rsi      # 0xe433
movl $0x1f, %edx
callq 0x2240
movq 0x10e91(%rip), %rdi     # 0x14fd8
movl %r14d, %esi
callq 0x2340
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2190
movq 0x10e58(%rip), %rdi     # 0x14fd8
leaq 0xa2cc(%rip), %rsi      # 0xe453
movl $0x20, %edx
callq 0x2240
movq 0x10e40(%rip), %rdi     # 0x14fd8
movl %ebp, %esi
callq 0x2340
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2190
movq 0x10e08(%rip), %rdi     # 0x14fd8
leaq 0xa29d(%rip), %rsi      # 0xe474
movl $0x14, %edx
callq 0x2240
movslq %r12d, %rax
subq %r15, %rbx
addq %rax, %rbx
movq 0x10de7(%rip), %rdi     # 0x14fd8
movq %rbx, %rsi
callq 0x2180
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2190
cmpq $0x17e6, %rbx           # imm = 0x17E6
jne 0x4297
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
je 0x423e
callq 0x21f0
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x424d
callq 0x21f0
leaq 0xc0(%rsp), %rdi
callq 0x8bf8
leaq 0x50(%rsp), %rdi
callq 0xa5b6
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x4278
callq 0x21f0
leaq 0xd8(%rsp), %rdi
callq 0x20a0
addq $0x2e8, %rsp            # imm = 0x2E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xa1eb(%rip), %rdi      # 0xe489
leaq 0xa200(%rip), %rsi      # 0xe4a5
leaq 0xa20b(%rip), %rcx      # 0xe4b7
movl $0xec, %edx
callq 0x2170
movq %rax, %rbx
movq 0x88(%rsp), %rdi
cmpq %r15, %rdi
je 0x42ff
callq 0x21f0
jmp 0x42ff
jmp 0x42fc
movq %rax, %rbx
jmp 0x4311
jmp 0x4326
movq %rax, %rbx
jmp 0x4336
movq %rax, %rbx
movq 0x50(%rsp), %rdi
cmpq %r14, %rdi
jne 0x434f
jmp 0x4354
jmp 0x42f3
jmp 0x42f3
movq %rax, %rbx
jmp 0x4340
movq %rax, %rbx
jmp 0x4354
jmp 0x42fc
jmp 0x4326
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
je 0x4311
callq 0x21f0
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x4329
callq 0x21f0
jmp 0x4329
jmp 0x4326
jmp 0x4326
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0x8bf8
leaq 0x50(%rsp), %rdi
callq 0xa5b6
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x4354
callq 0x21f0
leaq 0xd8(%rsp), %rdi
callq 0x20a0
movq %rbx, %rdi
callq 0x2350