#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 **dmatrix(int /*<<< orphan*/, int, int /*<<< orphan*/, int);
int /*<<< orphan*/ free_dmatrix(double **, int /*<<< orphan*/, int,
                                int /*<<< orphan*/);
int /*<<< orphan*/ matvec(double **, int, int, double *, double *);
int /*<<< orphan*/ transpose(double **, int, int, double **);
void vecmat(double *x, double **a, int nra, int nca, double *b) {
  double **t = dmatrix(0, nca - 1, 0, nra - 1);
  transpose(a, nra, nca, t);
  matvec(t, nca, nra, x, b);
  free_dmatrix(t, 0, nca - 1, 0);
}


x86 assembly (clang, -O0):
<vecmat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x18(%rbp),%esi
sub    $0x1,%esi
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
xor    %edx,%edx
mov    %edx,%edi
call   1030 <dmatrix@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x28(%rbp),%rcx
call   1040 <transpose@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x8(%rbp),%rcx
mov    -0x20(%rbp),%r8
call   1060 <matvec@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%edx
sub    $0x1,%edx
xor    %ecx,%ecx
mov    %ecx,%esi
call   1050 <free_dmatrix@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vecmat>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,(%rsp)
mov    %ecx,%ebx
mov    %edx,%r15d
mov    %rsi,%r12
mov    %rdi,%r13
lea    -0x1(%rbx),%ebp
lea    -0x1(%r15),%ecx
xor    %edi,%edi
mov    %ebp,%esi
xor    %edx,%edx
call   1030 <dmatrix@plt>
mov    %rax,%r14
mov    %r12,%rdi
mov    %r15d,%esi
mov    %ebx,%edx
mov    %rax,%rcx
call   1040 <transpose@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %r15d,%edx
mov    %r13,%rcx
mov    (%rsp),%r8
call   1060 <matvec@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    %ebp,%edx
xor    %ecx,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <free_dmatrix@plt>

LLVM IR (-O0):
define void @vecmat(double* %0, double** %1, i32 %2, i32 %3, double* %4) {
%6 = alloca double*
%7 = alloca double**
%8 = alloca i32
%9 = alloca i32
%10 = alloca double*
%11 = alloca double**
store double* %0, double** %6
store double** %1, double*** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store double* %4, double** %10
%12 = load i32, i32* %9
%13 = sub nsw i32 %12, 1
%14 = load i32, i32* %8
%15 = sub nsw i32 %14, 1
%16 = call double** @dmatrix(i32 0, i32 %13, i32 0, i32 %15)
store double** %16, double*** %11
%17 = load double**, double*** %7
%18 = load i32, i32* %8
%19 = load i32, i32* %9
%20 = load double**, double*** %11
%21 = call i32 @transpose(double** %17, i32 %18, i32 %19, double** %20)
%22 = load double**, double*** %11
%23 = load i32, i32* %9
%24 = load i32, i32* %8
%25 = load double*, double** %6
%26 = load double*, double** %10
%27 = call i32 @matvec(double** %22, i32 %23, i32 %24, double* %25, double* %26)
%28 = load double**, double*** %11
%29 = load i32, i32* %9
%30 = sub nsw i32 %29, 1
%31 = call i32 @free_dmatrix(double** %28, i32 0, i32 %30, i32 0)
ret void
}

LLVM IR (-O2):
define void @vecmat(double* %0, double** %1, i32 %2, i32 %3, double* %4) {
%6 = add nsw i32 %3, -1
%7 = add nsw i32 %2, -1
%8 = tail call double** @dmatrix(i32 0, i32 %6, i32 0, i32 %7)
%9 = tail call i32 @transpose(double** %1, i32 %2, i32 %3, double** %8)
%10 = tail call i32 @matvec(double** %8, i32 %3, i32 %2, double* %0, double* %4)
%11 = tail call i32 @free_dmatrix(double** %8, i32 0, i32 %6, i32 0)
ret void
}