; LLVM IR from pmla/polyhedral-template-matching :: ptm_quat.ll (ZN3ptm8quat_rotEPdS0_S0_)

; 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: mustprogress nounwind uwtable
define dso_local void @_ZN3ptm8quat_rotEPdS0_S0_(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = getelementptr inbounds double, ptr %7, i64 0
  %9 = load double, ptr %8, align 8, !tbaa !9
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = getelementptr inbounds double, ptr %10, i64 0
  %12 = load double, ptr %11, align 8, !tbaa !9
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds double, ptr %13, i64 1
  %15 = load double, ptr %14, align 8, !tbaa !9
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds double, ptr %16, i64 1
  %18 = load double, ptr %17, align 8, !tbaa !9
  %19 = fmul double %15, %18
  %20 = fneg double %19
  %21 = call double @llvm.fmuladd.f64(double %9, double %12, double %20)
  %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 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds double, ptr %25, i64 2
  %27 = load double, ptr %26, align 8, !tbaa !9
  %28 = fneg double %24
  %29 = call double @llvm.fmuladd.f64(double %28, double %27, double %21)
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds double, ptr %30, i64 3
  %32 = load double, ptr %31, align 8, !tbaa !9
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds double, ptr %33, i64 3
  %35 = load double, ptr %34, align 8, !tbaa !9
  %36 = fneg double %32
  %37 = call double @llvm.fmuladd.f64(double %36, double %35, double %29)
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = getelementptr inbounds double, ptr %38, i64 0
  store double %37, ptr %39, align 8, !tbaa !9
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds double, ptr %40, i64 0
  %42 = load double, ptr %41, align 8, !tbaa !9
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds double, ptr %43, i64 1
  %45 = load double, ptr %44, align 8, !tbaa !9
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds double, ptr %46, i64 1
  %48 = load double, ptr %47, align 8, !tbaa !9
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds double, ptr %49, i64 0
  %51 = load double, ptr %50, align 8, !tbaa !9
  %52 = fmul double %48, %51
  %53 = call double @llvm.fmuladd.f64(double %42, double %45, double %52)
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds double, ptr %54, i64 2
  %56 = load double, ptr %55, align 8, !tbaa !9
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = getelementptr inbounds double, ptr %57, i64 3
  %59 = load double, ptr %58, align 8, !tbaa !9
  %60 = call double @llvm.fmuladd.f64(double %56, double %59, double %53)
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = getelementptr inbounds double, ptr %61, i64 3
  %63 = load double, ptr %62, align 8, !tbaa !9
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = getelementptr inbounds double, ptr %64, i64 2
  %66 = load double, ptr %65, align 8, !tbaa !9
  %67 = fneg double %63
  %68 = call double @llvm.fmuladd.f64(double %67, double %66, double %60)
  %69 = load ptr, ptr %6, align 8, !tbaa !5
  %70 = getelementptr inbounds double, ptr %69, i64 1
  store double %68, ptr %70, align 8, !tbaa !9
  %71 = load ptr, ptr %4, align 8, !tbaa !5
  %72 = getelementptr inbounds double, ptr %71, i64 0
  %73 = load double, ptr %72, align 8, !tbaa !9
  %74 = load ptr, ptr %5, align 8, !tbaa !5
  %75 = getelementptr inbounds double, ptr %74, i64 2
  %76 = load double, ptr %75, align 8, !tbaa !9
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  %78 = getelementptr inbounds double, ptr %77, i64 1
  %79 = load double, ptr %78, align 8, !tbaa !9
  %80 = load ptr, ptr %5, align 8, !tbaa !5
  %81 = getelementptr inbounds double, ptr %80, i64 3
  %82 = load double, ptr %81, align 8, !tbaa !9
  %83 = fmul double %79, %82
  %84 = fneg double %83
  %85 = call double @llvm.fmuladd.f64(double %73, double %76, double %84)
  %86 = load ptr, ptr %4, align 8, !tbaa !5
  %87 = getelementptr inbounds double, ptr %86, i64 2
  %88 = load double, ptr %87, align 8, !tbaa !9
  %89 = load ptr, ptr %5, align 8, !tbaa !5
  %90 = getelementptr inbounds double, ptr %89, i64 0
  %91 = load double, ptr %90, align 8, !tbaa !9
  %92 = call double @llvm.fmuladd.f64(double %88, double %91, double %85)
  %93 = load ptr, ptr %4, align 8, !tbaa !5
  %94 = getelementptr inbounds double, ptr %93, i64 3
  %95 = load double, ptr %94, align 8, !tbaa !9
  %96 = load ptr, ptr %5, align 8, !tbaa !5
  %97 = getelementptr inbounds double, ptr %96, i64 1
  %98 = load double, ptr %97, align 8, !tbaa !9
  %99 = call double @llvm.fmuladd.f64(double %95, double %98, double %92)
  %100 = load ptr, ptr %6, align 8, !tbaa !5
  %101 = getelementptr inbounds double, ptr %100, i64 2
  store double %99, ptr %101, align 8, !tbaa !9
  %102 = load ptr, ptr %4, align 8, !tbaa !5
  %103 = getelementptr inbounds double, ptr %102, i64 0
  %104 = load double, ptr %103, align 8, !tbaa !9
  %105 = load ptr, ptr %5, align 8, !tbaa !5
  %106 = getelementptr inbounds double, ptr %105, i64 3
  %107 = load double, ptr %106, align 8, !tbaa !9
  %108 = load ptr, ptr %4, align 8, !tbaa !5
  %109 = getelementptr inbounds double, ptr %108, i64 1
  %110 = load double, ptr %109, align 8, !tbaa !9
  %111 = load ptr, ptr %5, align 8, !tbaa !5
  %112 = getelementptr inbounds double, ptr %111, i64 2
  %113 = load double, ptr %112, align 8, !tbaa !9
  %114 = fmul double %110, %113
  %115 = call double @llvm.fmuladd.f64(double %104, double %107, double %114)
  %116 = load ptr, ptr %4, align 8, !tbaa !5
  %117 = getelementptr inbounds double, ptr %116, i64 2
  %118 = load double, ptr %117, align 8, !tbaa !9
  %119 = load ptr, ptr %5, align 8, !tbaa !5
  %120 = getelementptr inbounds double, ptr %119, i64 1
  %121 = load double, ptr %120, align 8, !tbaa !9
  %122 = fneg double %118
  %123 = call double @llvm.fmuladd.f64(double %122, double %121, double %115)
  %124 = load ptr, ptr %4, align 8, !tbaa !5
  %125 = getelementptr inbounds double, ptr %124, i64 3
  %126 = load double, ptr %125, align 8, !tbaa !9
  %127 = load ptr, ptr %5, align 8, !tbaa !5
  %128 = getelementptr inbounds double, ptr %127, i64 0
  %129 = load double, ptr %128, align 8, !tbaa !9
  %130 = call double @llvm.fmuladd.f64(double %126, double %129, double %123)
  %131 = load ptr, ptr %6, align 8, !tbaa !5
  %132 = getelementptr inbounds double, ptr %131, i64 3
  store double %130, ptr %132, align 8, !tbaa !9
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress 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" }

!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++ 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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @_ZN3ptm8quat_rotEPdS0_S0_(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #1 {
  %4 = load double, ptr %0, align 8, !tbaa !5
  %5 = load double, ptr %1, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  %7 = load double, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %1, i64 8
  %9 = load double, ptr %8, align 8, !tbaa !5
  %10 = fneg double %7
  %11 = fmul double %9, %10
  %12 = tail call double @llvm.fmuladd.f64(double %4, double %5, double %11)
  %13 = getelementptr inbounds i8, ptr %0, i64 16
  %14 = load double, ptr %13, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %1, i64 16
  %16 = load double, ptr %15, align 8, !tbaa !5
  %17 = fneg double %14
  %18 = tail call double @llvm.fmuladd.f64(double %17, double %16, double %12)
  %19 = getelementptr inbounds i8, ptr %0, i64 24
  %20 = load double, ptr %19, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %1, i64 24
  %22 = load double, ptr %21, align 8, !tbaa !5
  %23 = fneg double %20
  %24 = tail call double @llvm.fmuladd.f64(double %23, double %22, double %18)
  store double %24, ptr %2, align 8, !tbaa !5
  %25 = load double, ptr %0, align 8, !tbaa !5
  %26 = load double, ptr %8, align 8, !tbaa !5
  %27 = load double, ptr %6, align 8, !tbaa !5
  %28 = load double, ptr %1, align 8, !tbaa !5
  %29 = fmul double %27, %28
  %30 = tail call double @llvm.fmuladd.f64(double %25, double %26, double %29)
  %31 = load double, ptr %13, align 8, !tbaa !5
  %32 = load double, ptr %21, align 8, !tbaa !5
  %33 = tail call double @llvm.fmuladd.f64(double %31, double %32, double %30)
  %34 = load double, ptr %19, align 8, !tbaa !5
  %35 = load double, ptr %15, align 8, !tbaa !5
  %36 = fneg double %34
  %37 = tail call double @llvm.fmuladd.f64(double %36, double %35, double %33)
  %38 = getelementptr inbounds i8, ptr %2, i64 8
  store double %37, ptr %38, align 8, !tbaa !5
  %39 = load double, ptr %0, align 8, !tbaa !5
  %40 = load double, ptr %15, align 8, !tbaa !5
  %41 = load double, ptr %6, align 8, !tbaa !5
  %42 = load double, ptr %21, align 8, !tbaa !5
  %43 = fneg double %41
  %44 = fmul double %42, %43
  %45 = tail call double @llvm.fmuladd.f64(double %39, double %40, double %44)
  %46 = load double, ptr %13, align 8, !tbaa !5
  %47 = load double, ptr %1, align 8, !tbaa !5
  %48 = tail call double @llvm.fmuladd.f64(double %46, double %47, double %45)
  %49 = load double, ptr %19, align 8, !tbaa !5
  %50 = load double, ptr %8, align 8, !tbaa !5
  %51 = tail call double @llvm.fmuladd.f64(double %49, double %50, double %48)
  %52 = getelementptr inbounds i8, ptr %2, i64 16
  store double %51, ptr %52, align 8, !tbaa !5
  %53 = load double, ptr %0, align 8, !tbaa !5
  %54 = load double, ptr %21, align 8, !tbaa !5
  %55 = load double, ptr %6, align 8, !tbaa !5
  %56 = load double, ptr %15, align 8, !tbaa !5
  %57 = fmul double %55, %56
  %58 = tail call double @llvm.fmuladd.f64(double %53, double %54, double %57)
  %59 = load double, ptr %13, align 8, !tbaa !5
  %60 = load double, ptr %8, align 8, !tbaa !5
  %61 = fneg double %59
  %62 = tail call double @llvm.fmuladd.f64(double %61, double %60, double %58)
  %63 = load double, ptr %19, align 8, !tbaa !5
  %64 = load double, ptr %1, align 8, !tbaa !5
  %65 = tail call double @llvm.fmuladd.f64(double %63, double %64, double %62)
  %66 = getelementptr inbounds i8, ptr %2, i64 24
  store double %65, ptr %66, align 8, !tbaa !5
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(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" }

!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++ TBAA"}


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