#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*/ transpose_block8x8(int, int *, int *);
void transpose2(int dim, int *src, int *dst) {
  int i, j, di = dim * 8, dj = dim * dim - 8;
  for (i = 0; i < dim; i += 8, dst += di - dim, src -= dj)
    for (j = 0; j < dim; j += 8, src += di, dst += 8)
      transpose_block8x8(dim, src, dst);
}


x86 assembly (clang, -O0):
<transpose2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x3,%eax
mov    %eax,-0x24(%rbp)
mov    -0x4(%rbp),%eax
imul   -0x4(%rbp),%eax
sub    $0x8,%eax
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11e3 <transpose2+0xd3>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    119e <transpose2+0x8e>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <transpose_block8x8@plt>
mov    -0x20(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rax
mov    %rax,-0x18(%rbp)
jmp    1153 <transpose2+0x43>
jmp    11a3 <transpose2+0x93>
mov    -0x1c(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x24(%rbp),%ecx
sub    -0x4(%rbp),%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x28(%rbp),%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rdx
xor    %ecx,%ecx
sub    %rdx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
jmp    1140 <transpose2+0x30>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<transpose2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %edi,%edi
jle    11b0 <transpose2+0xa0>
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %edi,%r15d
mov    %edi,%eax
imul   %r15d,%eax
cltq
shl    $0x2,%rax
lea    0x0(,%r15,8),%ecx
movslq %ecx,%r12
mov    %r12d,%ecx
sub    %edi,%ecx
movslq %ecx,%rcx
shl    $0x2,%r12
mov    $0x20,%edx
sub    %rax,%rdx
mov    %rdx,0x8(%rsp)
shl    $0x2,%rcx
mov    %rcx,0x10(%rsp)
xor    %r13d,%r13d
nopl   0x0(%rax,%rax,1)
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <transpose_block8x8@plt>
add    $0x8,%ebp
add    $0x20,%r14
add    %r12,%rbx
cmp    %r15d,%ebp
jl     1180 <transpose2+0x70>
add    $0x8,%r13d
add    0x10(%rsp),%r14
add    0x8(%rsp),%rbx
cmp    %r15d,%r13d
jl     1170 <transpose2+0x60>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @transpose2(i32 %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%11 = load i32, i32* %4
%12 = mul nsw i32 %11, 8
store i32 %12, i32* %9
%13 = load i32, i32* %4
%14 = load i32, i32* %4
%15 = mul nsw i32 %13, %14
%16 = sub nsw i32 %15, 8
store i32 %16, i32* %10
store i32 0, i32* %7
br label %17
17: ; preds = %41, %3
%18 = load i32, i32* %7
%19 = load i32, i32* %4
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %55
21: ; preds = %17
store i32 0, i32* %8
br label %22
22: ; preds = %31, %21
%23 = load i32, i32* %8
%24 = load i32, i32* %4
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %40
26: ; preds = %22
%27 = load i32, i32* %4
%28 = load i32*, i32** %5
%29 = load i32*, i32** %6
%30 = call i32 @transpose_block8x8(i32 %27, i32* %28, i32* %29)
br label %31
31: ; preds = %26
%32 = load i32, i32* %8
%33 = add nsw i32 %32, 8
store i32 %33, i32* %8
%34 = load i32, i32* %9
%35 = load i32*, i32** %5
%36 = sext i32 %34 to i64
%37 = getelementptr inbounds i32, i32* %35, i64 %36
store i32* %37, i32** %5
%38 = load i32*, i32** %6
%39 = getelementptr inbounds i32, i32* %38, i64 8
store i32* %39, i32** %6
br label %22
40: ; preds = %22
br label %41
41: ; preds = %40
%42 = load i32, i32* %7
%43 = add nsw i32 %42, 8
store i32 %43, i32* %7
%44 = load i32, i32* %9
%45 = load i32, i32* %4
%46 = sub nsw i32 %44, %45
%47 = load i32*, i32** %6
%48 = sext i32 %46 to i64
%49 = getelementptr inbounds i32, i32* %47, i64 %48
store i32* %49, i32** %6
%50 = load i32, i32* %10
%51 = load i32*, i32** %5
%52 = sext i32 %50 to i64
%53 = sub i64 0, %52
%54 = getelementptr inbounds i32, i32* %51, i64 %53
store i32* %54, i32** %5
br label %17
55: ; preds = %17
ret void
}

LLVM IR (-O2):
define void @transpose2(i32 %0, i32* %1, i32* %2) {
%4 = icmp sgt i32 %0, 0
br i1 %4, label %5, label %32
5: ; preds = %3
%6 = mul nsw i32 %0, %0
%7 = add nsw i32 %6, -8
%8 = shl nsw i32 %0, 3
%9 = sext i32 %8 to i64
%10 = mul i32 %0, 7
%11 = sext i32 %10 to i64
%12 = sext i32 %7 to i64
%13 = sub nsw i64 0, %12
br label %14
14: ; preds = %27, %5
%15 = phi i32* [ %1, %5 ], [ %30, %27 ]
%16 = phi i32* [ %2, %5 ], [ %29, %27 ]
%17 = phi i32 [ 0, %5 ], [ %28, %27 ]
br label %18
18: ; preds = %14, %18
%19 = phi i32* [ %24, %18 ], [ %15, %14 ]
%20 = phi i32* [ %25, %18 ], [ %16, %14 ]
%21 = phi i32 [ %23, %18 ], [ 0, %14 ]
%22 = tail call i32 @transpose_block8x8(i32 %0, i32* %19, i32* %20)
%23 = add nuw nsw i32 %21, 8
%24 = getelementptr inbounds i32, i32* %19, i64 %9
%25 = getelementptr inbounds i32, i32* %20, i64 8
%26 = icmp slt i32 %23, %0
br i1 %26, label %18, label %27
27: ; preds = %18
%28 = add nuw nsw i32 %17, 8
%29 = getelementptr inbounds i32, i32* %25, i64 %11
%30 = getelementptr inbounds i32, i32* %24, i64 %13
%31 = icmp slt i32 %28, %0
br i1 %31, label %14, label %32
32: ; preds = %27, %3
ret void
}