void trsp_swap(long N, long N_SQRT, long TR_BS,
               double _Complex data1[N_SQRT][N_SQRT],
               double _Complex data2[N_SQRT][N_SQRT]) {
  long i, j;
  for (i = 0; i < TR_BS; i += 8) {
    for (j = 0; j < TR_BS; j += 8) {
      middle_trsp_swap(N, N_SQRT, (double _Complex(*)[N_SQRT]) & data1[i][j],
                       (double _Complex(*)[N_SQRT]) & data2[j][i]);
    }
  }
}


x86 assembly (clang, -O0):
<trsp_swap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    11dc <trsp_swap+0xcc>
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    11c6 <trsp_swap+0xb6>
mov    -0x40(%rbp),%rax
mov    -0x48(%rbp),%rcx
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
imul   -0x30(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rdx
mov    -0x38(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rdx
mov    -0x28(%rbp),%rcx
imul   -0x38(%rbp),%rax
shl    $0x4,%rax
add    %rax,%rcx
mov    -0x30(%rbp),%rax
shl    $0x4,%rax
add    %rax,%rcx
mov    $0x0,%al
call   1030 <middle_trsp_swap@plt>
mov    -0x38(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x38(%rbp)
jmp    115a <trsp_swap+0x4a>
jmp    11cb <trsp_swap+0xbb>
mov    -0x30(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x30(%rbp)
jmp    1144 <trsp_swap+0x34>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trsp_swap>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
test   %rdx,%rdx
jle    11a7 <trsp_swap+0x97>
mov    %r8,%r14
mov    %rsi,%r13
mov    %rdi,%rbx
mov    %rsi,%r12
shl    $0x7,%r12
xor    %ebp,%ebp
mov    %rdx,0x20(%rsp)
xchg   %ax,%ax
mov    %rbp,0x8(%rsp)
mov    %rcx,0x10(%rsp)
mov    %rcx,%rbp
mov    %r14,0x18(%rsp)
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1030 <middle_trsp_swap@plt>
mov    0x20(%rsp),%rdx
add    $0x8,%r15
add    %r12,%r14
sub    $0xffffffffffffff80,%rbp
cmp    %rdx,%r15
jl     1160 <trsp_swap+0x50>
mov    0x8(%rsp),%rbp
add    $0x8,%rbp
mov    0x18(%rsp),%r14
sub    $0xffffffffffffff80,%r14
mov    0x10(%rsp),%rcx
add    %r12,%rcx
cmp    %rdx,%rbp
jl     1140 <trsp_swap+0x30>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @trsp_swap(i64 %0, i64 %1, i64 %2, { double, double }* %3, { double, double }* %4) {
%6 = icmp sgt i64 %2, 0
br i1 %6, label %7, label %23
7: ; preds = %5, %20
%8 = phi i64 [ %21, %20 ], [ 0, %5 ]
%9 = mul nsw i64 %8, %1
%10 = getelementptr inbounds { double, double }, { double, double }* %3, i64 %9
%11 = getelementptr inbounds { double, double }, { double, double }* %4, i64 %8
br label %12
12: ; preds = %7, %12
%13 = phi i64 [ 0, %7 ], [ %18, %12 ]
%14 = getelementptr inbounds { double, double }, { double, double }* %10, i64 %13
%15 = mul nsw i64 %13, %1
%16 = getelementptr inbounds { double, double }, { double, double }* %11, i64 %15
%17 = tail call i32 (i64, i64, { double, double }*, { double, double }*, ...) bitcast (i32 (...)* @middle_trsp_swap to i32 (i64, i64, { double, double }*, { double, double }*, ...)*)(i64 %0, i64 %1, { double, double }* %14, { double, double }* %16)
%18 = add nuw nsw i64 %13, 8
%19 = icmp slt i64 %18, %2
br i1 %19, label %12, label %20
20: ; preds = %12
%21 = add nuw nsw i64 %8, 8
%22 = icmp slt i64 %21, %2
br i1 %22, label %7, label %23
23: ; preds = %20, %5
ret void
}