// File: /workspace/github_cpp_makefile_star2_O2/chuckwolber[P]Cube/order/cli.cpp
// Function: calculateOrder(unsigned int)
void calculateOrder(const unsigned int threadNum) {
    Algorithm algorithm(initialAlgorithm);
    std::vector<Turn> turnSet;
    Cube c(CubieColor::RED, 3);
    unsigned int order;
    unsigned long long int algorithmCount = threadNum;

    algorithm += threadNum;
    while (algorithmCount < algorithmCountMax) {
        if (algorithmCount % skip_nth != 0)
            goto bypass;
        if (keepDuplicates || !algorithm.isRedundant()) {
            order = 0;
            turnSet = algorithm.getAlgorithm();
            do {
                ++order;
                c.performAlgorithm(turnSet);
            } while (!c.isSolved());

            printResult(threadNum, algorithmCount, turnSet, order);
            if (skipFoundOrders && !numSkipFoundOrders)
                return;
        }
        
        bypass:
        algorithmCount += numThreads;
        algorithm += numThreads;

        if (heartbeat > 0 && algorithmCount % heartbeat == 0) {
            coutMutex.lock();
            std::cout << "HB:" << algorithmCount << std::endl;
            coutMutex.unlock();
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movl %edi, %ebx
leaq 0xa6de(%rip), %rsi      # 0x12668
leaq 0x30(%rsp), %rdi
callq 0x4884
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
leaq 0x70(%rsp), %rdi
pushq $0x72
popq %rsi
pushq $0x3
popq %rdx
callq 0x5fd6
movl %ebx, 0xc(%rsp)
movl %ebx, %r14d
leaq 0x30(%rsp), %rdi
movq %r14, %rsi
callq 0x4b00
leaq 0x58(%rsp), %r15
leaq 0x30(%rsp), %r12
leaq 0x10(%rsp), %r13
leaq 0x70(%rsp), %rbp
cmpq 0xa65f(%rip), %r14      # 0x12640
jae 0x80e6
movq %r14, %rax
xorl %edx, %edx
divq 0xa645(%rip)            # 0x12638
testq %rdx, %rdx
je 0x8068
movl 0xa65a(%rip), %ebx      # 0x12658
movq %r12, %rdi
movq %rbx, %rsi
callq 0x4b00
addq %rbx, %r14
movq 0xa63d(%rip), %rcx      # 0x12650
testq %rcx, %rcx
je 0x7fda
movq %r14, %rax
xorl %edx, %edx
divq %rcx
testq %rdx, %rdx
jne 0x7fda
leaq 0xa59c(%rip), %rdi      # 0x125c8
callq 0x8986
movq 0x9f78(%rip), %rdi      # 0x11fb0
leaq 0x39bc(%rip), %rsi      # 0xb9fb
callq 0x42c0
movq %rax, %rdi
movq %r14, %rsi
callq 0x41c0
movq %rax, %rdi
callq 0x4120
leaq 0xa56a(%rip), %rdi      # 0x125c8
callq 0x4210
jmp 0x7fda
cmpb $0x0, 0xa5f1(%rip)      # 0x12660
jne 0x8081
movq %r12, %rdi
callq 0x4e38
testb %al, %al
jne 0x7ff8
movq %r15, %rdi
movq %r12, %rsi
callq 0x4dcc
movq %r13, %rdi
movq %r15, %rsi
callq 0xad9e
movq %r15, %rdi
callq 0x594c
xorl %ebx, %ebx
movq %rbp, %rdi
movq %r13, %rsi
callq 0x6366
movq %rbp, %rdi
callq 0x62d0
incl %ebx
testb %al, %al
je 0x80a1
movl 0xc(%rsp), %edi
movq %r14, %rsi
movq %r13, %rdx
movl %ebx, %ecx
callq 0x834c
cmpb $0x1, 0xa58f(%rip)      # 0x12661
jne 0x7ff8
cmpq $0x0, 0xa568(%rip)      # 0x12648
jne 0x7ff8
leaq 0x70(%rsp), %rdi
callq 0x6230
leaq 0x10(%rsp), %rdi
callq 0x594c
leaq 0x30(%rsp), %rdi
callq 0x5918
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x8121
movq %rax, %rbx
jmp 0x812e
jmp 0x8121
jmp 0x8121
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x6230
leaq 0x10(%rsp), %rdi
callq 0x594c
leaq 0x30(%rsp), %rdi
callq 0x5918
movq %rbx, %rdi
callq 0x4490