void mtransp(n, A, T) int n;
double *A, *T;
{
  int i, j, np1;
  double *pAc, *pAr, *pTc, *pTr, *pA0, *pT0;
  double x;
  np1 = n + 1;
  pA0 = A;
  pT0 = T;
  for (i = 0; i < n - 1; i++) {
    pAc = pA0;
    pAr = pAc + n;
    pTc = pT0;
    pTr = pTc + n;
    *pTc++ = *pAc++;
    for (j = i + 1; j < n; j++) {
      x = *pAr;
      *pTr = *pAc++;
      *pTc++ = x;
      pAr += n;
      pTr += n;
    }
    pA0 += np1;
    pT0 += np1;
  }
  *pT0 = *pA0;
}


x86 assembly (clang, -O0):
<mtransp>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x58(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1261 <mtransp+0x161>
mov    -0x50(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x4(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
movslq -0x4(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x30(%rbp)
movsd  (%rax),%xmm0
mov    -0x40(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x40(%rbp)
movsd  %xmm0,(%rax)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1229 <mtransp+0x129>
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x30(%rbp)
movsd  (%rax),%xmm0
mov    -0x48(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x60(%rbp),%xmm0
mov    -0x40(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x40(%rbp)
movsd  %xmm0,(%rax)
mov    -0x4(%rbp),%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x4(%rbp),%ecx
mov    -0x48(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11a5 <mtransp+0xa5>
mov    -0x24(%rbp),%ecx
mov    -0x50(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x50(%rbp)
mov    -0x24(%rbp),%ecx
mov    -0x58(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x58(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112f <mtransp+0x2f>
mov    -0x50(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x58(%rbp),%rax
movsd  %xmm0,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<mtransp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
jl     1382 <mtransp+0x282>
lea    -0x1(%rdi),%eax
mov    %eax,-0x80(%rsp)
mov    %edi,%ecx
lea    0x1(%rcx),%rax
mov    %rax,(%rsp)
lea    -0x2(%rdi),%eax
mov    %eax,-0x74(%rsp)
lea    0x8(,%rcx,8),%rax
mov    %rax,-0x8(%rsp)
lea    0x0(,%rcx,8),%rax
lea    (%rsi,%rcx,8),%rbp
mov    %rbp,-0x28(%rsp)
lea    (%rdx,%rcx,8),%rbp
mov    %rbp,-0x30(%rsp)
lea    0x3(%rdi),%ebp
lea    0x0(,%rcx,4),%rbx
mov    %rbx,-0x40(%rsp)
mov    %rcx,%rbx
shl    $0x5,%rbx
mov    %rbx,0x8(%rsp)
lea    (%rcx,%rcx,2),%rbx
mov    %rbx,-0x48(%rsp)
mov    %rcx,-0x38(%rsp)
add    %rcx,%rcx
mov    %rcx,-0x50(%rsp)
xor    %r9d,%r9d
xor    %ecx,%ecx
mov    %rdx,-0x18(%rsp)
mov    %rsi,-0x20(%rsp)
mov    %rdi,-0x70(%rsp)
jmp    11d7 <mtransp+0xd7>
xchg   %ax,%ax
mov    (%rsp),%rcx
mov    -0x60(%rsp),%rsi
lea    (%rsi,%rcx,8),%rsi
mov    -0x58(%rsp),%rdx
lea    (%rdx,%rcx,8),%rdx
add    -0x8(%rsp),%r9
mov    -0x68(%rsp),%rbp
add    $0x3,%bpl
mov    -0x7c(%rsp),%ecx
cmp    -0x80(%rsp),%ecx
mov    -0x70(%rsp),%rdi
je     1382 <mtransp+0x282>
mov    %ecx,%r14d
movzbl %bpl,%ebp
and    $0x3,%ebp
mov    %rbp,-0x68(%rsp)
mov    %rsi,-0x60(%rsp)
movsd  (%rsi),%xmm0
mov    %rdx,-0x58(%rsp)
movsd  %xmm0,(%rdx)
lea    0x1(%r14),%ecx
mov    %ecx,-0x7c(%rsp)
cmp    %edi,%ecx
jge    11a0 <mtransp+0xa0>
mov    -0x74(%rsp),%r8d
sub    %r14d,%r8d
mov    -0x80(%rsp),%edi
sub    %r14d,%edi
mov    -0x60(%rsp),%rsi
mov    %rsi,%r12
mov    -0x58(%rsp),%rdx
mov    %rdx,%r15
mov    -0x7c(%rsp),%ecx
test   $0x3,%dil
je     12b1 <mtransp+0x1b1>
mov    $0xffffffff,%edi
mov    -0x18(%rsp),%r15
mov    %r15,%rdx
mov    -0x20(%rsp),%r12
mov    %r12,%rsi
mov    -0x30(%rsp),%rbp
mov    -0x28(%rsp),%rbx
mov    -0x68(%rsp),%r10
cs nopw 0x0(%rax,%rax,1)
nop
movsd  (%rbx,%r9,1),%xmm0
movsd  0x8(%rsi,%r9,1),%xmm1
movsd  %xmm1,0x0(%rbp,%r9,1)
movsd  %xmm0,0x8(%rdx,%r9,1)
add    %rax,%r12
add    %rax,%rbx
add    %rax,%r15
add    %rax,%rbp
add    $0x8,%rsi
add    $0x8,%rdx
mov    %edi,%ecx
add    $0xffffffff,%edi
add    %r10d,%ecx
add    $0xffffffff,%ecx
cmp    $0xffffffff,%ecx
jne    1260 <mtransp+0x160>
add    %r9,%r12
add    %r9,%r15
add    %r9,%rsi
add    %r9,%rdx
sub    %edi,%r14d
mov    %r14d,%ecx
cmp    $0x3,%r8d
jb     11a0 <mtransp+0xa0>
mov    -0x40(%rsp),%rdi
lea    (%r12,%rdi,8),%rbp
mov    %rbp,-0x10(%rsp)
mov    -0x48(%rsp),%rbx
lea    (%r12,%rbx,8),%r8
mov    -0x50(%rsp),%rbp
lea    (%r12,%rbp,8),%r10
mov    %ecx,-0x78(%rsp)
mov    -0x38(%rsp),%rcx
lea    (%r12,%rcx,8),%r12
lea    (%r15,%rdi,8),%r11
lea    (%r15,%rbx,8),%r13
lea    (%r15,%rbp,8),%r14
lea    (%r15,%rcx,8),%r15
mov    -0x10(%rsp),%rbx
mov    -0x70(%rsp),%rdi
sub    -0x78(%rsp),%edi
xor    %ebp,%ebp
xor    %ecx,%ecx
nopw   0x0(%rax,%rax,1)
movsd  (%r12,%rcx,1),%xmm0
movsd  0x8(%rsi,%rbp,8),%xmm1
movsd  %xmm1,(%r15,%rcx,1)
movsd  %xmm0,0x8(%rdx,%rbp,8)
movsd  (%r10,%rcx,1),%xmm0
movsd  0x10(%rsi,%rbp,8),%xmm1
movsd  %xmm1,(%r14,%rcx,1)
movsd  %xmm0,0x10(%rdx,%rbp,8)
movsd  (%r8,%rcx,1),%xmm0
movsd  0x18(%rsi,%rbp,8),%xmm1
movsd  %xmm1,0x0(%r13,%rcx,1)
movsd  %xmm0,0x18(%rdx,%rbp,8)
movsd  (%rbx,%rcx,1),%xmm0
movsd  0x20(%rsi,%rbp,8),%xmm1
movsd  %xmm1,(%r11,%rcx,1)
movsd  %xmm0,0x20(%rdx,%rbp,8)
add    0x8(%rsp),%rcx
add    $0x4,%rbp
cmp    %ebp,%edi
jne    1310 <mtransp+0x210>
jmp    11a0 <mtransp+0xa0>
movsd  (%rsi),%xmm0
movsd  %xmm0,(%rdx)
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @mtransp(i32 %0, double* %1, double* %2) {
%4 = alloca i32
%5 = alloca double*
%6 = alloca double*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
%15 = alloca double*
%16 = alloca double
store i32 %0, i32* %4
store double* %1, double** %5
store double* %2, double** %6
%17 = load i32, i32* %4
%18 = add nsw i32 %17, 1
store i32 %18, i32* %9
%19 = load double*, double** %5
store double* %19, double** %14
%20 = load double*, double** %6
store double* %20, double** %15
store i32 0, i32* %7
br label %21
21: ; preds = %78, %3
%22 = load i32, i32* %7
%23 = load i32, i32* %4
%24 = sub nsw i32 %23, 1
%25 = icmp slt i32 %22, %24
br i1 %25, label %26, label %81
26: ; preds = %21
%27 = load double*, double** %14
store double* %27, double** %10
%28 = load double*, double** %10
%29 = load i32, i32* %4
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds double, double* %28, i64 %30
store double* %31, double** %11
%32 = load double*, double** %15
store double* %32, double** %12
%33 = load double*, double** %12
%34 = load i32, i32* %4
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %33, i64 %35
store double* %36, double** %13
%37 = load double*, double** %10
%38 = getelementptr inbounds double, double* %37, i32 1
store double* %38, double** %10
%39 = load double, double* %37
%40 = load double*, double** %12
%41 = getelementptr inbounds double, double* %40, i32 1
store double* %41, double** %12
store double %39, double* %40
%42 = load i32, i32* %7
%43 = add nsw i32 %42, 1
store i32 %43, i32* %8
br label %44
44: ; preds = %66, %26
%45 = load i32, i32* %8
%46 = load i32, i32* %4
%47 = icmp slt i32 %45, %46
br i1 %47, label %48, label %69
48: ; preds = %44
%49 = load double*, double** %11
%50 = load double, double* %49
store double %50, double* %16
%51 = load double*, double** %10
%52 = getelementptr inbounds double, double* %51, i32 1
store double* %52, double** %10
%53 = load double, double* %51
%54 = load double*, double** %13
store double %53, double* %54
%55 = load double, double* %16
%56 = load double*, double** %12
%57 = getelementptr inbounds double, double* %56, i32 1
store double* %57, double** %12
store double %55, double* %56
%58 = load i32, i32* %4
%59 = load double*, double** %11
%60 = sext i32 %58 to i64
%61 = getelementptr inbounds double, double* %59, i64 %60
store double* %61, double** %11
%62 = load i32, i32* %4
%63 = load double*, double** %13
%64 = sext i32 %62 to i64
%65 = getelementptr inbounds double, double* %63, i64 %64
store double* %65, double** %13
br label %66
66: ; preds = %48
%67 = load i32, i32* %8
%68 = add nsw i32 %67, 1
store i32 %68, i32* %8
br label %44
69: ; preds = %44
%70 = load i32, i32* %9
%71 = load double*, double** %14
%72 = sext i32 %70 to i64
%73 = getelementptr inbounds double, double* %71, i64 %72
store double* %73, double** %14
%74 = load i32, i32* %9
%75 = load double*, double** %15
%76 = sext i32 %74 to i64
%77 = getelementptr inbounds double, double* %75, i64 %76
store double* %77, double** %15
br label %78
78: ; preds = %69
%79 = load i32, i32* %7
%80 = add nsw i32 %79, 1
store i32 %80, i32* %7
br label %21
81: ; preds = %21
%82 = load double*, double** %14
%83 = load double, double* %82
%84 = load double*, double** %15
store double %83, double* %84
ret void
}

LLVM IR (-O2):
define void @mtransp(i32 %0, double* nocapture %1, double* nocapture writeonly %2) {
%4 = add i32 %0, -1
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %82
6: ; preds = %3
%7 = add nuw nsw i32 %0, 1
%8 = zext i32 %0 to i64
%9 = zext i32 %7 to i64
%10 = add i32 %0, -2
br label %11
11: ; preds = %6, %78
%12 = phi i32 [ 0, %6 ], [ %17, %78 ]
%13 = phi double* [ %2, %6 ], [ %80, %78 ]
%14 = phi double* [ %1, %6 ], [ %79, %78 ]
%15 = sub i32 %10, %12
%16 = load double, double* %14
store double %16, double* %13
%17 = add nuw nsw i32 %12, 1
%18 = icmp slt i32 %17, %0
br i1 %18, label %19, label %78
19: ; preds = %11
%20 = sub i32 %4, %12
%21 = and i32 %20, 3
%22 = icmp eq i32 %21, 0
br i1 %22, label %39, label %23
23: ; preds = %19, %23
%24 = phi double* [ %33, %23 ], [ %14, %19 ]
%25 = phi double* [ %32, %23 ], [ %13, %19 ]
%26 = phi double* [ %31, %23 ], [ %14, %19 ]
%27 = phi double* [ %30, %23 ], [ %13, %19 ]
%28 = phi i32 [ %36, %23 ], [ %17, %19 ]
%29 = phi i32 [ %37, %23 ], [ 0, %19 ]
%30 = getelementptr inbounds double, double* %27, i64 1
%31 = getelementptr inbounds double, double* %26, i64 1
%32 = getelementptr inbounds double, double* %25, i64 %8
%33 = getelementptr inbounds double, double* %24, i64 %8
%34 = load double, double* %33
%35 = load double, double* %31
store double %35, double* %32
store double %34, double* %30
%36 = add nuw nsw i32 %28, 1
%37 = add i32 %29, 1
%38 = icmp eq i32 %37, %21
br i1 %38, label %39, label %23
39: ; preds = %23, %19
%40 = phi double* [ %14, %19 ], [ %33, %23 ]
%41 = phi double* [ %13, %19 ], [ %32, %23 ]
%42 = phi double* [ %14, %19 ], [ %31, %23 ]
%43 = phi double* [ %13, %19 ], [ %30, %23 ]
%44 = phi i32 [ %17, %19 ], [ %36, %23 ]
%45 = icmp ult i32 %15, 3
br i1 %45, label %78, label %46
46: ; preds = %39, %46
%47 = phi double* [ %73, %46 ], [ %40, %39 ]
%48 = phi double* [ %72, %46 ], [ %41, %39 ]
%49 = phi double* [ %71, %46 ], [ %42, %39 ]
%50 = phi double* [ %70, %46 ], [ %43, %39 ]
%51 = phi i32 [ %76, %46 ], [ %44, %39 ]
%52 = getelementptr inbounds double, double* %50, i64 1
%53 = getelementptr inbounds double, double* %49, i64 1
%54 = getelementptr inbounds double, double* %48, i64 %8
%55 = getelementptr inbounds double, double* %47, i64 %8
%56 = load double, double* %55
%57 = load double, double* %53
store double %57, double* %54
store double %56, double* %52
%58 = getelementptr inbounds double, double* %50, i64 2
%59 = getelementptr inbounds double, double* %49, i64 2
%60 = getelementptr inbounds double, double* %54, i64 %8
%61 = getelementptr inbounds double, double* %55, i64 %8
%62 = load double, double* %61
%63 = load double, double* %59
store double %63, double* %60
store double %62, double* %58
%64 = getelementptr inbounds double, double* %50, i64 3
%65 = getelementptr inbounds double, double* %49, i64 3
%66 = getelementptr inbounds double, double* %60, i64 %8
%67 = getelementptr inbounds double, double* %61, i64 %8
%68 = load double, double* %67
%69 = load double, double* %65
store double %69, double* %66
store double %68, double* %64
%70 = getelementptr inbounds double, double* %50, i64 4
%71 = getelementptr inbounds double, double* %49, i64 4
%72 = getelementptr inbounds double, double* %66, i64 %8
%73 = getelementptr inbounds double, double* %67, i64 %8
%74 = load double, double* %73
%75 = load double, double* %71
store double %75, double* %72
store double %74, double* %70
%76 = add nuw nsw i32 %51, 4
%77 = icmp eq i32 %76, %0
br i1 %77, label %78, label %46
78: ; preds = %39, %46, %11
%79 = getelementptr inbounds double, double* %14, i64 %9
%80 = getelementptr inbounds double, double* %13, i64 %9
%81 = icmp eq i32 %17, %4
br i1 %81, label %82, label %11
82: ; preds = %78, %3
%83 = phi double* [ %1, %3 ], [ %79, %78 ]
%84 = phi double* [ %2, %3 ], [ %80, %78 ]
%85 = load double, double* %83
store double %85, double* %84
ret void
}