; LLVM IR from PyCee/NUS_library :: src/math (NUS_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"

%struct.NUS_quaternion = type { double, double, double, double }

; Function Attrs: nounwind uwtable
declare dso_local void @nus_quaternion_build(ptr dead_on_unwind noalias writable sret(%struct.NUS_quaternion) align 8, double noundef, double noundef, double noundef, double noundef) #0

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

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

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

!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, !7, i64 0}
!6 = !{!"NUS_quaternion", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = !{!6, !7, i64 16}
!12 = !{!6, !7, i64 24}


; 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"

%struct.NUS_quaternion = type { double, double, double, double }

; Function Attrs: nounwind uwtable
declare dso_local void @nus_quaternion_build(ptr dead_on_unwind noalias writable sret(%struct.NUS_quaternion) align 8, double noundef, double noundef, double noundef, double noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @nus_quaternion_h_product(ptr dead_on_unwind noalias writable sret(%struct.NUS_quaternion) align 8 %0, ptr nocapture noundef readonly byval(%struct.NUS_quaternion) align 8 %1, ptr nocapture noundef readonly byval(%struct.NUS_quaternion) align 8 %2) local_unnamed_addr #0 {
  %4 = load double, ptr %1, align 8, !tbaa !5
  %5 = load double, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %1, i64 8
  %7 = load double, ptr %6, align 8, !tbaa !10
  %8 = getelementptr inbounds i8, ptr %2, i64 8
  %9 = load double, ptr %8, align 8, !tbaa !10
  %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 %1, i64 16
  %14 = load double, ptr %13, align 8, !tbaa !11
  %15 = getelementptr inbounds i8, ptr %2, i64 16
  %16 = load double, ptr %15, align 8, !tbaa !11
  %17 = fneg double %14
  %18 = tail call double @llvm.fmuladd.f64(double %17, double %16, double %12)
  %19 = getelementptr inbounds i8, ptr %1, i64 24
  %20 = load double, ptr %19, align 8, !tbaa !12
  %21 = getelementptr inbounds i8, ptr %2, i64 24
  %22 = load double, ptr %21, align 8, !tbaa !12
  %23 = fneg double %20
  %24 = tail call double @llvm.fmuladd.f64(double %23, double %22, double %18)
  %25 = fmul double %5, %7
  %26 = tail call double @llvm.fmuladd.f64(double %4, double %9, double %25)
  %27 = tail call double @llvm.fmuladd.f64(double %14, double %22, double %26)
  %28 = tail call double @llvm.fmuladd.f64(double %23, double %16, double %27)
  %29 = fmul double %22, %10
  %30 = tail call double @llvm.fmuladd.f64(double %4, double %16, double %29)
  %31 = tail call double @llvm.fmuladd.f64(double %14, double %5, double %30)
  %32 = tail call double @llvm.fmuladd.f64(double %20, double %9, double %31)
  %33 = fmul double %7, %16
  %34 = tail call double @llvm.fmuladd.f64(double %4, double %22, double %33)
  %35 = tail call double @llvm.fmuladd.f64(double %17, double %9, double %34)
  %36 = tail call double @llvm.fmuladd.f64(double %20, double %5, double %35)
  tail call void @nus_quaternion_build(ptr dead_on_unwind writable sret(%struct.NUS_quaternion) align 8 %0, double noundef %24, double noundef %28, double noundef %32, double noundef %36)
  ret void
}

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

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

!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, !7, i64 0}
!6 = !{!"NUS_quaternion", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = !{!6, !7, i64 16}
!12 = !{!6, !7, i64 24}


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