#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 cos(float);
int /*<<< orphan*/ normalize3d(float *, float const *);
int /*<<< orphan*/ quatnormalize(float *, float *);
float sin(float);
void quatfromaxisangle(float *q, const float *axis, float radians) {
  float v[3];
  normalize3d(v, axis);
  float sn = sin(radians / 2.0f);
  q[0] = cos(radians / 2.0f);
  q[1] = sn * v[0];
  q[2] = sn * v[1];
  q[3] = sn * v[2];
  quatnormalize(q, q);
}


x86 assembly (clang, -O0):
<quatfromaxisangle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movss  %xmm0,-0x14(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <normalize3d@plt>
movss  -0x14(%rbp),%xmm0
movss  0xe91(%rip),%xmm1
divss  %xmm1,%xmm0
call   1040 <sin@plt>
movss  %xmm0,-0x24(%rbp)
movss  -0x14(%rbp),%xmm0
movss  0xe76(%rip),%xmm1
divss  %xmm1,%xmm0
call   1060 <cos@plt>
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x24(%rbp),%xmm0
mulss  -0x20(%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  -0x24(%rbp),%xmm0
mulss  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0xc(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <quatnormalize@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quatfromaxisangle>:
push   %rbx
sub    $0x20,%rsp
movss  %xmm0,0xc(%rsp)
mov    %rdi,%rbx
lea    0x14(%rsp),%rdi
call   1050 <normalize3d@plt>
movss  0xc(%rsp),%xmm0
mulss  0xe9a(%rip),%xmm0
movss  %xmm0,0xc(%rsp)
call   1040 <sin@plt>
movss  %xmm0,0x10(%rsp)
movss  0xc(%rsp),%xmm0
call   1060 <cos@plt>
movss  %xmm0,(%rbx)
movss  0x14(%rsp),%xmm0
movss  0x10(%rsp),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,0x4(%rbx)
movss  0x18(%rsp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,0x8(%rbx)
mulss  0x1c(%rsp),%xmm1
movss  %xmm1,0xc(%rbx)
mov    %rbx,%rdi
mov    %rbx,%rsi
call   1030 <quatnormalize@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @quatfromaxisangle(float* %0, float* %1, float %2) {
%4 = alloca float*
%5 = alloca float*
%6 = alloca float
%7 = alloca [3 x float]
%8 = alloca float
store float* %0, float** %4
store float* %1, float** %5
store float %2, float* %6
%9 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 0
%10 = load float*, float** %5
%11 = call i32 @normalize3d(float* %9, float* %10)
%12 = load float, float* %6
%13 = fdiv float %12, 2.000000e+00
%14 = call float @sin(float %13)
store float %14, float* %8
%15 = load float, float* %6
%16 = fdiv float %15, 2.000000e+00
%17 = call float @cos(float %16)
%18 = load float*, float** %4
%19 = getelementptr inbounds float, float* %18, i64 0
store float %17, float* %19
%20 = load float, float* %8
%21 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 0
%22 = load float, float* %21
%23 = fmul float %20, %22
%24 = load float*, float** %4
%25 = getelementptr inbounds float, float* %24, i64 1
store float %23, float* %25
%26 = load float, float* %8
%27 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 1
%28 = load float, float* %27
%29 = fmul float %26, %28
%30 = load float*, float** %4
%31 = getelementptr inbounds float, float* %30, i64 2
store float %29, float* %31
%32 = load float, float* %8
%33 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 2
%34 = load float, float* %33
%35 = fmul float %32, %34
%36 = load float*, float** %4
%37 = getelementptr inbounds float, float* %36, i64 3
store float %35, float* %37
%38 = load float*, float** %4
%39 = load float*, float** %4
%40 = call i32 @quatnormalize(float* %38, float* %39)
ret void
}

LLVM IR (-O2):
define void @quatfromaxisangle(float* %0, float* %1, float %2) {
%4 = alloca [3 x float]
%5 = bitcast [3 x float]* %4 to i8*
%6 = getelementptr inbounds [3 x float], [3 x float]* %4, i64 0, i64 0
%7 = call i32 @normalize3d(float* %6, float* %1)
%8 = fmul float %2, 5.000000e-01
%9 = call float @sin(float %8)
%10 = call float @cos(float %8)
store float %10, float* %0
%11 = load float, float* %6
%12 = fmul float %9, %11
%13 = getelementptr inbounds float, float* %0, i64 1
store float %12, float* %13
%14 = getelementptr inbounds [3 x float], [3 x float]* %4, i64 0, i64 1
%15 = load float, float* %14
%16 = fmul float %9, %15
%17 = getelementptr inbounds float, float* %0, i64 2
store float %16, float* %17
%18 = getelementptr inbounds [3 x float], [3 x float]* %4, i64 0, i64 2
%19 = load float, float* %18
%20 = fmul float %9, %19
%21 = getelementptr inbounds float, float* %0, i64 3
store float %20, float* %21
%22 = call i32 @quatnormalize(float* %0, float* %0)
ret void
}