#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*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
double **malloc_2d(int, int, int);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  double **test_array;
  int count = 0;
  test_array = malloc_2d(10, 5, sizeof(double));
  if (test_array == NULL) {
    exit(EXIT_FAILURE);
  }
  for (int rows = 0; rows < 10; rows++) {
    for (int columns = 0; columns < 5; columns++) {
      test_array[rows][columns] = count++;
    }
  }
  printf("\n");
  for (int rows = 0; rows < 10; rows++) {
    for (int columns = 0; columns < 5; columns++) {
      printf("%2f ", test_array[rows][columns]);
    }
    printf("\n");
  }
  printf("Test completed succesfully.\n");
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
mov    $0xa,%edi
mov    $0x5,%esi
mov    $0x8,%edx
call   1030 <malloc_2d@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1177 <main+0x47>
mov    0x2e70(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0xa,-0x18(%rbp)
jge    11de <main+0xae>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x5,-0x1c(%rbp)
jge    11cb <main+0x9b>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x14(%rbp)
cvtsi2sd %eax,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    118f <main+0x5f>
jmp    11d0 <main+0xa0>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    117e <main+0x4e>
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x20(%rbp)
cmpl   $0xa,-0x20(%rbp)
jge    125b <main+0x12b>
movl   $0x0,-0x24(%rbp)
cmpl   $0x5,-0x24(%rbp)
jge    123f <main+0x10f>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xdd6(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1204 <main+0xd4>
lea    0xdda(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11f3 <main+0xc3>
lea    0xda3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d68(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0xa,%edi
mov    $0x5,%esi
mov    $0x8,%edx
call   1040 <malloc_2d@plt>
test   %rax,%rax
jne    117c <main+0x2c>
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    %rax,%r14
mov    (%rax),%rax
xorps  %xmm0,%xmm0
movhps 0xe74(%rip),%xmm0
movups %xmm0,(%rax)
movaps 0xe7a(%rip),%xmm0
movups %xmm0,0x10(%rax)
movabs $0x4010000000000000,%rcx
mov    %rcx,0x20(%rax)
mov    0x8(%r14),%rax
movaps 0xe6d(%rip),%xmm0
movups %xmm0,(%rax)
movaps 0xe73(%rip),%xmm0
movups %xmm0,0x10(%rax)
movabs $0x4022000000000000,%rcx
mov    %rcx,0x20(%rax)
mov    0x10(%r14),%rax
movaps 0xe66(%rip),%xmm0
movups %xmm0,(%rax)
movaps 0xe6c(%rip),%xmm0
movups %xmm0,0x10(%rax)
movabs $0x402c000000000000,%rcx
mov    %rcx,0x20(%rax)
mov    0x18(%r14),%rax
movaps 0xe5f(%rip),%xmm0
movups %xmm0,(%rax)
movaps 0xe65(%rip),%xmm0
movups %xmm0,0x10(%rax)
movabs $0x4033000000000000,%rcx
mov    %rcx,0x20(%rax)
mov    0x20(%r14),%rax
movaps 0xe58(%rip),%xmm0
movups %xmm0,(%rax)
movaps 0xe5e(%rip),%xmm0
movups %xmm0,0x10(%rax)
movabs $0x4038000000000000,%rcx
mov    %rcx,0x20(%rax)
mov    0x28(%r14),%rax
movaps 0xe51(%rip),%xmm0
movups %xmm0,(%rax)
movaps 0xe57(%rip),%xmm0
movups %xmm0,0x10(%rax)
movabs $0x403d000000000000,%rcx
mov    %rcx,0x20(%rax)
mov    0x30(%r14),%rax
movaps 0xe4a(%rip),%xmm0
movups %xmm0,(%rax)
movaps 0xe50(%rip),%xmm0
movups %xmm0,0x10(%rax)
movabs $0x4041000000000000,%rcx
mov    %rcx,0x20(%rax)
mov    0x38(%r14),%rax
movaps 0xe43(%rip),%xmm0
movups %xmm0,(%rax)
movaps 0xe49(%rip),%xmm0
movups %xmm0,0x10(%rax)
movabs $0x4043800000000000,%rcx
80 43 40
mov    %rcx,0x20(%rax)
mov    0x40(%r14),%rax
movaps 0xe3c(%rip),%xmm0
movups %xmm0,(%rax)
movaps 0xe42(%rip),%xmm0
movups %xmm0,0x10(%rax)
movabs $0x4046000000000000,%rcx
mov    %rcx,0x20(%rax)
mov    0x48(%r14),%rax
movaps 0xe35(%rip),%xmm0
movups %xmm0,(%rax)
movaps 0xe3b(%rip),%xmm0
movups %xmm0,0x10(%rax)
movabs $0x4048800000000000,%rcx
mov    %rcx,0x20(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebx
lea    0xe26(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    (%r14,%rbx,8),%rax
movsd  (%rax),%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    (%r14,%rbx,8),%rax
movsd  0x8(%rax),%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    (%r14,%rbx,8),%rax
movsd  0x10(%rax),%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    (%r14,%rbx,8),%rax
movsd  0x18(%rax),%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    (%r14,%rbx,8),%rax
movsd  0x20(%rax),%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    $0xa,%rbx
jne    1320 <main+0x1d0>
lea    0xdac(%rip),%rdi
call   1050 <puts@plt>
mov    0x2c33(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

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

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str.1 = [5 x i8] c"%2f \00"
@EXIT_SUCCESS = global i32 0
@str = [28 x i8] c"Test completed succesfully.\00"
define i32 @main() {
%1 = tail call double** @malloc_2d(i32 10, i32 5, i32 8)
%2 = icmp eq double** %1, null
br i1 %2, label %64, label %3
3: ; preds = %0
%4 = load double*, double** %1
%5 = bitcast double* %4 to <2 x double>*
store <2 x double> <double 0.000000e+00, double 1.000000e+00>, <2 x double>* %5
%6 = getelementptr inbounds double, double* %4, i64 2
%7 = bitcast double* %6 to <2 x double>*
store <2 x double> <double 2.000000e+00, double 3.000000e+00>, <2 x double>* %7
%8 = getelementptr inbounds double, double* %4, i64 4
store double 4.000000e+00, double* %8
%9 = getelementptr inbounds double*, double** %1, i64 1
%10 = load double*, double** %9
%11 = bitcast double* %10 to <2 x double>*
store <2 x double> <double 5.000000e+00, double 6.000000e+00>, <2 x double>* %11
%12 = getelementptr inbounds double, double* %10, i64 2
%13 = bitcast double* %12 to <2 x double>*
store <2 x double> <double 7.000000e+00, double 8.000000e+00>, <2 x double>* %13
%14 = getelementptr inbounds double, double* %10, i64 4
store double 9.000000e+00, double* %14
%15 = getelementptr inbounds double*, double** %1, i64 2
%16 = load double*, double** %15
%17 = bitcast double* %16 to <2 x double>*
store <2 x double> <double 1.000000e+01, double 1.100000e+01>, <2 x double>* %17
%18 = getelementptr inbounds double, double* %16, i64 2
%19 = bitcast double* %18 to <2 x double>*
store <2 x double> <double 1.200000e+01, double 1.300000e+01>, <2 x double>* %19
%20 = getelementptr inbounds double, double* %16, i64 4
store double 1.400000e+01, double* %20
%21 = getelementptr inbounds double*, double** %1, i64 3
%22 = load double*, double** %21
%23 = bitcast double* %22 to <2 x double>*
store <2 x double> <double 1.500000e+01, double 1.600000e+01>, <2 x double>* %23
%24 = getelementptr inbounds double, double* %22, i64 2
%25 = bitcast double* %24 to <2 x double>*
store <2 x double> <double 1.700000e+01, double 1.800000e+01>, <2 x double>* %25
%26 = getelementptr inbounds double, double* %22, i64 4
store double 1.900000e+01, double* %26
%27 = getelementptr inbounds double*, double** %1, i64 4
%28 = load double*, double** %27
%29 = bitcast double* %28 to <2 x double>*
store <2 x double> <double 2.000000e+01, double 2.100000e+01>, <2 x double>* %29
%30 = getelementptr inbounds double, double* %28, i64 2
%31 = bitcast double* %30 to <2 x double>*
store <2 x double> <double 2.200000e+01, double 2.300000e+01>, <2 x double>* %31
%32 = getelementptr inbounds double, double* %28, i64 4
store double 2.400000e+01, double* %32
%33 = getelementptr inbounds double*, double** %1, i64 5
%34 = load double*, double** %33
%35 = bitcast double* %34 to <2 x double>*
store <2 x double> <double 2.500000e+01, double 2.600000e+01>, <2 x double>* %35
%36 = getelementptr inbounds double, double* %34, i64 2
%37 = bitcast double* %36 to <2 x double>*
store <2 x double> <double 2.700000e+01, double 2.800000e+01>, <2 x double>* %37
%38 = getelementptr inbounds double, double* %34, i64 4
store double 2.900000e+01, double* %38
%39 = getelementptr inbounds double*, double** %1, i64 6
%40 = load double*, double** %39
%41 = bitcast double* %40 to <2 x double>*
store <2 x double> <double 3.000000e+01, double 3.100000e+01>, <2 x double>* %41
%42 = getelementptr inbounds double, double* %40, i64 2
%43 = bitcast double* %42 to <2 x double>*
store <2 x double> <double 3.200000e+01, double 3.300000e+01>, <2 x double>* %43
%44 = getelementptr inbounds double, double* %40, i64 4
store double 3.400000e+01, double* %44
%45 = getelementptr inbounds double*, double** %1, i64 7
%46 = load double*, double** %45
%47 = bitcast double* %46 to <2 x double>*
store <2 x double> <double 3.500000e+01, double 3.600000e+01>, <2 x double>* %47
%48 = getelementptr inbounds double, double* %46, i64 2
%49 = bitcast double* %48 to <2 x double>*
store <2 x double> <double 3.700000e+01, double 3.800000e+01>, <2 x double>* %49
%50 = getelementptr inbounds double, double* %46, i64 4
store double 3.900000e+01, double* %50
%51 = getelementptr inbounds double*, double** %1, i64 8
%52 = load double*, double** %51
%53 = bitcast double* %52 to <2 x double>*
store <2 x double> <double 4.000000e+01, double 4.100000e+01>, <2 x double>* %53
%54 = getelementptr inbounds double, double* %52, i64 2
%55 = bitcast double* %54 to <2 x double>*
store <2 x double> <double 4.200000e+01, double 4.300000e+01>, <2 x double>* %55
%56 = getelementptr inbounds double, double* %52, i64 4
store double 4.400000e+01, double* %56
%57 = getelementptr inbounds double*, double** %1, i64 9
%58 = load double*, double** %57
%59 = bitcast double* %58 to <2 x double>*
store <2 x double> <double 4.500000e+01, double 4.600000e+01>, <2 x double>* %59
%60 = getelementptr inbounds double, double* %58, i64 2
%61 = bitcast double* %60 to <2 x double>*
store <2 x double> <double 4.700000e+01, double 4.800000e+01>, <2 x double>* %61
%62 = getelementptr inbounds double, double* %58, i64 4
store double 4.900000e+01, double* %62
%63 = tail call i32 @putchar(i32 10)
br label %67
64: ; preds = %0
%65 = load i32, i32* @EXIT_FAILURE
%66 = tail call i32 @exit(i32 %65)
unreachable
67: ; preds = %3, %67
%68 = phi i64 [ 0, %3 ], [ %90, %67 ]
%69 = getelementptr inbounds double*, double** %1, i64 %68
%70 = load double*, double** %69
%71 = load double, double* %70
%72 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double %71)
%73 = load double*, double** %69
%74 = getelementptr inbounds double, double* %73, i64 1
%75 = load double, double* %74
%76 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double %75)
%77 = load double*, double** %69
%78 = getelementptr inbounds double, double* %77, i64 2
%79 = load double, double* %78
%80 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double %79)
%81 = load double*, double** %69
%82 = getelementptr inbounds double, double* %81, i64 3
%83 = load double, double* %82
%84 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double %83)
%85 = load double*, double** %69
%86 = getelementptr inbounds double, double* %85, i64 4
%87 = load double, double* %86
%88 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double %87)
%89 = tail call i32 @putchar(i32 10)
%90 = add nuw nsw i64 %68, 1
%91 = icmp eq i64 %90, 10
br i1 %91, label %92, label %67
92: ; preds = %67
%93 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%94 = load i32, i32* @EXIT_SUCCESS
%95 = tail call i32 @exit(i32 %94)
unreachable
}