#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 */
float acosf(float);
float sinf(float);
void quat_slerp(float *dst, float *b, float t) {
  float ax = dst[0], ay = dst[1], az = dst[2], aw = dst[3];
  float bx = b[0], by = b[1], bz = b[2], bw = b[3];
  float omega, cosom, sinom, scale0, scale1;
  cosom = ax * bx + ay * by + az * bz + aw * bw;
  if (cosom < 0.0) {
    cosom = -cosom;
    bx = -bx;
    by = -by;
    bz = -bz;
    bw = -bw;
  }
  if ((1.0 - cosom) > 0.000001) {
    omega = acosf(cosom);
    sinom = sinf(omega);
    scale0 = sinf((1.0 - t) * omega) / sinom;
    scale1 = sinf(t * omega) / sinom;
  } else {
    scale0 = 1.0 - t;
    scale1 = t;
  }
  dst[0] = scale0 * ax + scale1 * bx;
  dst[1] = scale0 * ay + scale1 * by;
  dst[2] = scale0 * az + scale1 * bz;
  dst[3] = scale0 * aw + scale1 * bw;
}


x86 assembly (clang, -O0):
<quat_slerp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movss  %xmm0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
movss  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movss  0xc(%rax),%xmm0
movss  %xmm0,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movss  0x4(%rax),%xmm0
movss  %xmm0,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
movss  0x8(%rax),%xmm0
movss  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movss  0xc(%rax),%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x18(%rbp),%xmm0
movss  -0x28(%rbp),%xmm2
movss  -0x1c(%rbp),%xmm1
mulss  -0x2c(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  -0x20(%rbp),%xmm1
movss  -0x30(%rbp),%xmm2
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  -0x24(%rbp),%xmm0
movss  -0x34(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x3c(%rbp)
movss  -0x3c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    1271 <quat_slerp+0x151>
movss  -0x3c(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x3c(%rbp)
movss  -0x28(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x2c(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x30(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x34(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x3c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xd86(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  0xd72(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1309 <quat_slerp+0x1e9>
movss  -0x3c(%rbp),%xmm0
call   1040 <acosf@plt>
movss  %xmm0,-0x38(%rbp)
movss  -0x38(%rbp),%xmm0
call   1030 <sinf@plt>
movss  %xmm0,-0x40(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xd41(%rip),%xmm0
subsd  %xmm1,%xmm0
movss  -0x38(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1030 <sinf@plt>
divss  -0x40(%rbp),%xmm0
movss  %xmm0,-0x44(%rbp)
movss  -0x14(%rbp),%xmm0
mulss  -0x38(%rbp),%xmm0
call   1030 <sinf@plt>
divss  -0x40(%rbp),%xmm0
movss  %xmm0,-0x48(%rbp)
jmp    1331 <quat_slerp+0x211>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xcee(%rip),%xmm0
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x44(%rbp)
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x48(%rbp)
movss  -0x44(%rbp),%xmm0
movss  -0x18(%rbp),%xmm2
movss  -0x48(%rbp),%xmm1
mulss  -0x28(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x44(%rbp),%xmm0
movss  -0x1c(%rbp),%xmm2
movss  -0x48(%rbp),%xmm1
mulss  -0x2c(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x4(%rax)
movss  -0x44(%rbp),%xmm0
movss  -0x20(%rbp),%xmm2
movss  -0x48(%rbp),%xmm1
mulss  -0x30(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x8(%rax)
movss  -0x44(%rbp),%xmm0
movss  -0x24(%rbp),%xmm2
movss  -0x48(%rbp),%xmm1
mulss  -0x34(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0xc(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quat_slerp>:
push   %rbx
sub    $0x60,%rsp
movaps %xmm0,%xmm6
mov    %rdi,%rbx
movups (%rdi),%xmm7
movups (%rsi),%xmm5
movaps %xmm7,%xmm0
mulps  %xmm5,%xmm0
shufps $0x55,%xmm0,%xmm0
movaps %xmm7,%xmm1
mulss  %xmm5,%xmm1
addss  %xmm0,%xmm1
movaps %xmm7,%xmm0
unpckhpd %xmm7,%xmm0
movaps %xmm5,%xmm2
unpckhpd %xmm5,%xmm2
mulss  %xmm0,%xmm2
addss  %xmm1,%xmm2
movaps %xmm7,%xmm0
shufps $0xff,%xmm7,%xmm0
movaps %xmm5,%xmm3
shufps $0xff,%xmm5,%xmm3
mulss  %xmm0,%xmm3
addss  %xmm2,%xmm3
xorps  %xmm2,%xmm2
ucomiss %xmm3,%xmm2
movaps 0xe81(%rip),%xmm1
movaps %xmm3,%xmm4
xorps  %xmm1,%xmm4
movaps %xmm3,%xmm0
cmpltss %xmm2,%xmm0
andps  %xmm0,%xmm4
andnps %xmm3,%xmm0
orps   %xmm4,%xmm0
jbe    119b <quat_slerp+0x7b>
xorps  %xmm1,%xmm5
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  0xe66(%rip),%xmm2
subsd  %xmm1,%xmm2
ucomisd 0xe62(%rip),%xmm2
jbe    1242 <quat_slerp+0x122>
movaps %xmm5,0x50(%rsp)
movaps %xmm6,0x10(%rsp)
movaps %xmm7,0x40(%rsp)
call   1040 <acosf@plt>
movss  %xmm0,0xc(%rsp)
call   1030 <sinf@plt>
movaps %xmm0,0x30(%rsp)
movaps 0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe1f(%rip),%xmm1
subsd  %xmm0,%xmm1
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1030 <sinf@plt>
movaps %xmm0,0x20(%rsp)
movss  0xc(%rsp),%xmm0
mulss  0x10(%rsp),%xmm0
call   1030 <sinf@plt>
movaps 0x40(%rsp),%xmm7
movaps 0x50(%rsp),%xmm5
movaps %xmm0,%xmm6
unpcklps 0x20(%rsp),%xmm6
movaps 0x30(%rsp),%xmm0
shufps $0x0,%xmm0,%xmm0
divps  %xmm0,%xmm6
jmp    1251 <quat_slerp+0x131>
movss  0xdd6(%rip),%xmm0
subss  %xmm6,%xmm0
unpcklps %xmm0,%xmm6
movaps %xmm6,%xmm0
shufps $0x0,%xmm6,%xmm0
mulps  %xmm0,%xmm5
shufps $0x55,%xmm6,%xmm6
mulps  %xmm7,%xmm6
addps  %xmm5,%xmm6
movups %xmm6,(%rbx)
add    $0x60,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @quat_slerp(float* %0, float* %1, float %2) {
%4 = alloca float*
%5 = alloca float*
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca float
%15 = alloca float
%16 = alloca float
%17 = alloca float
%18 = alloca float
%19 = alloca float
store float* %0, float** %4
store float* %1, float** %5
store float %2, float* %6
%20 = load float*, float** %4
%21 = getelementptr inbounds float, float* %20, i64 0
%22 = load float, float* %21
store float %22, float* %7
%23 = load float*, float** %4
%24 = getelementptr inbounds float, float* %23, i64 1
%25 = load float, float* %24
store float %25, float* %8
%26 = load float*, float** %4
%27 = getelementptr inbounds float, float* %26, i64 2
%28 = load float, float* %27
store float %28, float* %9
%29 = load float*, float** %4
%30 = getelementptr inbounds float, float* %29, i64 3
%31 = load float, float* %30
store float %31, float* %10
%32 = load float*, float** %5
%33 = getelementptr inbounds float, float* %32, i64 0
%34 = load float, float* %33
store float %34, float* %11
%35 = load float*, float** %5
%36 = getelementptr inbounds float, float* %35, i64 1
%37 = load float, float* %36
store float %37, float* %12
%38 = load float*, float** %5
%39 = getelementptr inbounds float, float* %38, i64 2
%40 = load float, float* %39
store float %40, float* %13
%41 = load float*, float** %5
%42 = getelementptr inbounds float, float* %41, i64 3
%43 = load float, float* %42
store float %43, float* %14
%44 = load float, float* %7
%45 = load float, float* %11
%46 = load float, float* %8
%47 = load float, float* %12
%48 = fmul float %46, %47
%49 = call float @llvm.fmuladd.f32(float %44, float %45, float %48)
%50 = load float, float* %9
%51 = load float, float* %13
%52 = call float @llvm.fmuladd.f32(float %50, float %51, float %49)
%53 = load float, float* %10
%54 = load float, float* %14
%55 = call float @llvm.fmuladd.f32(float %53, float %54, float %52)
store float %55, float* %16
%56 = load float, float* %16
%57 = fpext float %56 to double
%58 = fcmp olt double %57, 0.000000e+00
br i1 %58, label %59, label %70
59: ; preds = %3
%60 = load float, float* %16
%61 = fneg float %60
store float %61, float* %16
%62 = load float, float* %11
%63 = fneg float %62
store float %63, float* %11
%64 = load float, float* %12
%65 = fneg float %64
store float %65, float* %12
%66 = load float, float* %13
%67 = fneg float %66
store float %67, float* %13
%68 = load float, float* %14
%69 = fneg float %68
store float %69, float* %14
br label %70
70: ; preds = %59, %3
%71 = load float, float* %16
%72 = fpext float %71 to double
%73 = fsub double 1.000000e+00, %72
%74 = fcmp ogt double %73, 0x3EB0C6F7A0B5ED8D
br i1 %74, label %75, label %96
75: ; preds = %70
%76 = load float, float* %16
%77 = call float @acosf(float %76)
store float %77, float* %15
%78 = load float, float* %15
%79 = call float @sinf(float %78)
store float %79, float* %17
%80 = load float, float* %6
%81 = fpext float %80 to double
%82 = fsub double 1.000000e+00, %81
%83 = load float, float* %15
%84 = fpext float %83 to double
%85 = fmul double %82, %84
%86 = fptrunc double %85 to float
%87 = call float @sinf(float %86)
%88 = load float, float* %17
%89 = fdiv float %87, %88
store float %89, float* %18
%90 = load float, float* %6
%91 = load float, float* %15
%92 = fmul float %90, %91
%93 = call float @sinf(float %92)
%94 = load float, float* %17
%95 = fdiv float %93, %94
store float %95, float* %19
br label %102
96: ; preds = %70
%97 = load float, float* %6
%98 = fpext float %97 to double
%99 = fsub double 1.000000e+00, %98
%100 = fptrunc double %99 to float
store float %100, float* %18
%101 = load float, float* %6
store float %101, float* %19
br label %102
102: ; preds = %96, %75
%103 = load float, float* %18
%104 = load float, float* %7
%105 = load float, float* %19
%106 = load float, float* %11
%107 = fmul float %105, %106
%108 = call float @llvm.fmuladd.f32(float %103, float %104, float %107)
%109 = load float*, float** %4
%110 = getelementptr inbounds float, float* %109, i64 0
store float %108, float* %110
%111 = load float, float* %18
%112 = load float, float* %8
%113 = load float, float* %19
%114 = load float, float* %12
%115 = fmul float %113, %114
%116 = call float @llvm.fmuladd.f32(float %111, float %112, float %115)
%117 = load float*, float** %4
%118 = getelementptr inbounds float, float* %117, i64 1
store float %116, float* %118
%119 = load float, float* %18
%120 = load float, float* %9
%121 = load float, float* %19
%122 = load float, float* %13
%123 = fmul float %121, %122
%124 = call float @llvm.fmuladd.f32(float %119, float %120, float %123)
%125 = load float*, float** %4
%126 = getelementptr inbounds float, float* %125, i64 2
store float %124, float* %126
%127 = load float, float* %18
%128 = load float, float* %10
%129 = load float, float* %19
%130 = load float, float* %14
%131 = fmul float %129, %130
%132 = call float @llvm.fmuladd.f32(float %127, float %128, float %131)
%133 = load float*, float** %4
%134 = getelementptr inbounds float, float* %133, i64 3
store float %132, float* %134
ret void
}

LLVM IR (-O2):
define void @quat_slerp(float* nocapture %0, float* nocapture %1, float %2) {
%4 = bitcast float* %0 to <4 x float>*
%5 = load <4 x float>, <4 x float>* %4
%6 = bitcast float* %1 to <4 x float>*
%7 = load <4 x float>, <4 x float>* %6
%8 = fmul <4 x float> %5, %7
%9 = extractelement <4 x float> %8, i64 1
%10 = extractelement <4 x float> %5, i64 0
%11 = extractelement <4 x float> %7, i64 0
%12 = tail call float @llvm.fmuladd.f32(float %10, float %11, float %9)
%13 = extractelement <4 x float> %5, i64 2
%14 = extractelement <4 x float> %7, i64 2
%15 = tail call float @llvm.fmuladd.f32(float %13, float %14, float %12)
%16 = extractelement <4 x float> %5, i64 3
%17 = extractelement <4 x float> %7, i64 3
%18 = tail call float @llvm.fmuladd.f32(float %16, float %17, float %15)
%19 = fcmp olt float %18, 0.000000e+00
%20 = fneg float %18
%21 = fneg <4 x float> %7
%22 = select i1 %19, float %20, float %18
%23 = select i1 %19, <4 x float> %21, <4 x float> %7
%24 = fpext float %22 to double
%25 = fsub double 1.000000e+00, %24
%26 = fcmp ogt double %25, 0x3EB0C6F7A0B5ED8D
br i1 %26, label %27, label %43
27: ; preds = %3
%28 = tail call float @acosf(float %22)
%29 = tail call float @sinf(float %28)
%30 = fpext float %2 to double
%31 = fsub double 1.000000e+00, %30
%32 = fpext float %28 to double
%33 = fmul double %31, %32
%34 = fptrunc double %33 to float
%35 = tail call float @sinf(float %34)
%36 = fmul float %28, %2
%37 = tail call float @sinf(float %36)
%38 = insertelement <2 x float> poison, float %37, i64 0
%39 = insertelement <2 x float> %38, float %35, i64 1
%40 = insertelement <2 x float> poison, float %29, i64 0
%41 = shufflevector <2 x float> %40, <2 x float> poison, <2 x i32> zeroinitializer
%42 = fdiv <2 x float> %39, %41
br label %47
43: ; preds = %3
%44 = fsub float 1.000000e+00, %2
%45 = insertelement <2 x float> poison, float %2, i64 0
%46 = insertelement <2 x float> %45, float %44, i64 1
br label %47
47: ; preds = %43, %27
%48 = phi <2 x float> [ %42, %27 ], [ %46, %43 ]
%49 = shufflevector <2 x float> %48, <2 x float> undef, <4 x i32> zeroinitializer
%50 = fmul <4 x float> %23, %49
%51 = shufflevector <2 x float> %48, <2 x float> undef, <4 x i32> <i32 1, i32 1, i32 1, i32 1>
%52 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %51, <4 x float> %5, <4 x float> %50)
%53 = bitcast float* %0 to <4 x float>*
store <4 x float> %52, <4 x float>* %53
ret void
}