; LLVM IR from HRI-EU/Rcs :: src/RcsCore (Rcs_quaternion)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
define dso_local void @Quat_fromEulerAngles(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds double, ptr %14, i64 0
  %16 = load double, ptr %15, align 8, !tbaa !9
  %17 = fmul double 5.000000e-01, %16
  store double %17, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds double, ptr %18, i64 1
  %20 = load double, ptr %19, align 8, !tbaa !9
  %21 = fmul double 5.000000e-01, %20
  store double %21, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds double, ptr %22, i64 2
  %24 = load double, ptr %23, align 8, !tbaa !9
  %25 = fmul double 5.000000e-01, %24
  store double %25, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %26 = load double, ptr %5, align 8, !tbaa !9
  %27 = call double @sin(double noundef %26) #4
  store double %27, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %28 = load double, ptr %6, align 8, !tbaa !9
  %29 = call double @sin(double noundef %28) #4
  store double %29, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %30 = load double, ptr %7, align 8, !tbaa !9
  %31 = call double @sin(double noundef %30) #4
  store double %31, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %32 = load double, ptr %5, align 8, !tbaa !9
  %33 = call double @cos(double noundef %32) #4
  store double %33, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %34 = load double, ptr %6, align 8, !tbaa !9
  %35 = call double @cos(double noundef %34) #4
  store double %35, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %36 = load double, ptr %7, align 8, !tbaa !9
  %37 = call double @cos(double noundef %36) #4
  store double %37, ptr %13, align 8, !tbaa !9
  %38 = load double, ptr %8, align 8, !tbaa !9
  %39 = fneg double %38
  %40 = load double, ptr %9, align 8, !tbaa !9
  %41 = fmul double %39, %40
  %42 = load double, ptr %10, align 8, !tbaa !9
  %43 = load double, ptr %11, align 8, !tbaa !9
  %44 = load double, ptr %12, align 8, !tbaa !9
  %45 = fmul double %43, %44
  %46 = load double, ptr %13, align 8, !tbaa !9
  %47 = fmul double %45, %46
  %48 = call double @llvm.fmuladd.f64(double %41, double %42, double %47)
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds double, ptr %49, i64 0
  store double %48, ptr %50, align 8, !tbaa !9
  %51 = load double, ptr %8, align 8, !tbaa !9
  %52 = load double, ptr %12, align 8, !tbaa !9
  %53 = fmul double %51, %52
  %54 = load double, ptr %13, align 8, !tbaa !9
  %55 = load double, ptr %9, align 8, !tbaa !9
  %56 = load double, ptr %10, align 8, !tbaa !9
  %57 = fmul double %55, %56
  %58 = load double, ptr %11, align 8, !tbaa !9
  %59 = fmul double %57, %58
  %60 = call double @llvm.fmuladd.f64(double %53, double %54, double %59)
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds double, ptr %61, i64 1
  store double %60, ptr %62, align 8, !tbaa !9
  %63 = load double, ptr %8, align 8, !tbaa !9
  %64 = fneg double %63
  %65 = load double, ptr %10, align 8, !tbaa !9
  %66 = fmul double %64, %65
  %67 = load double, ptr %12, align 8, !tbaa !9
  %68 = load double, ptr %9, align 8, !tbaa !9
  %69 = load double, ptr %11, align 8, !tbaa !9
  %70 = fmul double %68, %69
  %71 = load double, ptr %13, align 8, !tbaa !9
  %72 = fmul double %70, %71
  %73 = call double @llvm.fmuladd.f64(double %66, double %67, double %72)
  %74 = load ptr, ptr %3, align 8, !tbaa !5
  %75 = getelementptr inbounds double, ptr %74, i64 2
  store double %73, ptr %75, align 8, !tbaa !9
  %76 = load double, ptr %8, align 8, !tbaa !9
  %77 = load double, ptr %9, align 8, !tbaa !9
  %78 = fmul double %76, %77
  %79 = load double, ptr %13, align 8, !tbaa !9
  %80 = load double, ptr %10, align 8, !tbaa !9
  %81 = load double, ptr %11, align 8, !tbaa !9
  %82 = fmul double %80, %81
  %83 = load double, ptr %12, align 8, !tbaa !9
  %84 = fmul double %82, %83
  %85 = call double @llvm.fmuladd.f64(double %78, double %79, double %84)
  %86 = load ptr, ptr %3, align 8, !tbaa !5
  %87 = getelementptr inbounds double, ptr %86, i64 3
  store double %85, ptr %87, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret void
}

; Function Attrs: nounwind
declare double @sin(double noundef) #3

; Function Attrs: nounwind
declare double @cos(double noundef) #3

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: mustprogress nofree nounwind willreturn memory(write, argmem: readwrite) uwtable
define dso_local void @Quat_fromEulerAngles(ptr nocapture noundef writeonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = load double, ptr %1, align 8, !tbaa !5
  %4 = fmul double %3, 5.000000e-01
  %5 = getelementptr inbounds i8, ptr %1, i64 8
  %6 = load double, ptr %5, align 8, !tbaa !5
  %7 = fmul double %6, 5.000000e-01
  %8 = getelementptr inbounds i8, ptr %1, i64 16
  %9 = load double, ptr %8, align 8, !tbaa !5
  %10 = fmul double %9, 5.000000e-01
  %11 = tail call double @sin(double noundef %4) #3
  %12 = tail call double @sin(double noundef %7) #3
  %13 = tail call double @sin(double noundef %10) #3
  %14 = tail call double @cos(double noundef %4) #3
  %15 = tail call double @cos(double noundef %7) #3
  %16 = tail call double @cos(double noundef %10) #3
  %17 = fneg double %11
  %18 = insertelement <2 x double> poison, double %12, i64 0
  %19 = insertelement <2 x double> %18, double %11, i64 1
  %20 = insertelement <2 x double> poison, double %17, i64 0
  %21 = insertelement <2 x double> %20, double %15, i64 1
  %22 = fmul <2 x double> %19, %21
  %23 = insertelement <2 x double> poison, double %14, i64 0
  %24 = insertelement <2 x double> %23, double %12, i64 1
  %25 = insertelement <2 x double> poison, double %15, i64 0
  %26 = insertelement <2 x double> %25, double %13, i64 1
  %27 = fmul <2 x double> %24, %26
  %28 = insertelement <2 x double> poison, double %16, i64 0
  %29 = insertelement <2 x double> %28, double %14, i64 1
  %30 = fmul <2 x double> %27, %29
  %31 = shufflevector <2 x double> %26, <2 x double> %28, <2 x i32> <i32 1, i32 2>
  %32 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %22, <2 x double> %31, <2 x double> %30)
  store <2 x double> %32, ptr %0, align 8, !tbaa !5
  %33 = getelementptr inbounds i8, ptr %0, i64 16
  %34 = insertelement <2 x double> poison, double %13, i64 0
  %35 = insertelement <2 x double> %34, double %11, i64 1
  %36 = insertelement <2 x double> %20, double %12, i64 1
  %37 = fmul <2 x double> %35, %36
  %38 = shufflevector <2 x double> %36, <2 x double> %34, <2 x i32> <i32 1, i32 2>
  %39 = insertelement <2 x double> poison, double %14, i64 0
  %40 = shufflevector <2 x double> %39, <2 x double> poison, <2 x i32> zeroinitializer
  %41 = fmul <2 x double> %38, %40
  %42 = insertelement <2 x double> poison, double %16, i64 0
  %43 = insertelement <2 x double> %42, double %15, i64 1
  %44 = fmul <2 x double> %41, %43
  %45 = shufflevector <2 x double> %43, <2 x double> poison, <2 x i32> <i32 1, i32 0>
  %46 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %37, <2 x double> %45, <2 x double> %44)
  store <2 x double> %46, ptr %33, align 8, !tbaa !5
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sin(double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @cos(double noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #2

attributes #0 = { mustprogress nofree nounwind willreturn memory(write, argmem: readwrite) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nofree nounwind willreturn memory(write) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalDCEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,TailCallElimPass