; LLVM IR from jmbr/libpme6 :: spline.ll (ZNK7spline44diffEd)

; 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 noundef double @_ZNK7spline44diffEd(ptr noundef nonnull align 1 dereferenceable(1) %0, double noundef %1) #1 align 2 {
  %3 = alloca double, align 8
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store double %1, ptr %5, align 8, !tbaa !9
  %6 = load ptr, ptr %4, align 8
  %7 = load double, ptr %5, align 8, !tbaa !9
  %8 = fcmp olt double 0.000000e+00, %7
  br i1 %8, label %9, label %17

9:                                                ; preds = %2
  %10 = load double, ptr %5, align 8, !tbaa !9
  %11 = fcmp olt double %10, 1.000000e+00
  br i1 %11, label %12, label %17

12:                                               ; preds = %9
  %13 = load double, ptr %5, align 8, !tbaa !9
  %14 = fmul double 5.000000e-01, %13
  %15 = load double, ptr %5, align 8, !tbaa !9
  %16 = fmul double %14, %15
  store double %16, ptr %3, align 8
  br label %51

17:                                               ; preds = %9, %2
  %18 = load double, ptr %5, align 8, !tbaa !9
  %19 = fcmp ole double 1.000000e+00, %18
  br i1 %19, label %20, label %28

20:                                               ; preds = %17
  %21 = load double, ptr %5, align 8, !tbaa !9
  %22 = fcmp olt double %21, 2.000000e+00
  br i1 %22, label %23, label %28

23:                                               ; preds = %20
  %24 = load double, ptr %5, align 8, !tbaa !9
  %25 = call double @llvm.fmuladd.f64(double -1.500000e+00, double %24, double 4.000000e+00)
  %26 = load double, ptr %5, align 8, !tbaa !9
  %27 = call double @llvm.fmuladd.f64(double %25, double %26, double -2.000000e+00)
  store double %27, ptr %3, align 8
  br label %51

28:                                               ; preds = %20, %17
  %29 = load double, ptr %5, align 8, !tbaa !9
  %30 = fcmp ole double 2.000000e+00, %29
  br i1 %30, label %31, label %39

31:                                               ; preds = %28
  %32 = load double, ptr %5, align 8, !tbaa !9
  %33 = fcmp olt double %32, 3.000000e+00
  br i1 %33, label %34, label %39

34:                                               ; preds = %31
  %35 = load double, ptr %5, align 8, !tbaa !9
  %36 = call double @llvm.fmuladd.f64(double 1.500000e+00, double %35, double -8.000000e+00)
  %37 = load double, ptr %5, align 8, !tbaa !9
  %38 = call double @llvm.fmuladd.f64(double %36, double %37, double 1.000000e+01)
  store double %38, ptr %3, align 8
  br label %51

39:                                               ; preds = %31, %28
  %40 = load double, ptr %5, align 8, !tbaa !9
  %41 = fcmp ole double 3.000000e+00, %40
  br i1 %41, label %42, label %50

42:                                               ; preds = %39
  %43 = load double, ptr %5, align 8, !tbaa !9
  %44 = fcmp olt double %43, 4.000000e+00
  br i1 %44, label %45, label %50

45:                                               ; preds = %42
  %46 = load double, ptr %5, align 8, !tbaa !9
  %47 = call double @llvm.fmuladd.f64(double -5.000000e-01, double %46, double 4.000000e+00)
  %48 = load double, ptr %5, align 8, !tbaa !9
  %49 = call double @llvm.fmuladd.f64(double %47, double %48, double -8.000000e+00)
  store double %49, ptr %3, align 8
  br label %51

50:                                               ; preds = %42, %39
  store double 0.000000e+00, ptr %3, align 8
  br label %51

51:                                               ; preds = %50, %45, %34, %23, %12
  %52 = load double, ptr %3, align 8
  ret double %52
}

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(none) uwtable
define dso_local noundef double @_ZNK7spline44diffEd(ptr nocapture noundef nonnull readnone align 1 dereferenceable(1) %0, double noundef %1) local_unnamed_addr #1 align 2 {
  %3 = fcmp ogt double %1, 0.000000e+00
  %4 = fcmp olt double %1, 1.000000e+00
  %or.cond = and i1 %3, %4
  br i1 %or.cond, label %5, label %8

5:                                                ; preds = %2
  %6 = fmul double %1, 5.000000e-01
  %7 = fmul double %6, %1
  br label %26

8:                                                ; preds = %2
  %9 = fcmp oge double %1, 1.000000e+00
  %10 = fcmp olt double %1, 2.000000e+00
  %or.cond3 = and i1 %9, %10
  br i1 %or.cond3, label %11, label %14

11:                                               ; preds = %8
  %12 = tail call double @llvm.fmuladd.f64(double %1, double -1.500000e+00, double 4.000000e+00)
  %13 = tail call double @llvm.fmuladd.f64(double %12, double %1, double -2.000000e+00)
  br label %26

14:                                               ; preds = %8
  %15 = fcmp oge double %1, 2.000000e+00
  %16 = fcmp olt double %1, 3.000000e+00
  %or.cond5 = and i1 %15, %16
  br i1 %or.cond5, label %17, label %20

17:                                               ; preds = %14
  %18 = tail call double @llvm.fmuladd.f64(double %1, double 1.500000e+00, double -8.000000e+00)
  %19 = tail call double @llvm.fmuladd.f64(double %18, double %1, double 1.000000e+01)
  br label %26

20:                                               ; preds = %14
  %21 = fcmp oge double %1, 3.000000e+00
  %22 = fcmp olt double %1, 4.000000e+00
  %or.cond7 = and i1 %21, %22
  br i1 %or.cond7, label %23, label %26

23:                                               ; preds = %20
  %24 = tail call double @llvm.fmuladd.f64(double %1, double -5.000000e-01, double 4.000000e+00)
  %25 = tail call double @llvm.fmuladd.f64(double %24, double %1, double -8.000000e+00)
  br label %26

26:                                               ; preds = %20, %23, %17, %11, %5
  %.0 = phi double [ %7, %5 ], [ %13, %11 ], [ %19, %17 ], [ %25, %23 ], [ 0.000000e+00, %20 ]
  ret double %.0
}

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


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