#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 *allocate_real_vector(size_t);
int /*<<< orphan*/ free(double *);
int /*<<< orphan*/ mat_vec_prod(size_t, double *, double **, double *);
double vec_prod(size_t, double *, double *);
double bilinear_form(size_t n, double *x, double **a, double *y) {
  double *ay = allocate_real_vector(n);
  mat_vec_prod(n, ay, a, y);
  double xay = vec_prod(n, x, ay);
  free(ay);
  return xay;
}


x86 assembly (clang, -O0):
<bilinear_form>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <allocate_real_vector@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1050 <mat_vec_prod@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1060 <vec_prod@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movsd  -0x30(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bilinear_form>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%r14
mov    %rdx,%r12
mov    %rsi,%r15
mov    %rdi,%rbx
call   1040 <allocate_real_vector@plt>
mov    %rax,%r13
mov    %rbx,%rdi
mov    %rax,%rsi
mov    %r12,%rdx
mov    %r14,%rcx
call   1050 <mat_vec_prod@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r13,%rdx
call   1060 <vec_prod@plt>
movsd  %xmm0,0x8(%rsp)
mov    %r13,%rdi
call   1030 <free@plt>
movsd  0x8(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @bilinear_form(i64 %0, double* %1, double** %2, double* %3) {
%5 = alloca i64
%6 = alloca double*
%7 = alloca double**
%8 = alloca double*
%9 = alloca double*
%10 = alloca double
store i64 %0, i64* %5
store double* %1, double** %6
store double** %2, double*** %7
store double* %3, double** %8
%11 = load i64, i64* %5
%12 = call double* @allocate_real_vector(i64 %11)
store double* %12, double** %9
%13 = load i64, i64* %5
%14 = load double*, double** %9
%15 = load double**, double*** %7
%16 = load double*, double** %8
%17 = call i32 @mat_vec_prod(i64 %13, double* %14, double** %15, double* %16)
%18 = load i64, i64* %5
%19 = load double*, double** %6
%20 = load double*, double** %9
%21 = call double @vec_prod(i64 %18, double* %19, double* %20)
store double %21, double* %10
%22 = load double*, double** %9
%23 = call i32 @free(double* %22)
%24 = load double, double* %10
ret double %24
}

LLVM IR (-O2):
define double @bilinear_form(i64 %0, double* %1, double** %2, double* %3) {
%5 = tail call double* @allocate_real_vector(i64 %0)
%6 = tail call i32 @mat_vec_prod(i64 %0, double* %5, double** %2, double* %3)
%7 = tail call double @vec_prod(i64 %0, double* %1, double* %5)
%8 = tail call i32 @free(double* %5)
ret double %7
}