#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ swap(double *, double *);
void transpose(int n, double A[][800]) {
  int i, j;
  for (i = 0; i < n; i++)
    for (j = i + 1; j < n; j++)
      swap(&A[i][j], &A[j][i]);
}


x86 assembly (clang, -O0):
<transpose>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11a7 <transpose+0x97>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1194 <transpose+0x84>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
imul   $0x1900,%rax,%rax
add    %rax,%rdi
movslq -0x18(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
movslq -0x18(%rbp),%rax
imul   $0x1900,%rax,%rax
add    %rax,%rsi
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
call   1030 <swap@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113b <transpose+0x2b>
jmp    1199 <transpose+0x89>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1126 <transpose+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<transpose>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %edi,%edi
jle    11a1 <transpose+0x91>
mov    %rsi,%r14
mov    %edi,%eax
lea    0x8(%rsi),%r13
add    $0x1900,%r14
mov    $0x1,%ebp
xor    %ecx,%ecx
mov    %rax,0x8(%rsp)
jmp    1161 <transpose+0x51>
add    $0x1,%rbp
add    $0x1908,%r13
add    $0x1908,%r14
mov    0x8(%rsp),%rax
mov    0x10(%rsp),%rcx
cmp    %rax,%rcx
je     11a1 <transpose+0x91>
add    $0x1,%rcx
mov    %rcx,0x10(%rsp)
cmp    %rax,%rcx
jae    1140 <transpose+0x30>
mov    0x8(%rsp),%r12
mov    %r14,%r15
mov    %r13,%rbx
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <swap@plt>
add    $0x8,%rbx
add    $0x1900,%r15
add    $0xffffffffffffffff,%r12
cmp    %r12,%rbp
jne    1180 <transpose+0x70>
jmp    1140 <transpose+0x30>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @transpose(i32 %0, [800 x double]* %1) {
%3 = alloca i32
%4 = alloca [800 x double]*
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store [800 x double]* %1, [800 x double]** %4
store i32 0, i32* %5
br label %7
7: ; preds = %38, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %3
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %41
11: ; preds = %7
%12 = load i32, i32* %5
%13 = add nsw i32 %12, 1
store i32 %13, i32* %6
br label %14
14: ; preds = %34, %11
%15 = load i32, i32* %6
%16 = load i32, i32* %3
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %37
18: ; preds = %14
%19 = load [800 x double]*, [800 x double]** %4
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [800 x double], [800 x double]* %19, i64 %21
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [800 x double], [800 x double]* %22, i64 0, i64 %24
%26 = load [800 x double]*, [800 x double]** %4
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [800 x double], [800 x double]* %26, i64 %28
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [800 x double], [800 x double]* %29, i64 0, i64 %31
%33 = call i32 @swap(double* %25, double* %32)
br label %34
34: ; preds = %18
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
br label %14
37: ; preds = %14
br label %38
38: ; preds = %37
%39 = load i32, i32* %5
%40 = add nsw i32 %39, 1
store i32 %40, i32* %5
br label %7
41: ; preds = %7
ret void
}

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