#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 */
struct timespec {
  long tv_sec;
  double tv_nsec;
};

/* Variables and functions */
int /*<<< orphan*/ CLOCK_MONOTONIC;
int /*<<< orphan*/ RandMatrixGen(double *, int);
int atoi(char *);
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
int /*<<< orphan*/ dgemm0(double *, double *, double *, int);
int /*<<< orphan*/ dgemm1(double *, double *, double *, int);
int /*<<< orphan*/ dgemm2(double *, double *, double *, int);
int /*<<< orphan*/ dgemm3(double *, double *, double *, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, double);
double verification(double *, double *, int);
int main(int argc, char *argv[]) {
  int n, i;
  double *a, *b, *c0, *c1, *c2, *c3;
  double t0, t1, t2, t3;
  double diff1, diff2, diff3;
  struct timespec start, end;
  n = atoi(argv[1]);
  a = (double *)malloc(n * n * sizeof(double));
  b = (double *)malloc(n * n * sizeof(double));
  c0 = (double *)malloc(n * n * sizeof(double));
  c1 = (double *)malloc(n * n * sizeof(double));
  c2 = (double *)malloc(n * n * sizeof(double));
  c3 = (double *)malloc(n * n * sizeof(double));
  RandMatrixGen(a, n);
  RandMatrixGen(b, n);
  clock_gettime(CLOCK_MONOTONIC, &start);
  dgemm0(a, b, c0, n);
  clock_gettime(CLOCK_MONOTONIC, &end);
  t0 = (end.tv_sec - start.tv_sec) * 1000000000L + end.tv_nsec - start.tv_nsec;
  clock_gettime(CLOCK_MONOTONIC, &start);
  dgemm1(a, b, c1, n);
  clock_gettime(CLOCK_MONOTONIC, &end);
  t1 = (end.tv_sec - start.tv_sec) * 1000000000L + end.tv_nsec - start.tv_nsec;
  clock_gettime(CLOCK_MONOTONIC, &start);
  dgemm2(a, b, c2, n);
  clock_gettime(CLOCK_MONOTONIC, &end);
  t2 = (end.tv_sec - start.tv_sec) * 1000000000L + end.tv_nsec - start.tv_nsec;
  clock_gettime(CLOCK_MONOTONIC, &start);
  dgemm3(a, b, c3, n);
  clock_gettime(CLOCK_MONOTONIC, &end);
  t3 = (end.tv_sec - start.tv_sec) * 1000000000L + end.tv_nsec - start.tv_nsec;
  diff1 = verification(c0, c1, n);
  diff2 = verification(c0, c2, n);
  diff3 = verification(c0, c3, n);
  printf("matrix size: %d\n", n);
  printf("dgemm0 runtime: %llu nanoseconds\n", (long long unsigned int)t0);
  printf("dgemm1 runtime: %llu nanoseconds\n", (long long unsigned int)t1);
  printf("dgemm2 runtime: %llu nanoseconds\n", (long long unsigned int)t2);
  printf("dgemm3 runtime: %llu nanoseconds\n", (long long unsigned int)t3);
  printf("maximum difference between dgemm0 and dgemm1: %f\n", diff1);
  printf("maximum difference between dgemm0 and dgemm2: %f\n", diff2);
  printf("maximum difference between dgemm0 and dgemm3: %f\n", diff3);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
imul   %edi,%edi
shl    $0x3,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
imul   %edi,%edi
shl    $0x3,%edi
call   1070 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%edi
imul   %edi,%edi
shl    $0x3,%edi
call   1070 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%edi
imul   %edi,%edi
shl    $0x3,%edi
call   1070 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x14(%rbp),%edi
imul   %edi,%edi
shl    $0x3,%edi
call   1070 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x14(%rbp),%edi
imul   %edi,%edi
shl    $0x3,%edi
call   1070 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1090 <RandMatrixGen@plt>
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1090 <RandMatrixGen@plt>
mov    0x2d94(%rip),%rax
mov    %rax,-0xd0(%rbp)
mov    (%rax),%edi
lea    -0x90(%rbp),%rsi
mov    %rsi,-0xe0(%rbp)
call   1040 <clock_gettime@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x14(%rbp),%ecx
call   10b0 <dgemm0@plt>
mov    -0xd0(%rbp),%rax
mov    (%rax),%edi
lea    -0xa0(%rbp),%rsi
mov    %rsi,-0xd8(%rbp)
call   1040 <clock_gettime@plt>
mov    -0xe0(%rbp),%rsi
mov    -0xd0(%rbp),%rax
mov    -0xa0(%rbp),%rcx
mov    -0x90(%rbp),%rdx
sub    %rdx,%rcx
imul   $0x3b9aca00,%rcx,%rcx
cvtsi2sd %rcx,%xmm0
movsd  -0x98(%rbp),%xmm1
ff
addsd  %xmm1,%xmm0
movsd  -0x88(%rbp),%xmm1
ff
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    (%rax),%edi
call   1040 <clock_gettime@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x14(%rbp),%ecx
call   1050 <dgemm1@plt>
mov    -0xd8(%rbp),%rsi
mov    -0xd0(%rbp),%rax
mov    (%rax),%edi
call   1040 <clock_gettime@plt>
mov    -0xe0(%rbp),%rsi
mov    -0xd0(%rbp),%rax
mov    -0xa0(%rbp),%rcx
mov    -0x90(%rbp),%rdx
sub    %rdx,%rcx
imul   $0x3b9aca00,%rcx,%rcx
cvtsi2sd %rcx,%xmm0
movsd  -0x98(%rbp),%xmm1
ff
addsd  %xmm1,%xmm0
movsd  -0x88(%rbp),%xmm1
ff
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    (%rax),%edi
call   1040 <clock_gettime@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    -0x14(%rbp),%ecx
call   10a0 <dgemm2@plt>
mov    -0xd8(%rbp),%rsi
mov    -0xd0(%rbp),%rax
mov    (%rax),%edi
call   1040 <clock_gettime@plt>
mov    -0xe0(%rbp),%rsi
mov    -0xd0(%rbp),%rax
mov    -0xa0(%rbp),%rcx
mov    -0x90(%rbp),%rdx
sub    %rdx,%rcx
imul   $0x3b9aca00,%rcx,%rcx
cvtsi2sd %rcx,%xmm0
movsd  -0x98(%rbp),%xmm1
ff
addsd  %xmm1,%xmm0
movsd  -0x88(%rbp),%xmm1
ff
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    (%rax),%edi
call   1040 <clock_gettime@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x48(%rbp),%rdx
mov    -0x14(%rbp),%ecx
call   1030 <dgemm3@plt>
mov    -0xd8(%rbp),%rsi
mov    -0xd0(%rbp),%rax
mov    (%rax),%edi
call   1040 <clock_gettime@plt>
mov    -0xa0(%rbp),%rax
mov    -0x90(%rbp),%rcx
sub    %rcx,%rax
imul   $0x3b9aca00,%rax,%rax
cvtsi2sd %rax,%xmm0
movsd  -0x98(%rbp),%xmm1
ff
addsd  %xmm1,%xmm0
movsd  -0x88(%rbp),%xmm1
ff
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1080 <verification@plt>
movsd  %xmm0,-0x70(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1080 <verification@plt>
movsd  %xmm0,-0x78(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1080 <verification@plt>
movsd  %xmm0,-0x80(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm0
lea    0xba3(%rip),%rdi
call   1060 <printf@plt>
movsd  -0x50(%rbp),%xmm0
movsd  0xb61(%rip),%xmm2
movsd  %xmm2,-0xc8(%rbp)
ff
movaps %xmm0,%xmm1
subsd  %xmm2,%xmm1
cvttsd2si %xmm1,%rcx
cvttsd2si %xmm0,%rax
mov    %rax,%rdx
sar    $0x3f,%rdx
and    %rdx,%rcx
or     %rcx,%rax
movq   %rax,%xmm0
movaps 0xb3f(%rip),%xmm1
movaps %xmm1,-0xc0(%rbp)
punpckldq %xmm1,%xmm0
movapd 0xb3c(%rip),%xmm1
movaps %xmm1,-0xb0(%rbp)
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
lea    0xb40(%rip),%rdi
call   1060 <printf@plt>
movsd  -0xc8(%rbp),%xmm4
ff
movaps -0xc0(%rbp),%xmm2
movaps -0xb0(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm0
movaps %xmm0,%xmm3
subsd  %xmm4,%xmm3
cvttsd2si %xmm3,%rcx
cvttsd2si %xmm0,%rax
mov    %rax,%rdx
sar    $0x3f,%rdx
and    %rdx,%rcx
or     %rcx,%rax
movq   %rax,%xmm0
punpckldq %xmm2,%xmm0
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
lea    0xb05(%rip),%rdi
call   1060 <printf@plt>
movsd  -0xc8(%rbp),%xmm4
ff
movaps -0xc0(%rbp),%xmm2
movaps -0xb0(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm0
movaps %xmm0,%xmm3
subsd  %xmm4,%xmm3
cvttsd2si %xmm3,%rcx
cvttsd2si %xmm0,%rax
mov    %rax,%rdx
sar    $0x3f,%rdx
and    %rdx,%rcx
or     %rcx,%rax
movq   %rax,%xmm0
punpckldq %xmm2,%xmm0
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
lea    0xaca(%rip),%rdi
call   1060 <printf@plt>
movsd  -0xc8(%rbp),%xmm4
ff
movaps -0xc0(%rbp),%xmm2
movaps -0xb0(%rbp),%xmm1
movsd  -0x68(%rbp),%xmm0
movaps %xmm0,%xmm3
subsd  %xmm4,%xmm3
cvttsd2si %xmm3,%rcx
cvttsd2si %xmm0,%rax
mov    %rax,%rdx
sar    $0x3f,%rdx
and    %rdx,%rcx
or     %rcx,%rax
movq   %rax,%xmm0
punpckldq %xmm2,%xmm0
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
lea    0xa8f(%rip),%rdi
call   1060 <printf@plt>
movsd  -0x70(%rbp),%xmm0
lea    0xaa0(%rip),%rdi
call   1060 <printf@plt>
movsd  -0x78(%rbp),%xmm0
lea    0xac1(%rip),%rdi
call   1060 <printf@plt>
movsd  -0x80(%rbp),%xmm0
lea    0xae2(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    0x8(%rsi),%rdi
call   10c0 <atoi@plt>
mov    %eax,%r12d
mov    %eax,%ebx
imul   %eax,%ebx
shl    $0x3,%ebx
mov    %ebx,%edi
call   1070 <malloc@plt>
mov    %rax,%r13
mov    %ebx,%edi
call   1070 <malloc@plt>
mov    %rax,%r15
mov    %ebx,%edi
call   1070 <malloc@plt>
mov    %rax,%rbp
mov    %rax,0x38(%rsp)
mov    %ebx,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
mov    %rax,0x30(%rsp)
mov    %ebx,%edi
call   1070 <malloc@plt>
mov    %rax,0x10(%rsp)
mov    %ebx,%edi
call   1070 <malloc@plt>
mov    %rax,0x28(%rsp)
mov    %r13,%rdi
mov    %r12d,%esi
call   1090 <RandMatrixGen@plt>
mov    %r15,%rdi
mov    %r12d,%esi
call   1090 <RandMatrixGen@plt>
mov    0x2dbc(%rip),%rbx
mov    (%rbx),%edi
mov    %rsp,%rsi
call   1040 <clock_gettime@plt>
mov    %r13,%rdi
mov    %r15,%rsi
mov    %rbp,%rdx
mov    %r12d,%ecx
call   10b0 <dgemm0@plt>
mov    (%rbx),%edi
lea    0x18(%rsp),%rbp
mov    %rbp,%rsi
call   1040 <clock_gettime@plt>
mov    0x18(%rsp),%rax
sub    (%rsp),%rax
imul   $0x3b9aca00,%rax,%rax
cvtsi2sd %rax,%xmm0
addsd  0x20(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
movapd %xmm0,0x70(%rsp)
mov    (%rbx),%edi
mov    %rsp,%rsi
call   1040 <clock_gettime@plt>
mov    %r13,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %r12d,%ecx
call   1050 <dgemm1@plt>
mov    (%rbx),%edi
mov    %rbp,%rsi
mov    %rbp,%r14
call   1040 <clock_gettime@plt>
mov    0x18(%rsp),%rax
sub    (%rsp),%rax
imul   $0x3b9aca00,%rax,%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x20(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
movapd %xmm0,0x60(%rsp)
mov    (%rbx),%edi
mov    %rsp,%rsi
call   1040 <clock_gettime@plt>
mov    %r13,%rdi
mov    %r15,%rsi
mov    0x10(%rsp),%rdx
mov    %r12d,%ecx
call   10a0 <dgemm2@plt>
mov    (%rbx),%edi
mov    %rbp,%rsi
call   1040 <clock_gettime@plt>
mov    0x18(%rsp),%rax
sub    (%rsp),%rax
imul   $0x3b9aca00,%rax,%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x20(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
movapd %xmm0,0x50(%rsp)
mov    (%rbx),%edi
mov    %rsp,%rsi
call   1040 <clock_gettime@plt>
mov    %r13,%rdi
mov    %r15,%rsi
mov    0x28(%rsp),%rbp
mov    %rbp,%rdx
mov    %r12d,%ecx
call   1030 <dgemm3@plt>
mov    (%rbx),%edi
mov    %r14,%rsi
call   1040 <clock_gettime@plt>
mov    0x18(%rsp),%rax
sub    (%rsp),%rax
imul   $0x3b9aca00,%rax,%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x20(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
movapd %xmm0,0x40(%rsp)
mov    0x38(%rsp),%rbx
mov    %rbx,%rdi
mov    0x30(%rsp),%rsi
mov    %r12d,%edx
call   1080 <verification@plt>
movsd  %xmm0,0x30(%rsp)
mov    %rbx,%rdi
mov    0x10(%rsp),%rsi
mov    %r12d,%edx
call   1080 <verification@plt>
movsd  %xmm0,0x10(%rsp)
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r12d,%edx
call   1080 <verification@plt>
movsd  %xmm0,0x28(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %r12d,%xmm0
lea    0xc68(%rip),%rdi
call   1060 <printf@plt>
movapd 0x70(%rsp),%xmm0
cvttsd2si %xmm0,%rax
subsd  0xc20(%rip),%xmm0
cvttsd2si %xmm0,%rcx
mov    %rax,%rdx
sar    $0x3f,%rdx
and    %rcx,%rdx
or     %rax,%rdx
movq   %rdx,%xmm1
punpckldq 0xc11(%rip),%xmm1
subpd  0xc19(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
lea    0xc27(%rip),%rdi
call   1060 <printf@plt>
movapd 0x60(%rsp),%xmm0
cvttsd2si %xmm0,%rax
subsd  0xbce(%rip),%xmm0
cvttsd2si %xmm0,%rcx
mov    %rax,%rdx
sar    $0x3f,%rdx
and    %rcx,%rdx
or     %rax,%rdx
movq   %rdx,%xmm1
punpckldq 0xbbf(%rip),%xmm1
subpd  0xbc7(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
lea    0xbf7(%rip),%rdi
call   1060 <printf@plt>
movapd 0x50(%rsp),%xmm0
cvttsd2si %xmm0,%rax
subsd  0xb7c(%rip),%xmm0
cvttsd2si %xmm0,%rcx
mov    %rax,%rdx
sar    $0x3f,%rdx
and    %rcx,%rdx
or     %rax,%rdx
movq   %rdx,%xmm1
punpckldq 0xb6d(%rip),%xmm1
subpd  0xb75(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
lea    0xbc7(%rip),%rdi
call   1060 <printf@plt>
movapd 0x40(%rsp),%xmm0
cvttsd2si %xmm0,%rax
subsd  0xb2a(%rip),%xmm0
cvttsd2si %xmm0,%rcx
mov    %rax,%rdx
sar    $0x3f,%rdx
and    %rcx,%rdx
or     %rax,%rdx
movq   %rdx,%xmm1
punpckldq 0xb1b(%rip),%xmm1
subpd  0xb23(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
lea    0xb97(%rip),%rdi
call   1060 <printf@plt>
lea    0xbad(%rip),%rdi
movsd  0x30(%rsp),%xmm0
call   1060 <printf@plt>
lea    0xbcd(%rip),%rdi
movsd  0x10(%rsp),%xmm0
call   1060 <printf@plt>
lea    0xbed(%rip),%rdi
movsd  0x28(%rsp),%xmm0
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timespec = type { i64, double }
@CLOCK_MONOTONIC = global i32 0
@.str = [17 x i8] c"matrix size: %d\0A\00"
@.str.1 = [34 x i8] c"dgemm0 runtime: %llu nanoseconds\0A\00"
@.str.2 = [34 x i8] c"dgemm1 runtime: %llu nanoseconds\0A\00"
@.str.3 = [34 x i8] c"dgemm2 runtime: %llu nanoseconds\0A\00"
@.str.4 = [34 x i8] c"dgemm3 runtime: %llu nanoseconds\0A\00"
@.str.5 = [50 x i8] c"maximum difference between dgemm0 and dgemm1: %f\0A\00"
@.str.6 = [50 x i8] c"maximum difference between dgemm0 and dgemm2: %f\0A\00"
@.str.7 = [50 x i8] c"maximum difference between dgemm0 and dgemm3: %f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca double*
%9 = alloca double*
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca %struct.timespec
%22 = alloca %struct.timespec
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32 @atoi(i8* %25)
store i32 %26, i32* %6
%27 = load i32, i32* %6
%28 = load i32, i32* %6
%29 = mul nsw i32 %27, %28
%30 = sext i32 %29 to i64
%31 = mul i64 %30, 8
%32 = trunc i64 %31 to i32
%33 = call i64 @malloc(i32 %32)
%34 = inttoptr i64 %33 to double*
store double* %34, double** %8
%35 = load i32, i32* %6
%36 = load i32, i32* %6
%37 = mul nsw i32 %35, %36
%38 = sext i32 %37 to i64
%39 = mul i64 %38, 8
%40 = trunc i64 %39 to i32
%41 = call i64 @malloc(i32 %40)
%42 = inttoptr i64 %41 to double*
store double* %42, double** %9
%43 = load i32, i32* %6
%44 = load i32, i32* %6
%45 = mul nsw i32 %43, %44
%46 = sext i32 %45 to i64
%47 = mul i64 %46, 8
%48 = trunc i64 %47 to i32
%49 = call i64 @malloc(i32 %48)
%50 = inttoptr i64 %49 to double*
store double* %50, double** %10
%51 = load i32, i32* %6
%52 = load i32, i32* %6
%53 = mul nsw i32 %51, %52
%54 = sext i32 %53 to i64
%55 = mul i64 %54, 8
%56 = trunc i64 %55 to i32
%57 = call i64 @malloc(i32 %56)
%58 = inttoptr i64 %57 to double*
store double* %58, double** %11
%59 = load i32, i32* %6
%60 = load i32, i32* %6
%61 = mul nsw i32 %59, %60
%62 = sext i32 %61 to i64
%63 = mul i64 %62, 8
%64 = trunc i64 %63 to i32
%65 = call i64 @malloc(i32 %64)
%66 = inttoptr i64 %65 to double*
store double* %66, double** %12
%67 = load i32, i32* %6
%68 = load i32, i32* %6
%69 = mul nsw i32 %67, %68
%70 = sext i32 %69 to i64
%71 = mul i64 %70, 8
%72 = trunc i64 %71 to i32
%73 = call i64 @malloc(i32 %72)
%74 = inttoptr i64 %73 to double*
store double* %74, double** %13
%75 = load double*, double** %8
%76 = load i32, i32* %6
%77 = call i32 @RandMatrixGen(double* %75, i32 %76)
%78 = load double*, double** %9
%79 = load i32, i32* %6
%80 = call i32 @RandMatrixGen(double* %78, i32 %79)
%81 = load i32, i32* @CLOCK_MONOTONIC
%82 = call i32 @clock_gettime(i32 %81, %struct.timespec* %21)
%83 = load double*, double** %8
%84 = load double*, double** %9
%85 = load double*, double** %10
%86 = load i32, i32* %6
%87 = call i32 @dgemm0(double* %83, double* %84, double* %85, i32 %86)
%88 = load i32, i32* @CLOCK_MONOTONIC
%89 = call i32 @clock_gettime(i32 %88, %struct.timespec* %22)
%90 = getelementptr inbounds %struct.timespec, %struct.timespec* %22, i32 0, i32 0
%91 = load i64, i64* %90
%92 = getelementptr inbounds %struct.timespec, %struct.timespec* %21, i32 0, i32 0
%93 = load i64, i64* %92
%94 = sub nsw i64 %91, %93
%95 = mul nsw i64 %94, 1000000000
%96 = sitofp i64 %95 to double
%97 = getelementptr inbounds %struct.timespec, %struct.timespec* %22, i32 0, i32 1
%98 = load double, double* %97
%99 = fadd double %96, %98
%100 = getelementptr inbounds %struct.timespec, %struct.timespec* %21, i32 0, i32 1
%101 = load double, double* %100
%102 = fsub double %99, %101
store double %102, double* %14
%103 = load i32, i32* @CLOCK_MONOTONIC
%104 = call i32 @clock_gettime(i32 %103, %struct.timespec* %21)
%105 = load double*, double** %8
%106 = load double*, double** %9
%107 = load double*, double** %11
%108 = load i32, i32* %6
%109 = call i32 @dgemm1(double* %105, double* %106, double* %107, i32 %108)
%110 = load i32, i32* @CLOCK_MONOTONIC
%111 = call i32 @clock_gettime(i32 %110, %struct.timespec* %22)
%112 = getelementptr inbounds %struct.timespec, %struct.timespec* %22, i32 0, i32 0
%113 = load i64, i64* %112
%114 = getelementptr inbounds %struct.timespec, %struct.timespec* %21, i32 0, i32 0
%115 = load i64, i64* %114
%116 = sub nsw i64 %113, %115
%117 = mul nsw i64 %116, 1000000000
%118 = sitofp i64 %117 to double
%119 = getelementptr inbounds %struct.timespec, %struct.timespec* %22, i32 0, i32 1
%120 = load double, double* %119
%121 = fadd double %118, %120
%122 = getelementptr inbounds %struct.timespec, %struct.timespec* %21, i32 0, i32 1
%123 = load double, double* %122
%124 = fsub double %121, %123
store double %124, double* %15
%125 = load i32, i32* @CLOCK_MONOTONIC
%126 = call i32 @clock_gettime(i32 %125, %struct.timespec* %21)
%127 = load double*, double** %8
%128 = load double*, double** %9
%129 = load double*, double** %12
%130 = load i32, i32* %6
%131 = call i32 @dgemm2(double* %127, double* %128, double* %129, i32 %130)
%132 = load i32, i32* @CLOCK_MONOTONIC
%133 = call i32 @clock_gettime(i32 %132, %struct.timespec* %22)
%134 = getelementptr inbounds %struct.timespec, %struct.timespec* %22, i32 0, i32 0
%135 = load i64, i64* %134
%136 = getelementptr inbounds %struct.timespec, %struct.timespec* %21, i32 0, i32 0
%137 = load i64, i64* %136
%138 = sub nsw i64 %135, %137
%139 = mul nsw i64 %138, 1000000000
%140 = sitofp i64 %139 to double
%141 = getelementptr inbounds %struct.timespec, %struct.timespec* %22, i32 0, i32 1
%142 = load double, double* %141
%143 = fadd double %140, %142
%144 = getelementptr inbounds %struct.timespec, %struct.timespec* %21, i32 0, i32 1
%145 = load double, double* %144
%146 = fsub double %143, %145
store double %146, double* %16
%147 = load i32, i32* @CLOCK_MONOTONIC
%148 = call i32 @clock_gettime(i32 %147, %struct.timespec* %21)
%149 = load double*, double** %8
%150 = load double*, double** %9
%151 = load double*, double** %13
%152 = load i32, i32* %6
%153 = call i32 @dgemm3(double* %149, double* %150, double* %151, i32 %152)
%154 = load i32, i32* @CLOCK_MONOTONIC
%155 = call i32 @clock_gettime(i32 %154, %struct.timespec* %22)
%156 = getelementptr inbounds %struct.timespec, %struct.timespec* %22, i32 0, i32 0
%157 = load i64, i64* %156
%158 = getelementptr inbounds %struct.timespec, %struct.timespec* %21, i32 0, i32 0
%159 = load i64, i64* %158
%160 = sub nsw i64 %157, %159
%161 = mul nsw i64 %160, 1000000000
%162 = sitofp i64 %161 to double
%163 = getelementptr inbounds %struct.timespec, %struct.timespec* %22, i32 0, i32 1
%164 = load double, double* %163
%165 = fadd double %162, %164
%166 = getelementptr inbounds %struct.timespec, %struct.timespec* %21, i32 0, i32 1
%167 = load double, double* %166
%168 = fsub double %165, %167
store double %168, double* %17
%169 = load double*, double** %10
%170 = load double*, double** %11
%171 = load i32, i32* %6
%172 = call double @verification(double* %169, double* %170, i32 %171)
store double %172, double* %18
%173 = load double*, double** %10
%174 = load double*, double** %12
%175 = load i32, i32* %6
%176 = call double @verification(double* %173, double* %174, i32 %175)
store double %176, double* %19
%177 = load double*, double** %10
%178 = load double*, double** %13
%179 = load i32, i32* %6
%180 = call double @verification(double* %177, double* %178, i32 %179)
store double %180, double* %20
%181 = load i32, i32* %6
%182 = sitofp i32 %181 to double
%183 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), double %182)
%184 = load double, double* %14
%185 = fptoui double %184 to i64
%186 = uitofp i64 %185 to double
%187 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), double %186)
%188 = load double, double* %15
%189 = fptoui double %188 to i64
%190 = uitofp i64 %189 to double
%191 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), double %190)
%192 = load double, double* %16
%193 = fptoui double %192 to i64
%194 = uitofp i64 %193 to double
%195 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), double %194)
%196 = load double, double* %17
%197 = fptoui double %196 to i64
%198 = uitofp i64 %197 to double
%199 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), double %198)
%200 = load double, double* %18
%201 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.5, i64 0, i64 0), double %200)
%202 = load double, double* %19
%203 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0), double %202)
%204 = load double, double* %20
%205 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.7, i64 0, i64 0), double %204)
ret i32 0
}

LLVM IR (-O2):
%struct.timespec = type { i64, double }
@CLOCK_MONOTONIC = global i32 0
@.str = [17 x i8] c"matrix size: %d\0A\00"
@.str.1 = [34 x i8] c"dgemm0 runtime: %llu nanoseconds\0A\00"
@.str.2 = [34 x i8] c"dgemm1 runtime: %llu nanoseconds\0A\00"
@.str.3 = [34 x i8] c"dgemm2 runtime: %llu nanoseconds\0A\00"
@.str.4 = [34 x i8] c"dgemm3 runtime: %llu nanoseconds\0A\00"
@.str.5 = [50 x i8] c"maximum difference between dgemm0 and dgemm1: %f\0A\00"
@.str.6 = [50 x i8] c"maximum difference between dgemm0 and dgemm2: %f\0A\00"
@.str.7 = [50 x i8] c"maximum difference between dgemm0 and dgemm3: %f\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.timespec
%4 = alloca %struct.timespec
%5 = bitcast %struct.timespec* %3 to i8*
%6 = bitcast %struct.timespec* %4 to i8*
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
%10 = shl i32 %9, 3
%11 = mul i32 %10, %9
%12 = tail call i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to double*
%14 = tail call i64 @malloc(i32 %11)
%15 = inttoptr i64 %14 to double*
%16 = tail call i64 @malloc(i32 %11)
%17 = inttoptr i64 %16 to double*
%18 = tail call i64 @malloc(i32 %11)
%19 = inttoptr i64 %18 to double*
%20 = tail call i64 @malloc(i32 %11)
%21 = inttoptr i64 %20 to double*
%22 = tail call i64 @malloc(i32 %11)
%23 = inttoptr i64 %22 to double*
%24 = tail call i32 @RandMatrixGen(double* %13, i32 %9)
%25 = tail call i32 @RandMatrixGen(double* %15, i32 %9)
%26 = load i32, i32* @CLOCK_MONOTONIC
%27 = call i32 @clock_gettime(i32 %26, %struct.timespec* %3)
%28 = call i32 @dgemm0(double* %13, double* %15, double* %17, i32 %9)
%29 = load i32, i32* @CLOCK_MONOTONIC
%30 = call i32 @clock_gettime(i32 %29, %struct.timespec* %4)
%31 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i64 0, i32 0
%32 = load i64, i64* %31
%33 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 0
%34 = load i64, i64* %33
%35 = sub nsw i64 %32, %34
%36 = mul nsw i64 %35, 1000000000
%37 = sitofp i64 %36 to double
%38 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i64 0, i32 1
%39 = load double, double* %38
%40 = fadd double %39, %37
%41 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 1
%42 = load double, double* %41
%43 = fsub double %40, %42
%44 = load i32, i32* @CLOCK_MONOTONIC
%45 = call i32 @clock_gettime(i32 %44, %struct.timespec* %3)
%46 = call i32 @dgemm1(double* %13, double* %15, double* %19, i32 %9)
%47 = load i32, i32* @CLOCK_MONOTONIC
%48 = call i32 @clock_gettime(i32 %47, %struct.timespec* %4)
%49 = load i64, i64* %31
%50 = load i64, i64* %33
%51 = sub nsw i64 %49, %50
%52 = mul nsw i64 %51, 1000000000
%53 = sitofp i64 %52 to double
%54 = load double, double* %38
%55 = fadd double %54, %53
%56 = load double, double* %41
%57 = fsub double %55, %56
%58 = load i32, i32* @CLOCK_MONOTONIC
%59 = call i32 @clock_gettime(i32 %58, %struct.timespec* %3)
%60 = call i32 @dgemm2(double* %13, double* %15, double* %21, i32 %9)
%61 = load i32, i32* @CLOCK_MONOTONIC
%62 = call i32 @clock_gettime(i32 %61, %struct.timespec* %4)
%63 = load i64, i64* %31
%64 = load i64, i64* %33
%65 = sub nsw i64 %63, %64
%66 = mul nsw i64 %65, 1000000000
%67 = sitofp i64 %66 to double
%68 = load double, double* %38
%69 = fadd double %68, %67
%70 = load double, double* %41
%71 = fsub double %69, %70
%72 = load i32, i32* @CLOCK_MONOTONIC
%73 = call i32 @clock_gettime(i32 %72, %struct.timespec* %3)
%74 = call i32 @dgemm3(double* %13, double* %15, double* %23, i32 %9)
%75 = load i32, i32* @CLOCK_MONOTONIC
%76 = call i32 @clock_gettime(i32 %75, %struct.timespec* %4)
%77 = load i64, i64* %31
%78 = load i64, i64* %33
%79 = sub nsw i64 %77, %78
%80 = mul nsw i64 %79, 1000000000
%81 = sitofp i64 %80 to double
%82 = load double, double* %38
%83 = fadd double %82, %81
%84 = load double, double* %41
%85 = fsub double %83, %84
%86 = call double @verification(double* %17, double* %19, i32 %9)
%87 = call double @verification(double* %17, double* %21, i32 %9)
%88 = call double @verification(double* %17, double* %23, i32 %9)
%89 = sitofp i32 %9 to double
%90 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), double %89)
%91 = fptoui double %43 to i64
%92 = uitofp i64 %91 to double
%93 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), double %92)
%94 = fptoui double %57 to i64
%95 = uitofp i64 %94 to double
%96 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), double %95)
%97 = fptoui double %71 to i64
%98 = uitofp i64 %97 to double
%99 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), double %98)
%100 = fptoui double %85 to i64
%101 = uitofp i64 %100 to double
%102 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), double %101)
%103 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.5, i64 0, i64 0), double %86)
%104 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0), double %87)
%105 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.7, i64 0, i64 0), double %88)
ret i32 0
}