#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*/ rotate_layer(size_t, unsigned int **, size_t, size_t);
void rotate_image(size_t N, unsigned matrix[N][N]) {
  unsigned layers = N / 2;
  size_t l;
  for (l = 0; l < layers; l++) {
    rotate_layer(N, matrix, l, N - 2 * l);
  }
}


x86 assembly (clang, -O0):
<rotate_image>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
shr    $0x1,%rax
mov    %eax,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x14(%rbp),%ecx
cmp    %rcx,%rax
jae    1174 <rotate_image+0x64>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x8(%rbp),%rcx
mov    -0x20(%rbp),%rax
shl    $0x1,%rax
sub    %rax,%rcx
call   1030 <rotate_layer@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1133 <rotate_image+0x23>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rotate_image>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%rax
shr    %rax
mov    $0xffffffff,%r13d
and    %rax,%r13
je     115e <rotate_image+0x4e>
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
mov    %rdi,%r12
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
call   1030 <rotate_layer@plt>
add    $0x1,%rbx
add    $0xfffffffffffffffe,%r12
cmp    %rbx,%r13
jne    1140 <rotate_image+0x30>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @rotate_image(i64 %0, i32* %1) {
%3 = alloca i64
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i64
store i64 %0, i64* %3
store i32* %1, i32** %4
%7 = load i64, i64* %3
%8 = load i64, i64* %3
%9 = load i64, i64* %3
%10 = udiv i64 %9, 2
%11 = trunc i64 %10 to i32
store i32 %11, i32* %5
store i64 0, i64* %6
br label %12
12: ; preds = %27, %2
%13 = load i64, i64* %6
%14 = load i32, i32* %5
%15 = zext i32 %14 to i64
%16 = icmp ult i64 %13, %15
br i1 %16, label %17, label %30
17: ; preds = %12
%18 = load i64, i64* %3
%19 = load i32*, i32** %4
%20 = bitcast i32* %19 to i32**
%21 = load i64, i64* %6
%22 = load i64, i64* %3
%23 = load i64, i64* %6
%24 = mul i64 2, %23
%25 = sub i64 %22, %24
%26 = call i32 @rotate_layer(i64 %18, i32** %20, i64 %21, i64 %25)
br label %27
27: ; preds = %17
%28 = load i64, i64* %6
%29 = add i64 %28, 1
store i64 %29, i64* %6
br label %12
30: ; preds = %12
ret void
}

LLVM IR (-O2):
define void @rotate_image(i64 %0, i32* %1) {
%3 = lshr i64 %0, 1
%4 = and i64 %3, 4294967295
%5 = icmp eq i64 %4, 0
br i1 %5, label %15, label %6
6: ; preds = %2
%7 = bitcast i32* %1 to i32**
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %13, %8 ]
%10 = mul nsw i64 %9, -2
%11 = add i64 %10, %0
%12 = tail call i32 @rotate_layer(i64 %0, i32** %7, i64 %9, i64 %11)
%13 = add nuw nsw i64 %9, 1
%14 = icmp eq i64 %13, %4
br i1 %14, label %15, label %8
15: ; preds = %8, %2
ret void
}