; LLVM IR from kmilo17pet/qlibs :: qffmath (qFFMath_Hermite)

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

%union.anon = type { [2 x i32] }

@s_values = external hidden constant %union.anon, align 4

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

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

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @qFFMath_IsNaN(float noundef) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

; Function Attrs: nounwind uwtable
define dso_local float @qFFMath_Hermite(i64 noundef %0, float noundef %1) #1 {
  %3 = alloca i64, align 8
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca float, align 4
  store i64 %0, ptr %3, align 8, !tbaa !5
  store float %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store float 0.000000e+00, ptr %5, align 4, !tbaa !9
  %13 = load float, ptr %4, align 4, !tbaa !9
  %14 = call zeroext i1 @qFFMath_IsNaN(float noundef %13)
  br i1 %14, label %15, label %17

15:                                               ; preds = %2
  %16 = load float, ptr getelementptr (i8, ptr @s_values, i64 4), align 4, !tbaa !9
  store float %16, ptr %5, align 4, !tbaa !9
  br label %56

17:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store float 1.000000e+00, ptr %6, align 4, !tbaa !9
  %18 = load i64, ptr %3, align 8, !tbaa !5
  %19 = icmp eq i64 0, %18
  br i1 %19, label %20, label %21

20:                                               ; preds = %17
  store float 1.000000e+00, ptr %5, align 4, !tbaa !9
  br label %55

21:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %22 = load float, ptr %4, align 4, !tbaa !9
  %23 = fmul float 2.000000e+00, %22
  store float %23, ptr %7, align 4, !tbaa !9
  %24 = load i64, ptr %3, align 8, !tbaa !5
  %25 = icmp eq i64 1, %24
  br i1 %25, label %26, label %28

26:                                               ; preds = %21
  %27 = load float, ptr %7, align 4, !tbaa !9
  store float %27, ptr %5, align 4, !tbaa !9
  br label %54

28:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store float 1.000000e+00, ptr %9, align 4, !tbaa !9
  %29 = load float, ptr %7, align 4, !tbaa !9
  store float %29, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  store i64 2, ptr %10, align 8, !tbaa !5
  br label %30

30:                                               ; preds = %50, %28
  %31 = load i64, ptr %10, align 8, !tbaa !5
  %32 = load i64, ptr %3, align 8, !tbaa !5
  %33 = icmp ule i64 %31, %32
  br i1 %33, label %35, label %34

34:                                               ; preds = %30
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %53

35:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %36 = load i64, ptr %10, align 8, !tbaa !5
  %37 = sub i64 %36, 1
  store i64 %37, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %38 = load i64, ptr %11, align 8, !tbaa !5
  %39 = uitofp i64 %38 to float
  store float %39, ptr %12, align 4, !tbaa !9
  %40 = load float, ptr %4, align 4, !tbaa !9
  %41 = load float, ptr %8, align 4, !tbaa !9
  %42 = load float, ptr %12, align 4, !tbaa !9
  %43 = load float, ptr %9, align 4, !tbaa !9
  %44 = fmul float %42, %43
  %45 = fneg float %44
  %46 = call float @llvm.fmuladd.f32(float %40, float %41, float %45)
  %47 = fmul float 2.000000e+00, %46
  store float %47, ptr %5, align 4, !tbaa !9
  %48 = load float, ptr %8, align 4, !tbaa !9
  store float %48, ptr %9, align 4, !tbaa !9
  %49 = load float, ptr %5, align 4, !tbaa !9
  store float %49, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  br label %50

50:                                               ; preds = %35
  %51 = load i64, ptr %10, align 8, !tbaa !5
  %52 = add i64 %51, 1
  store i64 %52, ptr %10, align 8, !tbaa !5
  br label %30, !llvm.loop !11

53:                                               ; preds = %34
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %54

54:                                               ; preds = %53, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %55

55:                                               ; preds = %54, %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %56

56:                                               ; preds = %55, %15
  %57 = load float, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret float %57
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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

%union.anon = type { [2 x i32] }

@s_values = external hidden local_unnamed_addr constant %union.anon, align 4

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @qFFMath_IsNaN(float noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local float @qFFMath_Hermite(i64 noundef %0, float noundef %1) local_unnamed_addr #0 {
  %3 = tail call zeroext i1 @qFFMath_IsNaN(float noundef %1)
  br i1 %3, label %4, label %6

4:                                                ; preds = %2
  %5 = load float, ptr getelementptr inbounds (i8, ptr @s_values, i64 4), align 4, !tbaa !5
  br label %.loopexit

6:                                                ; preds = %2
  %7 = icmp eq i64 %0, 0
  br i1 %7, label %.loopexit, label %8

8:                                                ; preds = %6
  %9 = fmul float %1, 2.000000e+00
  %10 = icmp eq i64 %0, 1
  br i1 %10, label %.loopexit, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %8
  %11 = add i64 %0, 1
  %umax = tail call i64 @llvm.umax.i64(i64 %11, i64 3)
  %xtraiter = and i64 %umax, 1
  %12 = icmp ult i64 %11, 4
  br i1 %12, label %.loopexit.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %13 = and i64 %umax, -2
  %14 = add i64 %13, -4
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %.01724 = phi float [ %9, %.lr.ph.preheader.new ], [ %25, %.lr.ph ]
  %.01823 = phi i64 [ 2, %.lr.ph.preheader.new ], [ %26, %.lr.ph ]
  %.01922 = phi float [ 1.000000e+00, %.lr.ph.preheader.new ], [ %20, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.1, %.lr.ph ]
  %15 = add i64 %.01823, -1
  %16 = uitofp i64 %15 to float
  %17 = fneg float %.01922
  %18 = fmul float %17, %16
  %19 = tail call float @llvm.fmuladd.f32(float %1, float %.01724, float %18)
  %20 = fmul float %19, 2.000000e+00
  %21 = uitofp i64 %.01823 to float
  %22 = fneg float %.01724
  %23 = fmul float %22, %21
  %24 = tail call float @llvm.fmuladd.f32(float %1, float %20, float %23)
  %25 = fmul float %24, 2.000000e+00
  %26 = add nuw i64 %.01823, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter, %14
  br i1 %niter.ncmp.1, label %.loopexit.loopexit.unr-lcssa.loopexit, label %.lr.ph, !llvm.loop !9

.loopexit.loopexit.unr-lcssa.loopexit:            ; preds = %.lr.ph
  %27 = or disjoint i64 %.01823, 1
  %28 = uitofp i64 %27 to float
  br label %.loopexit.loopexit.unr-lcssa

.loopexit.loopexit.unr-lcssa:                     ; preds = %.loopexit.loopexit.unr-lcssa.loopexit, %.lr.ph.preheader
  %.lcssa.ph = phi float [ poison, %.lr.ph.preheader ], [ %25, %.loopexit.loopexit.unr-lcssa.loopexit ]
  %.01724.unr = phi float [ %9, %.lr.ph.preheader ], [ %25, %.loopexit.loopexit.unr-lcssa.loopexit ]
  %.01823.unr = phi float [ 1.000000e+00, %.lr.ph.preheader ], [ %28, %.loopexit.loopexit.unr-lcssa.loopexit ]
  %.01922.unr = phi float [ 1.000000e+00, %.lr.ph.preheader ], [ %20, %.loopexit.loopexit.unr-lcssa.loopexit ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.loopexit, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %.loopexit.loopexit.unr-lcssa
  %29 = fneg float %.01922.unr
  %30 = fmul float %.01823.unr, %29
  %31 = tail call float @llvm.fmuladd.f32(float %1, float %.01724.unr, float %30)
  %32 = fmul float %31, 2.000000e+00
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph.epil, %.loopexit.loopexit.unr-lcssa, %6, %8, %4
  %.3 = phi float [ %5, %4 ], [ 1.000000e+00, %6 ], [ %9, %8 ], [ %.lcssa.ph, %.loopexit.loopexit.unr-lcssa ], [ %32, %.lr.ph.epil ]
  ret float %.3
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umax.i64(i64, i64) #2

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) }
attributes #2 = { 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, !6, i64 0}
!6 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass