#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*/ memcpy(double **, double **, int);
void mat3_mul(double AB[3][3], double A[3][3], double B[3][3]) {
  int c, r;
  double T[3][3];
  for (c = 0; c < 3; c++) {
    for (r = 0; r < 3; r++) {
      T[r][c] = A[r][0] * B[0][c] + A[r][1] * B[1][c] + A[r][2] * B[2][c];
    }
  }
  memcpy(AB, T, sizeof(double) * 3 * 3);
}


x86 assembly (clang, -O0):
<mat3_mul>:
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    11f3 <mat3_mul+0xe3>
movl   $0x0,-0x20(%rbp)
cmpl   $0x3,-0x20(%rbp)
jge    11e0 <mat3_mul+0xd0>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  (%rax),%xmm1
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mulsd  0x18(%rax,%rcx,8),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  0x30(%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movslq -0x20(%rbp),%rcx
lea    -0x70(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    113c <mat3_mul+0x2c>
jmp    11e5 <mat3_mul+0xd5>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112b <mat3_mul+0x1b>
mov    -0x8(%rbp),%rdi
lea    -0x70(%rbp),%rsi
mov    $0x48,%edx
call   1030 <memcpy@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mat3_mul>:
sub    $0x58,%rsp
movupd (%rdx),%xmm3
movupd 0x18(%rdx),%xmm5
movupd 0x30(%rdx),%xmm4
movsd  0x30(%rsi),%xmm12
movsd  0x38(%rsi),%xmm10
movapd %xmm10,(%rsp)
movsd  0x40(%rsi),%xmm15
movsd  (%rsi),%xmm1
movsd  0x8(%rsi),%xmm7
movsd  0x10(%rsi),%xmm8
movsd  0x18(%rsi),%xmm9
movapd %xmm7,%xmm0
unpcklpd %xmm7,%xmm0
mulpd  %xmm5,%xmm0
movapd %xmm1,%xmm6
unpcklpd %xmm1,%xmm6
mulpd  %xmm3,%xmm6
addpd  %xmm0,%xmm6
movapd %xmm8,%xmm0
unpcklpd %xmm8,%xmm0
mulpd  %xmm4,%xmm0
addpd  %xmm6,%xmm0
movsd  0x20(%rsi),%xmm6
movsd  0x28(%rsi),%xmm14
movapd %xmm0,0x10(%rsp)
unpcklpd %xmm10,%xmm10
mulpd  %xmm5,%xmm10
movapd %xmm12,%xmm0
unpcklpd %xmm12,%xmm0
mulpd  %xmm3,%xmm0
addpd  %xmm10,%xmm0
movapd %xmm15,%xmm2
unpcklpd %xmm15,%xmm2
mulpd  %xmm4,%xmm2
addpd  %xmm0,%xmm2
movapd %xmm2,0x40(%rsp)
movsd  0x10(%rdx),%xmm11
movsd  0x28(%rdx),%xmm13
movsd  0x40(%rdx),%xmm10
unpcklpd %xmm6,%xmm7
movapd %xmm13,%xmm0
unpcklpd %xmm5,%xmm0
mulpd  %xmm7,%xmm0
unpcklpd %xmm9,%xmm1
movapd %xmm11,%xmm2
unpcklpd %xmm3,%xmm2
mulpd  %xmm1,%xmm2
addpd  %xmm0,%xmm2
unpcklpd %xmm14,%xmm8
movapd %xmm10,%xmm0
unpcklpd %xmm4,%xmm0
mulpd  %xmm8,%xmm0
addpd  %xmm2,%xmm0
movapd %xmm0,0x20(%rsp)
unpcklpd %xmm6,%xmm6
shufpd $0x1,%xmm13,%xmm5
mulpd  %xmm6,%xmm5
unpcklpd %xmm9,%xmm9
shufpd $0x1,%xmm11,%xmm3
mulpd  %xmm9,%xmm3
addpd  %xmm5,%xmm3
unpcklpd %xmm14,%xmm14
shufpd $0x1,%xmm10,%xmm4
mulpd  %xmm14,%xmm4
addpd  %xmm3,%xmm4
movapd %xmm4,0x30(%rsp)
movapd (%rsp),%xmm0
mulsd  %xmm13,%xmm0
mulsd  %xmm11,%xmm12
addsd  %xmm0,%xmm12
mulsd  %xmm10,%xmm15
addsd  %xmm12,%xmm15
movsd  %xmm15,0x50(%rsp)
lea    0x10(%rsp),%rsi
mov    $0x48,%edx
call   1030 <memcpy@plt>
add    $0x58,%rsp
ret

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

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