// File: /workspace/github_cpp_makefile_star2_O1/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 $0x58, %rsp
movl %edx, %ebx
movq %rdi, %r15
leal -0xa(%rsi), %eax
movl $0x1, %ecx
movq %rcx, 0x18(%rsp)
movl $0x1, %ecx
movq %rcx, 0x20(%rsp)
cmpl $0x4, %eax
jb 0x41e0
movl 0x8(%r15), %edi
movl 0x2c(%r15), %ecx
movq $0x0, 0x18(%rsp)
movl %esi, %eax
xorl %edx, %edx
divl %ecx
imull %edi, %edx
movq %rdx, 0x20(%rsp)
cmpl %esi, %ecx
ja 0x41e0
addl %ecx, %ecx
cmpl %esi, %ecx
setbe %cl
shll %cl, %edi
movl %edi, %eax
movq %rax, 0x18(%rsp)
movl 0x8(%r15), %eax
movq %rax, 0x28(%rsp)
cvtsi2ss %rax, %xmm0
mulss 0x60ea(%rip), %xmm0     # 0xa2e0
callq 0x2080
cvttss2si %xmm0, %rcx
testl %ecx, %ecx
je 0x433d
movq 0x10(%r15), %rax
movq 0x28(%rsp), %rsi
leal -0x1(%rsi), %edx
movl %edx, 0x14(%rsp)
movl %ecx, %ecx
movq %rcx, 0x38(%rsp)
movq 0x20(%rsp), %rcx
leal (%rsi,%rcx), %r11d
decl %r11d
movq 0x18(%rsp), %rdx
leal (%rsi,%rdx), %r15d
decl %r15d
xorl %r8d, %r8d
movl %ecx, 0x10(%rsp)
movl %edx, 0xc(%rsp)
movq %r8, 0x30(%rsp)
movq 0x28(%rsp), %rdx
subl %r8d, %edx
subl %r8d, %edx
cmpl $0x1, %edx
je 0x4317
movl 0x14(%rsp), %ecx
negq %rcx
movq %rcx, 0x50(%rsp)
movq 0x18(%rsp), %rcx
movq 0x30(%rsp), %r8
leal (%rcx,%r8), %r9d
movq 0x20(%rsp), %rcx
leal (%rcx,%r8), %r10d
leal (%rdx,%r10), %ecx
addl %r9d, %edx
decl %edx
decl %ecx
movq %rcx, 0x48(%rsp)
testb %bl, %bl
movl %r9d, %r14d
cmovnel %edx, %r14d
movl %r10d, %ecx
movq %rcx, 0x40(%rsp)
cmovnel %r9d, %edx
movq (%rax,%r14,8), %r12
movq (%rax,%rdx,8), %r14
xorl %edx, %edx
movl 0x10(%rsp), %r9d
movl 0xc(%rsp), %r10d
leal (%r15,%rdx), %r13d
leal (%r11,%rdx), %ecx
movq (%rax,%r13,8), %r13
testb %bl, %bl
movl %r9d, %r8d
cmovnel %ecx, %r8d
movl %ebx, %edi
movq 0x40(%rsp), %rbp
movb (%r13,%rbp), %bl
movb (%r12,%r8), %sil
movb %sil, (%r13,%rbp)
movl %r10d, %esi
cmovnel %r9d, %ecx
movq (%rax,%rsi,8), %rsi
movq 0x48(%rsp), %rbp
movb (%rsi,%rbp), %r13b
movb %r13b, (%r12,%r8)
movb (%r14,%rcx), %r8b
movb %r8b, (%rsi,%rbp)
movb %bl, (%r14,%rcx)
movl %edi, %ebx
incl %r10d
incl %r9d
decq %rdx
cmpq %rdx, 0x50(%rsp)
jne 0x42b7
movq 0x30(%rsp), %r8
incq %r8
addl $-0x2, 0x14(%rsp)
incl 0xc(%rsp)
incl 0x10(%rsp)
decq %r11
decq %r15
cmpq 0x38(%rsp), %r8
jne 0x4242
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq