// File: /workspace/github_cpp_makefile_star2_O1/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 0x2340
leaq 0x158(%rsp), %rdi
callq 0x20b0
testb %al, %al
je 0x4306
callq 0x88b8
movq %rax, %rbx
leaq 0x60(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xa6f4(%rip), %rsi      # 0xe3ee
leaq 0xa714(%rip), %rdx      # 0xe415
leaq 0x50(%rsp), %rdi
callq 0xbb3a
leaq 0x50(%rsp), %rsi
movq %rbx, %rdi
callq 0x8904
movq 0x50(%rsp), %rdi
cmpq %r14, %rdi
je 0x3d27
callq 0x2200
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 0x2210
movsbl %al, %edx
leaq 0xd8(%rsp), %rbx
leaq 0x18(%rsp), %rsi
movq %rbx, %rdi
callq 0x2380
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 0xa360(%rip), %xmm0     # 0xe120
callq 0x22d0
cvttsd2si %xmm0, %esi
leaq 0xc0(%rsp), %rdi
movl %esi, 0x10(%rsp)
callq 0x8a78
leaq 0x18(%rsp), %r15
movq 0xd8(%rsp), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2380
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x3f6d
movq 0x18(%rsp), %r13
movq 0x20(%rsp), %r14
leaq (%r14,%r13), %r12
movq %r14, %rbp
sarq $0x2, %rbp
testq %rbp, %rbp
jle 0x3e8e
andq $-0x4, %r14
addq %r13, %r14
incq %rbp
addq $0x3, %r13
movq %r13, %rbx
movsbl -0x3(%rbx), %edi
callq 0x2060
testl %eax, %eax
jne 0x3ee0
movsbl -0x2(%rbx), %edi
callq 0x2060
testl %eax, %eax
jne 0x3ee6
movsbl -0x1(%rbx), %edi
callq 0x2060
testl %eax, %eax
jne 0x3eec
movsbl (%rbx), %edi
callq 0x2060
testl %eax, %eax
jne 0x3eef
decq %rbp
addq $0x4, %rbx
cmpq $0x1, %rbp
jg 0x3e43
movq %r14, %r13
movq %r12, %rax
subq %r13, %rax
cmpq $0x1, %rax
je 0x3ecb
cmpq $0x2, %rax
je 0x3eba
movq %r12, %rbx
cmpq $0x3, %rax
jne 0x3eef
movsbl (%r13), %edi
callq 0x2060
testl %eax, %eax
jne 0x3edb
incq %r13
movsbl (%r13), %edi
callq 0x2060
testl %eax, %eax
jne 0x3edb
incq %r13
movsbl (%r13), %edi
callq 0x2060
testl %eax, %eax
cmoveq %r12, %r13
movq %r13, %rbx
jmp 0x3eef
addq $-0x3, %rbx
jmp 0x3eef
addq $-0x2, %rbx
jmp 0x3eef
decq %rbx
cmpq %r12, %rbx
sete %al
leaq 0x1(%rbx), %r14
cmpq %r12, %r14
sete %cl
orb %al, %cl
jne 0x3f21
movb (%r14), %bpl
movsbl %bpl, %edi
callq 0x2060
testl %eax, %eax
jne 0x3f19
movb %bpl, (%rbx)
incq %rbx
incq %r14
cmpq %r12, %r14
jne 0x3f03
movq %rbx, %rax
subq 0x18(%rsp), %rax
movq %rax, 0x20(%rsp)
movb $0x0, (%rbx)
leaq 0x88(%rsp), %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x8bdc
movl 0x88(%rsp), %eax
movl %eax, 0x38(%rsp)
leaq 0x50(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0xbd5a
leaq 0xd8(%rsp), %rbx
movb $0x0, (%rax)
jmp 0x3ddf
leaq 0xd8(%rsp), %rdi
callq 0x2050
callq 0x88b8
movq %rax, %rdi
callq 0x894e
movl 0xc(%rsp), %esi
leaq 0x38(%rsp), %rdi
movl $0x1, %edx
callq 0x3ba8
movl 0xc(%rsp), %esi
leaq 0xa8(%rsp), %rdi
movl $0x2, %edx
callq 0x3ba8
callq 0x88b8
movq %rax, %r14
leaq 0x98(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xa44b(%rip), %rsi      # 0xe416
leaq 0xa460(%rip), %rdx      # 0xe432
leaq 0x88(%rsp), %rdi
callq 0xbb3a
leaq 0x88(%rsp), %rsi
movq %r14, %rdi
callq 0x8904
movq 0x88(%rsp), %rdi
cmpq %r15, %rdi
je 0x4001
callq 0x2200
movq 0x60(%rsp), %r12
testq %r12, %r12
je 0x418a
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 0x40cc
movl 0x8(%r12), %ecx
movl (%rbx), %r8d
xorl %ecx, %r8d
movslq %r8d, %rax
movq 0x50(%rsp), %rdi
movq 0x58(%rsp), %r9
xorl %edx, %edx
divq %r9
movq %rdx, %rsi
movq (%rdi,%rdx,8), %rdx
movl $0x0, %eax
testq %rdx, %rdx
je 0x409c
movq (%rdx), %r10
movq %rdx, %rax
cmpl 0x8(%r10), %r8d
je 0x409c
movq %r10, %r11
movq (%r10), %r10
testq %r10, %r10
je 0x409a
movslq 0x8(%r10), %rdi
movq %rdi, %rax
xorl %edx, %edx
divq %r9
movl $0x0, %eax
cmpq %rsi, %rdx
jne 0x409c
movq %r11, %rax
cmpl %edi, %r8d
jne 0x406f
jmp 0x409c
xorl %eax, %eax
testq %rax, %rax
je 0x40a6
movq (%rax), %rax
jmp 0x40a8
xorl %eax, %eax
testq %rax, %rax
je 0x40c3
cmpb $0x0, 0xc(%rax)
jne 0x40c3
incl %r14d
movl 0x8(%rax), %esi
movq %r15, %rdi
movl %ecx, %edx
callq 0x8b72
addq $0x4, %rbx
jmp 0x402c
movq 0xa8(%rsp), %rbx
movq 0xb0(%rsp), %r13
cmpq %r13, %rbx
je 0x417b
movl 0x8(%r12), %ecx
movl (%rbx), %r8d
xorl %ecx, %r8d
movslq %r8d, %rax
movq 0x50(%rsp), %rdi
movq 0x58(%rsp), %r9
xorl %edx, %edx
divq %r9
movq %rdx, %rsi
movq (%rdi,%rdx,8), %rdx
movl $0x0, %eax
testq %rdx, %rdx
je 0x414c
movq (%rdx), %r10
movq %rdx, %rax
cmpl 0x8(%r10), %r8d
je 0x414c
movq %r10, %r11
movq (%r10), %r10
testq %r10, %r10
je 0x414a
movslq 0x8(%r10), %rdi
movq %rdi, %rax
xorl %edx, %edx
divq %r9
movl $0x0, %eax
cmpq %rsi, %rdx
jne 0x414c
movq %r11, %rax
cmpl %edi, %r8d
jne 0x411f
jmp 0x414c
xorl %eax, %eax
testq %rax, %rax
je 0x4156
movq (%rax), %rax
jmp 0x4158
xorl %eax, %eax
testq %rax, %rax
je 0x4172
cmpb $0x0, 0xc(%rax)
jne 0x4172
incl %ebp
movl 0x8(%rax), %esi
movq %r15, %rdi
movl %ecx, %edx
callq 0x8b72
addq $0x4, %rbx
jmp 0x40dc
movq (%r12), %r12
testq %r12, %r12
jne 0x401c
jmp 0x418f
xorl %ebp, %ebp
xorl %r14d, %r14d
callq 0x88b8
movq %rax, %rdi
callq 0x894e
movslq 0x14(%rsp), %r15
movl %r15d, %r12d
subl 0x10(%rsp), %r12d
addl 0xd0(%rsp), %r12d
movq 0x68(%rsp), %rbx
movq 0x10e1b(%rip), %rdi     # 0x14fd8
leaq 0xa26f(%rip), %rsi      # 0xe433
movl $0x1f, %edx
callq 0x2250
movq 0x10e03(%rip), %rdi     # 0x14fd8
movl %r14d, %esi
callq 0x2350
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2190
movq 0x10dca(%rip), %rdi     # 0x14fd8
leaq 0xa23e(%rip), %rsi      # 0xe453
movl $0x20, %edx
callq 0x2250
movq 0x10db2(%rip), %rdi     # 0x14fd8
movl %ebp, %esi
callq 0x2350
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2190
movq 0x10d7a(%rip), %rdi     # 0x14fd8
leaq 0xa20f(%rip), %rsi      # 0xe474
movl $0x14, %edx
callq 0x2250
movslq %r12d, %rax
subq %r15, %rbx
addq %rax, %rbx
movq 0x10d59(%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 0x2210
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2190
cmpq $0x17e6, %rbx           # imm = 0x17E6
jne 0x4325
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
je 0x42cc
callq 0x2200
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x42db
callq 0x2200
leaq 0xc0(%rsp), %rdi
callq 0x8bba
leaq 0x50(%rsp), %rdi
callq 0xa55e
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x4306
callq 0x2200
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 0xa15d(%rip), %rdi      # 0xe489
leaq 0xa172(%rip), %rsi      # 0xe4a5
leaq 0xa17d(%rip), %rcx      # 0xe4b7
movl $0xec, %edx
callq 0x2170
movq %rax, %rbx
movq 0x88(%rsp), %rdi
cmpq %r15, %rdi
je 0x438d
callq 0x2200
jmp 0x438d
jmp 0x438a
movq %rax, %rbx
jmp 0x439f
jmp 0x43b4
movq %rax, %rbx
jmp 0x43c4
movq %rax, %rbx
movq 0x50(%rsp), %rdi
cmpq %r14, %rdi
jne 0x43dd
jmp 0x43e2
jmp 0x4381
jmp 0x4381
movq %rax, %rbx
jmp 0x43ce
movq %rax, %rbx
jmp 0x43e2
jmp 0x438a
jmp 0x43b4
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
je 0x439f
callq 0x2200
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x43b7
callq 0x2200
jmp 0x43b7
jmp 0x43b4
jmp 0x43b4
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0x8bba
leaq 0x50(%rsp), %rdi
callq 0xa55e
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x43e2
callq 0x2200
leaq 0xd8(%rsp), %rdi
callq 0x20a0
movq %rbx, %rdi
callq 0x2360