#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*/ free(double *);
double *get_transpose(double const *);
double *multiply_matrices(double *, double const *);
double *get_metric(const double *M) {
  double *G, *M_T;
  G = NULL;
  M_T = NULL;
  if ((M_T = get_transpose(M)) == NULL) {
    return NULL;
  }
  if ((G = multiply_matrices(M_T, M)) == NULL) {
    return NULL;
  }
  free(M_T);
  M_T = NULL;
  return G;
}


x86 assembly (clang, -O0):
<get_metric>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <get_transpose@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1170 <get_metric+0x40>
movq   $0x0,-0x8(%rbp)
jmp    11b1 <get_metric+0x81>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <multiply_matrices@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1198 <get_metric+0x68>
movq   $0x0,-0x8(%rbp)
jmp    11b1 <get_metric+0x81>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_metric>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1050 <get_transpose@plt>
test   %rax,%rax
je     1161 <get_metric+0x31>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <multiply_matrices@plt>
test   %rax,%rax
je     1161 <get_metric+0x31>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    1164 <get_metric+0x34>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double* @get_metric(double* %0) {
%2 = alloca double*
%3 = alloca double*
%4 = alloca double*
%5 = alloca double*
store double* %0, double** %3
store double* null, double** %4
store double* null, double** %5
%6 = load double*, double** %3
%7 = call double* @get_transpose(double* %6)
store double* %7, double** %5
%8 = icmp eq double* %7, null
br i1 %8, label %9, label %10
9: ; preds = %1
store double* null, double** %2
br label %20
10: ; preds = %1
%11 = load double*, double** %5
%12 = load double*, double** %3
%13 = call double* @multiply_matrices(double* %11, double* %12)
store double* %13, double** %4
%14 = icmp eq double* %13, null
br i1 %14, label %15, label %16
15: ; preds = %10
store double* null, double** %2
br label %20
16: ; preds = %10
%17 = load double*, double** %5
%18 = call i32 @free(double* %17)
store double* null, double** %5
%19 = load double*, double** %4
store double* %19, double** %2
br label %20
20: ; preds = %16, %15, %9
%21 = load double*, double** %2
ret double* %21
}

LLVM IR (-O2):
define double* @get_metric(double* %0) {
%2 = tail call double* @get_transpose(double* %0)
%3 = icmp eq double* %2, null
br i1 %3, label %9, label %4
4: ; preds = %1
%5 = tail call double* @multiply_matrices(double* %2, double* %0)
%6 = icmp eq double* %5, null
br i1 %6, label %9, label %7
7: ; preds = %4
%8 = tail call i32 @free(double* %2)
br label %9
9: ; preds = %4, %1, %7
%10 = phi double* [ %5, %7 ], [ null, %1 ], [ null, %4 ]
ret double* %10
}