; LLVM IR from Slingshot-Physics/slingshot-community :: common/math/src/quadratic.ll (ZN8edbdmath14quadraticRootsEfff)

; 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.edbdmath::quadraticResult_t" = type { i32, [2 x float] }

; Function Attrs: mustprogress uwtable
define dso_local { i64, float } @_ZN8edbdmath14quadraticRootsEfff(float noundef %0, float noundef %1, float noundef %2) #0 {
  %4 = alloca %"struct.edbdmath::quadraticResult_t", 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 float, align 4
  %11 = alloca { i64, float }, align 8
  store float %0, ptr %5, align 4, !tbaa !5
  store float %1, ptr %6, align 4, !tbaa !5
  store float %2, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %12 = load float, ptr %6, align 4, !tbaa !5
  %13 = load float, ptr %6, align 4, !tbaa !5
  %14 = load float, ptr %5, align 4, !tbaa !5
  %15 = fmul float 4.000000e+00, %14
  %16 = load float, ptr %7, align 4, !tbaa !5
  %17 = fmul float %15, %16
  %18 = fneg float %17
  %19 = call float @llvm.fmuladd.f32(float %12, float %13, float %18)
  store float %19, ptr %8, align 4, !tbaa !5
  %20 = load float, ptr %8, align 4, !tbaa !5
  %21 = fcmp olt float %20, 0.000000e+00
  br i1 %21, label %22, label %24

22:                                               ; preds = %3
  %23 = getelementptr inbounds %"struct.edbdmath::quadraticResult_t", ptr %4, i32 0, i32 0
  store i32 0, ptr %23, align 4, !tbaa !9
  br label %103

24:                                               ; preds = %3
  %25 = load float, ptr %8, align 4, !tbaa !5
  %26 = fcmp oeq float %25, 0.000000e+00
  br i1 %26, label %27, label %44

27:                                               ; preds = %24
  %28 = load float, ptr %6, align 4, !tbaa !5
  %29 = fmul float -1.000000e+00, %28
  %30 = load float, ptr %5, align 4, !tbaa !5
  %31 = fmul float 2.000000e+00, %30
  %32 = fdiv float %29, %31
  %33 = getelementptr inbounds %"struct.edbdmath::quadraticResult_t", ptr %4, i32 0, i32 1
  %34 = getelementptr inbounds [2 x float], ptr %33, i64 0, i64 0
  store float %32, ptr %34, align 4, !tbaa !5
  %35 = getelementptr inbounds %"struct.edbdmath::quadraticResult_t", ptr %4, i32 0, i32 1
  %36 = getelementptr inbounds [2 x float], ptr %35, i64 0, i64 0
  %37 = load float, ptr %36, align 4, !tbaa !5
  %38 = call noundef zeroext i1 @_ZSt5isnanf(float noundef %37)
  br i1 %38, label %39, label %41

39:                                               ; preds = %27
  %40 = getelementptr inbounds %"struct.edbdmath::quadraticResult_t", ptr %4, i32 0, i32 0
  store i32 0, ptr %40, align 4, !tbaa !9
  br label %43

41:                                               ; preds = %27
  %42 = getelementptr inbounds %"struct.edbdmath::quadraticResult_t", ptr %4, i32 0, i32 0
  store i32 1, ptr %42, align 4, !tbaa !9
  br label %43

43:                                               ; preds = %41, %39
  br label %102

44:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %45 = load float, ptr %6, align 4, !tbaa !5
  %46 = load float, ptr %8, align 4, !tbaa !5
  %47 = call noundef float @_ZSt4sqrtf(float noundef %46)
  %48 = call float @llvm.fmuladd.f32(float -1.000000e+00, float %45, float %47)
  %49 = load float, ptr %5, align 4, !tbaa !5
  %50 = fmul float 2.000000e+00, %49
  %51 = fdiv float %48, %50
  store float %51, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %52 = load float, ptr %6, align 4, !tbaa !5
  %53 = load float, ptr %8, align 4, !tbaa !5
  %54 = call noundef float @_ZSt4sqrtf(float noundef %53)
  %55 = fneg float %54
  %56 = call float @llvm.fmuladd.f32(float -1.000000e+00, float %52, float %55)
  %57 = load float, ptr %5, align 4, !tbaa !5
  %58 = fmul float 2.000000e+00, %57
  %59 = fdiv float %56, %58
  store float %59, ptr %10, align 4, !tbaa !5
  %60 = load float, ptr %9, align 4, !tbaa !5
  %61 = call noundef zeroext i1 @_ZSt5isnanf(float noundef %60)
  br i1 %61, label %62, label %67

62:                                               ; preds = %44
  %63 = load float, ptr %10, align 4, !tbaa !5
  %64 = call noundef zeroext i1 @_ZSt5isnanf(float noundef %63)
  br i1 %64, label %65, label %67

65:                                               ; preds = %62
  %66 = getelementptr inbounds %"struct.edbdmath::quadraticResult_t", ptr %4, i32 0, i32 0
  store i32 0, ptr %66, align 4, !tbaa !9
  br label %101

67:                                               ; preds = %62, %44
  %68 = load float, ptr %9, align 4, !tbaa !5
  %69 = call noundef zeroext i1 @_ZSt5isnanf(float noundef %68)
  br i1 %69, label %78, label %70

70:                                               ; preds = %67
  %71 = load float, ptr %10, align 4, !tbaa !5
  %72 = call noundef zeroext i1 @_ZSt5isnanf(float noundef %71)
  br i1 %72, label %73, label %78

73:                                               ; preds = %70
  %74 = load float, ptr %9, align 4, !tbaa !5
  %75 = getelementptr inbounds %"struct.edbdmath::quadraticResult_t", ptr %4, i32 0, i32 1
  %76 = getelementptr inbounds [2 x float], ptr %75, i64 0, i64 0
  store float %74, ptr %76, align 4, !tbaa !5
  %77 = getelementptr inbounds %"struct.edbdmath::quadraticResult_t", ptr %4, i32 0, i32 0
  store i32 1, ptr %77, align 4, !tbaa !9
  br label %100

78:                                               ; preds = %70, %67
  %79 = load float, ptr %9, align 4, !tbaa !5
  %80 = call noundef zeroext i1 @_ZSt5isnanf(float noundef %79)
  br i1 %80, label %81, label %89

81:                                               ; preds = %78
  %82 = load float, ptr %10, align 4, !tbaa !5
  %83 = call noundef zeroext i1 @_ZSt5isnanf(float noundef %82)
  br i1 %83, label %89, label %84

84:                                               ; preds = %81
  %85 = load float, ptr %10, align 4, !tbaa !5
  %86 = getelementptr inbounds %"struct.edbdmath::quadraticResult_t", ptr %4, i32 0, i32 1
  %87 = getelementptr inbounds [2 x float], ptr %86, i64 0, i64 0
  store float %85, ptr %87, align 4, !tbaa !5
  %88 = getelementptr inbounds %"struct.edbdmath::quadraticResult_t", ptr %4, i32 0, i32 0
  store i32 1, ptr %88, align 4, !tbaa !9
  br label %99

89:                                               ; preds = %81, %78
  %90 = getelementptr inbounds %"struct.edbdmath::quadraticResult_t", ptr %4, i32 0, i32 0
  store i32 2, ptr %90, align 4, !tbaa !9
  %91 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIfERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %9, ptr noundef nonnull align 4 dereferenceable(4) %10)
  %92 = load float, ptr %91, align 4, !tbaa !5
  %93 = getelementptr inbounds %"struct.edbdmath::quadraticResult_t", ptr %4, i32 0, i32 1
  %94 = getelementptr inbounds [2 x float], ptr %93, i64 0, i64 0
  store float %92, ptr %94, align 4, !tbaa !5
  %95 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIfERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %9, ptr noundef nonnull align 4 dereferenceable(4) %10)
  %96 = load float, ptr %95, align 4, !tbaa !5
  %97 = getelementptr inbounds %"struct.edbdmath::quadraticResult_t", ptr %4, i32 0, i32 1
  %98 = getelementptr inbounds [2 x float], ptr %97, i64 0, i64 1
  store float %96, ptr %98, align 4, !tbaa !5
  br label %99

99:                                               ; preds = %89, %84
  br label %100

100:                                              ; preds = %99, %73
  br label %101

101:                                              ; preds = %100, %65
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %102

102:                                              ; preds = %101, %43
  br label %103

103:                                              ; preds = %102, %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %11, ptr align 4 %4, i64 12, i1 false)
  %104 = load { i64, float }, ptr %11, align 8
  ret { i64, float } %104
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZSt5isnanf(float noundef) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt4sqrtf(float noundef) #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIfERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIfERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #4

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

attributes #0 = { mustprogress 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 willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #4 = { inlinehint 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 #5 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_ZTSN8edbdmath17quadraticResult_tE", !11, i64 0, !7, i64 4}
!11 = !{!"int", !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 nounwind uwtable
define dso_local { i64, float } @_ZN8edbdmath14quadraticRootsEfff(float noundef %0, float noundef %1, float noundef %2) local_unnamed_addr #0 {
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = fmul float %0, -4.000000e+00
  %7 = fmul float %6, %2
  %8 = tail call float @llvm.fmuladd.f32(float %1, float %1, float %7)
  %9 = fcmp olt float %8, 0.000000e+00
  br i1 %9, label %43, label %10

10:                                               ; preds = %3
  %11 = fcmp oeq float %8, 0.000000e+00
  br i1 %11, label %12, label %17

12:                                               ; preds = %10
  %13 = fneg float %1
  %14 = fmul float %0, 2.000000e+00
  %15 = fdiv float %13, %14
  %16 = tail call noundef zeroext i1 @_ZSt5isnanf(float noundef %15)
  %not. = xor i1 %16, true
  %. = zext i1 %not. to i64
  br label %43

17:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #4
  %18 = tail call noundef float @_ZSt4sqrtf(float noundef %8)
  %19 = tail call float @llvm.fmuladd.f32(float %1, float -1.000000e+00, float %18)
  %20 = fmul float %0, 2.000000e+00
  %21 = fdiv float %19, %20
  store float %21, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #4
  %22 = tail call noundef float @_ZSt4sqrtf(float noundef %8)
  %23 = fneg float %22
  %24 = tail call float @llvm.fmuladd.f32(float %1, float -1.000000e+00, float %23)
  %25 = fdiv float %24, %20
  store float %25, ptr %5, align 4, !tbaa !5
  %26 = tail call noundef zeroext i1 @_ZSt5isnanf(float noundef %21)
  br i1 %26, label %27, label %29

27:                                               ; preds = %17
  %28 = tail call noundef zeroext i1 @_ZSt5isnanf(float noundef %25)
  br i1 %28, label %42, label %29

29:                                               ; preds = %27, %17
  %30 = tail call noundef zeroext i1 @_ZSt5isnanf(float noundef %21)
  br i1 %30, label %33, label %31

31:                                               ; preds = %29
  %32 = tail call noundef zeroext i1 @_ZSt5isnanf(float noundef %25)
  br i1 %32, label %42, label %33

33:                                               ; preds = %31, %29
  %34 = tail call noundef zeroext i1 @_ZSt5isnanf(float noundef %21)
  br i1 %34, label %35, label %37

35:                                               ; preds = %33
  %36 = tail call noundef zeroext i1 @_ZSt5isnanf(float noundef %25)
  br i1 %36, label %37, label %42

37:                                               ; preds = %35, %33
  %38 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIfERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %39 = load float, ptr %38, align 4, !tbaa !5
  %40 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIfERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %41 = load float, ptr %40, align 4, !tbaa !5
  br label %42

42:                                               ; preds = %35, %31, %27, %37
  %.sroa.016.0 = phi i64 [ 2, %37 ], [ 0, %27 ], [ 1, %31 ], [ 1, %35 ]
  %.sroa.8.0 = phi float [ %39, %37 ], [ undef, %27 ], [ %21, %31 ], [ %25, %35 ]
  %.sroa.14.0 = phi float [ %41, %37 ], [ undef, %27 ], [ undef, %31 ], [ undef, %35 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #4
  br label %43

43:                                               ; preds = %12, %3, %42
  %.sroa.016.1 = phi i64 [ %.sroa.016.0, %42 ], [ 0, %3 ], [ %., %12 ]
  %.sroa.8.1 = phi float [ %.sroa.8.0, %42 ], [ undef, %3 ], [ %15, %12 ]
  %.sroa.14.1 = phi float [ %.sroa.14.0, %42 ], [ undef, %3 ], [ undef, %12 ]
  %44 = bitcast float %.sroa.8.1 to i32
  %.sroa.0.sroa.2.0.insert.ext = zext i32 %44 to i64
  %.sroa.0.sroa.2.0.insert.shift = shl nuw i64 %.sroa.0.sroa.2.0.insert.ext, 32
  %.sroa.0.sroa.0.0.insert.insert = or i64 %.sroa.0.sroa.2.0.insert.shift, %.sroa.016.1
  %.fca.0.insert = insertvalue { i64, float } poison, i64 %.sroa.0.sroa.0.0.insert.insert, 0
  %.fca.1.insert = insertvalue { i64, float } %.fca.0.insert, float %.sroa.14.1, 1
  ret { i64, float } %.fca.1.insert
}

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt4sqrtf(float noundef) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIfERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIfERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { inlinehint 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 #4 = { 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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