#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*/ copyarray(char ***, char ***);
void transpose(char (*arr)[4][4]) {
  static char tmp[4][4];
  copyarray(arr, &tmp);
  for (int i = 0; i < 4; i++)
    for (int j = 0; j < 4; j++)
      (*arr)[i][j] = tmp[j][i];
}


x86 assembly (clang, -O0):
<transpose>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0x2f19(%rip),%rsi
call   1030 <copyarray@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
jge    119e <transpose+0x8e>
movl   $0x0,-0x10(%rbp)
cmpl   $0x4,-0x10(%rbp)
jge    118b <transpose+0x7b>
movslq -0x10(%rbp),%rcx
lea    0x2ee7(%rip),%rax
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1144 <transpose+0x34>
jmp    1190 <transpose+0x80>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1133 <transpose+0x23>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<transpose>:
push   %rbx
mov    %rdi,%rbx
lea    0x2f25(%rip),%rsi
call   1030 <copyarray@plt>
mov    0x2f1a(%rip),%al
mov    %al,(%rbx)
mov    0x2f16(%rip),%al
mov    %al,0x1(%rbx)
mov    0x2f11(%rip),%al
mov    %al,0x2(%rbx)
mov    0x2f0c(%rip),%al
mov    %al,0x3(%rbx)
mov    0x2ef8(%rip),%al
mov    %al,0x4(%rbx)
mov    0x2ef3(%rip),%al
mov    %al,0x5(%rbx)
mov    0x2eee(%rip),%al
mov    %al,0x6(%rbx)
mov    0x2ee9(%rip),%al
mov    %al,0x7(%rbx)
mov    0x2ed5(%rip),%al
mov    %al,0x8(%rbx)
mov    0x2ed0(%rip),%al
mov    %al,0x9(%rbx)
mov    0x2ecb(%rip),%al
mov    %al,0xa(%rbx)
mov    0x2ec6(%rip),%al
mov    %al,0xb(%rbx)
mov    0x2eb2(%rip),%al
mov    %al,0xc(%rbx)
mov    0x2ead(%rip),%al
mov    %al,0xd(%rbx)
mov    0x2ea8(%rip),%al
mov    %al,0xe(%rbx)
mov    0x2ea3(%rip),%al
mov    %al,0xf(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
@transpose.tmp = internal global [4 x [4 x i8]] zeroinitializer
define void @transpose([4 x [4 x i8]]* %0) {
%2 = alloca [4 x [4 x i8]]*
%3 = alloca i32
%4 = alloca i32
store [4 x [4 x i8]]* %0, [4 x [4 x i8]]** %2
%5 = load [4 x [4 x i8]]*, [4 x [4 x i8]]** %2
%6 = bitcast [4 x [4 x i8]]* %5 to i8***
%7 = call i32 @copyarray(i8*** %6, i8*** bitcast ([4 x [4 x i8]]* @transpose.tmp to i8***))
store i32 0, i32* %3
br label %8
8: ; preds = %34, %1
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 4
br i1 %10, label %11, label %37
11: ; preds = %8
store i32 0, i32* %4
br label %12
12: ; preds = %30, %11
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 4
br i1 %14, label %15, label %33
15: ; preds = %12
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [4 x [4 x i8]], [4 x [4 x i8]]* @transpose.tmp, i64 0, i64 %17
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [4 x i8], [4 x i8]* %18, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = load [4 x [4 x i8]]*, [4 x [4 x i8]]** %2
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [4 x [4 x i8]], [4 x [4 x i8]]* %23, i64 0, i64 %25
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [4 x i8], [4 x i8]* %26, i64 0, i64 %28
store i8 %22, i8* %29
br label %30
30: ; preds = %15
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 1
store i32 %32, i32* %4
br label %12
33: ; preds = %12
br label %34
34: ; preds = %33
%35 = load i32, i32* %3
%36 = add nsw i32 %35, 1
store i32 %36, i32* %3
br label %8
37: ; preds = %8
ret void
}

LLVM IR (-O2):
@transpose.tmp = internal global [4 x [4 x i8]] zeroinitializer
define void @transpose([4 x [4 x i8]]* %0) {
%2 = bitcast [4 x [4 x i8]]* %0 to i8***
%3 = tail call i32 @copyarray(i8*** %2, i8*** bitcast ([4 x [4 x i8]]* @transpose.tmp to i8***))
%4 = load i8, i8* getelementptr inbounds ([4 x [4 x i8]], [4 x [4 x i8]]* @transpose.tmp, i64 0, i64 0, i64 0)
%5 = getelementptr inbounds [4 x [4 x i8]], [4 x [4 x i8]]* %0, i64 0, i64 0, i64 0
store i8 %4, i8* %5
%6 = load i8, i8* getelementptr inbounds ([4 x [4 x i8]], [4 x [4 x i8]]* @transpose.tmp, i64 0, i64 1, i64 0)
%7 = getelementptr inbounds [4 x [4 x i8]], [4 x [4 x i8]]* %0, i64 0, i64 0, i64 1
store i8 %6, i8* %7
%8 = load i8, i8* getelementptr inbounds ([4 x [4 x i8]], [4 x [4 x i8]]* @transpose.tmp, i64 0, i64 2, i64 0)
%9 = getelementptr inbounds [4 x [4 x i8]], [4 x [4 x i8]]* %0, i64 0, i64 0, i64 2
store i8 %8, i8* %9
%10 = load i8, i8* getelementptr inbounds ([4 x [4 x i8]], [4 x [4 x i8]]* @transpose.tmp, i64 0, i64 3, i64 0)
%11 = getelementptr inbounds [4 x [4 x i8]], [4 x [4 x i8]]* %0, i64 0, i64 0, i64 3
store i8 %10, i8* %11
%12 = load i8, i8* getelementptr inbounds ([4 x [4 x i8]], [4 x [4 x i8]]* @transpose.tmp, i64 0, i64 0, i64 1)
%13 = getelementptr inbounds [4 x [4 x i8]], [4 x [4 x i8]]* %0, i64 0, i64 1, i64 0
store i8 %12, i8* %13
%14 = load i8, i8* getelementptr inbounds ([4 x [4 x i8]], [4 x [4 x i8]]* @transpose.tmp, i64 0, i64 1, i64 1)
%15 = getelementptr inbounds [4 x [4 x i8]], [4 x [4 x i8]]* %0, i64 0, i64 1, i64 1
store i8 %14, i8* %15
%16 = load i8, i8* getelementptr inbounds ([4 x [4 x i8]], [4 x [4 x i8]]* @transpose.tmp, i64 0, i64 2, i64 1)
%17 = getelementptr inbounds [4 x [4 x i8]], [4 x [4 x i8]]* %0, i64 0, i64 1, i64 2
store i8 %16, i8* %17
%18 = load i8, i8* getelementptr inbounds ([4 x [4 x i8]], [4 x [4 x i8]]* @transpose.tmp, i64 0, i64 3, i64 1)
%19 = getelementptr inbounds [4 x [4 x i8]], [4 x [4 x i8]]* %0, i64 0, i64 1, i64 3
store i8 %18, i8* %19
%20 = load i8, i8* getelementptr inbounds ([4 x [4 x i8]], [4 x [4 x i8]]* @transpose.tmp, i64 0, i64 0, i64 2)
%21 = getelementptr inbounds [4 x [4 x i8]], [4 x [4 x i8]]* %0, i64 0, i64 2, i64 0
store i8 %20, i8* %21
%22 = load i8, i8* getelementptr inbounds ([4 x [4 x i8]], [4 x [4 x i8]]* @transpose.tmp, i64 0, i64 1, i64 2)
%23 = getelementptr inbounds [4 x [4 x i8]], [4 x [4 x i8]]* %0, i64 0, i64 2, i64 1
store i8 %22, i8* %23
%24 = load i8, i8* getelementptr inbounds ([4 x [4 x i8]], [4 x [4 x i8]]* @transpose.tmp, i64 0, i64 2, i64 2)
%25 = getelementptr inbounds [4 x [4 x i8]], [4 x [4 x i8]]* %0, i64 0, i64 2, i64 2
store i8 %24, i8* %25
%26 = load i8, i8* getelementptr inbounds ([4 x [4 x i8]], [4 x [4 x i8]]* @transpose.tmp, i64 0, i64 3, i64 2)
%27 = getelementptr inbounds [4 x [4 x i8]], [4 x [4 x i8]]* %0, i64 0, i64 2, i64 3
store i8 %26, i8* %27
%28 = load i8, i8* getelementptr inbounds ([4 x [4 x i8]], [4 x [4 x i8]]* @transpose.tmp, i64 0, i64 0, i64 3)
%29 = getelementptr inbounds [4 x [4 x i8]], [4 x [4 x i8]]* %0, i64 0, i64 3, i64 0
store i8 %28, i8* %29
%30 = load i8, i8* getelementptr inbounds ([4 x [4 x i8]], [4 x [4 x i8]]* @transpose.tmp, i64 0, i64 1, i64 3)
%31 = getelementptr inbounds [4 x [4 x i8]], [4 x [4 x i8]]* %0, i64 0, i64 3, i64 1
store i8 %30, i8* %31
%32 = load i8, i8* getelementptr inbounds ([4 x [4 x i8]], [4 x [4 x i8]]* @transpose.tmp, i64 0, i64 2, i64 3)
%33 = getelementptr inbounds [4 x [4 x i8]], [4 x [4 x i8]]* %0, i64 0, i64 3, i64 2
store i8 %32, i8* %33
%34 = load i8, i8* getelementptr inbounds ([4 x [4 x i8]], [4 x [4 x i8]]* @transpose.tmp, i64 0, i64 3, i64 3)
%35 = getelementptr inbounds [4 x [4 x i8]], [4 x [4 x i8]]* %0, i64 0, i64 3, i64 3
store i8 %34, i8* %35
ret void
}