void tw_trsp_blk(long N, long N_SQRT, long TR_BS, long I,
                 double _Complex data[N_SQRT][N_SQRT]) {
  long i, j;
  for (i = 0; i < TR_BS; i += 8) {
    for (j = 0; j < i; j += 8) {
      middle_tw_trsp_swap(N, N_SQRT, I + i, I + j,
                          (double _Complex(*)[N_SQRT]) & data[i][j],
                          (double _Complex(*)[N_SQRT]) & data[j][i]);
    }
    middle_tw_trsp_blk(N, N_SQRT, I + i,
                       (double _Complex(*)[N_SQRT]) & data[i][i]);
  }
}


x86 assembly (clang, -O0):
<tw_trsp_blk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%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,-0x40(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    1224 <tw_trsp_blk+0x104>
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x30(%rbp),%rax
jge    11dd <tw_trsp_blk+0xbd>
mov    -0x40(%rbp),%rax
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
add    -0x30(%rbp),%rdx
mov    -0x20(%rbp),%rcx
add    -0x38(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    %rax,%r9
imul   -0x30(%rbp),%r9
shl    $0x4,%r9
add    %r9,%r8
mov    -0x38(%rbp),%r9
shl    $0x4,%r9
add    %r9,%r8
mov    -0x28(%rbp),%r9
imul   -0x38(%rbp),%rax
shl    $0x4,%rax
add    %rax,%r9
mov    -0x30(%rbp),%rax
shl    $0x4,%rax
add    %rax,%r9
mov    $0x0,%al
call   1040 <middle_tw_trsp_swap@plt>
mov    -0x38(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x38(%rbp)
jmp    1162 <tw_trsp_blk+0x42>
mov    -0x40(%rbp),%rax
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
add    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%rcx
imul   -0x30(%rbp),%rax
shl    $0x4,%rax
add    %rax,%rcx
mov    -0x30(%rbp),%rax
shl    $0x4,%rax
add    %rax,%rcx
mov    $0x0,%al
call   1030 <middle_tw_trsp_blk@plt>
mov    -0x30(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x30(%rbp)
jmp    114c <tw_trsp_blk+0x2c>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tw_trsp_blk>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r8,0x8(%rsp)
mov    %rdx,0x28(%rsp)
test   %rdx,%rdx
jle    123a <tw_trsp_blk+0x11a>
mov    %rcx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
mov    %rsi,%r12
shl    $0x7,%r12
mov    0x8(%rsp),%rax
mov    %rax,%r13
xor    %ebp,%ebp
mov    %rsi,0x18(%rsp)
mov    %rcx,0x10(%rsp)
jmp    11ad <tw_trsp_blk+0x8d>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
shl    $0x4,%rax
add    0x8(%rsp),%rax
mov    %rbp,%rcx
shl    $0x4,%rcx
add    %rax,%rcx
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <middle_tw_trsp_blk@plt>
add    $0x8,%rbp
mov    0x40(%rsp),%rax
sub    $0xffffffffffffff80,%rax
add    %r12,%r13
cmp    0x28(%rsp),%rbp
jge    123a <tw_trsp_blk+0x11a>
lea    (%r14,%rbp,1),%rdx
test   %rbp,%rbp
mov    %rax,0x40(%rsp)
je     1170 <tw_trsp_blk+0x50>
mov    %rbp,%rcx
imul   %rbx,%rcx
mov    %rcx,0x30(%rsp)
mov    %r13,0x38(%rsp)
mov    %r13,%r14
mov    %rbp,0x20(%rsp)
mov    %r15,%r13
mov    %rax,%r15
mov    %r12,%rbp
xor    %r12d,%r12d
mov    0x10(%rsp),%rax
lea    (%rax,%r12,1),%rcx
mov    %r13,%rdi
mov    0x18(%rsp),%rsi
mov    %rdx,%rbx
mov    %r14,%r8
mov    %r15,%r9
xor    %eax,%eax
call   1040 <middle_tw_trsp_swap@plt>
mov    %rbx,%rdx
add    $0x8,%r12
add    %rbp,%r15
sub    $0xffffffffffffff80,%r14
cmp    0x20(%rsp),%r12
jb     11e0 <tw_trsp_blk+0xc0>
mov    0x10(%rsp),%r14
mov    0x18(%rsp),%rbx
mov    %r13,%r15
mov    %rbp,%r12
mov    0x38(%rsp),%r13
mov    0x20(%rsp),%rbp
mov    0x30(%rsp),%rax
jmp    1172 <tw_trsp_blk+0x52>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @tw_trsp_blk(i64 %0, i64 %1, i64 %2, i64 %3, { double, double }* %4) {
%6 = icmp sgt i64 %2, 0
br i1 %6, label %7, label %31
7: ; preds = %5, %24
%8 = phi i64 [ %29, %24 ], [ 0, %5 ]
%9 = icmp eq i64 %8, 0
%10 = add nsw i64 %8, %3
br i1 %9, label %24, label %11
11: ; preds = %7
%12 = mul nsw i64 %8, %1
%13 = getelementptr inbounds { double, double }, { double, double }* %4, i64 %12
%14 = getelementptr inbounds { double, double }, { double, double }* %4, i64 %8
br label %15
15: ; preds = %11, %15
%16 = phi i64 [ 0, %11 ], [ %22, %15 ]
%17 = add nsw i64 %16, %3
%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 %10, i64 %17, { double, double }* %18, { double, double }* %20)
%22 = add nuw nsw i64 %16, 8
%23 = icmp ult i64 %22, %8
br i1 %23, label %15, label %24
24: ; preds = %15, %7
%25 = phi i64 [ 0, %7 ], [ %12, %15 ]
%26 = getelementptr inbounds { double, double }, { double, double }* %4, i64 %25
%27 = getelementptr inbounds { double, double }, { double, double }* %26, i64 %8
%28 = tail call i32 (i64, i64, i64, { double, double }*, ...) bitcast (i32 (...)* @middle_tw_trsp_blk to i32 (i64, i64, i64, { double, double }*, ...)*)(i64 %0, i64 %1, i64 %10, { double, double }* %27)
%29 = add nuw nsw i64 %8, 8
%30 = icmp slt i64 %29, %2
br i1 %30, label %7, label %31
31: ; preds = %24, %5
ret void
}