void quat_from_axis(float quat[4], float a, float x, float y, float z) {
  float sin_angle;
  float vn[3] = {x, y, z};
  a *= 0.5f;
  vec3_normalize(vn, vn);
  sin_angle = sin(a);
  quat[0] = cos(a);
  quat[1] = vn[0] * sin_angle;
  quat[2] = vn[1] * sin_angle;
  quat[3] = vn[2] * sin_angle;
}


x86 assembly (clang, -O0):
<quat_from_axis>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
movss  %xmm1,-0x10(%rbp)
movss  %xmm2,-0x14(%rbp)
movss  %xmm3,-0x18(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  0xe8a(%rip),%xmm0
mulss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
lea    -0x28(%rbp),%rdi
lea    -0x28(%rbp),%rsi
mov    $0x0,%al
call   1050 <vec3_normalize@plt>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
call   1030 <sin@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
call   1040 <cos@plt>
cvtsd2ss %xmm0,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x28(%rbp),%xmm0
mulss  -0x1c(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x4(%rax)
movss  -0x24(%rbp),%xmm0
mulss  -0x1c(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x8(%rax)
movss  -0x20(%rbp),%xmm0
mulss  -0x1c(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0xc(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quat_from_axis>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
movss  %xmm1,0xc(%rsp)
movss  %xmm2,0x10(%rsp)
movss  %xmm3,0x14(%rsp)
mulss  0xeae(%rip),%xmm0
movss  %xmm0,0x8(%rsp)
lea    0xc(%rsp),%rdi
mov    %rdi,%rsi
xor    %eax,%eax
call   1050 <vec3_normalize@plt>
movss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x18(%rsp)
call   1030 <sin@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
call   1040 <cos@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rbx)
movss  0xc(%rsp),%xmm0
movss  0x8(%rsp),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,0x4(%rbx)
movss  0x10(%rsp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,0x8(%rbx)
mulss  0x14(%rsp),%xmm1
movss  %xmm1,0xc(%rbx)
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @quat_from_axis(float* %0, float %1, float %2, float %3, float %4) {
%6 = alloca float*
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca [3 x float]
store float* %0, float** %6
store float %1, float* %7
store float %2, float* %8
store float %3, float* %9
store float %4, float* %10
%13 = getelementptr inbounds [3 x float], [3 x float]* %12, i64 0, i64 0
%14 = load float, float* %8
store float %14, float* %13
%15 = getelementptr inbounds float, float* %13, i64 1
%16 = load float, float* %9
store float %16, float* %15
%17 = getelementptr inbounds float, float* %15, i64 1
%18 = load float, float* %10
store float %18, float* %17
%19 = load float, float* %7
%20 = fmul float %19, 5.000000e-01
store float %20, float* %7
%21 = getelementptr inbounds [3 x float], [3 x float]* %12, i64 0, i64 0
%22 = getelementptr inbounds [3 x float], [3 x float]* %12, i64 0, i64 0
%23 = call i32 (float*, float*, ...) bitcast (i32 (...)* @vec3_normalize to i32 (float*, float*, ...)*)(float* %21, float* %22)
%24 = load float, float* %7
%25 = fpext float %24 to double
%26 = call double @sin(double %25)
%27 = fptrunc double %26 to float
store float %27, float* %11
%28 = load float, float* %7
%29 = fpext float %28 to double
%30 = call double @cos(double %29)
%31 = fptrunc double %30 to float
%32 = load float*, float** %6
%33 = getelementptr inbounds float, float* %32, i64 0
store float %31, float* %33
%34 = getelementptr inbounds [3 x float], [3 x float]* %12, i64 0, i64 0
%35 = load float, float* %34
%36 = load float, float* %11
%37 = fmul float %35, %36
%38 = load float*, float** %6
%39 = getelementptr inbounds float, float* %38, i64 1
store float %37, float* %39
%40 = getelementptr inbounds [3 x float], [3 x float]* %12, i64 0, i64 1
%41 = load float, float* %40
%42 = load float, float* %11
%43 = fmul float %41, %42
%44 = load float*, float** %6
%45 = getelementptr inbounds float, float* %44, i64 2
store float %43, float* %45
%46 = getelementptr inbounds [3 x float], [3 x float]* %12, i64 0, i64 2
%47 = load float, float* %46
%48 = load float, float* %11
%49 = fmul float %47, %48
%50 = load float*, float** %6
%51 = getelementptr inbounds float, float* %50, i64 3
store float %49, float* %51
ret void
}

LLVM IR (-O2):
define void @quat_from_axis(float* nocapture writeonly %0, float %1, float %2, float %3, float %4) {
%6 = alloca [3 x float]
%7 = bitcast [3 x float]* %6 to i8*
%8 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 0
store float %2, float* %8
%9 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 1
store float %3, float* %9
%10 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 2
store float %4, float* %10
%11 = fmul float %1, 5.000000e-01
%12 = call i32 (float*, float*, ...) bitcast (i32 (...)* @vec3_normalize to i32 (float*, float*, ...)*)(float* %8, float* %8)
%13 = fpext float %11 to double
%14 = call double @sin(double %13)
%15 = fptrunc double %14 to float
%16 = call double @cos(double %13)
%17 = fptrunc double %16 to float
store float %17, float* %0
%18 = load float, float* %8
%19 = fmul float %18, %15
%20 = getelementptr inbounds float, float* %0, i64 1
store float %19, float* %20
%21 = load float, float* %9
%22 = fmul float %21, %15
%23 = getelementptr inbounds float, float* %0, i64 2
store float %22, float* %23
%24 = load float, float* %10
%25 = fmul float %24, %15
%26 = getelementptr inbounds float, float* %0, i64 3
store float %25, float* %26
ret void
}