// File: /workspace/github_cpp_makefile_star2_O2/chuckwolber[P]Cube/test/../Cube.cpp
// Function: Cube::rotateLayer(Layer, bool)
void Cube::rotateLayer(Layer layer, bool clockwise) {
    unsigned int subCubeSize, subLayerMax;
    unsigned int ulr, ulc, urr, urc, llr, llc, lrr, lrc;

    /**
     * We have to set this to a throw-away value because -Ofast optimization
     * causes an unassigned variable to emit -Werror=maybe-uninitialized. This
     * warning cannot be squelched when using LLVM because of LLVM bug
     * https://bugs.llvm.org/show_bug.cgi?id=24979
     */
    Coordinate ul = {Layer::U, true};
   
    getLayerUpperLeft(ul, layer);
    subLayerMax = (unsigned int)ceil((float)cubeSize/2);
   
    for (unsigned int subLayer=0; subLayer<subLayerMax; subLayer++) {
        subCubeSize = cubeSize - 2*subLayer;
      
        ulr = ul.row + subLayer;
        urc = ul.col + subLayer + subCubeSize - 1;
        llc = ul.col + subLayer;
        lrr = ul.row + subLayer + subCubeSize - 1;
      
        for (unsigned int i=0; i<(subCubeSize - 1); i++) {
            ulc = ul.col + subLayer + i;
            urr = ul.row + subLayer + i;
            llr = ul.row + subLayer + subCubeSize - 1 - i;
            lrc = ul.col + subLayer + subCubeSize - 1 - i;
         
            fourWayRotate({{ulr, ulc},  // Upper Left
                           {urr, urc},  // Upper Right
                           {lrr, lrc},  // Lower Right
                           {llr, llc}}, // Lower Left
                            clockwise);
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movl %edx, %ebp
movl %esi, %edx
movq %rdi, %rbx
movabsq $0x100000001, %rax      # imm = 0x100000001
leaq 0xa0(%rsp), %r14
movq %rax, (%r14)
movq %r14, %rsi
callq 0x4326
movq %rbx, 0x50(%rsp)
movl 0x8(%rbx), %eax
cvtsi2ss %rax, %xmm0
mulss 0x514a(%rip), %xmm0     # 0x9250
callq 0x20d0
cvttss2si %xmm0, %rax
movq %rax, 0x88(%rsp)
movl (%r14), %eax
movl 0x4(%r14), %ecx
xorl %edx, %edx
pushq $-0x1
popq %rsi
movq %rsi, 0x38(%rsp)
movzbl %bpl, %esi
movl %esi, 0x4c(%rsp)
movl %eax, %r14d
movl %ecx, %ebx
movq %rax, 0x80(%rsp)
movq %rax, 0x30(%rsp)
movq %rcx, 0x78(%rsp)
movq %rcx, 0x28(%rsp)
cmpl 0x88(%rsp), %edx
je 0x425f
movq 0x50(%rsp), %rax
movl 0x8(%rax), %r13d
movl %r13d, %ecx
subl %edx, %ecx
subl %edx, %ecx
movq 0x80(%rsp), %rax
leal (%rax,%rdx), %esi
movq 0x78(%rsp), %rax
movq %rdx, 0x90(%rsp)
addl %edx, %eax
movq %rax, 0x98(%rsp)
leal (%rax,%rcx), %r15d
decl %r15d
movq %rsi, %rbp
leal (%rsi,%rcx), %r12d
decl %r12d
decl %r13d
movl %r14d, 0x48(%rsp)
movl %ebx, 0x44(%rsp)
movq 0x38(%rsp), %rax
addl %r13d, %eax
cmpl $-0x1, %eax
je 0x421d
movq 0x30(%rsp), %rax
addl %r13d, %eax
movq 0x28(%rsp), %rcx
leal (%rcx,%r13), %ecx
movl %ebp, 0x58(%rsp)
movl %ebx, 0x5c(%rsp)
movl %r14d, 0x60(%rsp)
movl %r15d, 0x64(%rsp)
movl %r12d, 0x68(%rsp)
movl %ecx, 0x6c(%rsp)
movl %eax, 0x70(%rsp)
movq 0x98(%rsp), %rax
movl %eax, 0x74(%rsp)
movups 0x58(%rsp), %xmm0
movups 0x68(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq 0x50(%rsp), %rdi
movl 0x4c(%rsp), %esi
callq 0x4362
decl %r13d
incl %ebx
incl %r14d
jmp 0x41a9
movq 0x90(%rsp), %rdx
incl %edx
movq 0x38(%rsp), %rax
addl $-0x2, %eax
movq %rax, 0x38(%rsp)
movq 0x28(%rsp), %rax
decl %eax
movq %rax, 0x28(%rsp)
movq 0x30(%rsp), %rax
decl %eax
movq %rax, 0x30(%rsp)
movl 0x44(%rsp), %ebx
incl %ebx
movl 0x48(%rsp), %r14d
incl %r14d
jmp 0x414d
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop