#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 */
scalar_t__ calloc(int, int);
double **array_to_double_pointer(double array[][1024], int n, int m) {
  double **output = (double **)calloc(n, sizeof(double *));
  for (int i = 0; i < n; i++) {
    output[i] = (double *)calloc(m, sizeof(double));
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      output[i][j] = array[i][j];
    }
  }
  return output;
}


x86 assembly (clang, -O0):
<array_to_double_pointer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1170 <array_to_double_pointer+0x60>
mov    -0x10(%rbp),%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113a <array_to_double_pointer+0x2a>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11e4 <array_to_double_pointer+0xd4>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11d1 <array_to_double_pointer+0xc1>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
shl    $0xd,%rcx
add    %rcx,%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    118a <array_to_double_pointer+0x7a>
jmp    11d6 <array_to_double_pointer+0xc6>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1177 <array_to_double_pointer+0x67>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<array_to_double_pointer>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %edx,%r14d
mov    %esi,%r12d
mov    %rdi,0x8(%rsp)
mov    %esi,%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,%r15
test   %r12d,%r12d
jle    136c <array_to_double_pointer+0x25c>
mov    %r12d,%r13d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    %r14d,%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1150 <array_to_double_pointer+0x40>
test   %r12d,%r12d
jle    136c <array_to_double_pointer+0x25c>
mov    %r14d,%eax
mov    %eax,%r8d
and    $0xfffffffc,%r8d
lea    -0x4(%r8),%rcx
mov    %rcx,0x20(%rsp)
shr    $0x2,%rcx
add    $0x1,%rcx
mov    %ecx,%r9d
and    $0x3,%r9d
and    $0xfffffffffffffffc,%rcx
mov    %rcx,0x10(%rsp)
mov    %eax,%r12d
and    $0x3,%r12d
mov    0x8(%rsp),%rdx
lea    0x70(%rdx),%rdi
mov    %r9,0x18(%rsp)
shl    $0x5,%r9
xor    %r10d,%r10d
jmp    11db <array_to_double_pointer+0xcb>
nopl   0x0(%rax)
add    $0x1,%r10
add    $0x2000,%rdi
add    $0x2000,%rdx
cmp    %r13,%r10
je     136c <array_to_double_pointer+0x25c>
test   %r14d,%r14d
jle    11c0 <array_to_double_pointer+0xb0>
mov    (%r15,%r10,8),%rbp
cmp    $0x4,%r14d
jb     1217 <array_to_double_pointer+0x107>
mov    %r10,%rcx
shl    $0xd,%rcx
add    0x8(%rsp),%rcx
lea    (%rcx,%rax,8),%rsi
cmp    %rsi,%rbp
jae    12a5 <array_to_double_pointer+0x195>
lea    0x0(,%rax,8),%rsi
add    %rbp,%rsi
cmp    %rsi,%rcx
jae    12a5 <array_to_double_pointer+0x195>
xor    %r11d,%r11d
mov    %r11,%rsi
not    %rsi
add    %rax,%rsi
test   %r12,%r12
je     1247 <array_to_double_pointer+0x137>
mov    %r12,%rbx
nopl   0x0(%rax,%rax,1)
movsd  (%rdx,%r11,8),%xmm0
movsd  %xmm0,0x0(%rbp,%r11,8)
add    $0x1,%r11
add    $0xffffffffffffffff,%rbx
jne    1230 <array_to_double_pointer+0x120>
cmp    $0x3,%rsi
jb     11c0 <array_to_double_pointer+0xb0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  (%rdx,%r11,8),%xmm0
movsd  %xmm0,0x0(%rbp,%r11,8)
movsd  0x8(%rdx,%r11,8),%xmm0
movsd  %xmm0,0x8(%rbp,%r11,8)
movsd  0x10(%rdx,%r11,8),%xmm0
movsd  %xmm0,0x10(%rbp,%r11,8)
movsd  0x18(%rdx,%r11,8),%xmm0
movsd  %xmm0,0x18(%rbp,%r11,8)
add    $0x4,%r11
cmp    %r11,%rax
jne    1260 <array_to_double_pointer+0x150>
jmp    11c0 <array_to_double_pointer+0xb0>
cmpq   $0xc,0x20(%rsp)
jae    12b1 <array_to_double_pointer+0x1a1>
xor    %ebx,%ebx
jmp    1319 <array_to_double_pointer+0x209>
mov    0x10(%rsp),%rsi
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movups -0x70(%rdi,%rbx,8),%xmm0
movups -0x60(%rdi,%rbx,8),%xmm1
movups %xmm0,0x0(%rbp,%rbx,8)
movups %xmm1,0x10(%rbp,%rbx,8)
movups -0x50(%rdi,%rbx,8),%xmm0
movups -0x40(%rdi,%rbx,8),%xmm1
movups %xmm0,0x20(%rbp,%rbx,8)
movups %xmm1,0x30(%rbp,%rbx,8)
movups -0x30(%rdi,%rbx,8),%xmm0
movups -0x20(%rdi,%rbx,8),%xmm1
movups %xmm0,0x40(%rbp,%rbx,8)
movups %xmm1,0x50(%rbp,%rbx,8)
movups -0x10(%rdi,%rbx,8),%xmm0
movups (%rdi,%rbx,8),%xmm1
movups %xmm0,0x60(%rbp,%rbx,8)
movups %xmm1,0x70(%rbp,%rbx,8)
add    $0x10,%rbx
add    $0xfffffffffffffffc,%rsi
jne    12c0 <array_to_double_pointer+0x1b0>
cmpq   $0x0,0x18(%rsp)
je     135b <array_to_double_pointer+0x24b>
lea    0x10(,%rbx,8),%rsi
add    %rbp,%rsi
lea    (%rdx,%rbx,8),%rbx
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movups (%rbx,%rcx,1),%xmm0
movups 0x10(%rbx,%rcx,1),%xmm1
movups %xmm0,-0x10(%rsi,%rcx,1)
movups %xmm1,(%rsi,%rcx,1)
add    $0x20,%rcx
cmp    %rcx,%r9
jne    1340 <array_to_double_pointer+0x230>
mov    %r8,%r11
cmp    %rax,%r8
je     11c0 <array_to_double_pointer+0xb0>
jmp    121a <array_to_double_pointer+0x10a>
mov    %r15,%rax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define double** @array_to_double_pointer([1024 x double]* nocapture %0, i32 %1, i32 %2) {
%4 = tail call i64 @calloc(i32 %1, i32 8)
%5 = inttoptr i64 %4 to double**
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %131
7: ; preds = %3
%8 = zext i32 %1 to i64
br label %27
9: ; preds = %27
br i1 %6, label %10, label %131
10: ; preds = %9
%11 = icmp sgt i32 %2, 0
%12 = zext i32 %1 to i64
%13 = zext i32 %2 to i64
%14 = and i64 %13, 4294967292
%15 = add nsw i64 %14, -4
%16 = lshr exact i64 %15, 2
%17 = add nuw nsw i64 %16, 1
%18 = icmp ult i32 %2, 4
%19 = and i64 %13, 4294967292
%20 = and i64 %17, 3
%21 = icmp ult i64 %15, 12
%22 = and i64 %17, 9223372036854775804
%23 = icmp eq i64 %20, 0
%24 = icmp eq i64 %19, %13
%25 = and i64 %13, 3
%26 = icmp eq i64 %25, 0
br label %34
27: ; preds = %7, %27
%28 = phi i64 [ 0, %7 ], [ %32, %27 ]
%29 = tail call i64 @calloc(i32 %2, i32 8)
%30 = inttoptr i64 %29 to double*
%31 = getelementptr inbounds double*, double** %5, i64 %28
store double* %30, double** %31
%32 = add nuw nsw i64 %28, 1
%33 = icmp eq i64 %32, %8
br i1 %33, label %9, label %27
34: ; preds = %10, %132
%35 = phi i64 [ 0, %10 ], [ %133, %132 ]
%36 = getelementptr [1024 x double], [1024 x double]* %0, i64 %35, i64 0
%37 = getelementptr [1024 x double], [1024 x double]* %0, i64 %35, i64 %13
br i1 %11, label %38, label %132
38: ; preds = %34
%39 = getelementptr inbounds double*, double** %5, i64 %35
%40 = load double*, double** %39
br i1 %18, label %115, label %41
41: ; preds = %38
%42 = getelementptr double, double* %40, i64 %13
%43 = icmp ult double* %40, %37
%44 = icmp ult double* %36, %42
%45 = and i1 %43, %44
br i1 %45, label %115, label %46
46: ; preds = %41
br i1 %21, label %96, label %47
47: ; preds = %46, %47
%48 = phi i64 [ %93, %47 ], [ 0, %46 ]
%49 = phi i64 [ %94, %47 ], [ 0, %46 ]
%50 = getelementptr inbounds [1024 x double], [1024 x double]* %0, i64 %35, i64 %48
%51 = bitcast double* %50 to <2 x double>*
%52 = load <2 x double>, <2 x double>* %51
%53 = getelementptr inbounds double, double* %50, i64 2
%54 = bitcast double* %53 to <2 x double>*
%55 = load <2 x double>, <2 x double>* %54
%56 = getelementptr inbounds double, double* %40, i64 %48
%57 = bitcast double* %56 to <2 x double>*
store <2 x double> %52, <2 x double>* %57
%58 = getelementptr inbounds double, double* %56, i64 2
%59 = bitcast double* %58 to <2 x double>*
store <2 x double> %55, <2 x double>* %59
%60 = or i64 %48, 4
%61 = getelementptr inbounds [1024 x double], [1024 x double]* %0, i64 %35, i64 %60
%62 = bitcast double* %61 to <2 x double>*
%63 = load <2 x double>, <2 x double>* %62
%64 = getelementptr inbounds double, double* %61, i64 2
%65 = bitcast double* %64 to <2 x double>*
%66 = load <2 x double>, <2 x double>* %65
%67 = getelementptr inbounds double, double* %40, i64 %60
%68 = bitcast double* %67 to <2 x double>*
store <2 x double> %63, <2 x double>* %68
%69 = getelementptr inbounds double, double* %67, i64 2
%70 = bitcast double* %69 to <2 x double>*
store <2 x double> %66, <2 x double>* %70
%71 = or i64 %48, 8
%72 = getelementptr inbounds [1024 x double], [1024 x double]* %0, i64 %35, i64 %71
%73 = bitcast double* %72 to <2 x double>*
%74 = load <2 x double>, <2 x double>* %73
%75 = getelementptr inbounds double, double* %72, i64 2
%76 = bitcast double* %75 to <2 x double>*
%77 = load <2 x double>, <2 x double>* %76
%78 = getelementptr inbounds double, double* %40, i64 %71
%79 = bitcast double* %78 to <2 x double>*
store <2 x double> %74, <2 x double>* %79
%80 = getelementptr inbounds double, double* %78, i64 2
%81 = bitcast double* %80 to <2 x double>*
store <2 x double> %77, <2 x double>* %81
%82 = or i64 %48, 12
%83 = getelementptr inbounds [1024 x double], [1024 x double]* %0, i64 %35, i64 %82
%84 = bitcast double* %83 to <2 x double>*
%85 = load <2 x double>, <2 x double>* %84
%86 = getelementptr inbounds double, double* %83, i64 2
%87 = bitcast double* %86 to <2 x double>*
%88 = load <2 x double>, <2 x double>* %87
%89 = getelementptr inbounds double, double* %40, i64 %82
%90 = bitcast double* %89 to <2 x double>*
store <2 x double> %85, <2 x double>* %90
%91 = getelementptr inbounds double, double* %89, i64 2
%92 = bitcast double* %91 to <2 x double>*
store <2 x double> %88, <2 x double>* %92
%93 = add nuw i64 %48, 16
%94 = add nuw i64 %49, 4
%95 = icmp eq i64 %94, %22
br i1 %95, label %96, label %47
96: ; preds = %47, %46
%97 = phi i64 [ 0, %46 ], [ %93, %47 ]
br i1 %23, label %114, label %98
98: ; preds = %96, %98
%99 = phi i64 [ %111, %98 ], [ %97, %96 ]
%100 = phi i64 [ %112, %98 ], [ 0, %96 ]
%101 = getelementptr inbounds [1024 x double], [1024 x double]* %0, i64 %35, i64 %99
%102 = bitcast double* %101 to <2 x double>*
%103 = load <2 x double>, <2 x double>* %102
%104 = getelementptr inbounds double, double* %101, i64 2
%105 = bitcast double* %104 to <2 x double>*
%106 = load <2 x double>, <2 x double>* %105
%107 = getelementptr inbounds double, double* %40, i64 %99
%108 = bitcast double* %107 to <2 x double>*
store <2 x double> %103, <2 x double>* %108
%109 = getelementptr inbounds double, double* %107, i64 2
%110 = bitcast double* %109 to <2 x double>*
store <2 x double> %106, <2 x double>* %110
%111 = add nuw i64 %99, 4
%112 = add i64 %100, 1
%113 = icmp eq i64 %112, %20
br i1 %113, label %114, label %98
114: ; preds = %98, %96
br i1 %24, label %132, label %115
115: ; preds = %41, %38, %114
%116 = phi i64 [ 0, %41 ], [ 0, %38 ], [ %19, %114 ]
%117 = xor i64 %116, -1
%118 = add nsw i64 %117, %13
br i1 %26, label %128, label %119
119: ; preds = %115, %119
%120 = phi i64 [ %125, %119 ], [ %116, %115 ]
%121 = phi i64 [ %126, %119 ], [ 0, %115 ]
%122 = getelementptr inbounds [1024 x double], [1024 x double]* %0, i64 %35, i64 %120
%123 = load double, double* %122
%124 = getelementptr inbounds double, double* %40, i64 %120
store double %123, double* %124
%125 = add nuw nsw i64 %120, 1
%126 = add i64 %121, 1
%127 = icmp eq i64 %126, %25
br i1 %127, label %128, label %119
128: ; preds = %119, %115
%129 = phi i64 [ %116, %115 ], [ %125, %119 ]
%130 = icmp ult i64 %118, 3
br i1 %130, label %132, label %135
131: ; preds = %132, %3, %9
ret double** %5
132: ; preds = %128, %135, %114, %34
%133 = add nuw nsw i64 %35, 1
%134 = icmp eq i64 %133, %12
br i1 %134, label %131, label %34
135: ; preds = %128, %135
%136 = phi i64 [ %152, %135 ], [ %129, %128 ]
%137 = getelementptr inbounds [1024 x double], [1024 x double]* %0, i64 %35, i64 %136
%138 = load double, double* %137
%139 = getelementptr inbounds double, double* %40, i64 %136
store double %138, double* %139
%140 = add nuw nsw i64 %136, 1
%141 = getelementptr inbounds [1024 x double], [1024 x double]* %0, i64 %35, i64 %140
%142 = load double, double* %141
%143 = getelementptr inbounds double, double* %40, i64 %140
store double %142, double* %143
%144 = add nuw nsw i64 %136, 2
%145 = getelementptr inbounds [1024 x double], [1024 x double]* %0, i64 %35, i64 %144
%146 = load double, double* %145
%147 = getelementptr inbounds double, double* %40, i64 %144
store double %146, double* %147
%148 = add nuw nsw i64 %136, 3
%149 = getelementptr inbounds [1024 x double], [1024 x double]* %0, i64 %35, i64 %148
%150 = load double, double* %149
%151 = getelementptr inbounds double, double* %40, i64 %148
store double %150, double* %151
%152 = add nuw nsw i64 %136, 4
%153 = icmp eq i64 %152, %13
br i1 %153, label %132, label %135
}