#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(float);
scalar_t__ sin(float);
int /*<<< orphan*/ v_nrm(float *, float const *);
void q_by_axisangle(float q[4], const float u[3], float a) {
  float c = ((float)cos((float)a * 0.5f));
  float s = ((float)sin((float)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  0xeb3(%rip),%xmm0
mulss  -0x14(%rbp),%xmm0
call   1050 <cos@plt>
cvtsi2ss %rax,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  0xe97(%rip),%xmm0
mulss  -0x14(%rbp),%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
mulss  0xebb(%rip),%xmm0
movss  %xmm0,0x4(%rsp)
call   1050 <cos@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movss  %xmm0,0x8(%rsp)
movss  0x4(%rsp),%xmm0
call   1040 <sin@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movss  %xmm0,0x4(%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  0x4(%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 = fmul float %10, 5.000000e-01
%12 = call i64 @cos(float %11)
%13 = sitofp i64 %12 to float
store float %13, float* %7
%14 = load float, float* %6
%15 = fmul float %14, 5.000000e-01
%16 = call i64 @sin(float %15)
%17 = sitofp i64 %16 to float
store float %17, float* %8
%18 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%19 = load float*, float** %5
%20 = call i32 @v_nrm(float* %18, float* %19)
%21 = load float, float* %7
%22 = load float*, float** %4
%23 = getelementptr inbounds float, float* %22, i64 0
store float %21, float* %23
%24 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%25 = load float, float* %24
%26 = load float, float* %8
%27 = fmul float %25, %26
%28 = load float*, float** %4
%29 = getelementptr inbounds float, float* %28, i64 1
store float %27, float* %29
%30 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 1
%31 = load float, float* %30
%32 = load float, float* %8
%33 = fmul float %31, %32
%34 = load float*, float** %4
%35 = getelementptr inbounds float, float* %34, i64 2
store float %33, float* %35
%36 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 2
%37 = load float, float* %36
%38 = load float, float* %8
%39 = fmul float %37, %38
%40 = load float*, float** %4
%41 = getelementptr inbounds float, float* %40, i64 3
store float %39, float* %41
ret void
}

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