#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 */
size_t mat3_getIndex(int, int);
float sqrtf(float const);
void quatf_from_mat3f(float quat[4], const float matrix[9]) {
  int X = 0, Y = 1, Z = 2, W = 3;
  float trace = matrix[0] + matrix[4] + matrix[8];
  if (trace > 0.0) {
    float s = sqrtf(trace + 1.0);
    quat[W] = s * 0.5;
    s = 0.5 / s;
    quat[X] = (matrix[mat3_getIndex(Z, Y)] - matrix[mat3_getIndex(Y, Z)]) * s;
    quat[Y] = (matrix[mat3_getIndex(X, Z)] - matrix[mat3_getIndex(Z, X)]) * s;
    quat[Z] = (matrix[mat3_getIndex(Y, Z)] - matrix[mat3_getIndex(X, Y)]) * s;
  } else {
    int next[3] = {Y, Z, X};
    int i = X;
    if (matrix[mat3_getIndex(Y, Y)] > matrix[mat3_getIndex(X, X)])
      i = Y;
    if (matrix[mat3_getIndex(Z, Z)] > matrix[mat3_getIndex(i, i)])
      i = Z;
    int j = next[i];
    int k = next[j];
    float s =
        sqrtf((matrix[mat3_getIndex(i, i)] -
               (matrix[mat3_getIndex(j, j)] + matrix[mat3_getIndex(k, k)])) +
              1.0);
    quat[i] = s * 0.5;
    s = 0.5 / s;
    quat[W] = (matrix[mat3_getIndex(k, j)] - matrix[mat3_getIndex(j, k)]) * s;
    quat[j] = (matrix[mat3_getIndex(j, i)] + matrix[mat3_getIndex(i, j)]) * s;
    quat[k] = (matrix[mat3_getIndex(k, i)] + matrix[mat3_getIndex(i, k)]) * s;
  }
}


x86 assembly (clang, -O0):
<quatf_from_mat3f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x2,-0x1c(%rbp)
movl   $0x3,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x10(%rbp),%rax
addss  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
addss  0x20(%rax),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    130a <quatf_from_mat3f+0x1ea>
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe73(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1030 <sqrtf@plt>
movss  %xmm0,-0x28(%rbp)
movss  -0x28(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe48(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
movss  -0x28(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe22(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1040 <mat3_getIndex@plt>
mov    %rax,%rcx
mov    -0x90(%rbp),%rax
movss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x84(%rbp)
ff
mov    -0x10(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1040 <mat3_getIndex@plt>
movss  -0x84(%rbp),%xmm0
ff
mov    %rax,%rcx
mov    -0x80(%rbp),%rax
subss  (%rax,%rcx,4),%xmm0
mulss  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x10(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1040 <mat3_getIndex@plt>
mov    %rax,%rcx
mov    -0x78(%rbp),%rax
movss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x6c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1040 <mat3_getIndex@plt>
movss  -0x6c(%rbp),%xmm0
mov    %rax,%rcx
mov    -0x68(%rbp),%rax
subss  (%rax,%rcx,4),%xmm0
mulss  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x10(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1040 <mat3_getIndex@plt>
mov    %rax,%rcx
mov    -0x60(%rbp),%rax
movss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x54(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1040 <mat3_getIndex@plt>
movss  -0x54(%rbp),%xmm0
mov    %rax,%rcx
mov    -0x50(%rbp),%rax
subss  (%rax,%rcx,4),%xmm0
mulss  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
jmp    163b <quatf_from_mat3f+0x51b>
mov    -0x18(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1040 <mat3_getIndex@plt>
mov    %rax,%rcx
mov    -0xa8(%rbp),%rax
movss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x9c(%rbp)
ff
mov    -0x10(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1040 <mat3_getIndex@plt>
movss  -0x9c(%rbp),%xmm0
ff
mov    %rax,%rcx
mov    -0x98(%rbp),%rax
ucomiss (%rax,%rcx,4),%xmm0
jbe    1387 <quatf_from_mat3f+0x267>
mov    -0x18(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0xc0(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1040 <mat3_getIndex@plt>
mov    %rax,%rcx
mov    -0xc0(%rbp),%rax
movss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0xb4(%rbp)
ff
mov    -0x10(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x38(%rbp),%edi
mov    -0x38(%rbp),%esi
call   1040 <mat3_getIndex@plt>
movss  -0xb4(%rbp),%xmm0
ff
mov    %rax,%rcx
mov    -0xb0(%rbp),%rax
ucomiss (%rax,%rcx,4),%xmm0
jbe    13ec <quatf_from_mat3f+0x2cc>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x38(%rbp)
movslq -0x38(%rbp),%rax
mov    -0x34(%rbp,%rax,4),%eax
mov    %eax,-0x3c(%rbp)
movslq -0x3c(%rbp),%rax
mov    -0x34(%rbp,%rax,4),%eax
mov    %eax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x128(%rbp)
mov    -0x38(%rbp),%edi
mov    -0x38(%rbp),%esi
call   1040 <mat3_getIndex@plt>
mov    %rax,%rcx
mov    -0x128(%rbp),%rax
movss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x114(%rbp)
ff
mov    -0x10(%rbp),%rax
mov    %rax,-0x120(%rbp)
mov    -0x3c(%rbp),%edi
mov    -0x3c(%rbp),%esi
call   1040 <mat3_getIndex@plt>
mov    %rax,%rcx
mov    -0x120(%rbp),%rax
movss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x118(%rbp)
ff
mov    -0x10(%rbp),%rax
mov    %rax,-0x110(%rbp)
mov    -0x40(%rbp),%edi
mov    -0x40(%rbp),%esi
call   1040 <mat3_getIndex@plt>
movss  -0x118(%rbp),%xmm1
ff
movss  -0x114(%rbp),%xmm0
ff
mov    %rax,%rcx
mov    -0x110(%rbp),%rax
addss  (%rax,%rcx,4),%xmm1
subss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xb67(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1030 <sqrtf@plt>
movss  %xmm0,-0x44(%rbp)
movss  -0x44(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xb3c(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x38(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
movss  -0x44(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xb16(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x44(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x108(%rbp)
mov    -0x40(%rbp),%edi
mov    -0x3c(%rbp),%esi
call   1040 <mat3_getIndex@plt>
mov    %rax,%rcx
mov    -0x108(%rbp),%rax
movss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0xfc(%rbp)
ff
mov    -0x10(%rbp),%rax
mov    %rax,-0xf8(%rbp)
mov    -0x3c(%rbp),%edi
mov    -0x40(%rbp),%esi
call   1040 <mat3_getIndex@plt>
movss  -0xfc(%rbp),%xmm0
ff
mov    %rax,%rcx
mov    -0xf8(%rbp),%rax
subss  (%rax,%rcx,4),%xmm0
mulss  -0x44(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x10(%rbp),%rax
mov    %rax,-0xf0(%rbp)
mov    -0x3c(%rbp),%edi
mov    -0x38(%rbp),%esi
call   1040 <mat3_getIndex@plt>
mov    %rax,%rcx
mov    -0xf0(%rbp),%rax
movss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0xe4(%rbp)
ff
mov    -0x10(%rbp),%rax
mov    %rax,-0xe0(%rbp)
mov    -0x38(%rbp),%edi
mov    -0x3c(%rbp),%esi
call   1040 <mat3_getIndex@plt>
movss  -0xe4(%rbp),%xmm0
ff
mov    %rax,%rcx
mov    -0xe0(%rbp),%rax
addss  (%rax,%rcx,4),%xmm0
mulss  -0x44(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x10(%rbp),%rax
mov    %rax,-0xd8(%rbp)
mov    -0x40(%rbp),%edi
mov    -0x38(%rbp),%esi
call   1040 <mat3_getIndex@plt>
mov    %rax,%rcx
mov    -0xd8(%rbp),%rax
movss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0xcc(%rbp)
ff
mov    -0x10(%rbp),%rax
mov    %rax,-0xc8(%rbp)
mov    -0x38(%rbp),%edi
mov    -0x40(%rbp),%esi
call   1040 <mat3_getIndex@plt>
movss  -0xcc(%rbp),%xmm0
ff
mov    %rax,%rcx
mov    -0xc8(%rbp),%rax
addss  (%rax,%rcx,4),%xmm0
mulss  -0x44(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x40(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quatf_from_mat3f>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
movss  (%rsi),%xmm0
addss  0x10(%rsi),%xmm0
addss  0x20(%rsi),%xmm0
mov    %rdi,%r14
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    1164 <quatf_from_mat3f+0x44>
addss  0xeae(%rip),%xmm0
ucomiss %xmm1,%xmm0
jb     1261 <quatf_from_mat3f+0x141>
sqrtss %xmm0,%xmm0
jmp    1266 <quatf_from_mat3f+0x146>
movabs $0x200000001,%rax
mov    %rax,0xc(%rsp)
movl   $0x0,0x14(%rsp)
mov    $0x1,%edi
mov    $0x1,%esi
call   1040 <mat3_getIndex@plt>
movss  (%rbx,%rax,4),%xmm0
movss  %xmm0,0x8(%rsp)
xor    %edi,%edi
xor    %esi,%esi
call   1040 <mat3_getIndex@plt>
xor    %r15d,%r15d
movss  0x8(%rsp),%xmm0
ucomiss (%rbx,%rax,4),%xmm0
seta   %r15b
mov    $0x2,%ebp
mov    $0x2,%edi
mov    $0x2,%esi
call   1040 <mat3_getIndex@plt>
movss  (%rbx,%rax,4),%xmm0
movss  %xmm0,0x8(%rsp)
mov    %r15d,%edi
mov    %r15d,%esi
call   1040 <mat3_getIndex@plt>
movss  0x8(%rsp),%xmm0
ucomiss (%rbx,%rax,4),%xmm0
cmova  %ebp,%r15d
mov    0xc(%rsp,%r15,4),%eax
movslq %eax,%r13
mov    0xc(%rsp,%r13,4),%eax
movslq %eax,%r12
mov    %r15d,%edi
mov    %r15d,%esi
call   1040 <mat3_getIndex@plt>
movss  (%rbx,%rax,4),%xmm0
movss  %xmm0,0x8(%rsp)
mov    %r13d,%edi
mov    %r13d,%esi
call   1040 <mat3_getIndex@plt>
movss  (%rbx,%rax,4),%xmm0
movss  %xmm0,0x4(%rsp)
mov    %r12d,%edi
mov    %r12d,%esi
call   1040 <mat3_getIndex@plt>
movss  0x8(%rsp),%xmm0
movss  0x4(%rsp),%xmm1
addss  (%rbx,%rax,4),%xmm1
subss  %xmm1,%xmm0
addss  0xdb5(%rip),%xmm0
ucomiss 0xdb6(%rip),%xmm0
jb     1340 <quatf_from_mat3f+0x220>
sqrtss %xmm0,%xmm0
jmp    1345 <quatf_from_mat3f+0x225>
call   1030 <sqrtf@plt>
movss  0xd96(%rip),%xmm2
movaps %xmm0,%xmm1
mulss  %xmm2,%xmm1
movss  %xmm1,0xc(%r14)
divss  %xmm0,%xmm2
movss  %xmm2,0x8(%rsp)
mov    $0x2,%edi
mov    $0x1,%esi
call   1040 <mat3_getIndex@plt>
movss  (%rbx,%rax,4),%xmm0
movss  %xmm0,0x4(%rsp)
mov    $0x1,%edi
mov    $0x2,%esi
call   1040 <mat3_getIndex@plt>
movss  0x4(%rsp),%xmm0
subss  (%rbx,%rax,4),%xmm0
mulss  0x8(%rsp),%xmm0
movss  %xmm0,(%r14)
xor    %edi,%edi
mov    $0x2,%esi
call   1040 <mat3_getIndex@plt>
movss  (%rbx,%rax,4),%xmm0
movss  %xmm0,0x4(%rsp)
mov    $0x2,%edi
xor    %esi,%esi
call   1040 <mat3_getIndex@plt>
movss  0x4(%rsp),%xmm0
subss  (%rbx,%rax,4),%xmm0
mulss  0x8(%rsp),%xmm0
movss  %xmm0,0x4(%r14)
mov    $0x1,%edi
mov    $0x2,%esi
call   1040 <mat3_getIndex@plt>
movss  (%rbx,%rax,4),%xmm0
movss  %xmm0,0x4(%rsp)
xor    %edi,%edi
mov    $0x1,%esi
call   1040 <mat3_getIndex@plt>
movss  0x4(%rsp),%xmm0
subss  (%rbx,%rax,4),%xmm0
mulss  0x8(%rsp),%xmm0
movss  %xmm0,0x8(%r14)
jmp    140c <quatf_from_mat3f+0x2ec>
call   1030 <sqrtf@plt>
movss  0xcb7(%rip),%xmm2
movaps %xmm0,%xmm1
mulss  %xmm2,%xmm1
movss  %xmm1,(%r14,%r15,4)
divss  %xmm0,%xmm2
movss  %xmm2,0x8(%rsp)
mov    %r12d,%edi
mov    %r13d,%esi
call   1040 <mat3_getIndex@plt>
movss  (%rbx,%rax,4),%xmm0
movss  %xmm0,0x4(%rsp)
mov    %r13d,%edi
mov    %r12d,%esi
call   1040 <mat3_getIndex@plt>
movss  0x4(%rsp),%xmm0
subss  (%rbx,%rax,4),%xmm0
mulss  0x8(%rsp),%xmm0
movss  %xmm0,0xc(%r14)
mov    %r13d,%edi
mov    %r15d,%esi
call   1040 <mat3_getIndex@plt>
movss  (%rbx,%rax,4),%xmm0
movss  %xmm0,0x4(%rsp)
mov    %r15d,%edi
mov    %r13d,%esi
call   1040 <mat3_getIndex@plt>
movss  0x4(%rsp),%xmm0
addss  (%rbx,%rax,4),%xmm0
mulss  0x8(%rsp),%xmm0
movss  %xmm0,(%r14,%r13,4)
mov    %r12d,%edi
mov    %r15d,%esi
call   1040 <mat3_getIndex@plt>
movss  (%rbx,%rax,4),%xmm0
movss  %xmm0,0x4(%rsp)
mov    %r15d,%edi
mov    %r12d,%esi
call   1040 <mat3_getIndex@plt>
movss  0x4(%rsp),%xmm0
addss  (%rbx,%rax,4),%xmm0
mulss  0x8(%rsp),%xmm0
movss  %xmm0,(%r14,%r12,4)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @quatf_from_mat3f(float* %0, float* %1) {
%3 = alloca float*
%4 = alloca float*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca float
%10 = alloca float
%11 = alloca [3 x i32]
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca float
store float* %0, float** %3
store float* %1, float** %4
store i32 0, i32* %5
store i32 1, i32* %6
store i32 2, i32* %7
store i32 3, i32* %8
%16 = load float*, float** %4
%17 = getelementptr inbounds float, float* %16, i64 0
%18 = load float, float* %17
%19 = load float*, float** %4
%20 = getelementptr inbounds float, float* %19, i64 4
%21 = load float, float* %20
%22 = fadd float %18, %21
%23 = load float*, float** %4
%24 = getelementptr inbounds float, float* %23, i64 8
%25 = load float, float* %24
%26 = fadd float %22, %25
store float %26, float* %9
%27 = load float, float* %9
%28 = fpext float %27 to double
%29 = fcmp ogt double %28, 0.000000e+00
br i1 %29, label %30, label %105
30: ; preds = %2
%31 = load float, float* %9
%32 = fpext float %31 to double
%33 = fadd double %32, 1.000000e+00
%34 = fptrunc double %33 to float
%35 = call float @sqrtf(float %34)
store float %35, float* %10
%36 = load float, float* %10
%37 = fpext float %36 to double
%38 = fmul double %37, 5.000000e-01
%39 = fptrunc double %38 to float
%40 = load float*, float** %3
%41 = load i32, i32* %8
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds float, float* %40, i64 %42
store float %39, float* %43
%44 = load float, float* %10
%45 = fpext float %44 to double
%46 = fdiv double 5.000000e-01, %45
%47 = fptrunc double %46 to float
store float %47, float* %10
%48 = load float*, float** %4
%49 = load i32, i32* %7
%50 = load i32, i32* %6
%51 = call i64 @mat3_getIndex(i32 %49, i32 %50)
%52 = getelementptr inbounds float, float* %48, i64 %51
%53 = load float, float* %52
%54 = load float*, float** %4
%55 = load i32, i32* %6
%56 = load i32, i32* %7
%57 = call i64 @mat3_getIndex(i32 %55, i32 %56)
%58 = getelementptr inbounds float, float* %54, i64 %57
%59 = load float, float* %58
%60 = fsub float %53, %59
%61 = load float, float* %10
%62 = fmul float %60, %61
%63 = load float*, float** %3
%64 = load i32, i32* %5
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds float, float* %63, i64 %65
store float %62, float* %66
%67 = load float*, float** %4
%68 = load i32, i32* %5
%69 = load i32, i32* %7
%70 = call i64 @mat3_getIndex(i32 %68, i32 %69)
%71 = getelementptr inbounds float, float* %67, i64 %70
%72 = load float, float* %71
%73 = load float*, float** %4
%74 = load i32, i32* %7
%75 = load i32, i32* %5
%76 = call i64 @mat3_getIndex(i32 %74, i32 %75)
%77 = getelementptr inbounds float, float* %73, i64 %76
%78 = load float, float* %77
%79 = fsub float %72, %78
%80 = load float, float* %10
%81 = fmul float %79, %80
%82 = load float*, float** %3
%83 = load i32, i32* %6
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds float, float* %82, i64 %84
store float %81, float* %85
%86 = load float*, float** %4
%87 = load i32, i32* %6
%88 = load i32, i32* %7
%89 = call i64 @mat3_getIndex(i32 %87, i32 %88)
%90 = getelementptr inbounds float, float* %86, i64 %89
%91 = load float, float* %90
%92 = load float*, float** %4
%93 = load i32, i32* %5
%94 = load i32, i32* %6
%95 = call i64 @mat3_getIndex(i32 %93, i32 %94)
%96 = getelementptr inbounds float, float* %92, i64 %95
%97 = load float, float* %96
%98 = fsub float %91, %97
%99 = load float, float* %10
%100 = fmul float %98, %99
%101 = load float*, float** %3
%102 = load i32, i32* %7
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds float, float* %101, i64 %103
store float %100, float* %104
br label %246
105: ; preds = %2
%106 = getelementptr inbounds [3 x i32], [3 x i32]* %11, i64 0, i64 0
%107 = load i32, i32* %6
store i32 %107, i32* %106
%108 = getelementptr inbounds i32, i32* %106, i64 1
%109 = load i32, i32* %7
store i32 %109, i32* %108
%110 = getelementptr inbounds i32, i32* %108, i64 1
%111 = load i32, i32* %5
store i32 %111, i32* %110
%112 = load i32, i32* %5
store i32 %112, i32* %12
%113 = load float*, float** %4
%114 = load i32, i32* %6
%115 = load i32, i32* %6
%116 = call i64 @mat3_getIndex(i32 %114, i32 %115)
%117 = getelementptr inbounds float, float* %113, i64 %116
%118 = load float, float* %117
%119 = load float*, float** %4
%120 = load i32, i32* %5
%121 = load i32, i32* %5
%122 = call i64 @mat3_getIndex(i32 %120, i32 %121)
%123 = getelementptr inbounds float, float* %119, i64 %122
%124 = load float, float* %123
%125 = fcmp ogt float %118, %124
br i1 %125, label %126, label %128
126: ; preds = %105
%127 = load i32, i32* %6
store i32 %127, i32* %12
br label %128
128: ; preds = %126, %105
%129 = load float*, float** %4
%130 = load i32, i32* %7
%131 = load i32, i32* %7
%132 = call i64 @mat3_getIndex(i32 %130, i32 %131)
%133 = getelementptr inbounds float, float* %129, i64 %132
%134 = load float, float* %133
%135 = load float*, float** %4
%136 = load i32, i32* %12
%137 = load i32, i32* %12
%138 = call i64 @mat3_getIndex(i32 %136, i32 %137)
%139 = getelementptr inbounds float, float* %135, i64 %138
%140 = load float, float* %139
%141 = fcmp ogt float %134, %140
br i1 %141, label %142, label %144
142: ; preds = %128
%143 = load i32, i32* %7
store i32 %143, i32* %12
br label %144
144: ; preds = %142, %128
%145 = load i32, i32* %12
%146 = sext i32 %145 to i64
%147 = getelementptr inbounds [3 x i32], [3 x i32]* %11, i64 0, i64 %146
%148 = load i32, i32* %147
store i32 %148, i32* %13
%149 = load i32, i32* %13
%150 = sext i32 %149 to i64
%151 = getelementptr inbounds [3 x i32], [3 x i32]* %11, i64 0, i64 %150
%152 = load i32, i32* %151
store i32 %152, i32* %14
%153 = load float*, float** %4
%154 = load i32, i32* %12
%155 = load i32, i32* %12
%156 = call i64 @mat3_getIndex(i32 %154, i32 %155)
%157 = getelementptr inbounds float, float* %153, i64 %156
%158 = load float, float* %157
%159 = load float*, float** %4
%160 = load i32, i32* %13
%161 = load i32, i32* %13
%162 = call i64 @mat3_getIndex(i32 %160, i32 %161)
%163 = getelementptr inbounds float, float* %159, i64 %162
%164 = load float, float* %163
%165 = load float*, float** %4
%166 = load i32, i32* %14
%167 = load i32, i32* %14
%168 = call i64 @mat3_getIndex(i32 %166, i32 %167)
%169 = getelementptr inbounds float, float* %165, i64 %168
%170 = load float, float* %169
%171 = fadd float %164, %170
%172 = fsub float %158, %171
%173 = fpext float %172 to double
%174 = fadd double %173, 1.000000e+00
%175 = fptrunc double %174 to float
%176 = call float @sqrtf(float %175)
store float %176, float* %15
%177 = load float, float* %15
%178 = fpext float %177 to double
%179 = fmul double %178, 5.000000e-01
%180 = fptrunc double %179 to float
%181 = load float*, float** %3
%182 = load i32, i32* %12
%183 = sext i32 %182 to i64
%184 = getelementptr inbounds float, float* %181, i64 %183
store float %180, float* %184
%185 = load float, float* %15
%186 = fpext float %185 to double
%187 = fdiv double 5.000000e-01, %186
%188 = fptrunc double %187 to float
store float %188, float* %15
%189 = load float*, float** %4
%190 = load i32, i32* %14
%191 = load i32, i32* %13
%192 = call i64 @mat3_getIndex(i32 %190, i32 %191)
%193 = getelementptr inbounds float, float* %189, i64 %192
%194 = load float, float* %193
%195 = load float*, float** %4
%196 = load i32, i32* %13
%197 = load i32, i32* %14
%198 = call i64 @mat3_getIndex(i32 %196, i32 %197)
%199 = getelementptr inbounds float, float* %195, i64 %198
%200 = load float, float* %199
%201 = fsub float %194, %200
%202 = load float, float* %15
%203 = fmul float %201, %202
%204 = load float*, float** %3
%205 = load i32, i32* %8
%206 = sext i32 %205 to i64
%207 = getelementptr inbounds float, float* %204, i64 %206
store float %203, float* %207
%208 = load float*, float** %4
%209 = load i32, i32* %13
%210 = load i32, i32* %12
%211 = call i64 @mat3_getIndex(i32 %209, i32 %210)
%212 = getelementptr inbounds float, float* %208, i64 %211
%213 = load float, float* %212
%214 = load float*, float** %4
%215 = load i32, i32* %12
%216 = load i32, i32* %13
%217 = call i64 @mat3_getIndex(i32 %215, i32 %216)
%218 = getelementptr inbounds float, float* %214, i64 %217
%219 = load float, float* %218
%220 = fadd float %213, %219
%221 = load float, float* %15
%222 = fmul float %220, %221
%223 = load float*, float** %3
%224 = load i32, i32* %13
%225 = sext i32 %224 to i64
%226 = getelementptr inbounds float, float* %223, i64 %225
store float %222, float* %226
%227 = load float*, float** %4
%228 = load i32, i32* %14
%229 = load i32, i32* %12
%230 = call i64 @mat3_getIndex(i32 %228, i32 %229)
%231 = getelementptr inbounds float, float* %227, i64 %230
%232 = load float, float* %231
%233 = load float*, float** %4
%234 = load i32, i32* %12
%235 = load i32, i32* %14
%236 = call i64 @mat3_getIndex(i32 %234, i32 %235)
%237 = getelementptr inbounds float, float* %233, i64 %236
%238 = load float, float* %237
%239 = fadd float %232, %238
%240 = load float, float* %15
%241 = fmul float %239, %240
%242 = load float*, float** %3
%243 = load i32, i32* %14
%244 = sext i32 %243 to i64
%245 = getelementptr inbounds float, float* %242, i64 %244
store float %241, float* %245
br label %246
246: ; preds = %144, %30
ret void
}

LLVM IR (-O2):
define void @quatf_from_mat3f(float* nocapture writeonly %0, float* %1) {
%3 = alloca [3 x i32]
%4 = load float, float* %1
%5 = getelementptr inbounds float, float* %1, i64 4
%6 = load float, float* %5
%7 = fadd float %4, %6
%8 = getelementptr inbounds float, float* %1, i64 8
%9 = load float, float* %8
%10 = fadd float %7, %9
%11 = fcmp ogt float %10, 0.000000e+00
br i1 %11, label %12, label %44
12: ; preds = %2
%13 = fadd float %10, 1.000000e+00
%14 = tail call float @sqrtf(float %13)
%15 = fmul float %14, 5.000000e-01
%16 = getelementptr inbounds float, float* %0, i64 3
store float %15, float* %16
%17 = fdiv float 5.000000e-01, %14
%18 = tail call i64 @mat3_getIndex(i32 2, i32 1)
%19 = getelementptr inbounds float, float* %1, i64 %18
%20 = load float, float* %19
%21 = tail call i64 @mat3_getIndex(i32 1, i32 2)
%22 = getelementptr inbounds float, float* %1, i64 %21
%23 = load float, float* %22
%24 = fsub float %20, %23
%25 = fmul float %17, %24
store float %25, float* %0
%26 = tail call i64 @mat3_getIndex(i32 0, i32 2)
%27 = getelementptr inbounds float, float* %1, i64 %26
%28 = load float, float* %27
%29 = tail call i64 @mat3_getIndex(i32 2, i32 0)
%30 = getelementptr inbounds float, float* %1, i64 %29
%31 = load float, float* %30
%32 = fsub float %28, %31
%33 = fmul float %17, %32
%34 = getelementptr inbounds float, float* %0, i64 1
store float %33, float* %34
%35 = tail call i64 @mat3_getIndex(i32 1, i32 2)
%36 = getelementptr inbounds float, float* %1, i64 %35
%37 = load float, float* %36
%38 = tail call i64 @mat3_getIndex(i32 0, i32 1)
%39 = getelementptr inbounds float, float* %1, i64 %38
%40 = load float, float* %39
%41 = fsub float %37, %40
%42 = fmul float %17, %41
%43 = getelementptr inbounds float, float* %0, i64 2
store float %42, float* %43
br label %115
44: ; preds = %2
%45 = bitcast [3 x i32]* %3 to i8*
%46 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 0
store i32 1, i32* %46
%47 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 1
store i32 2, i32* %47
%48 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 2
store i32 0, i32* %48
%49 = tail call i64 @mat3_getIndex(i32 1, i32 1)
%50 = getelementptr inbounds float, float* %1, i64 %49
%51 = load float, float* %50
%52 = tail call i64 @mat3_getIndex(i32 0, i32 0)
%53 = getelementptr inbounds float, float* %1, i64 %52
%54 = load float, float* %53
%55 = fcmp ogt float %51, %54
%56 = zext i1 %55 to i32
%57 = tail call i64 @mat3_getIndex(i32 2, i32 2)
%58 = getelementptr inbounds float, float* %1, i64 %57
%59 = load float, float* %58
%60 = tail call i64 @mat3_getIndex(i32 %56, i32 %56)
%61 = getelementptr inbounds float, float* %1, i64 %60
%62 = load float, float* %61
%63 = fcmp ogt float %59, %62
%64 = select i1 %63, i32 2, i32 %56
%65 = zext i32 %64 to i64
%66 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 %65
%67 = load i32, i32* %66
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 %68
%70 = load i32, i32* %69
%71 = tail call i64 @mat3_getIndex(i32 %64, i32 %64)
%72 = getelementptr inbounds float, float* %1, i64 %71
%73 = load float, float* %72
%74 = tail call i64 @mat3_getIndex(i32 %67, i32 %67)
%75 = getelementptr inbounds float, float* %1, i64 %74
%76 = load float, float* %75
%77 = tail call i64 @mat3_getIndex(i32 %70, i32 %70)
%78 = getelementptr inbounds float, float* %1, i64 %77
%79 = load float, float* %78
%80 = fadd float %76, %79
%81 = fsub float %73, %80
%82 = fadd float %81, 1.000000e+00
%83 = tail call float @sqrtf(float %82)
%84 = fmul float %83, 5.000000e-01
%85 = getelementptr inbounds float, float* %0, i64 %65
store float %84, float* %85
%86 = fdiv float 5.000000e-01, %83
%87 = tail call i64 @mat3_getIndex(i32 %70, i32 %67)
%88 = getelementptr inbounds float, float* %1, i64 %87
%89 = load float, float* %88
%90 = tail call i64 @mat3_getIndex(i32 %67, i32 %70)
%91 = getelementptr inbounds float, float* %1, i64 %90
%92 = load float, float* %91
%93 = fsub float %89, %92
%94 = fmul float %86, %93
%95 = getelementptr inbounds float, float* %0, i64 3
store float %94, float* %95
%96 = tail call i64 @mat3_getIndex(i32 %67, i32 %64)
%97 = getelementptr inbounds float, float* %1, i64 %96
%98 = load float, float* %97
%99 = tail call i64 @mat3_getIndex(i32 %64, i32 %67)
%100 = getelementptr inbounds float, float* %1, i64 %99
%101 = load float, float* %100
%102 = fadd float %98, %101
%103 = fmul float %86, %102
%104 = getelementptr inbounds float, float* %0, i64 %68
store float %103, float* %104
%105 = tail call i64 @mat3_getIndex(i32 %70, i32 %64)
%106 = getelementptr inbounds float, float* %1, i64 %105
%107 = load float, float* %106
%108 = tail call i64 @mat3_getIndex(i32 %64, i32 %70)
%109 = getelementptr inbounds float, float* %1, i64 %108
%110 = load float, float* %109
%111 = fadd float %107, %110
%112 = fmul float %86, %111
%113 = sext i32 %70 to i64
%114 = getelementptr inbounds float, float* %0, i64 %113
store float %112, float* %114
br label %115
115: ; preds = %44, %12
ret void
}