#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*/ doubles_mat_AB(double const *, int, int, double const *, int,
                                  int, double *, int, int);
int /*<<< orphan*/ free(double *);
scalar_t__ malloc(int);
void doubles_mat_ABC(const double *A, int Arows, int Acols, const double *B,
                     int Brows, int Bcols, const double *C, int Crows,
                     int Ccols, double *R, int Rrows, int Rcols) {
  double *tmp = (double *)malloc(sizeof(double) * Arows * Bcols);
  doubles_mat_AB(A, Arows, Acols, B, Brows, Bcols, tmp, Arows, Bcols);
  doubles_mat_AB(tmp, Arows, Bcols, C, Crows, Ccols, R, Rrows, Rcols);
  free(tmp);
}


x86 assembly (clang, -O0):
<doubles_mat_ABC>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x38(%rbp),%eax
mov    0x30(%rbp),%eax
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
movslq -0x20(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x1c(%rbp),%r8d
mov    -0x20(%rbp),%r9d
mov    -0x28(%rbp),%r11
mov    -0xc(%rbp),%r10d
mov    -0x20(%rbp),%eax
mov    %r11,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1050 <doubles_mat_AB@plt>
mov    -0x28(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    0x10(%rbp),%rcx
mov    0x18(%rbp),%r8d
mov    0x20(%rbp),%r9d
mov    0x28(%rbp),%r11
mov    0x30(%rbp),%r10d
mov    0x38(%rbp),%eax
mov    %r11,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1050 <doubles_mat_AB@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doubles_mat_ABC>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9d,%ebx
mov    %r8d,0xc(%rsp)
mov    %rcx,%r15
mov    %edx,%r12d
mov    %esi,%ebp
mov    %rdi,%r14
mov    0x70(%rsp),%rax
mov    %rax,0x20(%rsp)
mov    0x78(%rsp),%eax
mov    %eax,0x14(%rsp)
mov    0x80(%rsp),%eax
mov    %eax,0x10(%rsp)
mov    0x88(%rsp),%rax
mov    %rax,0x30(%rsp)
mov    0x90(%rsp),%eax
mov    %rax,0x28(%rsp)
mov    0x98(%rsp),%eax
mov    %rax,0x18(%rsp)
mov    %esi,%edi
imul   %r9d,%edi
shl    $0x3,%edi
call   1040 <malloc@plt>
mov    %rax,%r13
sub    $0x8,%rsp
mov    %r14,%rdi
mov    %ebp,%esi
mov    %r12d,%edx
mov    %r15,%rcx
mov    0x14(%rsp),%r8d
mov    %ebx,%r9d
push   %rbx
push   %rbp
push   %rax
call   1050 <doubles_mat_AB@plt>
add    $0x18,%rsp
mov    %r13,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    0x28(%rsp),%rcx
mov    0x1c(%rsp),%r8d
mov    0x18(%rsp),%r9d
push   0x20(%rsp)
push   0x38(%rsp)
push   0x48(%rsp)
call   1050 <doubles_mat_AB@plt>
add    $0x20,%rsp
mov    %r13,%rdi
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @doubles_mat_ABC(double* %0, i32 %1, i32 %2, double* %3, i32 %4, i32 %5, double* %6, i32 %7, i32 %8, double* %9, i32 %10, i32 %11) {
%13 = alloca double*
%14 = alloca i32
%15 = alloca i32
%16 = alloca double*
%17 = alloca i32
%18 = alloca i32
%19 = alloca double*
%20 = alloca i32
%21 = alloca i32
%22 = alloca double*
%23 = alloca i32
%24 = alloca i32
%25 = alloca double*
store double* %0, double** %13
store i32 %1, i32* %14
store i32 %2, i32* %15
store double* %3, double** %16
store i32 %4, i32* %17
store i32 %5, i32* %18
store double* %6, double** %19
store i32 %7, i32* %20
store i32 %8, i32* %21
store double* %9, double** %22
store i32 %10, i32* %23
store i32 %11, i32* %24
%26 = load i32, i32* %14
%27 = sext i32 %26 to i64
%28 = mul i64 8, %27
%29 = load i32, i32* %18
%30 = sext i32 %29 to i64
%31 = mul i64 %28, %30
%32 = trunc i64 %31 to i32
%33 = call i64 @malloc(i32 %32)
%34 = inttoptr i64 %33 to double*
store double* %34, double** %25
%35 = load double*, double** %13
%36 = load i32, i32* %14
%37 = load i32, i32* %15
%38 = load double*, double** %16
%39 = load i32, i32* %17
%40 = load i32, i32* %18
%41 = load double*, double** %25
%42 = load i32, i32* %14
%43 = load i32, i32* %18
%44 = call i32 @doubles_mat_AB(double* %35, i32 %36, i32 %37, double* %38, i32 %39, i32 %40, double* %41, i32 %42, i32 %43)
%45 = load double*, double** %25
%46 = load i32, i32* %14
%47 = load i32, i32* %18
%48 = load double*, double** %19
%49 = load i32, i32* %20
%50 = load i32, i32* %21
%51 = load double*, double** %22
%52 = load i32, i32* %23
%53 = load i32, i32* %24
%54 = call i32 @doubles_mat_AB(double* %45, i32 %46, i32 %47, double* %48, i32 %49, i32 %50, double* %51, i32 %52, i32 %53)
%55 = load double*, double** %25
%56 = call i32 @free(double* %55)
ret void
}

LLVM IR (-O2):
define void @doubles_mat_ABC(double* %0, i32 %1, i32 %2, double* %3, i32 %4, i32 %5, double* %6, i32 %7, i32 %8, double* %9, i32 %10, i32 %11) {
%13 = shl i32 %1, 3
%14 = mul i32 %13, %5
%15 = tail call i64 @malloc(i32 %14)
%16 = inttoptr i64 %15 to double*
%17 = tail call i32 @doubles_mat_AB(double* %0, i32 %1, i32 %2, double* %3, i32 %4, i32 %5, double* %16, i32 %1, i32 %5)
%18 = tail call i32 @doubles_mat_AB(double* %16, i32 %1, i32 %5, double* %6, i32 %7, i32 %8, double* %9, i32 %10, i32 %11)
%19 = tail call i32 @free(double* %16)
ret void
}