#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*/ getchar();
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, double, double, double);
int /*<<< orphan*/ vMv(double *, int, double **, double *, int);
void testvMv() {
  double *v1 = (double *)malloc(sizeof(double) * 2);
  v1[0] = 1;
  v1[1] = 2;
  double **M = (double **)malloc(sizeof(double *) * 2);
  M[0] = (double *)malloc(sizeof(double) * 3);
  M[1] = (double *)malloc(sizeof(double) * 3);
  M[0][0] = 1;
  M[0][1] = 0.5;
  M[0][2] = 0.2;
  M[1][0] = 0.3;
  M[1][1] = 0.4;
  M[1][2] = -2;
  double *v2 = (double *)malloc(sizeof(double) * 3);
  vMv(v1, 2, M, v2, 3);
  printf("%lf %lf %lf", v2[0], v2[1], v2[2]);
  getchar();
}


x86 assembly (clang, -O0):
<testvMv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x10,%edi
call   1050 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsd  0xec6(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  0xebe(%rip),%xmm0
movsd  %xmm0,0x8(%rax)
mov    $0x10,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x18,%edi
call   1050 <malloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    $0x18,%edi
call   1050 <malloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsd  0xe6b(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsd  0xe50(%rip),%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsd  0xe34(%rip),%xmm0
movsd  %xmm0,0x10(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsd  0xe17(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsd  0xdfb(%rip),%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsd  0xdde(%rip),%xmm0
movsd  %xmm0,0x10(%rax)
mov    $0x18,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    $0x2,%esi
mov    $0x3,%r8d
call   1060 <vMv@plt>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm2
lea    0xdc6(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testvMv>:
push   %r15
push   %r14
push   %rbx
mov    $0x10,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
movaps 0xea7(%rip),%xmm0
movups %xmm0,(%rax)
mov    $0x10,%edi
call   1050 <malloc@plt>
mov    %rax,%r15
mov    $0x18,%edi
call   1050 <malloc@plt>
mov    %rax,(%r15)
mov    $0x18,%edi
call   1050 <malloc@plt>
mov    %rax,0x8(%r15)
mov    (%r15),%rcx
movaps 0xe82(%rip),%xmm0
movups %xmm0,(%rcx)
movabs $0x3fc999999999999a,%rdx
99 c9 3f
mov    %rdx,0x10(%rcx)
movaps 0xe7a(%rip),%xmm0
movups %xmm0,(%rax)
movabs $0xc000000000000000,%rcx
mov    %rcx,0x10(%rax)
mov    $0x18,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    $0x2,%esi
mov    %r15,%rdx
mov    %rax,%rcx
mov    $0x3,%r8d
call   1060 <vMv@plt>
movsd  (%rbx),%xmm0
movsd  0x8(%rbx),%xmm1
movsd  0x10(%rbx),%xmm2
lea    0xe3e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <getchar@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"%lf %lf %lf\00"
define void @testvMv() {
%1 = alloca double*
%2 = alloca double**
%3 = alloca double*
%4 = call i64 @malloc(i32 16)
%5 = inttoptr i64 %4 to double*
store double* %5, double** %1
%6 = load double*, double** %1
%7 = getelementptr inbounds double, double* %6, i64 0
store double 1.000000e+00, double* %7
%8 = load double*, double** %1
%9 = getelementptr inbounds double, double* %8, i64 1
store double 2.000000e+00, double* %9
%10 = call i64 @malloc(i32 16)
%11 = inttoptr i64 %10 to double**
store double** %11, double*** %2
%12 = call i64 @malloc(i32 24)
%13 = inttoptr i64 %12 to double*
%14 = load double**, double*** %2
%15 = getelementptr inbounds double*, double** %14, i64 0
store double* %13, double** %15
%16 = call i64 @malloc(i32 24)
%17 = inttoptr i64 %16 to double*
%18 = load double**, double*** %2
%19 = getelementptr inbounds double*, double** %18, i64 1
store double* %17, double** %19
%20 = load double**, double*** %2
%21 = getelementptr inbounds double*, double** %20, i64 0
%22 = load double*, double** %21
%23 = getelementptr inbounds double, double* %22, i64 0
store double 1.000000e+00, double* %23
%24 = load double**, double*** %2
%25 = getelementptr inbounds double*, double** %24, i64 0
%26 = load double*, double** %25
%27 = getelementptr inbounds double, double* %26, i64 1
store double 5.000000e-01, double* %27
%28 = load double**, double*** %2
%29 = getelementptr inbounds double*, double** %28, i64 0
%30 = load double*, double** %29
%31 = getelementptr inbounds double, double* %30, i64 2
store double 2.000000e-01, double* %31
%32 = load double**, double*** %2
%33 = getelementptr inbounds double*, double** %32, i64 1
%34 = load double*, double** %33
%35 = getelementptr inbounds double, double* %34, i64 0
store double 3.000000e-01, double* %35
%36 = load double**, double*** %2
%37 = getelementptr inbounds double*, double** %36, i64 1
%38 = load double*, double** %37
%39 = getelementptr inbounds double, double* %38, i64 1
store double 4.000000e-01, double* %39
%40 = load double**, double*** %2
%41 = getelementptr inbounds double*, double** %40, i64 1
%42 = load double*, double** %41
%43 = getelementptr inbounds double, double* %42, i64 2
store double -2.000000e+00, double* %43
%44 = call i64 @malloc(i32 24)
%45 = inttoptr i64 %44 to double*
store double* %45, double** %3
%46 = load double*, double** %1
%47 = load double**, double*** %2
%48 = load double*, double** %3
%49 = call i32 @vMv(double* %46, i32 2, double** %47, double* %48, i32 3)
%50 = load double*, double** %3
%51 = getelementptr inbounds double, double* %50, i64 0
%52 = load double, double* %51
%53 = load double*, double** %3
%54 = getelementptr inbounds double, double* %53, i64 1
%55 = load double, double* %54
%56 = load double*, double** %3
%57 = getelementptr inbounds double, double* %56, i64 2
%58 = load double, double* %57
%59 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), double %52, double %55, double %58)
%60 = call i32 (...) @getchar()
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"%lf %lf %lf\00"
define void @testvMv() {
%1 = tail call i64 @malloc(i32 16)
%2 = inttoptr i64 %1 to double*
%3 = inttoptr i64 %1 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 2.000000e+00>, <2 x double>* %3
%4 = tail call i64 @malloc(i32 16)
%5 = inttoptr i64 %4 to double**
%6 = tail call i64 @malloc(i32 24)
%7 = inttoptr i64 %6 to double*
store double* %7, double** %5
%8 = tail call i64 @malloc(i32 24)
%9 = inttoptr i64 %8 to double*
%10 = getelementptr inbounds double*, double** %5, i64 1
store double* %9, double** %10
%11 = load double*, double** %5
%12 = bitcast double* %11 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 5.000000e-01>, <2 x double>* %12
%13 = getelementptr inbounds double, double* %11, i64 2
store double 2.000000e-01, double* %13
%14 = inttoptr i64 %8 to <2 x double>*
store <2 x double> <double 3.000000e-01, double 4.000000e-01>, <2 x double>* %14
%15 = getelementptr inbounds double, double* %9, i64 2
store double -2.000000e+00, double* %15
%16 = tail call i64 @malloc(i32 24)
%17 = inttoptr i64 %16 to double*
%18 = tail call i32 @vMv(double* %2, i32 2, double** %5, double* %17, i32 3)
%19 = load double, double* %17
%20 = getelementptr inbounds double, double* %17, i64 1
%21 = load double, double* %20
%22 = getelementptr inbounds double, double* %17, i64 2
%23 = load double, double* %22
%24 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), double %19, double %21, double %23)
%25 = tail call i32 (...) @getchar()
ret void
}