#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 fabs(double);
int bot_quat_to_matrix(const double quat[4], double rot[9]) {
  double norm = quat[0] * quat[0] + quat[1] * quat[1] + quat[2] * quat[2] +
                quat[3] * quat[3];
  if (fabs(norm) < 1e-10)
    return -1;
  norm = 1 / norm;
  double x = quat[1] * norm;
  double y = quat[2] * norm;
  double z = quat[3] * norm;
  double w = quat[0] * norm;
  double x2 = x * x;
  double y2 = y * y;
  double z2 = z * z;
  double w2 = w * w;
  double xy = 2 * x * y;
  double xz = 2 * x * z;
  double yz = 2 * y * z;
  double wx = 2 * w * x;
  double wy = 2 * w * y;
  double wz = 2 * w * z;
  rot[0] = w2 + x2 - y2 - z2;
  rot[1] = xy - wz;
  rot[2] = xz + wy;
  rot[3] = xy + wz;
  rot[4] = w2 - x2 + y2 - z2;
  rot[5] = yz - wx;
  rot[6] = xz - wy;
  rot[7] = yz + wx;
  rot[8] = w2 - x2 - y2 + z2;
  return 0;
}


x86 assembly (clang, -O0):
<bot_quat_to_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <fabs@plt>
cvtsi2sd %eax,%xmm1
movsd  0xe64(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11b2 <bot_quat_to_matrix+0xa2>
movl   $0xffffffff,-0x4(%rbp)
jmp    13b6 <bot_quat_to_matrix+0x2a6>
movsd  0xe56(%rip),%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x30(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x40(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  0xdb5(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  0xd9e(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  0xd87(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  0xd70(%rip),%xmm0
mulsd  -0x40(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  0xd59(%rip),%xmm0
mulsd  -0x40(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  0xd3f(%rip),%xmm0
mulsd  -0x40(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x60(%rbp),%xmm0
addsd  -0x48(%rbp),%xmm0
subsd  -0x50(%rbp),%xmm0
subsd  -0x58(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x68(%rbp),%xmm0
subsd  -0x90(%rbp),%xmm0
ff
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x70(%rbp),%xmm0
addsd  -0x88(%rbp),%xmm0
ff
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
movsd  -0x68(%rbp),%xmm0
addsd  -0x90(%rbp),%xmm0
ff
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x18(%rax)
movsd  -0x60(%rbp),%xmm0
subsd  -0x48(%rbp),%xmm0
addsd  -0x50(%rbp),%xmm0
subsd  -0x58(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x20(%rax)
movsd  -0x78(%rbp),%xmm0
subsd  -0x80(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x28(%rax)
movsd  -0x70(%rbp),%xmm0
subsd  -0x88(%rbp),%xmm0
ff
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x30(%rax)
movsd  -0x78(%rbp),%xmm0
addsd  -0x80(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x38(%rax)
movsd  -0x60(%rbp),%xmm0
subsd  -0x48(%rbp),%xmm0
subsd  -0x50(%rbp),%xmm0
addsd  -0x58(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x40(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bot_quat_to_matrix>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  (%rdi),%xmm0
movsd  0x8(%rdi),%xmm1
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0x10(%rdi),%xmm1
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0x18(%rdi),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
call   1030 <fabs@plt>
test   %eax,%eax
jle    1265 <bot_quat_to_matrix+0x155>
movsd  0xe9d(%rip),%xmm5
divsd  (%rsp),%xmm5
movsd  0x8(%rbx),%xmm4
mulsd  %xmm5,%xmm4
movupd 0x10(%rbx),%xmm1
movapd %xmm5,%xmm3
unpcklpd %xmm5,%xmm3
mulpd  %xmm1,%xmm3
mulsd  (%rbx),%xmm5
movapd %xmm4,%xmm9
mulsd  %xmm4,%xmm9
movapd %xmm5,%xmm2
mulsd  %xmm5,%xmm2
movapd %xmm4,%xmm1
addsd  %xmm4,%xmm1
unpcklpd %xmm1,%xmm1
mulpd  %xmm3,%xmm1
movapd %xmm1,%xmm10
shufpd $0x1,%xmm1,%xmm10
movapd %xmm3,%xmm8
addsd  %xmm3,%xmm8
unpcklpd %xmm3,%xmm5
movsd  0xe3f(%rip),%xmm7
unpcklpd %xmm3,%xmm7
mulpd  %xmm5,%xmm7
movapd %xmm9,%xmm6
addsd  %xmm2,%xmm6
movapd %xmm7,%xmm5
subsd  %xmm9,%xmm2
unpcklpd %xmm2,%xmm4
movapd %xmm4,%xmm0
mulpd  %xmm7,%xmm0
subpd  %xmm7,%xmm4
unpcklpd %xmm7,%xmm7
mulpd  %xmm3,%xmm7
unpckhpd %xmm3,%xmm3
mulpd  %xmm8,%xmm3
unpckhpd %xmm5,%xmm5
subsd  %xmm5,%xmm6
movsd  %xmm3,%xmm1
movsd  %xmm0,%xmm4
addpd  %xmm3,%xmm4
unpckhpd %xmm3,%xmm3
subsd  %xmm3,%xmm6
movsd  %xmm6,(%r14)
movapd %xmm10,%xmm6
subpd  %xmm7,%xmm6
movhpd %xmm6,0x8(%r14)
addpd  %xmm7,%xmm10
movupd %xmm10,0x10(%r14)
addsd  %xmm2,%xmm5
subsd  %xmm3,%xmm5
movsd  %xmm5,0x20(%r14)
unpcklpd %xmm7,%xmm0
subpd  %xmm0,%xmm1
movupd %xmm1,0x28(%r14)
movupd %xmm4,0x38(%r14)
xor    %eax,%eax
jmp    126a <bot_quat_to_matrix+0x15a>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @bot_quat_to_matrix(double* %0, double* %1) {
%3 = alloca i32
%4 = alloca double*
%5 = alloca double*
%6 = alloca double
%7 = alloca double
%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
store double* %0, double** %4
store double* %1, double** %5
%21 = load double*, double** %4
%22 = getelementptr inbounds double, double* %21, i64 0
%23 = load double, double* %22
%24 = load double*, double** %4
%25 = getelementptr inbounds double, double* %24, i64 0
%26 = load double, double* %25
%27 = load double*, double** %4
%28 = getelementptr inbounds double, double* %27, i64 1
%29 = load double, double* %28
%30 = load double*, double** %4
%31 = getelementptr inbounds double, double* %30, i64 1
%32 = load double, double* %31
%33 = fmul double %29, %32
%34 = call double @llvm.fmuladd.f64(double %23, double %26, double %33)
%35 = load double*, double** %4
%36 = getelementptr inbounds double, double* %35, i64 2
%37 = load double, double* %36
%38 = load double*, double** %4
%39 = getelementptr inbounds double, double* %38, i64 2
%40 = load double, double* %39
%41 = call double @llvm.fmuladd.f64(double %37, double %40, double %34)
%42 = load double*, double** %4
%43 = getelementptr inbounds double, double* %42, i64 3
%44 = load double, double* %43
%45 = load double*, double** %4
%46 = getelementptr inbounds double, double* %45, i64 3
%47 = load double, double* %46
%48 = call double @llvm.fmuladd.f64(double %44, double %47, double %41)
store double %48, double* %6
%49 = load double, double* %6
%50 = call i32 @fabs(double %49)
%51 = sitofp i32 %50 to double
%52 = fcmp olt double %51, 1.000000e-10
br i1 %52, label %53, label %54
53: ; preds = %2
store i32 -1, i32* %3
br label %170
54: ; preds = %2
%55 = load double, double* %6
%56 = fdiv double 1.000000e+00, %55
store double %56, double* %6
%57 = load double*, double** %4
%58 = getelementptr inbounds double, double* %57, i64 1
%59 = load double, double* %58
%60 = load double, double* %6
%61 = fmul double %59, %60
store double %61, double* %7
%62 = load double*, double** %4
%63 = getelementptr inbounds double, double* %62, i64 2
%64 = load double, double* %63
%65 = load double, double* %6
%66 = fmul double %64, %65
store double %66, double* %8
%67 = load double*, double** %4
%68 = getelementptr inbounds double, double* %67, i64 3
%69 = load double, double* %68
%70 = load double, double* %6
%71 = fmul double %69, %70
store double %71, double* %9
%72 = load double*, double** %4
%73 = getelementptr inbounds double, double* %72, i64 0
%74 = load double, double* %73
%75 = load double, double* %6
%76 = fmul double %74, %75
store double %76, double* %10
%77 = load double, double* %7
%78 = load double, double* %7
%79 = fmul double %77, %78
store double %79, double* %11
%80 = load double, double* %8
%81 = load double, double* %8
%82 = fmul double %80, %81
store double %82, double* %12
%83 = load double, double* %9
%84 = load double, double* %9
%85 = fmul double %83, %84
store double %85, double* %13
%86 = load double, double* %10
%87 = load double, double* %10
%88 = fmul double %86, %87
store double %88, double* %14
%89 = load double, double* %7
%90 = fmul double 2.000000e+00, %89
%91 = load double, double* %8
%92 = fmul double %90, %91
store double %92, double* %15
%93 = load double, double* %7
%94 = fmul double 2.000000e+00, %93
%95 = load double, double* %9
%96 = fmul double %94, %95
store double %96, double* %16
%97 = load double, double* %8
%98 = fmul double 2.000000e+00, %97
%99 = load double, double* %9
%100 = fmul double %98, %99
store double %100, double* %17
%101 = load double, double* %10
%102 = fmul double 2.000000e+00, %101
%103 = load double, double* %7
%104 = fmul double %102, %103
store double %104, double* %18
%105 = load double, double* %10
%106 = fmul double 2.000000e+00, %105
%107 = load double, double* %8
%108 = fmul double %106, %107
store double %108, double* %19
%109 = load double, double* %10
%110 = fmul double 2.000000e+00, %109
%111 = load double, double* %9
%112 = fmul double %110, %111
store double %112, double* %20
%113 = load double, double* %14
%114 = load double, double* %11
%115 = fadd double %113, %114
%116 = load double, double* %12
%117 = fsub double %115, %116
%118 = load double, double* %13
%119 = fsub double %117, %118
%120 = load double*, double** %5
%121 = getelementptr inbounds double, double* %120, i64 0
store double %119, double* %121
%122 = load double, double* %15
%123 = load double, double* %20
%124 = fsub double %122, %123
%125 = load double*, double** %5
%126 = getelementptr inbounds double, double* %125, i64 1
store double %124, double* %126
%127 = load double, double* %16
%128 = load double, double* %19
%129 = fadd double %127, %128
%130 = load double*, double** %5
%131 = getelementptr inbounds double, double* %130, i64 2
store double %129, double* %131
%132 = load double, double* %15
%133 = load double, double* %20
%134 = fadd double %132, %133
%135 = load double*, double** %5
%136 = getelementptr inbounds double, double* %135, i64 3
store double %134, double* %136
%137 = load double, double* %14
%138 = load double, double* %11
%139 = fsub double %137, %138
%140 = load double, double* %12
%141 = fadd double %139, %140
%142 = load double, double* %13
%143 = fsub double %141, %142
%144 = load double*, double** %5
%145 = getelementptr inbounds double, double* %144, i64 4
store double %143, double* %145
%146 = load double, double* %17
%147 = load double, double* %18
%148 = fsub double %146, %147
%149 = load double*, double** %5
%150 = getelementptr inbounds double, double* %149, i64 5
store double %148, double* %150
%151 = load double, double* %16
%152 = load double, double* %19
%153 = fsub double %151, %152
%154 = load double*, double** %5
%155 = getelementptr inbounds double, double* %154, i64 6
store double %153, double* %155
%156 = load double, double* %17
%157 = load double, double* %18
%158 = fadd double %156, %157
%159 = load double*, double** %5
%160 = getelementptr inbounds double, double* %159, i64 7
store double %158, double* %160
%161 = load double, double* %14
%162 = load double, double* %11
%163 = fsub double %161, %162
%164 = load double, double* %12
%165 = fsub double %163, %164
%166 = load double, double* %13
%167 = fadd double %165, %166
%168 = load double*, double** %5
%169 = getelementptr inbounds double, double* %168, i64 8
store double %167, double* %169
store i32 0, i32* %3
br label %170
170: ; preds = %54, %53
%171 = load i32, i32* %3
ret i32 %171
}

LLVM IR (-O2):
define i32 @bot_quat_to_matrix(double* nocapture %0, double* nocapture writeonly %1) {
%3 = load double, double* %0
%4 = getelementptr inbounds double, double* %0, i64 1
%5 = load double, double* %4
%6 = fmul double %5, %5
%7 = tail call double @llvm.fmuladd.f64(double %3, double %3, double %6)
%8 = getelementptr inbounds double, double* %0, i64 2
%9 = load double, double* %8
%10 = tail call double @llvm.fmuladd.f64(double %9, double %9, double %7)
%11 = getelementptr inbounds double, double* %0, i64 3
%12 = load double, double* %11
%13 = tail call double @llvm.fmuladd.f64(double %12, double %12, double %10)
%14 = tail call i32 @fabs(double %13)
%15 = icmp slt i32 %14, 1
br i1 %15, label %73, label %16
16: ; preds = %2
%17 = fdiv double 1.000000e+00, %13
%18 = load double, double* %4
%19 = fmul double %17, %18
%20 = bitcast double* %8 to <2 x double>*
%21 = load <2 x double>, <2 x double>* %20
%22 = insertelement <2 x double> poison, double %17, i64 0
%23 = shufflevector <2 x double> %22, <2 x double> poison, <2 x i32> zeroinitializer
%24 = fmul <2 x double> %23, %21
%25 = load double, double* %0
%26 = fmul double %17, %25
%27 = fmul double %19, %19
%28 = extractelement <2 x double> %24, i64 0
%29 = fmul double %26, %26
%30 = fmul double %19, 2.000000e+00
%31 = insertelement <2 x double> poison, double %30, i64 0
%32 = shufflevector <2 x double> %31, <2 x double> poison, <2 x i32> zeroinitializer
%33 = fmul <2 x double> %32, %24
%34 = shufflevector <2 x double> %33, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%35 = fmul double %28, 2.000000e+00
%36 = insertelement <2 x double> %24, double %35, i64 0
%37 = shufflevector <2 x double> %24, <2 x double> undef, <2 x i32> <i32 1, i32 1>
%38 = fmul <2 x double> %36, %37
%39 = insertelement <2 x double> poison, double %26, i64 0
%40 = shufflevector <2 x double> %39, <2 x double> %24, <2 x i32> <i32 0, i32 2>
%41 = shufflevector <2 x double> <double 2.000000e+00, double poison>, <2 x double> %24, <2 x i32> <i32 0, i32 2>
%42 = fmul <2 x double> %40, %41
%43 = shufflevector <2 x double> %42, <2 x double> undef, <2 x i32> zeroinitializer
%44 = fmul <2 x double> %24, %43
%45 = fadd double %27, %29
%46 = extractelement <2 x double> %42, i64 1
%47 = fsub double %45, %46
%48 = extractelement <2 x double> %38, i64 1
%49 = fsub double %47, %48
store double %49, double* %1
%50 = fsub <2 x double> %34, %44
%51 = extractelement <2 x double> %50, i64 1
%52 = getelementptr inbounds double, double* %1, i64 1
store double %51, double* %52
%53 = getelementptr inbounds double, double* %1, i64 2
%54 = fadd <2 x double> %34, %44
%55 = bitcast double* %53 to <2 x double>*
store <2 x double> %54, <2 x double>* %55
%56 = fsub double %29, %27
%57 = fadd double %46, %56
%58 = fsub double %57, %48
%59 = getelementptr inbounds double, double* %1, i64 4
store double %58, double* %59
%60 = getelementptr inbounds double, double* %1, i64 5
%61 = shufflevector <2 x double> %38, <2 x double> %33, <2 x i32> <i32 0, i32 3>
%62 = insertelement <2 x double> poison, double %19, i64 0
%63 = insertelement <2 x double> %62, double %56, i64 1
%64 = fmul <2 x double> %63, %42
%65 = fsub <2 x double> %63, %42
%66 = shufflevector <2 x double> %64, <2 x double> %65, <2 x i32> <i32 0, i32 3>
%67 = shufflevector <2 x double> %64, <2 x double> %44, <2 x i32> <i32 0, i32 2>
%68 = fsub <2 x double> %61, %67
%69 = bitcast double* %60 to <2 x double>*
store <2 x double> %68, <2 x double>* %69
%70 = getelementptr inbounds double, double* %1, i64 7
%71 = fadd <2 x double> %38, %66
%72 = bitcast double* %70 to <2 x double>*
store <2 x double> %71, <2 x double>* %72
br label %73
73: ; preds = %2, %16
%74 = phi i32 [ 0, %16 ], [ -1, %2 ]
ret i32 %74
}