mtransp(n, A, T) int n;
double *A, *T;
{
  int i, j, np1;
  double *pAc, *pAr, *pTc, *pTr, *pA0, *pT0;
  double x, y;
  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,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%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    -0x8(%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 -0x8(%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 -0x8(%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    -0x8(%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    -0x8(%rbp),%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%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)
mov    -0x4(%rbp),%eax
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 i32 @mtransp(i32 %0, double* %1, double* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca double*
%7 = alloca double*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
%15 = alloca double*
%16 = alloca double*
%17 = alloca double
%18 = alloca double
store i32 %0, i32* %5
store double* %1, double** %6
store double* %2, double** %7
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %10
%21 = load double*, double** %6
store double* %21, double** %15
%22 = load double*, double** %7
store double* %22, double** %16
store i32 0, i32* %8
br label %23
23: ; preds = %80, %3
%24 = load i32, i32* %8
%25 = load i32, i32* %5
%26 = sub nsw i32 %25, 1
%27 = icmp slt i32 %24, %26
br i1 %27, label %28, label %83
28: ; preds = %23
%29 = load double*, double** %15
store double* %29, double** %11
%30 = load double*, double** %11
%31 = load i32, i32* %5
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %30, i64 %32
store double* %33, double** %12
%34 = load double*, double** %16
store double* %34, double** %13
%35 = load double*, double** %13
%36 = load i32, i32* %5
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %35, i64 %37
store double* %38, double** %14
%39 = load double*, double** %11
%40 = getelementptr inbounds double, double* %39, i32 1
store double* %40, double** %11
%41 = load double, double* %39
%42 = load double*, double** %13
%43 = getelementptr inbounds double, double* %42, i32 1
store double* %43, double** %13
store double %41, double* %42
%44 = load i32, i32* %8
%45 = add nsw i32 %44, 1
store i32 %45, i32* %9
br label %46
46: ; preds = %68, %28
%47 = load i32, i32* %9
%48 = load i32, i32* %5
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %71
50: ; preds = %46
%51 = load double*, double** %12
%52 = load double, double* %51
store double %52, double* %17
%53 = load double*, double** %11
%54 = getelementptr inbounds double, double* %53, i32 1
store double* %54, double** %11
%55 = load double, double* %53
%56 = load double*, double** %14
store double %55, double* %56
%57 = load double, double* %17
%58 = load double*, double** %13
%59 = getelementptr inbounds double, double* %58, i32 1
store double* %59, double** %13
store double %57, double* %58
%60 = load i32, i32* %5
%61 = load double*, double** %12
%62 = sext i32 %60 to i64
%63 = getelementptr inbounds double, double* %61, i64 %62
store double* %63, double** %12
%64 = load i32, i32* %5
%65 = load double*, double** %14
%66 = sext i32 %64 to i64
%67 = getelementptr inbounds double, double* %65, i64 %66
store double* %67, double** %14
br label %68
68: ; preds = %50
%69 = load i32, i32* %9
%70 = add nsw i32 %69, 1
store i32 %70, i32* %9
br label %46
71: ; preds = %46
%72 = load i32, i32* %10
%73 = load double*, double** %15
%74 = sext i32 %72 to i64
%75 = getelementptr inbounds double, double* %73, i64 %74
store double* %75, double** %15
%76 = load i32, i32* %10
%77 = load double*, double** %16
%78 = sext i32 %76 to i64
%79 = getelementptr inbounds double, double* %77, i64 %78
store double* %79, double** %16
br label %80
80: ; preds = %71
%81 = load i32, i32* %8
%82 = add nsw i32 %81, 1
store i32 %82, i32* %8
br label %23
83: ; preds = %23
%84 = load double*, double** %15
%85 = load double, double* %84
%86 = load double*, double** %16
store double %85, double* %86
%87 = load i32, i32* %4
ret i32 %87
}

LLVM IR (-O2):
define i32 @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 i32 undef
}