; LLVM IR from corentinartaud/graphics :: ThirdParty/FreeImage-3170/Source/OpenEXR/Imath/ImathFun.ll (ZN9Imath_2_25preddEd)

; 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.2 = type { double }

; 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: mustprogress nounwind uwtable
define dso_local noundef double @_ZN9Imath_2_25preddEd(double noundef %0) #1 {
  %2 = alloca double, align 8
  %3 = alloca %union.anon.2, align 8
  store double %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  %4 = load double, ptr %2, align 8, !tbaa !5
  store double %4, ptr %3, align 8, !tbaa !9
  %5 = load i64, ptr %3, align 8, !tbaa !9
  %6 = and i64 %5, 9218868437227405312
  %7 = icmp eq i64 %6, 9218868437227405312
  br i1 %7, label %8, label %9

8:                                                ; preds = %1
  br label %27

9:                                                ; preds = %1
  %10 = load i64, ptr %3, align 8, !tbaa !9
  %11 = icmp eq i64 %10, 0
  br i1 %11, label %15, label %12

12:                                               ; preds = %9
  %13 = load i64, ptr %3, align 8, !tbaa !9
  %14 = icmp eq i64 %13, -9223372036854775808
  br i1 %14, label %15, label %16

15:                                               ; preds = %12, %9
  store i64 -9223372036854775807, ptr %3, align 8, !tbaa !9
  br label %26

16:                                               ; preds = %12
  %17 = load double, ptr %3, align 8, !tbaa !9
  %18 = fcmp ogt double %17, 0.000000e+00
  br i1 %18, label %19, label %22

19:                                               ; preds = %16
  %20 = load i64, ptr %3, align 8, !tbaa !9
  %21 = add i64 %20, -1
  store i64 %21, ptr %3, align 8, !tbaa !9
  br label %25

22:                                               ; preds = %16
  %23 = load i64, ptr %3, align 8, !tbaa !9
  %24 = add i64 %23, 1
  store i64 %24, ptr %3, align 8, !tbaa !9
  br label %25

25:                                               ; preds = %22, %19
  br label %26

26:                                               ; preds = %25, %15
  br label %27

27:                                               ; preds = %26, %8
  %28 = load double, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  ret double %28
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !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 nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local noundef double @_ZN9Imath_2_25preddEd(double noundef %0) local_unnamed_addr #0 {
  %2 = bitcast double %0 to i64
  %3 = and i64 %2, 9218868437227405312
  %4 = icmp eq i64 %3, 9218868437227405312
  br i1 %4, label %14, label %5

5:                                                ; preds = %1
  %or.cond = fcmp oeq double %0, 0.000000e+00
  br i1 %or.cond, label %14, label %6

6:                                                ; preds = %5
  %7 = fcmp ogt double %0, 0.000000e+00
  br i1 %7, label %8, label %11

8:                                                ; preds = %6
  %9 = add nsw i64 %2, -1
  %10 = bitcast i64 %9 to double
  br label %14

11:                                               ; preds = %6
  %12 = add nsw i64 %2, 1
  %13 = bitcast i64 %12 to double
  br label %14

14:                                               ; preds = %5, %11, %8, %1
  %.sroa.0.0 = phi double [ %0, %1 ], [ %10, %8 ], [ %13, %11 ], [ -4.940660e-324, %5 ]
  ret double %.sroa.0.0
}

attributes #0 = { 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: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass