#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*/ mat333Multiply(double **, double **, double **);
int /*<<< orphan*/ mat33Transpose(double **, double **);
int /*<<< orphan*/ vec3Cross(double *, double *, double *);
void mat33BasisRotation(double u[3], double v[3], double a[3], double b[3],
                        double rot[3][3]) {
  double w[3];
  vec3Cross(u, v, w);
  double R[3][3] = {
      u[0], v[0], w[0], u[1], v[1], w[1], u[2], v[2], w[2],
  };
  double ab[3];
  vec3Cross(a, b, ab);
  double S[3][3] = {
      a[0], b[0], ab[0], a[1], b[1], ab[1], a[2], b[2], ab[2],
  };
  double Rtrans[3][3];
  mat33Transpose(R, Rtrans);
  mat333Multiply(S, Rtrans, rot);
}


x86 assembly (clang, -O0):
<mat33BasisRotation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x40(%rbp),%rdx
call   1040 <vec3Cross@plt>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x78(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    -0xb0(%rbp),%rdx
call   1040 <vec3Cross@plt>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x100(%rbp)
ff
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0xf8(%rbp)
ff
movsd  -0xb0(%rbp),%xmm0
ff
movsd  %xmm0,-0xf0(%rbp)
ff
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0xe8(%rbp)
ff
mov    -0x20(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0xe0(%rbp)
ff
movsd  -0xa8(%rbp),%xmm0
ff
movsd  %xmm0,-0xd8(%rbp)
ff
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
mov    -0x20(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
movsd  -0xa0(%rbp),%xmm0
ff
movsd  %xmm0,-0xc0(%rbp)
ff
lea    -0x90(%rbp),%rdi
lea    -0x150(%rbp),%rsi
call   1050 <mat33Transpose@plt>
lea    -0x100(%rbp),%rdi
lea    -0x150(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <mat333Multiply@plt>
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mat33BasisRotation>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x130,%rsp
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%r13
mov    %rdi,%rbx
lea    0x20(%rsp),%rdx
call   1040 <vec3Cross@plt>
movsd  (%rbx),%xmm0
movsd  %xmm0,0x90(%rsp)
movsd  0x0(%r13),%xmm0
movsd  %xmm0,0x98(%rsp)
movsd  0x20(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
movsd  %xmm0,0xa0(%rsp)
movsd  0x8(%rbx),%xmm0
movsd  %xmm0,0xa8(%rsp)
movsd  0x8(%r13),%xmm0
movsd  %xmm0,0xb0(%rsp)
movsd  %xmm1,0xb8(%rsp)
movsd  0x10(%rbx),%xmm0
movsd  %xmm0,0xc0(%rsp)
movsd  0x10(%r13),%xmm0
movsd  %xmm0,0xc8(%rsp)
movsd  0x30(%rsp),%xmm0
movsd  %xmm0,0xd0(%rsp)
mov    %rsp,%rdx
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <vec3Cross@plt>
movsd  (%r12),%xmm0
movsd  %xmm0,0x40(%rsp)
movsd  (%r15),%xmm0
movsd  %xmm0,0x48(%rsp)
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  %xmm0,0x50(%rsp)
movsd  0x8(%r12),%xmm0
movsd  %xmm0,0x58(%rsp)
movsd  0x8(%r15),%xmm0
movsd  %xmm0,0x60(%rsp)
movsd  %xmm1,0x68(%rsp)
movsd  0x10(%r12),%xmm0
movsd  %xmm0,0x70(%rsp)
movsd  0x10(%r15),%xmm0
movsd  %xmm0,0x78(%rsp)
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x80(%rsp)
lea    0x90(%rsp),%rdi
lea    0xe0(%rsp),%rbx
mov    %rbx,%rsi
call   1050 <mat33Transpose@plt>
lea    0x40(%rsp),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <mat333Multiply@plt>
add    $0x130,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @mat33BasisRotation(double* %0, double* %1, double* %2, double* %3, [3 x double]* %4) {
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = alloca [3 x double]*
%11 = alloca [3 x double]
%12 = alloca [3 x [3 x double]]
%13 = alloca [3 x double]
%14 = alloca [3 x [3 x double]]
%15 = alloca [3 x [3 x double]]
store double* %0, double** %6
store double* %1, double** %7
store double* %2, double** %8
store double* %3, double** %9
store [3 x double]* %4, [3 x double]** %10
%16 = load double*, double** %6
%17 = load double*, double** %7
%18 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%19 = call i32 @vec3Cross(double* %16, double* %17, double* %18)
%20 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %12, i64 0, i64 0
%21 = getelementptr inbounds [3 x double], [3 x double]* %20, i64 0, i64 0
%22 = load double*, double** %6
%23 = getelementptr inbounds double, double* %22, i64 0
%24 = load double, double* %23
store double %24, double* %21
%25 = getelementptr inbounds double, double* %21, i64 1
%26 = load double*, double** %7
%27 = getelementptr inbounds double, double* %26, i64 0
%28 = load double, double* %27
store double %28, double* %25
%29 = getelementptr inbounds double, double* %25, i64 1
%30 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%31 = load double, double* %30
store double %31, double* %29
%32 = getelementptr inbounds [3 x double], [3 x double]* %20, i64 1
%33 = getelementptr inbounds [3 x double], [3 x double]* %32, i64 0, i64 0
%34 = load double*, double** %6
%35 = getelementptr inbounds double, double* %34, i64 1
%36 = load double, double* %35
store double %36, double* %33
%37 = getelementptr inbounds double, double* %33, i64 1
%38 = load double*, double** %7
%39 = getelementptr inbounds double, double* %38, i64 1
%40 = load double, double* %39
store double %40, double* %37
%41 = getelementptr inbounds double, double* %37, i64 1
%42 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 1
%43 = load double, double* %42
store double %43, double* %41
%44 = getelementptr inbounds [3 x double], [3 x double]* %32, i64 1
%45 = getelementptr inbounds [3 x double], [3 x double]* %44, i64 0, i64 0
%46 = load double*, double** %6
%47 = getelementptr inbounds double, double* %46, i64 2
%48 = load double, double* %47
store double %48, double* %45
%49 = getelementptr inbounds double, double* %45, i64 1
%50 = load double*, double** %7
%51 = getelementptr inbounds double, double* %50, i64 2
%52 = load double, double* %51
store double %52, double* %49
%53 = getelementptr inbounds double, double* %49, i64 1
%54 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 2
%55 = load double, double* %54
store double %55, double* %53
%56 = load double*, double** %8
%57 = load double*, double** %9
%58 = getelementptr inbounds [3 x double], [3 x double]* %13, i64 0, i64 0
%59 = call i32 @vec3Cross(double* %56, double* %57, double* %58)
%60 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %14, i64 0, i64 0
%61 = getelementptr inbounds [3 x double], [3 x double]* %60, i64 0, i64 0
%62 = load double*, double** %8
%63 = getelementptr inbounds double, double* %62, i64 0
%64 = load double, double* %63
store double %64, double* %61
%65 = getelementptr inbounds double, double* %61, i64 1
%66 = load double*, double** %9
%67 = getelementptr inbounds double, double* %66, i64 0
%68 = load double, double* %67
store double %68, double* %65
%69 = getelementptr inbounds double, double* %65, i64 1
%70 = getelementptr inbounds [3 x double], [3 x double]* %13, i64 0, i64 0
%71 = load double, double* %70
store double %71, double* %69
%72 = getelementptr inbounds [3 x double], [3 x double]* %60, i64 1
%73 = getelementptr inbounds [3 x double], [3 x double]* %72, i64 0, i64 0
%74 = load double*, double** %8
%75 = getelementptr inbounds double, double* %74, i64 1
%76 = load double, double* %75
store double %76, double* %73
%77 = getelementptr inbounds double, double* %73, i64 1
%78 = load double*, double** %9
%79 = getelementptr inbounds double, double* %78, i64 1
%80 = load double, double* %79
store double %80, double* %77
%81 = getelementptr inbounds double, double* %77, i64 1
%82 = getelementptr inbounds [3 x double], [3 x double]* %13, i64 0, i64 1
%83 = load double, double* %82
store double %83, double* %81
%84 = getelementptr inbounds [3 x double], [3 x double]* %72, i64 1
%85 = getelementptr inbounds [3 x double], [3 x double]* %84, i64 0, i64 0
%86 = load double*, double** %8
%87 = getelementptr inbounds double, double* %86, i64 2
%88 = load double, double* %87
store double %88, double* %85
%89 = getelementptr inbounds double, double* %85, i64 1
%90 = load double*, double** %9
%91 = getelementptr inbounds double, double* %90, i64 2
%92 = load double, double* %91
store double %92, double* %89
%93 = getelementptr inbounds double, double* %89, i64 1
%94 = getelementptr inbounds [3 x double], [3 x double]* %13, i64 0, i64 2
%95 = load double, double* %94
store double %95, double* %93
%96 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %12, i64 0, i64 0
%97 = bitcast [3 x double]* %96 to double**
%98 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %15, i64 0, i64 0
%99 = bitcast [3 x double]* %98 to double**
%100 = call i32 @mat33Transpose(double** %97, double** %99)
%101 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %14, i64 0, i64 0
%102 = bitcast [3 x double]* %101 to double**
%103 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %15, i64 0, i64 0
%104 = bitcast [3 x double]* %103 to double**
%105 = load [3 x double]*, [3 x double]** %10
%106 = bitcast [3 x double]* %105 to double**
%107 = call i32 @mat333Multiply(double** %102, double** %104, double** %106)
ret void
}

LLVM IR (-O2):
define void @mat33BasisRotation(double* %0, double* %1, double* %2, double* %3, [3 x double]* %4) {
%6 = alloca [3 x double]
%7 = alloca [3 x [3 x double]]
%8 = alloca [3 x double]
%9 = alloca [3 x [3 x double]]
%10 = alloca [3 x [3 x double]]
%11 = bitcast [3 x double]* %6 to i8*
%12 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%13 = call i32 @vec3Cross(double* %0, double* %1, double* %12)
%14 = bitcast [3 x [3 x double]]* %7 to i8*
%15 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %7, i64 0, i64 0, i64 0
%16 = load double, double* %0
store double %16, double* %15
%17 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %7, i64 0, i64 0, i64 1
%18 = load double, double* %1
store double %18, double* %17
%19 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %7, i64 0, i64 0, i64 2
%20 = load double, double* %12
store double %20, double* %19
%21 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %7, i64 0, i64 1, i64 0
%22 = getelementptr inbounds double, double* %0, i64 1
%23 = load double, double* %22
store double %23, double* %21
%24 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %7, i64 0, i64 1, i64 1
%25 = getelementptr inbounds double, double* %1, i64 1
%26 = load double, double* %25
store double %26, double* %24
%27 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %7, i64 0, i64 1, i64 2
%28 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 1
%29 = load double, double* %28
store double %29, double* %27
%30 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %7, i64 0, i64 2, i64 0
%31 = getelementptr inbounds double, double* %0, i64 2
%32 = load double, double* %31
store double %32, double* %30
%33 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %7, i64 0, i64 2, i64 1
%34 = getelementptr inbounds double, double* %1, i64 2
%35 = load double, double* %34
store double %35, double* %33
%36 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %7, i64 0, i64 2, i64 2
%37 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 2
%38 = load double, double* %37
store double %38, double* %36
%39 = bitcast [3 x double]* %8 to i8*
%40 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
%41 = call i32 @vec3Cross(double* %2, double* %3, double* %40)
%42 = bitcast [3 x [3 x double]]* %9 to i8*
%43 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %9, i64 0, i64 0, i64 0
%44 = load double, double* %2
store double %44, double* %43
%45 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %9, i64 0, i64 0, i64 1
%46 = load double, double* %3
store double %46, double* %45
%47 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %9, i64 0, i64 0, i64 2
%48 = load double, double* %40
store double %48, double* %47
%49 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %9, i64 0, i64 1, i64 0
%50 = getelementptr inbounds double, double* %2, i64 1
%51 = load double, double* %50
store double %51, double* %49
%52 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %9, i64 0, i64 1, i64 1
%53 = getelementptr inbounds double, double* %3, i64 1
%54 = load double, double* %53
store double %54, double* %52
%55 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %9, i64 0, i64 1, i64 2
%56 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 1
%57 = load double, double* %56
store double %57, double* %55
%58 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %9, i64 0, i64 2, i64 0
%59 = getelementptr inbounds double, double* %2, i64 2
%60 = load double, double* %59
store double %60, double* %58
%61 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %9, i64 0, i64 2, i64 1
%62 = getelementptr inbounds double, double* %3, i64 2
%63 = load double, double* %62
store double %63, double* %61
%64 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %9, i64 0, i64 2, i64 2
%65 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 2
%66 = load double, double* %65
store double %66, double* %64
%67 = bitcast [3 x [3 x double]]* %10 to i8*
%68 = bitcast [3 x [3 x double]]* %7 to double**
%69 = bitcast [3 x [3 x double]]* %10 to double**
%70 = call i32 @mat33Transpose(double** %68, double** %69)
%71 = bitcast [3 x [3 x double]]* %9 to double**
%72 = bitcast [3 x double]* %4 to double**
%73 = call i32 @mat333Multiply(double** %71, double** %69, double** %72)
ret void
}