// File: kmyk[P]codevs-for-student-2016/Main.cpp
// Function: primitive::rotate(primitive::blocks_t<3ul, 3ul>, int)
pack_t rotate(pack_t a, rotate_t r) {
        assert (pack_size == 3);
        pack_t b;
        switch (r % 4 + (r < 0 ? 4 : 0)) {
            case 0: b = a; break;
            case 1: repeat (x, pack_size) repeat (y, pack_size) b.at[x][y] = a.at[2-y][  x]; break;
            case 2: repeat (x, pack_size) repeat (y, pack_size) b.at[x][y] = a.at[2-x][2-y]; break;
            case 3: repeat (x, pack_size) repeat (y, pack_size) b.at[x][y] = a.at[  y][2-x]; break;
        }
        return b;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movb %sil, %al
movq %rdi, -0x28(%rbp)
movb %al, -0x20(%rbp)
movb -0x20(%rbp), %al
movb %al, -0x10(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x18(%rbp)
movl %edx, -0x2c(%rbp)
movl -0x2c(%rbp), %edx
movl %edx, %ecx
addl $0x3, %ecx
testl %edx, %edx
movl %edx, %eax
cmovsl %ecx, %eax
andl $-0x4, %eax
movl %edx, %ecx
subl %eax, %ecx
shrl $0x1f, %edx
movl %ecx, %eax
movl %edx, %ecx
leal (%rax,%rcx,4), %eax
movl %eax, %ecx
movq %rcx, -0x60(%rbp)
subl $0x3, %eax
ja 0x2c28
movq -0x60(%rbp), %rax
leaq 0x23573(%rip), %rcx     # 0x26010
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x18(%rbp), %rax
movq %rax, -0x9(%rbp)
movb -0x10(%rbp), %al
movb %al, -0x1(%rbp)
jmp 0x2c28
movl $0x0, -0x30(%rbp)
cmpl $0x3, -0x30(%rbp)
jge 0x2b2e
movl $0x0, -0x34(%rbp)
cmpl $0x3, -0x34(%rbp)
jge 0x2b21
leaq -0x18(%rbp), %rdi
movl $0x2, %eax
subl -0x34(%rbp), %eax
movslq %eax, %rsi
callq 0x6600
movq %rax, %rdi
movslq -0x30(%rbp), %rsi
callq 0x6630
movb (%rax), %al
movb %al, -0x61(%rbp)
leaq -0x9(%rbp), %rdi
movslq -0x30(%rbp), %rsi
callq 0x6600
movq %rax, %rdi
movslq -0x34(%rbp), %rsi
callq 0x6630
movb -0x61(%rbp), %cl
movb %cl, (%rax)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x2acd
jmp 0x2b23
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x2ac0
jmp 0x2c28
movl $0x0, -0x38(%rbp)
cmpl $0x3, -0x38(%rbp)
jge 0x2baf
movl $0x0, -0x3c(%rbp)
cmpl $0x3, -0x3c(%rbp)
jge 0x2ba2
leaq -0x18(%rbp), %rdi
movl $0x2, %eax
subl -0x38(%rbp), %eax
movslq %eax, %rsi
callq 0x6600
movq %rax, %rdi
movl $0x2, %eax
subl -0x3c(%rbp), %eax
movslq %eax, %rsi
callq 0x6630
movb (%rax), %al
movb %al, -0x62(%rbp)
leaq -0x9(%rbp), %rdi
movslq -0x38(%rbp), %rsi
callq 0x6600
movq %rax, %rdi
movslq -0x3c(%rbp), %rsi
callq 0x6630
movb -0x62(%rbp), %cl
movb %cl, (%rax)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x2b47
jmp 0x2ba4
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x2b3a
jmp 0x2c28
movl $0x0, -0x40(%rbp)
cmpl $0x3, -0x40(%rbp)
jge 0x2c26
movl $0x0, -0x44(%rbp)
cmpl $0x3, -0x44(%rbp)
jge 0x2c19
leaq -0x18(%rbp), %rdi
movslq -0x44(%rbp), %rsi
callq 0x6600
movq %rax, %rdi
movl $0x2, %eax
subl -0x40(%rbp), %eax
movslq %eax, %rsi
callq 0x6630
movb (%rax), %al
movb %al, -0x63(%rbp)
leaq -0x9(%rbp), %rdi
movslq -0x40(%rbp), %rsi
callq 0x6600
movq %rax, %rdi
movslq -0x44(%rbp), %rsi
callq 0x6630
movb -0x63(%rbp), %cl
movb %cl, (%rax)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x2bc5
jmp 0x2c1b
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x2bb8
jmp 0x2c28
movb -0x1(%rbp), %al
movb %al, -0x50(%rbp)
movq -0x9(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movb -0x50(%rbp), %dl
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)