#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);
double sin(double);
double sqrt(float);
void lib3ds_quat_axis_angle(float c[4], float axis[3], float angle) {
  double omega, s;
  double l;
  l = sqrt(axis[0] * axis[0] + axis[1] * axis[1] + axis[2] * axis[2]);
  if (l < (1e-5)) {
    c[0] = c[1] = c[2] = 0.0f;
    c[3] = 1.0f;
  } else {
    omega = -0.5 * angle;
    s = sin(omega) / l;
    c[0] = (float)s * axis[0];
    c[1] = (float)s * axis[1];
    c[2] = (float)s * axis[2];
    c[3] = (float)cos(omega);
  }
}


x86 assembly (clang, -O0):
<lib3ds_quat_axis_angle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movss  %xmm0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm1
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm2
mov    -0x10(%rbp),%rax
movss  0x4(%rax),%xmm0
mov    -0x10(%rbp),%rax
mulss  0x4(%rax),%xmm0
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
mov    -0x10(%rbp),%rax
movss  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
movss  0x8(%rax),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  0xe65(%rip),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    11df <lib3ds_quat_axis_angle+0xaf>
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x4(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movss  0xe3b(%rip),%xmm0
movss  %xmm0,0xc(%rax)
jmp    1274 <lib3ds_quat_axis_angle+0x144>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe18(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <sin@plt>
divsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x10(%rbp),%rax
mulss  (%rax),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movsd  -0x28(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x10(%rbp),%rax
mulss  0x4(%rax),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x4(%rax)
movsd  -0x28(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x10(%rbp),%rax
mulss  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x8(%rax)
movsd  -0x20(%rbp),%xmm0
call   1040 <cos@plt>
cvtsi2ss %rax,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0xc(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lib3ds_quat_axis_angle>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movss  %xmm0,0x8(%rsp)
mov    %rsi,%rbx
mov    %rdi,%r14
movss  (%rsi),%xmm1
movss  0x4(%rsi),%xmm0
mulss  %xmm0,%xmm0
mulss  %xmm1,%xmm1
addss  %xmm0,%xmm1
movss  0x8(%rsi),%xmm0
mulss  %xmm0,%xmm0
addss  %xmm1,%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xe8b(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1194 <lib3ds_quat_axis_angle+0x64>
movl   $0x0,0x8(%r14)
movq   $0x0,(%r14)
movss  0xe7e(%rip),%xmm0
jmp    11fb <lib3ds_quat_axis_angle+0xcb>
movss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xe62(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  %xmm1,0x10(%rsp)
call   1030 <sin@plt>
divsd  0x10(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  (%rbx),%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,(%r14)
movss  0x4(%rbx),%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,0x4(%r14)
mulss  0x8(%rbx),%xmm0
movss  %xmm0,0x8(%r14)
movsd  0x8(%rsp),%xmm0
call   1040 <cos@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movss  %xmm0,0xc(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @lib3ds_quat_axis_angle(float* %0, float* %1, float %2) {
%4 = alloca float*
%5 = alloca float*
%6 = alloca float
%7 = alloca double
%8 = alloca double
%9 = alloca double
store float* %0, float** %4
store float* %1, float** %5
store float %2, float* %6
%10 = load float*, float** %5
%11 = getelementptr inbounds float, float* %10, i64 0
%12 = load float, float* %11
%13 = load float*, float** %5
%14 = getelementptr inbounds float, float* %13, i64 0
%15 = load float, float* %14
%16 = load float*, float** %5
%17 = getelementptr inbounds float, float* %16, i64 1
%18 = load float, float* %17
%19 = load float*, float** %5
%20 = getelementptr inbounds float, float* %19, i64 1
%21 = load float, float* %20
%22 = fmul float %18, %21
%23 = call float @llvm.fmuladd.f32(float %12, float %15, float %22)
%24 = load float*, float** %5
%25 = getelementptr inbounds float, float* %24, i64 2
%26 = load float, float* %25
%27 = load float*, float** %5
%28 = getelementptr inbounds float, float* %27, i64 2
%29 = load float, float* %28
%30 = call float @llvm.fmuladd.f32(float %26, float %29, float %23)
%31 = call double @sqrt(float %30)
store double %31, double* %9
%32 = load double, double* %9
%33 = fcmp olt double %32, 1.000000e-05
br i1 %33, label %34, label %43
34: ; preds = %3
%35 = load float*, float** %4
%36 = getelementptr inbounds float, float* %35, i64 2
store float 0.000000e+00, float* %36
%37 = load float*, float** %4
%38 = getelementptr inbounds float, float* %37, i64 1
store float 0.000000e+00, float* %38
%39 = load float*, float** %4
%40 = getelementptr inbounds float, float* %39, i64 0
store float 0.000000e+00, float* %40
%41 = load float*, float** %4
%42 = getelementptr inbounds float, float* %41, i64 3
store float 1.000000e+00, float* %42
br label %80
43: ; preds = %3
%44 = load float, float* %6
%45 = fpext float %44 to double
%46 = fmul double -5.000000e-01, %45
store double %46, double* %7
%47 = load double, double* %7
%48 = call double @sin(double %47)
%49 = load double, double* %9
%50 = fdiv double %48, %49
store double %50, double* %8
%51 = load double, double* %8
%52 = fptrunc double %51 to float
%53 = load float*, float** %5
%54 = getelementptr inbounds float, float* %53, i64 0
%55 = load float, float* %54
%56 = fmul float %52, %55
%57 = load float*, float** %4
%58 = getelementptr inbounds float, float* %57, i64 0
store float %56, float* %58
%59 = load double, double* %8
%60 = fptrunc double %59 to float
%61 = load float*, float** %5
%62 = getelementptr inbounds float, float* %61, i64 1
%63 = load float, float* %62
%64 = fmul float %60, %63
%65 = load float*, float** %4
%66 = getelementptr inbounds float, float* %65, i64 1
store float %64, float* %66
%67 = load double, double* %8
%68 = fptrunc double %67 to float
%69 = load float*, float** %5
%70 = getelementptr inbounds float, float* %69, i64 2
%71 = load float, float* %70
%72 = fmul float %68, %71
%73 = load float*, float** %4
%74 = getelementptr inbounds float, float* %73, i64 2
store float %72, float* %74
%75 = load double, double* %7
%76 = call i64 @cos(double %75)
%77 = sitofp i64 %76 to float
%78 = load float*, float** %4
%79 = getelementptr inbounds float, float* %78, i64 3
store float %77, float* %79
br label %80
80: ; preds = %43, %34
ret void
}

LLVM IR (-O2):
define void @lib3ds_quat_axis_angle(float* nocapture writeonly %0, float* nocapture %1, float %2) {
%4 = load float, float* %1
%5 = getelementptr inbounds float, float* %1, i64 1
%6 = load float, float* %5
%7 = fmul float %6, %6
%8 = tail call float @llvm.fmuladd.f32(float %4, float %4, float %7)
%9 = getelementptr inbounds float, float* %1, i64 2
%10 = load float, float* %9
%11 = tail call float @llvm.fmuladd.f32(float %10, float %10, float %8)
%12 = tail call double @sqrt(float %11)
%13 = fcmp olt double %12, 1.000000e-05
br i1 %13, label %14, label %17
14: ; preds = %3
%15 = getelementptr inbounds float, float* %0, i64 2
store float 0.000000e+00, float* %15
%16 = getelementptr inbounds float, float* %0, i64 1
store float 0.000000e+00, float* %16
store float 0.000000e+00, float* %0
br label %33
17: ; preds = %3
%18 = fpext float %2 to double
%19 = fmul double %18, -5.000000e-01
%20 = tail call double @sin(double %19)
%21 = fdiv double %20, %12
%22 = fptrunc double %21 to float
%23 = load float, float* %1
%24 = fmul float %23, %22
store float %24, float* %0
%25 = load float, float* %5
%26 = fmul float %25, %22
%27 = getelementptr inbounds float, float* %0, i64 1
store float %26, float* %27
%28 = load float, float* %9
%29 = fmul float %28, %22
%30 = getelementptr inbounds float, float* %0, i64 2
store float %29, float* %30
%31 = tail call i64 @cos(double %19)
%32 = sitofp i64 %31 to float
br label %33
33: ; preds = %17, %14
%34 = phi float [ 1.000000e+00, %14 ], [ %32, %17 ]
%35 = getelementptr inbounds float, float* %0, i64 3
store float %34, float* %35
ret void
}