#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 cosf(float);
float sinf(float);
void quat_rotateY(float *dst, float rad) {
  rad *= 0.5;
  float ax = dst[0], ay = dst[1], az = dst[2], aw = dst[3];
  float by = sinf(rad), bw = cosf(rad);
  dst[0] = ax * bw - az * by;
  dst[1] = ay * bw + aw * by;
  dst[2] = az * bw + ax * by;
  dst[3] = aw * bw - ay * by;
}


x86 assembly (clang, -O0):
<quat_rotateY>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xebe(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movss  0xc(%rax),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <sinf@plt>
movss  %xmm0,-0x20(%rbp)
movss  -0xc(%rbp),%xmm0
call   1040 <cosf@plt>
movss  %xmm0,-0x24(%rbp)
movss  -0x10(%rbp),%xmm0
movss  -0x24(%rbp),%xmm2
movss  -0x18(%rbp),%xmm1
mulss  -0x20(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x14(%rbp),%xmm0
movss  -0x24(%rbp),%xmm2
movss  -0x1c(%rbp),%xmm1
mulss  -0x20(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x4(%rax)
movss  -0x18(%rbp),%xmm0
movss  -0x24(%rbp),%xmm2
movss  -0x10(%rbp),%xmm1
mulss  -0x20(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x8(%rax)
movss  -0x1c(%rbp),%xmm0
movss  -0x24(%rbp),%xmm2
movss  -0x14(%rbp),%xmm1
mulss  -0x20(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0xc(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quat_rotateY>:
push   %rbx
sub    $0x30,%rsp
mov    %rdi,%rbx
mulss  0xed0(%rip),%xmm0
movss  %xmm0,0xc(%rsp)
movups (%rdi),%xmm1
movaps %xmm1,0x20(%rsp)
call   1030 <sinf@plt>
movaps %xmm0,0x10(%rsp)
movss  0xc(%rsp),%xmm0
call   1040 <cosf@plt>
movaps 0x20(%rsp),%xmm2
movaps %xmm2,%xmm1
shufps $0xe6,%xmm2,%xmm1
xorps  0xeaa(%rip),%xmm1
movaps 0x10(%rsp),%xmm3
shufps $0x0,%xmm3,%xmm3
shufps $0x34,%xmm2,%xmm1
shufps $0x78,%xmm1,%xmm1
mulps  %xmm3,%xmm1
shufps $0x0,%xmm0,%xmm0
mulps  %xmm2,%xmm0
addps  %xmm1,%xmm0
movups %xmm0,(%rbx)
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @quat_rotateY(float* %0, float %1) {
%3 = alloca float*
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
store float* %0, float** %3
store float %1, float* %4
%11 = load float, float* %4
%12 = fpext float %11 to double
%13 = fmul double %12, 5.000000e-01
%14 = fptrunc double %13 to float
store float %14, float* %4
%15 = load float*, float** %3
%16 = getelementptr inbounds float, float* %15, i64 0
%17 = load float, float* %16
store float %17, float* %5
%18 = load float*, float** %3
%19 = getelementptr inbounds float, float* %18, i64 1
%20 = load float, float* %19
store float %20, float* %6
%21 = load float*, float** %3
%22 = getelementptr inbounds float, float* %21, i64 2
%23 = load float, float* %22
store float %23, float* %7
%24 = load float*, float** %3
%25 = getelementptr inbounds float, float* %24, i64 3
%26 = load float, float* %25
store float %26, float* %8
%27 = load float, float* %4
%28 = call float @sinf(float %27)
store float %28, float* %9
%29 = load float, float* %4
%30 = call float @cosf(float %29)
store float %30, float* %10
%31 = load float, float* %5
%32 = load float, float* %10
%33 = load float, float* %7
%34 = load float, float* %9
%35 = fmul float %33, %34
%36 = fneg float %35
%37 = call float @llvm.fmuladd.f32(float %31, float %32, float %36)
%38 = load float*, float** %3
%39 = getelementptr inbounds float, float* %38, i64 0
store float %37, float* %39
%40 = load float, float* %6
%41 = load float, float* %10
%42 = load float, float* %8
%43 = load float, float* %9
%44 = fmul float %42, %43
%45 = call float @llvm.fmuladd.f32(float %40, float %41, float %44)
%46 = load float*, float** %3
%47 = getelementptr inbounds float, float* %46, i64 1
store float %45, float* %47
%48 = load float, float* %7
%49 = load float, float* %10
%50 = load float, float* %5
%51 = load float, float* %9
%52 = fmul float %50, %51
%53 = call float @llvm.fmuladd.f32(float %48, float %49, float %52)
%54 = load float*, float** %3
%55 = getelementptr inbounds float, float* %54, i64 2
store float %53, float* %55
%56 = load float, float* %8
%57 = load float, float* %10
%58 = load float, float* %6
%59 = load float, float* %9
%60 = fmul float %58, %59
%61 = fneg float %60
%62 = call float @llvm.fmuladd.f32(float %56, float %57, float %61)
%63 = load float*, float** %3
%64 = getelementptr inbounds float, float* %63, i64 3
store float %62, float* %64
ret void
}

LLVM IR (-O2):
define void @quat_rotateY(float* nocapture %0, float %1) {
%3 = fmul float %1, 5.000000e-01
%4 = bitcast float* %0 to <4 x float>*
%5 = load <4 x float>, <4 x float>* %4
%6 = tail call float @sinf(float %3)
%7 = tail call float @cosf(float %3)
%8 = shufflevector <4 x float> %5, <4 x float> undef, <2 x i32> <i32 2, i32 1>
%9 = fneg <2 x float> %8
%10 = shufflevector <2 x float> %9, <2 x float> poison, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
%11 = shufflevector <4 x float> %5, <4 x float> %10, <4 x i32> <i32 0, i32 4, i32 5, i32 undef>
%12 = shufflevector <4 x float> %11, <4 x float> %5, <4 x i32> <i32 0, i32 1, i32 2, i32 7>
%13 = insertelement <4 x float> poison, float %6, i64 0
%14 = shufflevector <4 x float> %13, <4 x float> poison, <4 x i32> zeroinitializer
%15 = fmul <4 x float> %12, %14
%16 = shufflevector <4 x float> %15, <4 x float> poison, <4 x i32> <i32 1, i32 3, i32 0, i32 2>
%17 = insertelement <4 x float> poison, float %7, i64 0
%18 = shufflevector <4 x float> %17, <4 x float> poison, <4 x i32> zeroinitializer
%19 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %5, <4 x float> %18, <4 x float> %16)
%20 = bitcast float* %0 to <4 x float>*
store <4 x float> %19, <4 x float>* %20
ret void
}