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

; 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 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: nounwind uwtable
define dso_local zeroext i1 @qFFMath_InRangeCoerce(ptr noundef %0, float noundef %1, float noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca i8, align 1
  store ptr %0, ptr %4, align 8, !tbaa !5
  store float %1, ptr %5, align 4, !tbaa !9
  store float %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #2
  store i8 0, ptr %7, align 1, !tbaa !11
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = getelementptr inbounds float, ptr %8, i64 0
  %10 = load float, ptr %9, align 4, !tbaa !9
  %11 = call zeroext i1 @qFFMath_IsNaN(float noundef %10)
  br i1 %11, label %12, label %16

12:                                               ; preds = %3
  %13 = load float, ptr %5, align 4, !tbaa !9
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds float, ptr %14, i64 0
  store float %13, ptr %15, align 4, !tbaa !9
  br label %39

16:                                               ; preds = %3
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds float, ptr %17, i64 0
  %19 = load float, ptr %18, align 4, !tbaa !9
  %20 = load float, ptr %5, align 4, !tbaa !9
  %21 = fcmp olt float %19, %20
  br i1 %21, label %22, label %26

22:                                               ; preds = %16
  %23 = load float, ptr %5, align 4, !tbaa !9
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds float, ptr %24, i64 0
  store float %23, ptr %25, align 4, !tbaa !9
  br label %38

26:                                               ; preds = %16
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds float, ptr %27, i64 0
  %29 = load float, ptr %28, align 4, !tbaa !9
  %30 = load float, ptr %6, align 4, !tbaa !9
  %31 = fcmp ogt float %29, %30
  br i1 %31, label %32, label %36

32:                                               ; preds = %26
  %33 = load float, ptr %6, align 4, !tbaa !9
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds float, ptr %34, i64 0
  store float %33, ptr %35, align 4, !tbaa !9
  br label %37

36:                                               ; preds = %26
  store i8 1, ptr %7, align 1, !tbaa !11
  br label %37

37:                                               ; preds = %36, %32
  br label %38

38:                                               ; preds = %37, %22
  br label %39

39:                                               ; preds = %38, %12
  %40 = load i8, ptr %7, align 1, !tbaa !11, !range !13, !noundef !14
  %41 = trunc i8 %40 to i1
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #2
  ret i1 %41
}

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 = { 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 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}


; 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: nounwind uwtable
declare dso_local zeroext i1 @qFFMath_IsNaN(float noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @qFFMath_InRangeCoerce(ptr nocapture noundef %0, float noundef %1, float noundef %2) local_unnamed_addr #0 {
  %4 = load float, ptr %0, align 4, !tbaa !5
  %5 = tail call zeroext i1 @qFFMath_IsNaN(float noundef %4)
  br i1 %5, label %.sink.split, label %6

6:                                                ; preds = %3
  %7 = load float, ptr %0, align 4, !tbaa !5
  %8 = fcmp olt float %7, %1
  br i1 %8, label %.sink.split, label %9

9:                                                ; preds = %6
  %10 = fcmp ogt float %7, %2
  br i1 %10, label %.sink.split, label %11

.sink.split:                                      ; preds = %9, %6, %3
  %.sink = phi float [ %1, %3 ], [ %1, %6 ], [ %2, %9 ]
  store float %.sink, ptr %0, align 4, !tbaa !5
  br label %11

11:                                               ; preds = %.sink.split, %9
  %.0 = phi i1 [ true, %9 ], [ false, %.sink.split ]
  ret i1 %.0
}

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

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


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