#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 M_PI;
double cos(double);
double sin(double);
double sqrt(double);
void quatd_rotateAxis_new(double quat[4], double degrees, double x, double y,
                          double z) {
  int X = 0, Y = 1, Z = 2, W = 3;
  double angle = -degrees * M_PI / 180;
  double length = sqrt(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;
  double cosA = cos(angle / 2.0);
  double sinA = sin(angle / 2.0);
  quat[W] = cosA;
  quat[X] = sinA * x;
  quat[Y] = sinA * y;
  quat[Z] = sinA * z;
}


x86 assembly (clang, -O0):
<quatd_rotateAxis_new>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x1,-0x30(%rbp)
movl   $0x2,-0x34(%rbp)
movl   $0x3,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    0x2e59(%rip),%rax
mulsd  (%rax),%xmm0
movsd  0xe6d(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  0xe1c(%rip),%xmm0
ucomisd -0x48(%rbp),%xmm0
jbe    1239 <quatd_rotateAxis_new+0x109>
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  0xde9(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    12ff <quatd_rotateAxis_new+0x1cf>
movsd  -0x48(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x48(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x48(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  0xd91(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  0xd76(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x50(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x58(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x58(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x58(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quatd_rotateAxis_new>:
push   %rbx
sub    $0x40,%rsp
movapd %xmm0,%xmm4
mov    %rdi,%rbx
mov    0x2ea5(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,(%rsp)
movapd %xmm2,0x20(%rsp)
movapd %xmm2,%xmm0
mulsd  %xmm2,%xmm0
movsd  %xmm1,0x8(%rsp)
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movapd %xmm3,%xmm0
mulsd  %xmm3,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1184 <quatd_rotateAxis_new+0x54>
sqrtsd %xmm0,%xmm0
jmp    11a1 <quatd_rotateAxis_new+0x71>
movapd %xmm3,0x10(%rsp)
movsd  %xmm4,0x38(%rsp)
call   1050 <sqrt@plt>
movsd  0x38(%rsp),%xmm4
movapd 0x10(%rsp),%xmm3
movsd  0xe57(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    11c4 <quatd_rotateAxis_new+0x94>
movq   $0x0,(%rbx)
xorpd  %xmm0,%xmm0
movsd  0xe56(%rip),%xmm1
jmp    1241 <quatd_rotateAxis_new+0x111>
movsd  (%rsp),%xmm2
mulsd  %xmm4,%xmm2
divsd  0xe33(%rip),%xmm2
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movapd 0x20(%rsp),%xmm1
unpcklpd %xmm3,%xmm1
unpcklpd %xmm0,%xmm0
divpd  %xmm0,%xmm1
movapd %xmm1,0x20(%rsp)
mulsd  0xe0b(%rip),%xmm2
movsd  %xmm2,(%rsp)
movapd %xmm2,%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
call   1030 <sin@plt>
movsd  0x10(%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
mulsd  %xmm0,%xmm2
movsd  %xmm2,(%rbx)
unpcklpd %xmm0,%xmm0
mulpd  0x20(%rsp),%xmm0
movupd %xmm0,0x8(%rbx)
movsd  %xmm1,0x18(%rbx)
add    $0x40,%rsp
pop    %rbx
ret

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

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