#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ rotate_left(int, int **, int **);
int /*<<< orphan*/ rotate_right(int, int **);
int /*<<< orphan*/ show_array(int, int **);
int main() {
  printf("original\n");
  int arr[4][4] = {
      {0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11}, {12, 13, 14, 15}};
  int rot[4][4];
  show_array(4, arr);
  rotate_left(4, arr, rot);
  show_array(4, rot);
  printf("rotate right\n");
  rotate_right(4, arr);
  show_array(4, arr);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe97(%rip),%rdi
call   1030 <printf@plt>
lea    -0x50(%rbp),%rdi
lea    0xea7(%rip),%rsi
mov    $0x40,%edx
call   1040 <memcpy@plt>
lea    -0x50(%rbp),%rsi
mov    $0x4,%edi
call   1050 <show_array@plt>
lea    -0x50(%rbp),%rsi
lea    -0x90(%rbp),%rdx
mov    $0x4,%edi
call   1060 <rotate_left@plt>
lea    -0x90(%rbp),%rsi
mov    $0x4,%edi
call   1050 <show_array@plt>
lea    0xe4c(%rip),%rdi
call   1030 <printf@plt>
lea    -0x50(%rbp),%rsi
mov    $0x4,%edi
call   1070 <rotate_right@plt>
lea    -0x50(%rbp),%rsi
mov    $0x4,%edi
call   1050 <show_array@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x88,%rsp
lea    0xeef(%rip),%rdi
call   1030 <puts@plt>
movaps 0xed3(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xeb7(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe9b(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe7f(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rbx
mov    $0x4,%edi
mov    %rbx,%rsi
call   1040 <show_array@plt>
lea    0x40(%rsp),%r14
mov    $0x4,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <rotate_left@plt>
mov    $0x4,%edi
mov    %r14,%rsi
call   1040 <show_array@plt>
lea    0xe8b(%rip),%rdi
call   1030 <puts@plt>
mov    $0x4,%edi
mov    %rbx,%rsi
call   1060 <rotate_right@plt>
mov    $0x4,%edi
mov    %rbx,%rsi
call   1040 <show_array@plt>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [10 x i8] c"original\0A\00"
@__const.main.arr = [4 x [4 x i32]] [[4 x i32] [i32 0, i32 1, i32 2, i32 3], [4 x i32] [i32 4, i32 5, i32 6, i32 7], [4 x i32] [i32 8, i32 9, i32 10, i32 11], [4 x i32] [i32 12, i32 13, i32 14, i32 15]]
@.str.1 = [14 x i8] c"rotate right\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x [4 x i32]]
%3 = alloca [4 x [4 x i32]]
store i32 0, i32* %1
%4 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%5 = bitcast [4 x [4 x i32]]* %2 to i8*
%6 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %2, i64 0, i64 0
%7 = bitcast [4 x i32]* %6 to i32**
%8 = call i32 @show_array(i32 4, i32** %7)
%9 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %2, i64 0, i64 0
%10 = bitcast [4 x i32]* %9 to i32**
%11 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %3, i64 0, i64 0
%12 = bitcast [4 x i32]* %11 to i32**
%13 = call i32 @rotate_left(i32 4, i32** %10, i32** %12)
%14 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %3, i64 0, i64 0
%15 = bitcast [4 x i32]* %14 to i32**
%16 = call i32 @show_array(i32 4, i32** %15)
%17 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%18 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %2, i64 0, i64 0
%19 = bitcast [4 x i32]* %18 to i32**
%20 = call i32 @rotate_right(i32 4, i32** %19)
%21 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %2, i64 0, i64 0
%22 = bitcast [4 x i32]* %21 to i32**
%23 = call i32 @show_array(i32 4, i32** %22)
ret i32 0
}

LLVM IR (-O2):
@__const.main.arr = [4 x [4 x i32]] [[4 x i32] [i32 0, i32 1, i32 2, i32 3], [4 x i32] [i32 4, i32 5, i32 6, i32 7], [4 x i32] [i32 8, i32 9, i32 10, i32 11], [4 x i32] [i32 12, i32 13, i32 14, i32 15]]
@str = [9 x i8] c"original\00"
@str.2 = [13 x i8] c"rotate right\00"
define i32 @main() {
%1 = alloca [4 x [4 x i32]]
%2 = alloca [4 x [4 x i32]]
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%4 = bitcast [4 x [4 x i32]]* %1 to i8*
%5 = bitcast [4 x [4 x i32]]* %2 to i8*
%6 = bitcast [4 x [4 x i32]]* %1 to i32**
%7 = call i32 @show_array(i32 4, i32** %6)
%8 = bitcast [4 x [4 x i32]]* %2 to i32**
%9 = call i32 @rotate_left(i32 4, i32** %6, i32** %8)
%10 = call i32 @show_array(i32 4, i32** %8)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.2, i64 0, i64 0))
%12 = call i32 @rotate_right(i32 4, i32** %6)
%13 = call i32 @show_array(i32 4, i32** %6)
ret i32 0
}