#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 add(double **, int, int);
double **allocMem(int, int);
int /*<<< orphan*/ initMem(double **, int, int);
int /*<<< orphan*/ print(double **, int, int);
int /*<<< orphan*/ printf(char *, double);
int main() {
  double **a = allocMem(2, 2);
  print(a, 2, 2);
  initMem(a, 2, 2);
  a[0][0] = 1;
  a[0][1] = 2;
  a[1][0] = 0;
  a[1][1] = 3;
  print(a, 2, 2);
  printf("%f", add(a, 2, 2));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x2,%esi
mov    %esi,%edi
call   1070 <allocMem@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2,%edx
mov    %edx,%esi
call   1060 <print@plt>
mov    -0x8(%rbp),%rdi
mov    $0x2,%edx
mov    %edx,%esi
call   1050 <initMem@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsd  0xe79(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsd  0xe5e(%rip),%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
movsd  0xe32(%rip),%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rdi
mov    $0x2,%edx
mov    %edx,%esi
call   1060 <print@plt>
mov    -0x8(%rbp),%rdi
mov    $0x2,%edx
mov    %edx,%esi
call   1030 <add@plt>
lea    0xe1e(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x2,%edi
mov    $0x2,%esi
call   1070 <allocMem@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x2,%esi
mov    $0x2,%edx
call   1060 <print@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x2,%edx
call   1050 <initMem@plt>
mov    (%rbx),%rax
movaps 0xe6f(%rip),%xmm0
movups %xmm0,(%rax)
mov    0x8(%rbx),%rax
xorps  %xmm0,%xmm0
movhps 0xe6e(%rip),%xmm0
movups %xmm0,(%rax)
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x2,%edx
call   1060 <print@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x2,%edx
call   1030 <add@plt>
lea    0xe48(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%f\00"
define i32 @main() {
%1 = alloca double**
%2 = call double** @allocMem(i32 2, i32 2)
store double** %2, double*** %1
%3 = load double**, double*** %1
%4 = call i32 @print(double** %3, i32 2, i32 2)
%5 = load double**, double*** %1
%6 = call i32 @initMem(double** %5, i32 2, i32 2)
%7 = load double**, double*** %1
%8 = getelementptr inbounds double*, double** %7, i64 0
%9 = load double*, double** %8
%10 = getelementptr inbounds double, double* %9, i64 0
store double 1.000000e+00, double* %10
%11 = load double**, double*** %1
%12 = getelementptr inbounds double*, double** %11, i64 0
%13 = load double*, double** %12
%14 = getelementptr inbounds double, double* %13, i64 1
store double 2.000000e+00, double* %14
%15 = load double**, double*** %1
%16 = getelementptr inbounds double*, double** %15, i64 1
%17 = load double*, double** %16
%18 = getelementptr inbounds double, double* %17, i64 0
store double 0.000000e+00, double* %18
%19 = load double**, double*** %1
%20 = getelementptr inbounds double*, double** %19, i64 1
%21 = load double*, double** %20
%22 = getelementptr inbounds double, double* %21, i64 1
store double 3.000000e+00, double* %22
%23 = load double**, double*** %1
%24 = call i32 @print(double** %23, i32 2, i32 2)
%25 = load double**, double*** %1
%26 = call double @add(double** %25, i32 2, i32 2)
%27 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), double %26)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%f\00"
define i32 @main() {
%1 = tail call double** @allocMem(i32 2, i32 2)
%2 = tail call i32 @print(double** %1, i32 2, i32 2)
%3 = tail call i32 @initMem(double** %1, i32 2, i32 2)
%4 = bitcast double** %1 to <2 x double>**
%5 = load <2 x double>*, <2 x double>** %4
store <2 x double> <double 1.000000e+00, double 2.000000e+00>, <2 x double>* %5
%6 = getelementptr inbounds double*, double** %1, i64 1
%7 = bitcast double** %6 to <2 x double>**
%8 = load <2 x double>*, <2 x double>** %7
store <2 x double> <double 0.000000e+00, double 3.000000e+00>, <2 x double>* %8
%9 = tail call i32 @print(double** %1, i32 2, i32 2)
%10 = tail call double @add(double** %1, i32 2, i32 2)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), double %10)
ret i32 0
}