#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*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ rotate(int **, int, int);
int main(int argc, char *argv[]) {
  int row1[2] = {1, 2};
  int row2[2] = {3, 4};
  int *image[2];
  image[0] = row1;
  image[1] = row2;
  int p[][2] = {{3, 1}, {4, 2}};
  rotate(image, 2, 2);
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < 2; ++j) {
      if (!(image[i][j] == p[i][j])) {
        printf("assert fail: %s\n", "test");
        exit(-1);
      };
    }
  }
  printf("everything is fine!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xeb3(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeb0(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    0xe9d(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe9a(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0x2,%edx
mov    %edx,%esi
call   1040 <rotate@plt>
movl   $0x0,-0x44(%rbp)
cmpl   $0x2,-0x44(%rbp)
jge    1225 <main+0xf5>
movl   $0x0,-0x48(%rbp)
cmpl   $0x2,-0x48(%rbp)
jge    1212 <main+0xe2>
movslq -0x44(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rax
movslq -0x48(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
movslq -0x44(%rbp),%rdx
lea    -0x40(%rbp),%rcx
shl    $0x3,%rdx
add    %rdx,%rcx
movslq -0x48(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
je     11ff <main+0xcf>
lea    0xe39(%rip),%rdi
lea    0xe43(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
jmp    1204 <main+0xd4>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    11aa <main+0x7a>
jmp    1217 <main+0xe7>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1199 <main+0x69>
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
movabs $0x200000001,%rax
mov    %rax,0x20(%rsp)
movabs $0x400000003,%rax
mov    %rax,0x18(%rsp)
lea    0x20(%rsp),%rax
mov    %rax,(%rsp)
lea    0x18(%rsp),%rax
mov    %rax,0x8(%rsp)
mov    %rsp,%rdi
mov    $0x2,%esi
mov    $0x2,%edx
call   1050 <rotate@plt>
mov    (%rsp),%rax
cmpl   $0x3,(%rax)
jne    11b9 <main+0x79>
cmpl   $0x1,0x4(%rax)
jne    11b9 <main+0x79>
mov    0x8(%rsp),%rax
cmpl   $0x4,(%rax)
jne    11b9 <main+0x79>
cmpl   $0x2,0x4(%rax)
jne    11b9 <main+0x79>
lea    0xe69(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret
lea    0xe40(%rip),%rdi
lea    0xe4a(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@__const.main.row1 = [2 x i32] [i32 1, i32 2]
@__const.main.row2 = [2 x i32] [i32 3, i32 4]
@__const.main.p = [2 x [2 x i32]] [[2 x i32] [i32 3, i32 1], [2 x i32] [i32 4, i32 2]]
@.str = [17 x i8] c"assert fail: %s\0A\00"
@.str.1 = [5 x i8] c"test\00"
@.str.2 = [21 x i8] c"everything is fine!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [2 x i32]
%7 = alloca [2 x i32]
%8 = alloca [2 x i32*]
%9 = alloca [2 x [2 x i32]]
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = bitcast [2 x i32]* %6 to i8*
%13 = bitcast [2 x i32]* %7 to i8*
%14 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%15 = getelementptr inbounds [2 x i32*], [2 x i32*]* %8, i64 0, i64 0
store i32* %14, i32** %15
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%17 = getelementptr inbounds [2 x i32*], [2 x i32*]* %8, i64 0, i64 1
store i32* %16, i32** %17
%18 = bitcast [2 x [2 x i32]]* %9 to i8*
%19 = getelementptr inbounds [2 x i32*], [2 x i32*]* %8, i64 0, i64 0
%20 = call i32 @rotate(i32** %19, i32 2, i32 2)
store i32 0, i32* %10
br label %21
21: ; preds = %53, %2
%22 = load i32, i32* %10
%23 = icmp slt i32 %22, 2
br i1 %23, label %24, label %56
24: ; preds = %21
store i32 0, i32* %11
br label %25
25: ; preds = %49, %24
%26 = load i32, i32* %11
%27 = icmp slt i32 %26, 2
br i1 %27, label %28, label %52
28: ; preds = %25
%29 = load i32, i32* %10
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [2 x i32*], [2 x i32*]* %8, i64 0, i64 %30
%32 = load i32*, i32** %31
%33 = load i32, i32* %11
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %32, i64 %34
%36 = load i32, i32* %35
%37 = load i32, i32* %10
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %9, i64 0, i64 %38
%40 = load i32, i32* %11
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [2 x i32], [2 x i32]* %39, i64 0, i64 %41
%43 = load i32, i32* %42
%44 = icmp eq i32 %36, %43
br i1 %44, label %48, label %45
45: ; preds = %28
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%47 = call i32 @exit(i32 -1)
unreachable
48: ; preds = %28
br label %49
49: ; preds = %48
%50 = load i32, i32* %11
%51 = add nsw i32 %50, 1
store i32 %51, i32* %11
br label %25
52: ; preds = %25
br label %53
53: ; preds = %52
%54 = load i32, i32* %10
%55 = add nsw i32 %54, 1
store i32 %55, i32* %10
br label %21
56: ; preds = %21
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"assert fail: %s\0A\00"
@.str.1 = [5 x i8] c"test\00"
@str = [20 x i8] c"everything is fine!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca [2 x i32*]
%6 = bitcast i64* %3 to i8*
store i64 8589934593, i64* %3
%7 = bitcast i64* %4 to i8*
store i64 17179869187, i64* %4
%8 = bitcast [2 x i32*]* %5 to i8*
%9 = getelementptr inbounds [2 x i32*], [2 x i32*]* %5, i64 0, i64 0
%10 = bitcast [2 x i32*]* %5 to i64**
store i64* %3, i64** %10
%11 = getelementptr inbounds [2 x i32*], [2 x i32*]* %5, i64 0, i64 1
%12 = bitcast i32** %11 to i64**
store i64* %4, i64** %12
%13 = call i32 @rotate(i32** %9, i32 2, i32 2)
%14 = load i32*, i32** %9
%15 = load i32, i32* %14
%16 = icmp eq i32 %15, 3
br i1 %16, label %17, label %31
17: ; preds = %2
%18 = getelementptr inbounds i32, i32* %14, i64 1
%19 = load i32, i32* %18
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %31
21: ; preds = %17
%22 = load i32*, i32** %11
%23 = load i32, i32* %22
%24 = icmp eq i32 %23, 4
br i1 %24, label %25, label %31
25: ; preds = %21
%26 = getelementptr inbounds i32, i32* %22, i64 1
%27 = load i32, i32* %26
%28 = icmp eq i32 %27, 2
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
ret i32 0
31: ; preds = %25, %21, %17, %2
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%33 = call i32 @exit(i32 -1)
unreachable
}