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


x86 assembly (clang, -O0):
<quat_rotateX>:
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  -0x1c(%rbp),%xmm1
mulss  -0x20(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x14(%rbp),%xmm0
movss  -0x24(%rbp),%xmm2
movss  -0x18(%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  -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,0x8(%rax)
movss  -0x1c(%rbp),%xmm0
movss  -0x24(%rbp),%xmm2
movss  -0x10(%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_rotateX>:
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),%xmm3
movaps %xmm3,%xmm1
shufps $0xe1,%xmm3,%xmm1
xorps  0xeaa(%rip),%xmm1
movaps 0x10(%rsp),%xmm4
shufps $0x0,%xmm4,%xmm4
movaps %xmm3,%xmm2
shufps $0x4b,%xmm1,%xmm2
mulps  %xmm4,%xmm2
shufps $0x0,%xmm0,%xmm0
mulps  %xmm3,%xmm0
addps  %xmm2,%xmm0
movups %xmm0,(%rbx)
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @quat_rotateX(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* %8
%34 = load float, float* %9
%35 = fmul float %33, %34
%36 = call float @llvm.fmuladd.f32(float %31, float %32, float %35)
%37 = load float*, float** %3
%38 = getelementptr inbounds float, float* %37, i64 0
store float %36, float* %38
%39 = load float, float* %6
%40 = load float, float* %10
%41 = load float, float* %7
%42 = load float, float* %9
%43 = fmul float %41, %42
%44 = call float @llvm.fmuladd.f32(float %39, float %40, float %43)
%45 = load float*, float** %3
%46 = getelementptr inbounds float, float* %45, i64 1
store float %44, float* %46
%47 = load float, float* %7
%48 = load float, float* %10
%49 = load float, float* %6
%50 = load float, float* %9
%51 = fmul float %49, %50
%52 = fneg float %51
%53 = call float @llvm.fmuladd.f32(float %47, float %48, 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* %5
%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_rotateX(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 1, i32 0>
%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> %10, <4 x float> %5, <4 x i32> <i32 0, i32 1, i32 6, i32 7>
%12 = insertelement <4 x float> poison, float %6, i64 0
%13 = shufflevector <4 x float> %12, <4 x float> poison, <4 x i32> zeroinitializer
%14 = fmul <4 x float> %11, %13
%15 = shufflevector <4 x float> %14, <4 x float> poison, <4 x i32> <i32 3, i32 2, i32 0, i32 1>
%16 = insertelement <4 x float> poison, float %7, i64 0
%17 = shufflevector <4 x float> %16, <4 x float> poison, <4 x i32> zeroinitializer
%18 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %5, <4 x float> %17, <4 x float> %15)
%19 = bitcast float* %0 to <4 x float>*
store <4 x float> %18, <4 x float>* %19
ret void
}