#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*/ dgemm_(char *, char *, int *, int *, int *, double *,
                          double *, int *, double *, int *, double *, double *,
                          int *);
void reference_dgemm(int N, double ALPHA, double *A, double *B, double *C) {
  char TRANSA = 'N';
  char TRANSB = 'N';
  int M = N;
  int K = N;
  double BETA = 1.;
  int LDA = N;
  int LDB = N;
  int LDC = N;
  dgemm_(&TRANSA, &TRANSB, &M, &N, &K, &ALPHA, A, &LDA, B, &LDB, &BETA, C,
         &LDC);
}


x86 assembly (clang, -O0):
<reference_dgemm>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x90,%rsp
mov    %edi,-0x24(%rbp)
movsd  %xmm0,-0x30(%rbp)
mov    %rsi,-0x38(%rbp)
mov    %rdx,-0x40(%rbp)
mov    %rcx,-0x48(%rbp)
movb   $0x4e,-0x49(%rbp)
movb   $0x4e,-0x4a(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x54(%rbp)
movsd  0xeae(%rip),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x68(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x38(%rbp),%r12
mov    -0x40(%rbp),%r14
mov    -0x48(%rbp),%r10
lea    -0x49(%rbp),%rdi
lea    -0x4a(%rbp),%rsi
lea    -0x50(%rbp),%rdx
lea    -0x24(%rbp),%rcx
lea    -0x54(%rbp),%r8
lea    -0x30(%rbp),%r9
lea    -0x64(%rbp),%r15
lea    -0x68(%rbp),%rbx
lea    -0x60(%rbp),%r11
lea    -0x6c(%rbp),%rax
mov    %r12,(%rsp)
mov    %r15,0x8(%rsp)
mov    %r14,0x10(%rsp)
mov    %rbx,0x18(%rsp)
mov    %r11,0x20(%rsp)
mov    %r10,0x28(%rsp)
mov    %rax,0x30(%rsp)
call   1030 <dgemm_@plt>
add    $0x90,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<reference_dgemm>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rcx,%rax
mov    %rdx,%r11
mov    %rsi,%r10
mov    %edi,0x24(%rsp)
movsd  %xmm0,0x30(%rsp)
movb   $0x4e,0xf(%rsp)
movb   $0x4e,0xe(%rsp)
mov    %edi,0x20(%rsp)
mov    %edi,0x1c(%rsp)
movabs $0x3ff0000000000000,%rcx
mov    %rcx,0x28(%rsp)
mov    %edi,0x18(%rsp)
mov    %edi,0x14(%rsp)
mov    %edi,0x10(%rsp)
sub    $0x8,%rsp
lea    0x18(%rsp),%rbx
lea    0x30(%rsp),%r14
lea    0x1c(%rsp),%r15
lea    0x20(%rsp),%r12
lea    0x17(%rsp),%rdi
lea    0x16(%rsp),%rsi
lea    0x28(%rsp),%rdx
lea    0x2c(%rsp),%rcx
lea    0x24(%rsp),%r8
lea    0x38(%rsp),%r9
push   %rbx
push   %rax
push   %r14
push   %r15
push   %r11
push   %r12
push   %r10
call   1030 <dgemm_@plt>
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @reference_dgemm(i32 %0, double %1, double* %2, double* %3, double* %4) {
%6 = alloca i32
%7 = alloca double
%8 = alloca double*
%9 = alloca double*
%10 = alloca double*
%11 = alloca i8
%12 = alloca i8
%13 = alloca i32
%14 = alloca i32
%15 = alloca double
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
store i32 %0, i32* %6
store double %1, double* %7
store double* %2, double** %8
store double* %3, double** %9
store double* %4, double** %10
store i8 78, i8* %11
store i8 78, i8* %12
%19 = load i32, i32* %6
store i32 %19, i32* %13
%20 = load i32, i32* %6
store i32 %20, i32* %14
store double 1.000000e+00, double* %15
%21 = load i32, i32* %6
store i32 %21, i32* %16
%22 = load i32, i32* %6
store i32 %22, i32* %17
%23 = load i32, i32* %6
store i32 %23, i32* %18
%24 = load double*, double** %8
%25 = load double*, double** %9
%26 = load double*, double** %10
%27 = call i32 @dgemm_(i8* %11, i8* %12, i32* %13, i32* %6, i32* %14, double* %7, double* %24, i32* %16, double* %25, i32* %17, double* %15, double* %26, i32* %18)
ret void
}

LLVM IR (-O2):
define void @reference_dgemm(i32 %0, double %1, double* %2, double* %3, double* %4) {
%6 = alloca i32
%7 = alloca double
%8 = alloca i8
%9 = alloca i8
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32 %0, i32* %6
store double %1, double* %7
store i8 78, i8* %8
store i8 78, i8* %9
%16 = bitcast i32* %10 to i8*
store i32 %0, i32* %10
%17 = bitcast i32* %11 to i8*
store i32 %0, i32* %11
%18 = bitcast double* %12 to i8*
store double 1.000000e+00, double* %12
%19 = bitcast i32* %13 to i8*
store i32 %0, i32* %13
%20 = bitcast i32* %14 to i8*
store i32 %0, i32* %14
%21 = bitcast i32* %15 to i8*
store i32 %0, i32* %15
%22 = call i32 @dgemm_(i8* %8, i8* %9, i32* %10, i32* %6, i32* %11, double* %7, double* %2, i32* %13, double* %3, i32* %14, double* %12, double* %4, i32* %15)
ret void
}