#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 */
double acosf(float);
float sinf(float);
float quat_getAxisAngle(float *out_axis, float *q) {
  float rad = acosf(q[3]) * 2.0;
  float s = sinf(rad / 2.0);
  if (s > 0.000001) {
    out_axis[0] = q[0] / s;
    out_axis[1] = q[1] / s;
    out_axis[2] = q[2] / s;
  } else {
    out_axis[0] = 1;
    out_axis[1] = 0;
    out_axis[2] = 0;
  }
  return rad;
}


x86 assembly (clang, -O0):
<quat_getAxisAngle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movss  0xc(%rax),%xmm0
call   1040 <acosf@plt>
movsd  0xec2(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xea4(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1030 <sinf@plt>
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe79(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11d9 <quat_getAxisAngle+0xb9>
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
divss  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movss  0x4(%rax),%xmm0
divss  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x4(%rax)
mov    -0x10(%rbp),%rax
movss  0x8(%rax),%xmm0
divss  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x8(%rax)
jmp    1201 <quat_getAxisAngle+0xe1>
mov    -0x8(%rbp),%rax
movss  0xe2b(%rip),%xmm0
movss  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x4(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x8(%rax)
movss  -0x14(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quat_getAxisAngle>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
movss  0xc(%rsi),%xmm0
call   1040 <acosf@plt>
addsd  %xmm0,%xmm0
cvtsd2ss %xmm0,%xmm1
movss  0xebc(%rip),%xmm0
movss  %xmm1,0x4(%rsp)
mulss  %xmm1,%xmm0
call   1030 <sinf@plt>
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
ucomisd 0xea6(%rip),%xmm1
jbe    118b <quat_getAxisAngle+0x6b>
movss  (%rbx),%xmm1
divss  %xmm0,%xmm1
movss  %xmm1,(%r14)
movss  0x4(%rbx),%xmm1
divss  %xmm0,%xmm1
movss  %xmm1,0x4(%r14)
movss  0x8(%rbx),%xmm1
divss  %xmm0,%xmm1
jmp    1195 <quat_getAxisAngle+0x75>
movq   $0x3f800000,(%r14)
xorps  %xmm1,%xmm1
movss  %xmm1,0x8(%r14)
movss  0x4(%rsp),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define float @quat_getAxisAngle(float* %0, float* %1) {
%3 = alloca float*
%4 = alloca float*
%5 = alloca float
%6 = alloca float
store float* %0, float** %3
store float* %1, float** %4
%7 = load float*, float** %4
%8 = getelementptr inbounds float, float* %7, i64 3
%9 = load float, float* %8
%10 = call double @acosf(float %9)
%11 = fmul double %10, 2.000000e+00
%12 = fptrunc double %11 to float
store float %12, float* %5
%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 float @sinf(float %16)
store float %17, float* %6
%18 = load float, float* %6
%19 = fpext float %18 to double
%20 = fcmp ogt double %19, 0x3EB0C6F7A0B5ED8D
br i1 %20, label %21, label %43
21: ; preds = %2
%22 = load float*, float** %4
%23 = getelementptr inbounds float, float* %22, i64 0
%24 = load float, float* %23
%25 = load float, float* %6
%26 = fdiv float %24, %25
%27 = load float*, float** %3
%28 = getelementptr inbounds float, float* %27, i64 0
store float %26, float* %28
%29 = load float*, float** %4
%30 = getelementptr inbounds float, float* %29, i64 1
%31 = load float, float* %30
%32 = load float, float* %6
%33 = fdiv float %31, %32
%34 = load float*, float** %3
%35 = getelementptr inbounds float, float* %34, i64 1
store float %33, float* %35
%36 = load float*, float** %4
%37 = getelementptr inbounds float, float* %36, i64 2
%38 = load float, float* %37
%39 = load float, float* %6
%40 = fdiv float %38, %39
%41 = load float*, float** %3
%42 = getelementptr inbounds float, float* %41, i64 2
store float %40, float* %42
br label %50
43: ; preds = %2
%44 = load float*, float** %3
%45 = getelementptr inbounds float, float* %44, i64 0
store float 1.000000e+00, float* %45
%46 = load float*, float** %3
%47 = getelementptr inbounds float, float* %46, i64 1
store float 0.000000e+00, float* %47
%48 = load float*, float** %3
%49 = getelementptr inbounds float, float* %48, i64 2
store float 0.000000e+00, float* %49
br label %50
50: ; preds = %43, %21
%51 = load float, float* %5
ret float %51
}

LLVM IR (-O2):
define float @quat_getAxisAngle(float* nocapture writeonly %0, float* nocapture %1) {
%3 = getelementptr inbounds float, float* %1, i64 3
%4 = load float, float* %3
%5 = tail call double @acosf(float %4)
%6 = fmul double %5, 2.000000e+00
%7 = fptrunc double %6 to float
%8 = fmul float %7, 5.000000e-01
%9 = tail call float @sinf(float %8)
%10 = fpext float %9 to double
%11 = fcmp ogt double %10, 0x3EB0C6F7A0B5ED8D
br i1 %11, label %12, label %22
12: ; preds = %2
%13 = load float, float* %1
%14 = fdiv float %13, %9
store float %14, float* %0
%15 = getelementptr inbounds float, float* %1, i64 1
%16 = load float, float* %15
%17 = fdiv float %16, %9
%18 = getelementptr inbounds float, float* %0, i64 1
store float %17, float* %18
%19 = getelementptr inbounds float, float* %1, i64 2
%20 = load float, float* %19
%21 = fdiv float %20, %9
br label %24
22: ; preds = %2
store float 1.000000e+00, float* %0
%23 = getelementptr inbounds float, float* %0, i64 1
store float 0.000000e+00, float* %23
br label %24
24: ; preds = %22, %12
%25 = phi float [ %21, %12 ], [ 0.000000e+00, %22 ]
%26 = getelementptr inbounds float, float* %0, i64 2
store float %25, float* %26
ret float %7
}