#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 */
scalar_t__ cos(double);
scalar_t__ sin(double);
int /*<<< orphan*/ v_nrm(float *, float const *);
void q_by_axisangle(float q[4], const float u[3], float a) {
  float c = ((float)cos((double)a * 0.5f));
  float s = ((float)sin((double)a * 0.5f));
  float n[3];
  v_nrm(n, u);
  q[0] = c;
  q[1] = n[0] * s;
  q[2] = n[1] * s;
  q[3] = n[2] * s;
}


x86 assembly (clang, -O0):
<q_by_axisangle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xeaa(%rip),%xmm1
mulsd  %xmm1,%xmm0
call   1050 <cos@plt>
cvtsi2ss %rax,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe86(%rip),%xmm1
mulsd  %xmm1,%xmm0
call   1040 <sin@plt>
cvtsi2ss %rax,%xmm0
movss  %xmm0,-0x1c(%rbp)
lea    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <v_nrm@plt>
movss  -0x18(%rbp),%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):
<q_by_axisangle>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
cvtss2sd %xmm0,%xmm0
mulsd  0xeb7(%rip),%xmm0
movsd  %xmm0,(%rsp)
call   1050 <cos@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movss  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
call   1040 <sin@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movss  %xmm0,(%rsp)
lea    0xc(%rsp),%rdi
mov    %r14,%rsi
call   1030 <v_nrm@plt>
movss  0x8(%rsp),%xmm0
movss  %xmm0,(%rbx)
movss  0xc(%rsp),%xmm0
movss  (%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    $0x18,%rsp
pop    %rbx
pop    %r14
ret

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

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