void tw_trsp_swap(long N, long N_SQRT, long TR_BS, long I, long J,
                  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_tw_trsp_swap(N, N_SQRT, I + i, J + j,
                          (double _Complex(*)[N_SQRT]) & data1[i][j],
                          (double _Complex(*)[N_SQRT]) & data2[j][i]);
    }
  }
}


x86 assembly (clang, -O0):
<tw_trsp_swap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    11f4 <tw_trsp_swap+0xe4>
movq   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    11de <tw_trsp_swap+0xce>
mov    -0x48(%rbp),%rax
mov    -0x50(%rbp),%r9
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
add    -0x38(%rbp),%rdx
mov    -0x28(%rbp),%rcx
add    -0x40(%rbp),%rcx
mov    -0x30(%rbp),%r8
imul   -0x38(%rbp),%r9
shl    $0x4,%r9
add    %r9,%r8
mov    -0x40(%rbp),%r9
shl    $0x4,%r9
add    %r9,%r8
mov    0x10(%rbp),%r9
imul   -0x40(%rbp),%rax
shl    $0x4,%rax
add    %rax,%r9
mov    -0x38(%rbp),%rax
shl    $0x4,%rax
add    %rax,%r9
mov    $0x0,%al
call   1030 <middle_tw_trsp_swap@plt>
mov    -0x40(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x40(%rbp)
jmp    1162 <tw_trsp_swap+0x52>
jmp    11e3 <tw_trsp_swap+0xd3>
mov    -0x38(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x38(%rbp)
jmp    114c <tw_trsp_swap+0x3c>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tw_trsp_swap>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rcx,(%rsp)
test   %rdx,%rdx
jle    11c5 <tw_trsp_swap+0xb5>
mov    %r9,%r14
mov    %r8,%rbx
mov    %rsi,%r15
mov    %rdi,%r13
mov    0x70(%rsp),%r12
mov    %rsi,%rcx
shl    $0x7,%rcx
xor    %ebp,%ebp
mov    %rdx,0x28(%rsp)
mov    %rcx,0x20(%rsp)
nop
mov    (%rsp),%rax
mov    %rbp,0x8(%rsp)
add    %rbp,%rax
mov    %rax,0x30(%rsp)
mov    %r14,0x18(%rsp)
mov    %r12,0x10(%rsp)
xor    %ebp,%ebp
nopl   (%rax)
lea    (%rbx,%rbp,1),%rcx
mov    %r13,%rdi
mov    %r15,%rsi
mov    0x30(%rsp),%rdx
mov    %r14,%r8
mov    %r12,%r9
xor    %eax,%eax
call   1030 <middle_tw_trsp_swap@plt>
mov    0x20(%rsp),%rcx
mov    0x28(%rsp),%rdx
add    $0x8,%rbp
add    %rcx,%r12
sub    $0xffffffffffffff80,%r14
cmp    %rdx,%rbp
jl     1170 <tw_trsp_swap+0x60>
mov    0x8(%rsp),%rbp
add    $0x8,%rbp
mov    0x10(%rsp),%r12
sub    $0xffffffffffffff80,%r12
mov    0x18(%rsp),%r14
add    %rcx,%r14
cmp    %rdx,%rbp
jl     1150 <tw_trsp_swap+0x40>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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