#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 M_PI;
float cosf(float);
float sinf(float);
float sqrtf(float);
void quatf_rotateAxis_new(float quat[4], float degrees, float x, float y,
                          float z) {
  int X = 0, Y = 1, Z = 2, W = 3;
  float angle = -degrees * M_PI / 180;
  float length = sqrtf(x * x + y * y + z * z);
  if (length < 1e-10) {
    quat[X] = 0;
    quat[Y] = 0;
    quat[Z] = 0;
    quat[W] = 1;
    return;
  }
  x /= length;
  y /= length;
  z /= length;
  float cosA = cosf(angle / 2.0);
  float sinA = sinf(angle / 2.0);
  quat[W] = cosA;
  quat[X] = sinA * x;
  quat[Y] = sinA * y;
  quat[Z] = sinA * z;
}


x86 assembly (clang, -O0):
<quatf_rotateAxis_new>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
movss  %xmm1,-0x10(%rbp)
movss  %xmm2,-0x14(%rbp)
movss  %xmm3,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
movl   $0x2,-0x24(%rbp)
movl   $0x3,-0x28(%rbp)
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mov    0x2e63(%rip),%rax
mulss  (%rax),%xmm0
movss  0xe7f(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x10(%rbp),%xmm1
movss  -0x10(%rbp),%xmm2
movss  -0x14(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  -0x18(%rbp),%xmm0
movss  -0x18(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1050 <sqrtf@plt>
movss  %xmm0,-0x30(%rbp)
movss  -0x30(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe1d(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1237 <quatf_rotateAxis_new+0x107>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
movss  0xde7(%rip),%xmm0
movss  %xmm0,(%rax,%rcx,4)
jmp    130d <quatf_rotateAxis_new+0x1dd>
movss  -0x30(%rbp),%xmm1
movss  -0x10(%rbp),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x30(%rbp),%xmm1
movss  -0x14(%rbp),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x30(%rbp),%xmm1
movss  -0x18(%rbp),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd87(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1040 <cosf@plt>
movss  %xmm0,-0x34(%rbp)
movss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd64(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1030 <sinf@plt>
movss  %xmm0,-0x38(%rbp)
movss  -0x34(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
movss  -0x38(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
movss  -0x38(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
movss  -0x38(%rbp),%xmm0
mulss  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quatf_rotateAxis_new>:
push   %rbx
sub    $0x30,%rsp
movaps %xmm0,%xmm4
mov    %rdi,%rbx
mov    0x2ea6(%rip),%rax
movss  (%rax),%xmm0
movss  %xmm0,0x4(%rsp)
movaps %xmm2,0x20(%rsp)
movaps %xmm2,%xmm0
mulss  %xmm2,%xmm0
movss  %xmm1,0x8(%rsp)
mulss  %xmm1,%xmm1
addss  %xmm0,%xmm1
movaps %xmm3,%xmm0
mulss  %xmm3,%xmm0
addss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     117f <quatf_rotateAxis_new+0x4f>
sqrtss %xmm0,%xmm0
jmp    119a <quatf_rotateAxis_new+0x6a>
movaps %xmm3,0x10(%rsp)
movss  %xmm4,0xc(%rsp)
call   1050 <sqrtf@plt>
movss  0xc(%rsp),%xmm4
movaps 0x10(%rsp),%xmm3
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  0xe57(%rip),%xmm2
ucomisd %xmm1,%xmm2
jbe    11c2 <quatf_rotateAxis_new+0x92>
movl   $0x0,(%rbx)
xorps  %xmm0,%xmm0
movss  0xe50(%rip),%xmm1
jmp    123c <quatf_rotateAxis_new+0x10c>
movss  0x4(%rsp),%xmm2
mulss  %xmm4,%xmm2
divss  0xe34(%rip),%xmm2
movss  0x8(%rsp),%xmm1
divss  %xmm0,%xmm1
movss  %xmm1,0x8(%rsp)
movaps 0x20(%rsp),%xmm1
unpcklps %xmm3,%xmm1
shufps $0x0,%xmm0,%xmm0
divps  %xmm0,%xmm1
movaps %xmm1,0x20(%rsp)
mulss  0xe0c(%rip),%xmm2
movss  %xmm2,0x4(%rsp)
movaps %xmm2,%xmm0
call   1040 <cosf@plt>
movss  %xmm0,0x10(%rsp)
movss  0x4(%rsp),%xmm0
call   1030 <sinf@plt>
movss  0x10(%rsp),%xmm1
movss  0x8(%rsp),%xmm2
mulss  %xmm0,%xmm2
movss  %xmm2,(%rbx)
shufps $0x0,%xmm0,%xmm0
mulps  0x20(%rsp),%xmm0
movss  %xmm0,0x4(%rbx)
shufps $0x55,%xmm0,%xmm0
movss  %xmm0,0x8(%rbx)
movss  %xmm1,0xc(%rbx)
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@M_PI = global float 0.000000e+00
define void @quatf_rotateAxis_new(float* %0, float %1, float %2, float %3, float %4) {
%6 = alloca float*
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca float
%16 = alloca float
%17 = alloca float
%18 = alloca float
store float* %0, float** %6
store float %1, float* %7
store float %2, float* %8
store float %3, float* %9
store float %4, float* %10
store i32 0, i32* %11
store i32 1, i32* %12
store i32 2, i32* %13
store i32 3, i32* %14
%19 = load float, float* %7
%20 = fneg float %19
%21 = load float, float* @M_PI
%22 = fmul float %20, %21
%23 = fdiv float %22, 1.800000e+02
store float %23, float* %15
%24 = load float, float* %8
%25 = load float, float* %8
%26 = load float, float* %9
%27 = load float, float* %9
%28 = fmul float %26, %27
%29 = call float @llvm.fmuladd.f32(float %24, float %25, float %28)
%30 = load float, float* %10
%31 = load float, float* %10
%32 = call float @llvm.fmuladd.f32(float %30, float %31, float %29)
%33 = call float @sqrtf(float %32)
store float %33, float* %16
%34 = load float, float* %16
%35 = fpext float %34 to double
%36 = fcmp olt double %35, 1.000000e-10
br i1 %36, label %37, label %54
37: ; preds = %5
%38 = load float*, float** %6
%39 = load i32, i32* %11
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds float, float* %38, i64 %40
store float 0.000000e+00, float* %41
%42 = load float*, float** %6
%43 = load i32, i32* %12
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds float, float* %42, i64 %44
store float 0.000000e+00, float* %45
%46 = load float*, float** %6
%47 = load i32, i32* %13
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds float, float* %46, i64 %48
store float 0.000000e+00, float* %49
%50 = load float*, float** %6
%51 = load i32, i32* %14
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds float, float* %50, i64 %52
store float 1.000000e+00, float* %53
br label %100
54: ; preds = %5
%55 = load float, float* %16
%56 = load float, float* %8
%57 = fdiv float %56, %55
store float %57, float* %8
%58 = load float, float* %16
%59 = load float, float* %9
%60 = fdiv float %59, %58
store float %60, float* %9
%61 = load float, float* %16
%62 = load float, float* %10
%63 = fdiv float %62, %61
store float %63, float* %10
%64 = load float, float* %15
%65 = fpext float %64 to double
%66 = fdiv double %65, 2.000000e+00
%67 = fptrunc double %66 to float
%68 = call float @cosf(float %67)
store float %68, float* %17
%69 = load float, float* %15
%70 = fpext float %69 to double
%71 = fdiv double %70, 2.000000e+00
%72 = fptrunc double %71 to float
%73 = call float @sinf(float %72)
store float %73, float* %18
%74 = load float, float* %17
%75 = load float*, float** %6
%76 = load i32, i32* %14
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds float, float* %75, i64 %77
store float %74, float* %78
%79 = load float, float* %18
%80 = load float, float* %8
%81 = fmul float %79, %80
%82 = load float*, float** %6
%83 = load i32, i32* %11
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds float, float* %82, i64 %84
store float %81, float* %85
%86 = load float, float* %18
%87 = load float, float* %9
%88 = fmul float %86, %87
%89 = load float*, float** %6
%90 = load i32, i32* %12
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds float, float* %89, i64 %91
store float %88, float* %92
%93 = load float, float* %18
%94 = load float, float* %10
%95 = fmul float %93, %94
%96 = load float*, float** %6
%97 = load i32, i32* %13
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds float, float* %96, i64 %98
store float %95, float* %99
br label %100
100: ; preds = %54, %37
ret void
}

LLVM IR (-O2):
@M_PI = global float 0.000000e+00
define void @quatf_rotateAxis_new(float* nocapture writeonly %0, float %1, float %2, float %3, float %4) {
%6 = load float, float* @M_PI
%7 = fmul float %3, %3
%8 = tail call float @llvm.fmuladd.f32(float %2, float %2, float %7)
%9 = tail call float @llvm.fmuladd.f32(float %4, float %4, float %8)
%10 = tail call float @sqrtf(float %9)
%11 = fpext float %10 to double
%12 = fcmp olt double %11, 1.000000e-10
br i1 %12, label %13, label %14
13: ; preds = %5
store float 0.000000e+00, float* %0
br label %31
14: ; preds = %5
%15 = fneg float %1
%16 = fmul float %6, %15
%17 = fdiv float %16, 1.800000e+02
%18 = fdiv float %2, %10
%19 = insertelement <2 x float> poison, float %3, i64 0
%20 = insertelement <2 x float> %19, float %4, i64 1
%21 = insertelement <2 x float> poison, float %10, i64 0
%22 = shufflevector <2 x float> %21, <2 x float> poison, <2 x i32> zeroinitializer
%23 = fdiv <2 x float> %20, %22
%24 = fmul float %17, 5.000000e-01
%25 = tail call float @cosf(float %24)
%26 = tail call float @sinf(float %24)
%27 = fmul float %18, %26
store float %27, float* %0
%28 = insertelement <2 x float> poison, float %26, i64 0
%29 = shufflevector <2 x float> %28, <2 x float> poison, <2 x i32> zeroinitializer
%30 = fmul <2 x float> %23, %29
br label %31
31: ; preds = %14, %13
%32 = phi float [ 1.000000e+00, %13 ], [ %25, %14 ]
%33 = phi <2 x float> [ zeroinitializer, %13 ], [ %30, %14 ]
%34 = getelementptr inbounds float, float* %0, i64 1
%35 = extractelement <2 x float> %33, i64 0
store float %35, float* %34
%36 = getelementptr inbounds float, float* %0, i64 2
%37 = extractelement <2 x float> %33, i64 1
store float %37, float* %36
%38 = getelementptr inbounds float, float* %0, i64 3
store float %32, float* %38
ret void
}