#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*/ mat_copy_matrix_d3(double **, double **);
void mat_multiply_matrix_ld3(double m[3][3], long a[3][3], double b[3][3]) {
  int i, j;
  double c[3][3];
  for (i = 0; i < 3; i++) {
    for (j = 0; j < 3; j++) {
      c[i][j] = a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j];
    }
  }
  mat_copy_matrix_d3(m, c);
}


x86 assembly (clang, -O0):
<mat_multiply_matrix_ld3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jge    11f6 <mat_multiply_matrix_ld3+0xe6>
movl   $0x0,-0x20(%rbp)
cmpl   $0x3,-0x20(%rbp)
jge    11e3 <mat_multiply_matrix_ld3+0xd3>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
cvtsi2sdq (%rax),%xmm1
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
cvtsi2sdq 0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mulsd  0x18(%rax,%rcx,8),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
cvtsi2sdq 0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  0x30(%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movslq -0x1c(%rbp),%rcx
lea    -0x70(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    113c <mat_multiply_matrix_ld3+0x2c>
jmp    11e8 <mat_multiply_matrix_ld3+0xd8>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112b <mat_multiply_matrix_ld3+0x1b>
mov    -0x8(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1030 <mat_copy_matrix_d3@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mat_multiply_matrix_ld3>:
sub    $0x48,%rsp
cvtsi2sdq (%rsi),%xmm6
cvtsi2sdq 0x8(%rsi),%xmm5
cvtsi2sdq 0x10(%rsi),%xmm7
movapd %xmm5,%xmm3
unpcklpd %xmm5,%xmm3
movupd (%rdx),%xmm9
movupd 0x18(%rdx),%xmm10
movupd 0x30(%rdx),%xmm8
mulpd  %xmm10,%xmm3
movapd %xmm6,%xmm4
unpcklpd %xmm6,%xmm4
mulpd  %xmm9,%xmm4
addpd  %xmm3,%xmm4
movapd %xmm7,%xmm3
unpcklpd %xmm7,%xmm3
mulpd  %xmm8,%xmm3
addpd  %xmm4,%xmm3
movapd %xmm3,(%rsp)
movsd  0x10(%rdx),%xmm4
movsd  0x28(%rdx),%xmm1
mulsd  %xmm1,%xmm5
mulsd  %xmm4,%xmm6
addsd  %xmm5,%xmm6
movsd  0x40(%rdx),%xmm5
mulsd  %xmm5,%xmm7
addsd  %xmm6,%xmm7
movsd  %xmm7,0x10(%rsp)
cvtsi2sdq 0x18(%rsi),%xmm2
xorps  %xmm7,%xmm7
cvtsi2sdq 0x20(%rsi),%xmm7
cvtsi2sdq 0x28(%rsi),%xmm0
movapd %xmm1,%xmm3
mulsd  %xmm7,%xmm3
unpcklpd %xmm7,%xmm7
mulpd  %xmm10,%xmm7
movapd %xmm2,%xmm6
unpcklpd %xmm2,%xmm6
mulpd  %xmm9,%xmm6
addpd  %xmm7,%xmm6
movapd %xmm0,%xmm7
unpcklpd %xmm0,%xmm7
mulpd  %xmm8,%xmm7
addpd  %xmm6,%xmm7
movupd %xmm7,0x18(%rsp)
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
mulsd  %xmm5,%xmm0
addsd  %xmm2,%xmm0
movsd  %xmm0,0x28(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sdq 0x30(%rsi),%xmm0
xorps  %xmm2,%xmm2
cvtsi2sdq 0x38(%rsi),%xmm2
xorps  %xmm3,%xmm3
cvtsi2sdq 0x40(%rsi),%xmm3
mulsd  %xmm2,%xmm1
unpcklpd %xmm2,%xmm2
mulpd  %xmm10,%xmm2
movapd %xmm0,%xmm6
unpcklpd %xmm0,%xmm6
mulpd  %xmm9,%xmm6
addpd  %xmm2,%xmm6
movapd %xmm3,%xmm2
unpcklpd %xmm3,%xmm2
mulpd  %xmm8,%xmm2
addpd  %xmm6,%xmm2
movapd %xmm2,0x30(%rsp)
mulsd  %xmm4,%xmm0
addsd  %xmm1,%xmm0
mulsd  %xmm5,%xmm3
addsd  %xmm0,%xmm3
movsd  %xmm3,0x40(%rsp)
mov    %rsp,%rsi
call   1030 <mat_copy_matrix_d3@plt>
add    $0x48,%rsp
ret

LLVM IR (-O0):
define void @mat_multiply_matrix_ld3([3 x double]* %0, [3 x i64]* %1, [3 x double]* %2) {
%4 = alloca [3 x double]*
%5 = alloca [3 x i64]*
%6 = alloca [3 x double]*
%7 = alloca i32
%8 = alloca i32
%9 = alloca [3 x [3 x double]]
store [3 x double]* %0, [3 x double]** %4
store [3 x i64]* %1, [3 x i64]** %5
store [3 x double]* %2, [3 x double]** %6
store i32 0, i32* %7
br label %10
10: ; preds = %70, %3
%11 = load i32, i32* %7
%12 = icmp slt i32 %11, 3
br i1 %12, label %13, label %73
13: ; preds = %10
store i32 0, i32* %8
br label %14
14: ; preds = %66, %13
%15 = load i32, i32* %8
%16 = icmp slt i32 %15, 3
br i1 %16, label %17, label %69
17: ; preds = %14
%18 = load [3 x i64]*, [3 x i64]** %5
%19 = load i32, i32* %7
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [3 x i64], [3 x i64]* %18, i64 %20
%22 = getelementptr inbounds [3 x i64], [3 x i64]* %21, i64 0, i64 0
%23 = load i64, i64* %22
%24 = sitofp i64 %23 to double
%25 = load [3 x double]*, [3 x double]** %6
%26 = getelementptr inbounds [3 x double], [3 x double]* %25, i64 0
%27 = load i32, i32* %8
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [3 x double], [3 x double]* %26, i64 0, i64 %28
%30 = load double, double* %29
%31 = load [3 x i64]*, [3 x i64]** %5
%32 = load i32, i32* %7
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [3 x i64], [3 x i64]* %31, i64 %33
%35 = getelementptr inbounds [3 x i64], [3 x i64]* %34, i64 0, i64 1
%36 = load i64, i64* %35
%37 = sitofp i64 %36 to double
%38 = load [3 x double]*, [3 x double]** %6
%39 = getelementptr inbounds [3 x double], [3 x double]* %38, i64 1
%40 = load i32, i32* %8
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [3 x double], [3 x double]* %39, i64 0, i64 %41
%43 = load double, double* %42
%44 = fmul double %37, %43
%45 = call double @llvm.fmuladd.f64(double %24, double %30, double %44)
%46 = load [3 x i64]*, [3 x i64]** %5
%47 = load i32, i32* %7
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [3 x i64], [3 x i64]* %46, i64 %48
%50 = getelementptr inbounds [3 x i64], [3 x i64]* %49, i64 0, i64 2
%51 = load i64, i64* %50
%52 = sitofp i64 %51 to double
%53 = load [3 x double]*, [3 x double]** %6
%54 = getelementptr inbounds [3 x double], [3 x double]* %53, i64 2
%55 = load i32, i32* %8
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [3 x double], [3 x double]* %54, i64 0, i64 %56
%58 = load double, double* %57
%59 = call double @llvm.fmuladd.f64(double %52, double %58, double %45)
%60 = load i32, i32* %7
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %9, i64 0, i64 %61
%63 = load i32, i32* %8
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [3 x double], [3 x double]* %62, i64 0, i64 %64
store double %59, double* %65
br label %66
66: ; preds = %17
%67 = load i32, i32* %8
%68 = add nsw i32 %67, 1
store i32 %68, i32* %8
br label %14
69: ; preds = %14
br label %70
70: ; preds = %69
%71 = load i32, i32* %7
%72 = add nsw i32 %71, 1
store i32 %72, i32* %7
br label %10
73: ; preds = %10
%74 = load [3 x double]*, [3 x double]** %4
%75 = bitcast [3 x double]* %74 to double**
%76 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %9, i64 0, i64 0
%77 = bitcast [3 x double]* %76 to double**
%78 = call i32 @mat_copy_matrix_d3(double** %75, double** %77)
ret void
}

LLVM IR (-O2):
define void @mat_multiply_matrix_ld3([3 x double]* %0, [3 x i64]* nocapture %1, [3 x double]* nocapture %2) {
%4 = alloca [3 x [3 x double]]
%5 = bitcast [3 x [3 x double]]* %4 to i8*
%6 = getelementptr inbounds [3 x i64], [3 x i64]* %1, i64 0, i64 0
%7 = load i64, i64* %6
%8 = sitofp i64 %7 to double
%9 = getelementptr inbounds [3 x i64], [3 x i64]* %1, i64 0, i64 1
%10 = load i64, i64* %9
%11 = sitofp i64 %10 to double
%12 = getelementptr inbounds [3 x i64], [3 x i64]* %1, i64 0, i64 2
%13 = load i64, i64* %12
%14 = sitofp i64 %13 to double
%15 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 1, i64 0
%16 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 2, i64 0
%17 = bitcast [3 x double]* %2 to <2 x double>*
%18 = load <2 x double>, <2 x double>* %17
%19 = bitcast double* %15 to <2 x double>*
%20 = load <2 x double>, <2 x double>* %19
%21 = insertelement <2 x double> poison, double %11, i64 0
%22 = shufflevector <2 x double> %21, <2 x double> poison, <2 x i32> zeroinitializer
%23 = fmul <2 x double> %20, %22
%24 = insertelement <2 x double> poison, double %8, i64 0
%25 = shufflevector <2 x double> %24, <2 x double> poison, <2 x i32> zeroinitializer
%26 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %25, <2 x double> %18, <2 x double> %23)
%27 = bitcast double* %16 to <2 x double>*
%28 = load <2 x double>, <2 x double>* %27
%29 = insertelement <2 x double> poison, double %14, i64 0
%30 = shufflevector <2 x double> %29, <2 x double> poison, <2 x i32> zeroinitializer
%31 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %30, <2 x double> %28, <2 x double> %26)
%32 = bitcast [3 x [3 x double]]* %4 to <2 x double>*
store <2 x double> %31, <2 x double>* %32
%33 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 2
%34 = load double, double* %33
%35 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 1, i64 2
%36 = load double, double* %35
%37 = fmul double %36, %11
%38 = tail call double @llvm.fmuladd.f64(double %8, double %34, double %37)
%39 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 2, i64 2
%40 = load double, double* %39
%41 = tail call double @llvm.fmuladd.f64(double %14, double %40, double %38)
%42 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %4, i64 0, i64 0, i64 2
store double %41, double* %42
%43 = getelementptr inbounds [3 x i64], [3 x i64]* %1, i64 1, i64 0
%44 = load i64, i64* %43
%45 = sitofp i64 %44 to double
%46 = getelementptr inbounds [3 x i64], [3 x i64]* %1, i64 1, i64 1
%47 = load i64, i64* %46
%48 = sitofp i64 %47 to double
%49 = getelementptr inbounds [3 x i64], [3 x i64]* %1, i64 1, i64 2
%50 = load i64, i64* %49
%51 = sitofp i64 %50 to double
%52 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %4, i64 0, i64 1, i64 0
%53 = insertelement <2 x double> poison, double %48, i64 0
%54 = shufflevector <2 x double> %53, <2 x double> poison, <2 x i32> zeroinitializer
%55 = fmul <2 x double> %20, %54
%56 = insertelement <2 x double> poison, double %45, i64 0
%57 = shufflevector <2 x double> %56, <2 x double> poison, <2 x i32> zeroinitializer
%58 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %57, <2 x double> %18, <2 x double> %55)
%59 = insertelement <2 x double> poison, double %51, i64 0
%60 = shufflevector <2 x double> %59, <2 x double> poison, <2 x i32> zeroinitializer
%61 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %60, <2 x double> %28, <2 x double> %58)
%62 = bitcast double* %52 to <2 x double>*
store <2 x double> %61, <2 x double>* %62
%63 = fmul double %36, %48
%64 = tail call double @llvm.fmuladd.f64(double %45, double %34, double %63)
%65 = tail call double @llvm.fmuladd.f64(double %51, double %40, double %64)
%66 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %4, i64 0, i64 1, i64 2
store double %65, double* %66
%67 = getelementptr inbounds [3 x i64], [3 x i64]* %1, i64 2, i64 0
%68 = load i64, i64* %67
%69 = sitofp i64 %68 to double
%70 = getelementptr inbounds [3 x i64], [3 x i64]* %1, i64 2, i64 1
%71 = load i64, i64* %70
%72 = sitofp i64 %71 to double
%73 = getelementptr inbounds [3 x i64], [3 x i64]* %1, i64 2, i64 2
%74 = load i64, i64* %73
%75 = sitofp i64 %74 to double
%76 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %4, i64 0, i64 2, i64 0
%77 = insertelement <2 x double> poison, double %72, i64 0
%78 = shufflevector <2 x double> %77, <2 x double> poison, <2 x i32> zeroinitializer
%79 = fmul <2 x double> %20, %78
%80 = insertelement <2 x double> poison, double %69, i64 0
%81 = shufflevector <2 x double> %80, <2 x double> poison, <2 x i32> zeroinitializer
%82 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %81, <2 x double> %18, <2 x double> %79)
%83 = insertelement <2 x double> poison, double %75, i64 0
%84 = shufflevector <2 x double> %83, <2 x double> poison, <2 x i32> zeroinitializer
%85 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %84, <2 x double> %28, <2 x double> %82)
%86 = bitcast double* %76 to <2 x double>*
store <2 x double> %85, <2 x double>* %86
%87 = fmul double %36, %72
%88 = tail call double @llvm.fmuladd.f64(double %69, double %34, double %87)
%89 = tail call double @llvm.fmuladd.f64(double %75, double %40, double %88)
%90 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %4, i64 0, i64 2, i64 2
store double %89, double* %90
%91 = bitcast [3 x double]* %0 to double**
%92 = bitcast [3 x [3 x double]]* %4 to double**
%93 = call i32 @mat_copy_matrix_d3(double** %91, double** %92)
ret void
}