// File: chuckwolber[P]Cube/test/../Algorithm.cpp
// Function: Algorithm::hasHiddenInversion()
bool Algorithm::hasHiddenInversion() {
    if (algorithm.size() < 3)
        return false;

    /* X (Y | Y') X' */
    for (unsigned int i = 0; i < algorithm.size() - 2; i++) {
        unsigned int o1 = getOppositeFace(algorithm.at(i));
        unsigned int o2 = o1 + 1;

        if (algorithm.at(i+1) != o1 && algorithm.at(i+1) != o2)
            continue;

        if (algorithm.at(i) % 2 == 0 &&
            algorithm.at(i) == algorithm.at(i+2) - 1)
            return true;

        if (algorithm.at(i) % 2 == 1 &&
            algorithm.at(i) == algorithm.at(i+2) + 1)
            return true;
    }

    if (algorithm.size() < 4)
        return false;
    
    /* X (Y | Y') (Y | Y') X' */
    for (unsigned int i = 0; i < algorithm.size() - 3; i++) {
        unsigned int o1 = getOppositeFace(algorithm.at(i));
        unsigned int o2 = o1 + 1;

        if ((algorithm.at(i+1) != o1 && algorithm.at(i+1) != o2) ||
            (algorithm.at(i+2) != o1 && algorithm.at(i+2) != o2))
            continue;
        
        if (algorithm.at(i) % 2 == 0 &&
            algorithm.at(i) == algorithm.at(i+3) - 1)
            return true;

        if (algorithm.at(i) % 2 == 1 &&
            algorithm.at(i) == algorithm.at(i+3) + 1)
            return true;
    }

    return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x30(%rbp)
callq 0x4ca0
cmpq $0x3, %rax
jae 0x3688
movb $0x0, -0x1(%rbp)
jmp 0x399a
movl $0x0, -0x14(%rbp)
movq -0x30(%rbp), %rdi
movl -0x14(%rbp), %eax
movq %rax, -0x38(%rbp)
callq 0x4ca0
movq %rax, %rcx
movq -0x38(%rbp), %rax
subq $0x2, %rcx
cmpq %rcx, %rax
jae 0x37e8
movq -0x30(%rbp), %rdi
movl -0x14(%rbp), %eax
movl %eax, %esi
callq 0x4cc0
movq -0x30(%rbp), %rdi
movq (%rax), %rsi
callq 0x4740
movq -0x30(%rbp), %rdi
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
callq 0x4cc0
movq (%rax), %rax
movl -0x18(%rbp), %ecx
cmpq %rcx, %rax
je 0x371a
movq -0x30(%rbp), %rdi
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
callq 0x4cc0
movq (%rax), %rax
movl -0x1c(%rbp), %ecx
cmpq %rcx, %rax
je 0x371a
jmp 0x37da
movq -0x30(%rbp), %rdi
movl -0x14(%rbp), %eax
movl %eax, %esi
callq 0x4cc0
movq (%rax), %rax
andq $0x1, %rax
cmpq $0x0, %rax
jne 0x3779
movq -0x30(%rbp), %rdi
movl -0x14(%rbp), %eax
movl %eax, %esi
callq 0x4cc0
movq -0x30(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movl -0x14(%rbp), %eax
addl $0x2, %eax
movl %eax, %eax
movl %eax, %esi
callq 0x4cc0
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq (%rcx), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jne 0x3779
movb $0x1, -0x1(%rbp)
jmp 0x399a
movq -0x30(%rbp), %rdi
movl -0x14(%rbp), %eax
movl %eax, %esi
callq 0x4cc0
movq (%rax), %rax
andq $0x1, %rax
cmpq $0x1, %rax
jne 0x37d8
movq -0x30(%rbp), %rdi
movl -0x14(%rbp), %eax
movl %eax, %esi
callq 0x4cc0
movq -0x30(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movl -0x14(%rbp), %eax
addl $0x2, %eax
movl %eax, %eax
movl %eax, %esi
callq 0x4cc0
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq (%rcx), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
jne 0x37d8
movb $0x1, -0x1(%rbp)
jmp 0x399a
jmp 0x37da
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x368f
movq -0x30(%rbp), %rdi
callq 0x4ca0
cmpq $0x4, %rax
jae 0x3800
movb $0x0, -0x1(%rbp)
jmp 0x399a
movl $0x0, -0x20(%rbp)
movq -0x30(%rbp), %rdi
movl -0x20(%rbp), %eax
movq %rax, -0x50(%rbp)
callq 0x4ca0
movq %rax, %rcx
movq -0x50(%rbp), %rax
subq $0x3, %rcx
cmpq %rcx, %rax
jae 0x3996
movq -0x30(%rbp), %rdi
movl -0x20(%rbp), %eax
movl %eax, %esi
callq 0x4cc0
movq -0x30(%rbp), %rdi
movq (%rax), %rsi
callq 0x4740
movq -0x30(%rbp), %rdi
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
callq 0x4cc0
movq (%rax), %rax
movl -0x24(%rbp), %ecx
cmpq %rcx, %rax
je 0x388d
movq -0x30(%rbp), %rdi
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
callq 0x4cc0
movq (%rax), %rax
movl -0x28(%rbp), %ecx
cmpq %rcx, %rax
jne 0x38c9
movq -0x30(%rbp), %rdi
movl -0x20(%rbp), %eax
addl $0x2, %eax
movl %eax, %eax
movl %eax, %esi
callq 0x4cc0
movq (%rax), %rax
movl -0x24(%rbp), %ecx
cmpq %rcx, %rax
je 0x38ce
movq -0x30(%rbp), %rdi
movl -0x20(%rbp), %eax
addl $0x2, %eax
movl %eax, %eax
movl %eax, %esi
callq 0x4cc0
movq (%rax), %rax
movl -0x28(%rbp), %ecx
cmpq %rcx, %rax
je 0x38ce
jmp 0x3988
movq -0x30(%rbp), %rdi
movl -0x20(%rbp), %eax
movl %eax, %esi
callq 0x4cc0
movq (%rax), %rax
andq $0x1, %rax
cmpq $0x0, %rax
jne 0x392a
movq -0x30(%rbp), %rdi
movl -0x20(%rbp), %eax
movl %eax, %esi
callq 0x4cc0
movq -0x30(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movl -0x20(%rbp), %eax
addl $0x3, %eax
movl %eax, %eax
movl %eax, %esi
callq 0x4cc0
movq %rax, %rcx
movq -0x58(%rbp), %rax
movq (%rcx), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jne 0x392a
movb $0x1, -0x1(%rbp)
jmp 0x399a
movq -0x30(%rbp), %rdi
movl -0x20(%rbp), %eax
movl %eax, %esi
callq 0x4cc0
movq (%rax), %rax
andq $0x1, %rax
cmpq $0x1, %rax
jne 0x3986
movq -0x30(%rbp), %rdi
movl -0x20(%rbp), %eax
movl %eax, %esi
callq 0x4cc0
movq -0x30(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x60(%rbp)
movl -0x20(%rbp), %eax
addl $0x3, %eax
movl %eax, %eax
movl %eax, %esi
callq 0x4cc0
movq %rax, %rcx
movq -0x60(%rbp), %rax
movq (%rcx), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
jne 0x3986
movb $0x1, -0x1(%rbp)
jmp 0x399a
jmp 0x3988
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x3807
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)