#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*/ dump_array(int **);
int /*<<< orphan*/ printf(char *);
int main() {
  int nums[4][4], another[4][4];
  unsigned i, j;
  for (i = 0; i < 4; ++i)
    for (j = 0; j < 4; ++j)
      nums[i][j] = i * 4 + j;
  printf("Contents of nums:\n");
  dump_array(nums);
  for (i = 0; i < 4; ++i)
    for (j = 0; j < 4; ++j)
      another[j][i] = nums[i][j];
  printf("\nTransposed array:\n");
  dump_array(another);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x94(%rbp)
cmpl   $0x4,-0x94(%rbp)
jae    11b8 <main+0x98>
movl   $0x0,-0x98(%rbp)
cmpl   $0x4,-0x98(%rbp)
jae    119f <main+0x7f>
mov    -0x94(%rbp),%edx
shl    $0x2,%edx
add    -0x98(%rbp),%edx
mov    -0x94(%rbp),%eax
mov    %eax,%ecx
lea    -0x50(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    -0x98(%rbp),%ecx
mov    %edx,(%rax,%rcx,4)
mov    -0x98(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x98(%rbp)
jmp    1153 <main+0x33>
jmp    11a4 <main+0x84>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    113c <main+0x1c>
lea    0xe41(%rip),%rdi
call   1040 <printf@plt>
lea    -0x50(%rbp),%rdi
call   1030 <dump_array@plt>
movl   $0x0,-0x94(%rbp)
cmpl   $0x4,-0x94(%rbp)
jae    1263 <main+0x143>
movl   $0x0,-0x98(%rbp)
cmpl   $0x4,-0x98(%rbp)
jae    124a <main+0x12a>
mov    -0x94(%rbp),%eax
mov    %eax,%ecx
lea    -0x50(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    -0x98(%rbp),%ecx
mov    (%rax,%rcx,4),%edx
mov    -0x98(%rbp),%eax
mov    %eax,%ecx
lea    -0x90(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    -0x94(%rbp),%ecx
mov    %edx,(%rax,%rcx,4)
mov    -0x98(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x98(%rbp)
jmp    11ee <main+0xce>
jmp    124f <main+0x12f>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    11d7 <main+0xb7>
lea    0xda9(%rip),%rdi
call   1040 <printf@plt>
lea    -0x90(%rbp),%rdi
call   1030 <dump_array@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x88,%rsp
movaps 0xed2(%rip),%xmm0
movaps %xmm0,(%rsp)
movaps 0xed7(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xedb(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xedf(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
lea    0xee3(%rip),%rdi
call   1040 <puts@plt>
mov    %rsp,%rdi
call   1030 <dump_array@plt>
mov    (%rsp),%eax
mov    0x4(%rsp),%ecx
mov    %eax,0x40(%rsp)
mov    %ecx,0x50(%rsp)
mov    0x8(%rsp),%eax
mov    %eax,0x60(%rsp)
mov    0xc(%rsp),%eax
mov    %eax,0x70(%rsp)
mov    0x10(%rsp),%eax
mov    %eax,0x44(%rsp)
mov    0x14(%rsp),%eax
mov    %eax,0x54(%rsp)
mov    0x18(%rsp),%eax
mov    %eax,0x64(%rsp)
mov    0x1c(%rsp),%eax
mov    %eax,0x74(%rsp)
mov    0x20(%rsp),%eax
mov    %eax,0x48(%rsp)
mov    0x24(%rsp),%eax
mov    0x28(%rsp),%ecx
mov    %eax,0x58(%rsp)
mov    %ecx,0x68(%rsp)
mov    0x2c(%rsp),%eax
mov    %eax,0x78(%rsp)
mov    0x30(%rsp),%eax
mov    %eax,0x4c(%rsp)
mov    0x34(%rsp),%eax
mov    %eax,0x5c(%rsp)
mov    0x38(%rsp),%eax
mov    %eax,0x6c(%rsp)
mov    0x3c(%rsp),%eax
mov    %eax,0x7c(%rsp)
lea    0xe62(%rip),%rdi
call   1040 <puts@plt>
lea    0x40(%rsp),%rdi
call   1030 <dump_array@plt>
xor    %eax,%eax
add    $0x88,%rsp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Contents of nums:\0A\00"
@.str.1 = [20 x i8] c"\0ATransposed array:\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x [4 x i32]]
%3 = alloca [4 x [4 x i32]]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
br label %6
6: ; preds = %28, %0
%7 = load i32, i32* %4
%8 = icmp ult i32 %7, 4
br i1 %8, label %9, label %31
9: ; preds = %6
store i32 0, i32* %5
br label %10
10: ; preds = %24, %9
%11 = load i32, i32* %5
%12 = icmp ult i32 %11, 4
br i1 %12, label %13, label %27
13: ; preds = %10
%14 = load i32, i32* %4
%15 = mul i32 %14, 4
%16 = load i32, i32* %5
%17 = add i32 %15, %16
%18 = load i32, i32* %4
%19 = zext i32 %18 to i64
%20 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %2, i64 0, i64 %19
%21 = load i32, i32* %5
%22 = zext i32 %21 to i64
%23 = getelementptr inbounds [4 x i32], [4 x i32]* %20, i64 0, i64 %22
store i32 %17, i32* %23
br label %24
24: ; preds = %13
%25 = load i32, i32* %5
%26 = add i32 %25, 1
store i32 %26, i32* %5
br label %10
27: ; preds = %10
br label %28
28: ; preds = %27
%29 = load i32, i32* %4
%30 = add i32 %29, 1
store i32 %30, i32* %4
br label %6
31: ; preds = %6
%32 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%33 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %2, i64 0, i64 0
%34 = bitcast [4 x i32]* %33 to i32**
%35 = call i32 @dump_array(i32** %34)
store i32 0, i32* %4
br label %36
36: ; preds = %61, %31
%37 = load i32, i32* %4
%38 = icmp ult i32 %37, 4
br i1 %38, label %39, label %64
39: ; preds = %36
store i32 0, i32* %5
br label %40
40: ; preds = %57, %39
%41 = load i32, i32* %5
%42 = icmp ult i32 %41, 4
br i1 %42, label %43, label %60
43: ; preds = %40
%44 = load i32, i32* %4
%45 = zext i32 %44 to i64
%46 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %2, i64 0, i64 %45
%47 = load i32, i32* %5
%48 = zext i32 %47 to i64
%49 = getelementptr inbounds [4 x i32], [4 x i32]* %46, i64 0, i64 %48
%50 = load i32, i32* %49
%51 = load i32, i32* %5
%52 = zext i32 %51 to i64
%53 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %3, i64 0, i64 %52
%54 = load i32, i32* %4
%55 = zext i32 %54 to i64
%56 = getelementptr inbounds [4 x i32], [4 x i32]* %53, i64 0, i64 %55
store i32 %50, i32* %56
br label %57
57: ; preds = %43
%58 = load i32, i32* %5
%59 = add i32 %58, 1
store i32 %59, i32* %5
br label %40
60: ; preds = %40
br label %61
61: ; preds = %60
%62 = load i32, i32* %4
%63 = add i32 %62, 1
store i32 %63, i32* %4
br label %36
64: ; preds = %36
%65 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%66 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %3, i64 0, i64 0
%67 = bitcast [4 x i32]* %66 to i32**
%68 = call i32 @dump_array(i32** %67)
ret i32 0
}

LLVM IR (-O2):
@str = [18 x i8] c"Contents of nums:\00"
@str.2 = [19 x i8] c"\0ATransposed array:\00"
define i32 @main() {
%1 = alloca [4 x [4 x i32]]
%2 = alloca [4 x [4 x i32]]
%3 = bitcast [4 x [4 x i32]]* %1 to i8*
%4 = bitcast [4 x [4 x i32]]* %2 to i8*
%5 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 0, i64 0
%6 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 0, i64 1
%7 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 0, i64 2
%8 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 0, i64 3
%9 = bitcast [4 x [4 x i32]]* %1 to <4 x i32>*
store <4 x i32> <i32 0, i32 1, i32 2, i32 3>, <4 x i32>* %9
%10 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 1, i64 0
%11 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 1, i64 1
%12 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 1, i64 2
%13 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 1, i64 3
%14 = bitcast i32* %10 to <4 x i32>*
store <4 x i32> <i32 4, i32 5, i32 6, i32 7>, <4 x i32>* %14
%15 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 2, i64 0
%16 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 2, i64 1
%17 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 2, i64 2
%18 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 2, i64 3
%19 = bitcast i32* %15 to <4 x i32>*
store <4 x i32> <i32 8, i32 9, i32 10, i32 11>, <4 x i32>* %19
%20 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 3, i64 0
%21 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 3, i64 1
%22 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 3, i64 2
%23 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 3, i64 3
%24 = bitcast i32* %20 to <4 x i32>*
store <4 x i32> <i32 12, i32 13, i32 14, i32 15>, <4 x i32>* %24
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%26 = bitcast [4 x [4 x i32]]* %1 to i32**
%27 = call i32 @dump_array(i32** %26)
%28 = load i32, i32* %5
%29 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %2, i64 0, i64 0, i64 0
store i32 %28, i32* %29
%30 = load i32, i32* %6
%31 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %2, i64 0, i64 1, i64 0
store i32 %30, i32* %31
%32 = load i32, i32* %7
%33 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %2, i64 0, i64 2, i64 0
store i32 %32, i32* %33
%34 = load i32, i32* %8
%35 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %2, i64 0, i64 3, i64 0
store i32 %34, i32* %35
%36 = load i32, i32* %10
%37 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %2, i64 0, i64 0, i64 1
store i32 %36, i32* %37
%38 = load i32, i32* %11
%39 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %2, i64 0, i64 1, i64 1
store i32 %38, i32* %39
%40 = load i32, i32* %12
%41 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %2, i64 0, i64 2, i64 1
store i32 %40, i32* %41
%42 = load i32, i32* %13
%43 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %2, i64 0, i64 3, i64 1
store i32 %42, i32* %43
%44 = load i32, i32* %15
%45 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %2, i64 0, i64 0, i64 2
store i32 %44, i32* %45
%46 = load i32, i32* %16
%47 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %2, i64 0, i64 1, i64 2
store i32 %46, i32* %47
%48 = load i32, i32* %17
%49 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %2, i64 0, i64 2, i64 2
store i32 %48, i32* %49
%50 = load i32, i32* %18
%51 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %2, i64 0, i64 3, i64 2
store i32 %50, i32* %51
%52 = load i32, i32* %20
%53 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %2, i64 0, i64 0, i64 3
store i32 %52, i32* %53
%54 = load i32, i32* %21
%55 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %2, i64 0, i64 1, i64 3
store i32 %54, i32* %55
%56 = load i32, i32* %22
%57 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %2, i64 0, i64 2, i64 3
store i32 %56, i32* %57
%58 = load i32, i32* %23
%59 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %2, i64 0, i64 3, i64 3
store i32 %58, i32* %59
%60 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.2, i64 0, i64 0))
%61 = bitcast [4 x [4 x i32]]* %2 to i32**
%62 = call i32 @dump_array(i32** %61)
ret i32 0
}