#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 */
double **get_double_matrix(int, int);
double **transpose_double_matrix(double **a, int m, int n) {
  double **at = get_double_matrix(n + 1, m + 1);
  int i, j;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      at[i][j] = a[j][i];
    }
  }
  return at;
}


x86 assembly (clang, -O0):
<transpose_double_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%edi
add    $0x1,%edi
mov    -0xc(%rbp),%esi
add    $0x1,%esi
call   1030 <get_double_matrix@plt>
mov    %rax,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     11a8 <transpose_double_matrix+0x98>
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1195 <transpose_double_matrix+0x85>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1151 <transpose_double_matrix+0x41>
jmp    119a <transpose_double_matrix+0x8a>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113e <transpose_double_matrix+0x2e>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<transpose_double_matrix>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%ebp
mov    %esi,%r14d
mov    %rdi,%rbx
lea    0x1(%rbp),%r12d
lea    0x1(%r14),%r15d
mov    %r12d,%edi
mov    %r15d,%esi
call   1030 <get_double_matrix@plt>
test   %ebp,%ebp
jle    120c <transpose_double_matrix+0xfc>
mov    %r12d,%r9d
mov    %r15d,%r8d
lea    -0x1(%r8),%r10
add    $0xfffffffffffffffe,%r8
mov    %r10d,%r11d
and    $0x3,%r11d
and    $0xfffffffffffffffc,%r10
mov    $0x1,%ebp
jmp    116d <transpose_double_matrix+0x5d>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    %r9,%rbp
je     120c <transpose_double_matrix+0xfc>
test   %r14d,%r14d
jle    1160 <transpose_double_matrix+0x50>
mov    (%rax,%rbp,8),%rdx
mov    $0x1,%ecx
cmp    $0x3,%r8
jb     11dd <transpose_double_matrix+0xcd>
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x8(%rbx,%rcx,8),%rsi
movsd  (%rsi,%rbp,8),%xmm0
movsd  %xmm0,0x8(%rdx,%rcx,8)
mov    0x10(%rbx,%rcx,8),%rsi
movsd  (%rsi,%rbp,8),%xmm0
movsd  %xmm0,0x10(%rdx,%rcx,8)
mov    0x18(%rbx,%rcx,8),%rsi
movsd  (%rsi,%rbp,8),%xmm0
movsd  %xmm0,0x18(%rdx,%rcx,8)
mov    0x20(%rbx,%rcx,8),%rsi
movsd  (%rsi,%rbp,8),%xmm0
movsd  %xmm0,0x20(%rdx,%rcx,8)
add    $0x4,%rcx
cmp    %rcx,%r10
jne    1190 <transpose_double_matrix+0x80>
add    $0x1,%rcx
test   %r11,%r11
je     1160 <transpose_double_matrix+0x50>
lea    (%rdx,%rcx,8),%rdx
lea    (%rbx,%rcx,8),%rcx
xor    %esi,%esi
mov    (%rcx,%rsi,8),%rdi
movsd  (%rdi,%rbp,8),%xmm0
movsd  %xmm0,(%rdx,%rsi,8)
add    $0x1,%rsi
cmp    %rsi,%r11
jne    11f0 <transpose_double_matrix+0xe0>
jmp    1160 <transpose_double_matrix+0x50>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double** @transpose_double_matrix(double** %0, i32 %1, i32 %2) {
%4 = alloca double**
%5 = alloca i32
%6 = alloca i32
%7 = alloca double**
%8 = alloca i32
%9 = alloca i32
store double** %0, double*** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%10 = load i32, i32* %6
%11 = add nsw i32 %10, 1
%12 = load i32, i32* %5
%13 = add nsw i32 %12, 1
%14 = call double** @get_double_matrix(i32 %11, i32 %13)
store double** %14, double*** %7
store i32 1, i32* %8
br label %15
15: ; preds = %46, %3
%16 = load i32, i32* %8
%17 = load i32, i32* %6
%18 = icmp sle i32 %16, %17
br i1 %18, label %19, label %49
19: ; preds = %15
store i32 1, i32* %9
br label %20
20: ; preds = %42, %19
%21 = load i32, i32* %9
%22 = load i32, i32* %5
%23 = icmp sle i32 %21, %22
br i1 %23, label %24, label %45
24: ; preds = %20
%25 = load double**, double*** %4
%26 = load i32, i32* %9
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double*, double** %25, i64 %27
%29 = load double*, double** %28
%30 = load i32, i32* %8
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
%33 = load double, double* %32
%34 = load double**, double*** %7
%35 = load i32, i32* %8
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double*, double** %34, i64 %36
%38 = load double*, double** %37
%39 = load i32, i32* %9
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %38, i64 %40
store double %33, double* %41
br label %42
42: ; preds = %24
%43 = load i32, i32* %9
%44 = add nsw i32 %43, 1
store i32 %44, i32* %9
br label %20
45: ; preds = %20
br label %46
46: ; preds = %45
%47 = load i32, i32* %8
%48 = add nsw i32 %47, 1
store i32 %48, i32* %8
br label %15
49: ; preds = %15
%50 = load double**, double*** %7
ret double** %50
}

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