#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*/ sin(float);
int /*<<< orphan*/ vcopy(float *, float *);
int /*<<< orphan*/ vnormal(float *);
int /*<<< orphan*/ vscale(float *, int /*<<< orphan*/);
void axis_to_quat(float a[3], float phi, float q[4]) {
  vnormal(a);
  vcopy(a, q);
  vscale(q, sin(phi / 2.0));
  q[3] = cos(phi / 2.0);
}


x86 assembly (clang, -O0):
<axis_to_quat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <vnormal@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <vcopy@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe6c(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1040 <sin@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%esi
call   1060 <vscale@plt>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe43(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1050 <cos@plt>
mov    -0x18(%rbp),%rax
movss  %xmm0,0xc(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<axis_to_quat>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
movss  %xmm0,0x4(%rsp)
mov    %rdi,%rbx
call   1030 <vnormal@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <vcopy@plt>
movss  0x4(%rsp),%xmm0
mulss  0xe82(%rip),%xmm0
movss  %xmm0,0x4(%rsp)
call   1040 <sin@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1060 <vscale@plt>
movss  0x4(%rsp),%xmm0
call   1050 <cos@plt>
movss  %xmm0,0xc(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @axis_to_quat(float* %0, float %1, float* %2) {
%4 = alloca float*
%5 = alloca float
%6 = alloca float*
store float* %0, float** %4
store float %1, float* %5
store float* %2, float** %6
%7 = load float*, float** %4
%8 = call i32 @vnormal(float* %7)
%9 = load float*, float** %4
%10 = load float*, float** %6
%11 = call i32 @vcopy(float* %9, float* %10)
%12 = load float*, float** %6
%13 = load float, float* %5
%14 = fpext float %13 to double
%15 = fdiv double %14, 2.000000e+00
%16 = fptrunc double %15 to float
%17 = call i32 @sin(float %16)
%18 = call i32 @vscale(float* %12, i32 %17)
%19 = load float, float* %5
%20 = fpext float %19 to double
%21 = fdiv double %20, 2.000000e+00
%22 = fptrunc double %21 to float
%23 = call float @cos(float %22)
%24 = load float*, float** %6
%25 = getelementptr inbounds float, float* %24, i64 3
store float %23, float* %25
ret void
}

LLVM IR (-O2):
define void @axis_to_quat(float* %0, float %1, float* %2) {
%4 = tail call i32 @vnormal(float* %0)
%5 = tail call i32 @vcopy(float* %0, float* %2)
%6 = fmul float %1, 5.000000e-01
%7 = tail call i32 @sin(float %6)
%8 = tail call i32 @vscale(float* %2, i32 %7)
%9 = tail call float @cos(float %6)
%10 = getelementptr inbounds float, float* %2, i64 3
store float %9, float* %10
ret void
}