// File: chuckwolber[P]Cube/test/test_algorithm.cpp
// Function: test_hidden_inversions()
void test_hidden_inversions() {
    std::cout << "Testing hidden inversions... ";

    Algorithm alg_1;
    alg_1.addTurn({Layer::R, true});
    alg_1.addTurn({Layer::F, true});
    alg_1.addTurn({Layer::R, false});
    assert(!alg_1.hasHiddenInversion());

    Algorithm alg_2;
    alg_2.addTurn({Layer::R, true});
    alg_2.addTurn({Layer::L, true});
    alg_2.addTurn({Layer::R, false});
    assert(alg_2.hasHiddenInversion());

    Algorithm alg_3;
    alg_3.addTurn({Layer::R, true});
    alg_3.addTurn({Layer::L, true});
    alg_3.addTurn({Layer::L, true});
    alg_3.addTurn({Layer::R, false});
    assert(alg_3.hasHiddenInversion());

    Algorithm alg_4;
    alg_4.addTurn({Layer::R, true});
    alg_4.addTurn({Layer::F, true});
    alg_4.addTurn({Layer::R, false});
    alg_4.addTurn({Layer::R, true});
    alg_4.addTurn({Layer::L, true});
    alg_4.addTurn({Layer::L, true});
    alg_4.addTurn({Layer::R, false});
    alg_4.addTurn({Layer::R, true});
    alg_4.addTurn({Layer::F, true});
    alg_4.addTurn({Layer::R, false});
    assert(alg_4.hasHiddenInversion());

    Algorithm alg_5;
    alg_5.addTurn({Layer::R, true});
    alg_5.addTurn({Layer::F, true});
    alg_5.addTurn({Layer::R, false});
    alg_5.addTurn({Layer::R, true});
    alg_5.addTurn({Layer::L, true});
    alg_5.addTurn({Layer::L, false});
    alg_5.addTurn({Layer::R, false});
    alg_5.addTurn({Layer::R, true});
    alg_5.addTurn({Layer::F, true});
    alg_5.addTurn({Layer::R, false});
    assert(alg_5.hasHiddenInversion());

    std::cout << "Passed" << std::endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1e0, %rsp            # imm = 0x1E0
movq 0x9ce6(%rip), %rdi      # 0x15fd8
leaq 0x428c(%rip), %rsi      # 0x10585
callq 0x2190
leaq -0x28(%rbp), %rdi
movq %rdi, -0x1d0(%rbp)
callq 0x2420
movq -0x1d0(%rbp), %rdi
movl $0x6, -0x30(%rbp)
movb $0x1, -0x2c(%rbp)
movq -0x30(%rbp), %rsi
callq 0x2490
jmp 0xc32b
movl $0x5, -0x44(%rbp)
movb $0x1, -0x40(%rbp)
movq -0x44(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x2490
jmp 0xc345
movl $0x6, -0x4c(%rbp)
movb $0x0, -0x48(%rbp)
movq -0x4c(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x2490
jmp 0xc35f
leaq -0x28(%rbp), %rdi
callq 0x3660
movb %al, -0x1d1(%rbp)
jmp 0xc370
movb -0x1d1(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0xc37e
jmp 0xc380
jmp 0xc3b0
leaq 0x421c(%rip), %rdi      # 0x105a3
leaq 0x3f4b(%rip), %rsi      # 0x102d9
movl $0x125, %edx            # imm = 0x125
leaq 0x4225(%rip), %rcx      # 0x105bf
callq 0x2100
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xc9b4
leaq -0x78(%rbp), %rdi
callq 0x2420
jmp 0xc3bb
movl $0x6, -0x80(%rbp)
movb $0x1, -0x7c(%rbp)
movq -0x80(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x2490
jmp 0xc3d5
movl $0x4, -0x88(%rbp)
movb $0x1, -0x84(%rbp)
movq -0x88(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x2490
jmp 0xc3f8
movl $0x6, -0x90(%rbp)
movb $0x0, -0x8c(%rbp)
movq -0x90(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x2490
jmp 0xc41b
leaq -0x78(%rbp), %rdi
callq 0x3660
movb %al, -0x1d2(%rbp)
jmp 0xc42c
movb -0x1d2(%rbp), %al
testb $0x1, %al
jne 0xc438
jmp 0xc43a
jmp 0xc46a
leaq 0x419c(%rip), %rdi      # 0x105dd
leaq 0x3e91(%rip), %rsi      # 0x102d9
movl $0x12b, %edx            # imm = 0x12B
leaq 0x416b(%rip), %rcx      # 0x105bf
callq 0x2100
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xc9ab
leaq -0xb8(%rbp), %rdi
callq 0x2420
jmp 0xc478
movl $0x6, -0xc0(%rbp)
movb $0x1, -0xbc(%rbp)
movq -0xc0(%rbp), %rsi
leaq -0xb8(%rbp), %rdi
callq 0x2490
jmp 0xc49e
movl $0x4, -0xc8(%rbp)
movb $0x1, -0xc4(%rbp)
movq -0xc8(%rbp), %rsi
leaq -0xb8(%rbp), %rdi
callq 0x2490
jmp 0xc4c4
movl $0x4, -0xd0(%rbp)
movb $0x1, -0xcc(%rbp)
movq -0xd0(%rbp), %rsi
leaq -0xb8(%rbp), %rdi
callq 0x2490
jmp 0xc4ea
movl $0x6, -0xd8(%rbp)
movb $0x0, -0xd4(%rbp)
movq -0xd8(%rbp), %rsi
leaq -0xb8(%rbp), %rdi
callq 0x2490
jmp 0xc510
leaq -0xb8(%rbp), %rdi
callq 0x3660
movb %al, -0x1d3(%rbp)
jmp 0xc524
movb -0x1d3(%rbp), %al
testb $0x1, %al
jne 0xc530
jmp 0xc532
jmp 0xc562
leaq 0x40bf(%rip), %rdi      # 0x105f8
leaq 0x3d99(%rip), %rsi      # 0x102d9
movl $0x132, %edx            # imm = 0x132
leaq 0x4073(%rip), %rcx      # 0x105bf
callq 0x2100
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xc99f
leaq -0x100(%rbp), %rdi
callq 0x2420
jmp 0xc570
movl $0x6, -0x108(%rbp)
movb $0x1, -0x104(%rbp)
movq -0x108(%rbp), %rsi
leaq -0x100(%rbp), %rdi
callq 0x2490
jmp 0xc596
movl $0x5, -0x110(%rbp)
movb $0x1, -0x10c(%rbp)
movq -0x110(%rbp), %rsi
leaq -0x100(%rbp), %rdi
callq 0x2490
jmp 0xc5bc
movl $0x6, -0x118(%rbp)
movb $0x0, -0x114(%rbp)
movq -0x118(%rbp), %rsi
leaq -0x100(%rbp), %rdi
callq 0x2490
jmp 0xc5e2
movl $0x6, -0x120(%rbp)
movb $0x1, -0x11c(%rbp)
movq -0x120(%rbp), %rsi
leaq -0x100(%rbp), %rdi
callq 0x2490
jmp 0xc608
movl $0x4, -0x128(%rbp)
movb $0x1, -0x124(%rbp)
movq -0x128(%rbp), %rsi
leaq -0x100(%rbp), %rdi
callq 0x2490
jmp 0xc62e
movl $0x4, -0x130(%rbp)
movb $0x1, -0x12c(%rbp)
movq -0x130(%rbp), %rsi
leaq -0x100(%rbp), %rdi
callq 0x2490
jmp 0xc654
movl $0x6, -0x138(%rbp)
movb $0x0, -0x134(%rbp)
movq -0x138(%rbp), %rsi
leaq -0x100(%rbp), %rdi
callq 0x2490
jmp 0xc67a
movl $0x6, -0x140(%rbp)
movb $0x1, -0x13c(%rbp)
movq -0x140(%rbp), %rsi
leaq -0x100(%rbp), %rdi
callq 0x2490
jmp 0xc6a0
movl $0x5, -0x148(%rbp)
movb $0x1, -0x144(%rbp)
movq -0x148(%rbp), %rsi
leaq -0x100(%rbp), %rdi
callq 0x2490
jmp 0xc6c6
movl $0x6, -0x150(%rbp)
movb $0x0, -0x14c(%rbp)
movq -0x150(%rbp), %rsi
leaq -0x100(%rbp), %rdi
callq 0x2490
jmp 0xc6ec
leaq -0x100(%rbp), %rdi
callq 0x3660
movb %al, -0x1d4(%rbp)
jmp 0xc700
movb -0x1d4(%rbp), %al
testb $0x1, %al
jne 0xc70c
jmp 0xc70e
jmp 0xc73e
leaq 0x3efe(%rip), %rdi      # 0x10613
leaq 0x3bbd(%rip), %rsi      # 0x102d9
movl $0x13f, %edx            # imm = 0x13F
leaq 0x3e97(%rip), %rcx      # 0x105bf
callq 0x2100
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xc993
leaq -0x178(%rbp), %rdi
callq 0x2420
jmp 0xc74c
movl $0x6, -0x180(%rbp)
movb $0x1, -0x17c(%rbp)
movq -0x180(%rbp), %rsi
leaq -0x178(%rbp), %rdi
callq 0x2490
jmp 0xc772
movl $0x5, -0x188(%rbp)
movb $0x1, -0x184(%rbp)
movq -0x188(%rbp), %rsi
leaq -0x178(%rbp), %rdi
callq 0x2490
jmp 0xc798
movl $0x6, -0x190(%rbp)
movb $0x0, -0x18c(%rbp)
movq -0x190(%rbp), %rsi
leaq -0x178(%rbp), %rdi
callq 0x2490
jmp 0xc7be
movl $0x6, -0x198(%rbp)
movb $0x1, -0x194(%rbp)
movq -0x198(%rbp), %rsi
leaq -0x178(%rbp), %rdi
callq 0x2490
jmp 0xc7e4
movl $0x4, -0x1a0(%rbp)
movb $0x1, -0x19c(%rbp)
movq -0x1a0(%rbp), %rsi
leaq -0x178(%rbp), %rdi
callq 0x2490
jmp 0xc80a
movl $0x4, -0x1a8(%rbp)
movb $0x0, -0x1a4(%rbp)
movq -0x1a8(%rbp), %rsi
leaq -0x178(%rbp), %rdi
callq 0x2490
jmp 0xc830
movl $0x6, -0x1b0(%rbp)
movb $0x0, -0x1ac(%rbp)
movq -0x1b0(%rbp), %rsi
leaq -0x178(%rbp), %rdi
callq 0x2490
jmp 0xc856
movl $0x6, -0x1b8(%rbp)
movb $0x1, -0x1b4(%rbp)
movq -0x1b8(%rbp), %rsi
leaq -0x178(%rbp), %rdi
callq 0x2490
jmp 0xc87c
movl $0x5, -0x1c0(%rbp)
movb $0x1, -0x1bc(%rbp)
movq -0x1c0(%rbp), %rsi
leaq -0x178(%rbp), %rdi
callq 0x2490
jmp 0xc8a2
movl $0x6, -0x1c8(%rbp)
movb $0x0, -0x1c4(%rbp)
movq -0x1c8(%rbp), %rsi
leaq -0x178(%rbp), %rdi
callq 0x2490
jmp 0xc8c8
leaq -0x178(%rbp), %rdi
callq 0x3660
movb %al, -0x1d5(%rbp)
jmp 0xc8dc
movb -0x1d5(%rbp), %al
testb $0x1, %al
jne 0xc8e8
jmp 0xc8ea
jmp 0xc923
leaq 0x3d3d(%rip), %rdi      # 0x1062e
leaq 0x39e1(%rip), %rsi      # 0x102d9
movl $0x14c, %edx            # imm = 0x14C
leaq 0x3cbb(%rip), %rcx      # 0x105bf
callq 0x2100
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x178(%rbp), %rdi
callq 0x4bd0
jmp 0xc993
movq 0x96ae(%rip), %rdi      # 0x15fd8
leaq 0x3a85(%rip), %rsi      # 0x103b6
callq 0x2190
movq %rax, -0x1e0(%rbp)
jmp 0xc93f
movq -0x1e0(%rbp), %rdi
movq 0x967b(%rip), %rsi      # 0x15fc8
callq 0x21c0
jmp 0xc954
leaq -0x178(%rbp), %rdi
callq 0x4bd0
leaq -0x100(%rbp), %rdi
callq 0x4bd0
leaq -0xb8(%rbp), %rdi
callq 0x4bd0
leaq -0x78(%rbp), %rdi
callq 0x4bd0
leaq -0x28(%rbp), %rdi
callq 0x4bd0
addq $0x1e0, %rsp            # imm = 0x1E0
popq %rbp
retq
leaq -0x100(%rbp), %rdi
callq 0x4bd0
leaq -0xb8(%rbp), %rdi
callq 0x4bd0
leaq -0x78(%rbp), %rdi
callq 0x4bd0
leaq -0x28(%rbp), %rdi
callq 0x4bd0
movq -0x38(%rbp), %rdi
callq 0x22a0
nopw %cs:(%rax,%rax)