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


x86 assembly (clang, -O0):
<quat_rotateZ>:
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  -0x14(%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  -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,0x4(%rax)
movss  -0x18(%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,0x8(%rax)
movss  -0x1c(%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,0xc(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quat_rotateZ>:
push   %rbx
sub    $0x30,%rsp
movaps %xmm0,%xmm1
mov    %rdi,%rbx
mulss  0xecd(%rip),%xmm1
movss  %xmm1,0xc(%rsp)
movups (%rdi),%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm1,%xmm0
call   1030 <sinf@plt>
movaps %xmm0,0x10(%rsp)
movss  0xc(%rsp),%xmm0
call   1040 <cosf@plt>
movaps 0xeb0(%rip),%xmm1
movaps 0x20(%rsp),%xmm4
xorps  %xmm4,%xmm1
movaps %xmm4,%xmm2
movss  %xmm1,%xmm2
movaps 0x10(%rsp),%xmm5
shufps $0x0,%xmm5,%xmm5
movaps %xmm4,%xmm3
shufps $0x23,%xmm1,%xmm3
shufps $0x81,%xmm3,%xmm2
mulps  %xmm5,%xmm2
shufps $0x0,%xmm0,%xmm0
mulps  %xmm4,%xmm0
addps  %xmm2,%xmm0
movups %xmm0,(%rbx)
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @quat_rotateZ(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* %6
%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* %5
%42 = load float, float* %9
%43 = fmul float %41, %42
%44 = fneg float %43
%45 = call float @llvm.fmuladd.f32(float %39, float %40, 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* %8
%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* %7
%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_rotateZ(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 = extractelement <4 x float> %5, i64 0
%9 = fneg float %8
%10 = extractelement <4 x float> %5, i64 2
%11 = fneg float %10
%12 = insertelement <4 x float> poison, float %9, i64 0
%13 = extractelement <4 x float> %5, i64 1
%14 = insertelement <4 x float> %12, float %13, i64 1
%15 = insertelement <4 x float> %14, float %11, i64 2
%16 = shufflevector <4 x float> %15, <4 x float> %5, <4 x i32> <i32 0, i32 1, i32 2, i32 7>
%17 = insertelement <4 x float> poison, float %6, i64 0
%18 = shufflevector <4 x float> %17, <4 x float> poison, <4 x i32> zeroinitializer
%19 = fmul <4 x float> %16, %18
%20 = shufflevector <4 x float> %19, <4 x float> poison, <4 x i32> <i32 1, i32 0, i32 3, i32 2>
%21 = insertelement <4 x float> poison, float %7, i64 0
%22 = shufflevector <4 x float> %21, <4 x float> poison, <4 x i32> zeroinitializer
%23 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %5, <4 x float> %22, <4 x float> %20)
%24 = bitcast float* %0 to <4 x float>*
store <4 x float> %23, <4 x float>* %24
ret void
}