#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 const *, float *);
int /*<<< orphan*/ vnormal(float *);
int /*<<< orphan*/ vscale(float *, int /*<<< orphan*/);
void axis_to_quat(const float a[3], float phi, float q[4]) {
  vcopy(a, q);
  vnormal(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
mov    -0x18(%rbp),%rsi
call   1070 <vcopy@plt>
mov    -0x18(%rbp),%rdi
call   1030 <vnormal@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   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
movss  %xmm0,0xc(%rsp)
call   1070 <vcopy@plt>
mov    %rbx,%rdi
call   1030 <vnormal@plt>
movss  0xc(%rsp),%xmm0
mulss  0xe87(%rip),%xmm0
movss  %xmm0,0xc(%rsp)
call   1040 <sin@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1060 <vscale@plt>
movss  0xc(%rsp),%xmm0
call   1050 <cos@plt>
movss  %xmm0,0xc(%rbx)
add    $0x10,%rsp
pop    %rbx
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 = load float*, float** %6
%9 = call i32 @vcopy(float* %7, float* %8)
%10 = load float*, float** %6
%11 = call i32 @vnormal(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 @vcopy(float* %0, float* %2)
%5 = tail call i32 @vnormal(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
}