#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 **array2dNcAlloc(int, int);
int /*<<< orphan*/ array2dNcFree(double **, int);
int /*<<< orphan*/ printf(char *, double);
int main() {
  int dim1 = 50;
  int dim2 = 100;
  int i, j;
  double **array = array2dNcAlloc(dim1, dim2);
  for (i = 1; i < dim1; i++) {
    for (j = 1; j < dim2; j++) {
      array[i][j] = i * j;
    }
  }
  for (i = 1; i < dim1; i++) {
    for (j = 1; j < dim2; j++) {
      printf("%f\n", array[i][j]);
    }
  }
  array2dNcFree(array, dim1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x32,-0x8(%rbp)
movl   $0x64,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <array2dNcAlloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11c3 <main+0x93>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b0 <main+0x80>
mov    -0x10(%rbp),%eax
imul   -0x14(%rbp),%eax
cvtsi2sd %eax,%xmm0
mov    -0x20(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1176 <main+0x46>
jmp    11b5 <main+0x85>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1163 <main+0x33>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    122b <main+0xfb>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1218 <main+0xe8>
mov    -0x20(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xdfb(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11dd <main+0xad>
jmp    121d <main+0xed>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11ca <main+0x9a>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1030 <array2dNcFree@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0x32,%edi
mov    $0x64,%esi
call   1050 <array2dNcAlloc@plt>
mov    %rax,%r14
mov    $0x1,%r9d
mov    $0x3,%eax
mov    $0x2,%r8d
nopl   0x0(%rax,%rax,1)
mov    (%r14,%r9,8),%rsi
mov    $0x3,%edi
mov    %r8d,%edx
mov    %r9d,%ebx
mov    %eax,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  %xmm0,-0x10(%rsi,%rdi,8)
xorps  %xmm0,%xmm0
cvtsi2sd %edx,%xmm0
movsd  %xmm0,-0x8(%rsi,%rdi,8)
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
movsd  %xmm0,(%rsi,%rdi,8)
add    $0x3,%rdi
add    %eax,%ecx
add    %eax,%ebx
add    %eax,%edx
cmp    $0x66,%rdi
jne    1180 <main+0x50>
add    $0x1,%r9
add    $0x3,%eax
add    $0x2,%r8d
cmp    $0x32,%r9
jne    1160 <main+0x30>
mov    $0x1,%r12d
lea    0xe2c(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r14,%r12,8),%rax
movsd  (%rax,%rbx,8),%xmm0
mov    %r15,%rdi
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    11f0 <main+0xc0>
add    $0x1,%r12
cmp    $0x32,%r12
jne    11e0 <main+0xb0>
mov    %r14,%rdi
mov    $0x32,%esi
call   1030 <array2dNcFree@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%f\0A\00"
define i32 @main() {
%1 = tail call double** @array2dNcAlloc(i32 50, i32 100)
br label %2
2: ; preds = %0, %24
%3 = phi i64 [ 1, %0 ], [ %25, %24 ]
%4 = getelementptr inbounds double*, double** %1, i64 %3
%5 = load double*, double** %4
br label %6
6: ; preds = %6, %2
%7 = phi i64 [ 1, %2 ], [ %22, %6 ]
%8 = mul nuw nsw i64 %7, %3
%9 = trunc i64 %8 to i32
%10 = sitofp i32 %9 to double
%11 = getelementptr inbounds double, double* %5, i64 %7
store double %10, double* %11
%12 = add nuw nsw i64 %7, 1
%13 = mul nuw nsw i64 %12, %3
%14 = trunc i64 %13 to i32
%15 = sitofp i32 %14 to double
%16 = getelementptr inbounds double, double* %5, i64 %12
store double %15, double* %16
%17 = add nuw nsw i64 %7, 2
%18 = mul nuw nsw i64 %17, %3
%19 = trunc i64 %18 to i32
%20 = sitofp i32 %19 to double
%21 = getelementptr inbounds double, double* %5, i64 %17
store double %20, double* %21
%22 = add nuw nsw i64 %7, 3
%23 = icmp eq i64 %22, 100
br i1 %23, label %24, label %6
24: ; preds = %6
%25 = add nuw nsw i64 %3, 1
%26 = icmp eq i64 %25, 50
br i1 %26, label %27, label %2
27: ; preds = %24, %38
%28 = phi i64 [ %39, %38 ], [ 1, %24 ]
%29 = getelementptr inbounds double*, double** %1, i64 %28
br label %30
30: ; preds = %27, %30
%31 = phi i64 [ 1, %27 ], [ %36, %30 ]
%32 = load double*, double** %29
%33 = getelementptr inbounds double, double* %32, i64 %31
%34 = load double, double* %33
%35 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %34)
%36 = add nuw nsw i64 %31, 1
%37 = icmp eq i64 %36, 100
br i1 %37, label %38, label %30
38: ; preds = %30
%39 = add nuw nsw i64 %28, 1
%40 = icmp eq i64 %39, 50
br i1 %40, label %41, label %27
41: ; preds = %38
%42 = tail call i32 @array2dNcFree(double** %1, i32 50)
ret i32 0
}