; LLVM IR from robinrodricks/InspiritImage :: Inspirit.Assurf/clib (utils)

; 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
define dso_local i32 @solve_deg2(double noundef %0, double noundef %1, double noundef %2, ptr noundef %3, ptr noundef %4) #1 {
  %6 = alloca i32, align 4
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca double, align 8
  %13 = alloca i32, align 4
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  store double %0, ptr %7, align 8, !tbaa !5
  store double %1, ptr %8, align 8, !tbaa !5
  store double %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !9
  store ptr %4, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %16 = load double, ptr %8, align 8, !tbaa !5
  %17 = load double, ptr %8, align 8, !tbaa !5
  %18 = load double, ptr %7, align 8, !tbaa !5
  %19 = fmul double 4.000000e+00, %18
  %20 = load double, ptr %9, align 8, !tbaa !5
  %21 = fmul double %19, %20
  %22 = fneg double %21
  %23 = call double @llvm.fmuladd.f64(double %16, double %17, double %22)
  store double %23, ptr %12, align 8, !tbaa !5
  %24 = load double, ptr %12, align 8, !tbaa !5
  %25 = fcmp olt double %24, 0.000000e+00
  br i1 %25, label %26, label %27

26:                                               ; preds = %5
  store i32 0, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %59

27:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %28 = load double, ptr %7, align 8, !tbaa !5
  %29 = fdiv double 5.000000e-01, %28
  store double %29, ptr %14, align 8, !tbaa !5
  %30 = load double, ptr %12, align 8, !tbaa !5
  %31 = fcmp oeq double %30, 0.000000e+00
  br i1 %31, label %32, label %41

32:                                               ; preds = %27
  %33 = load double, ptr %8, align 8, !tbaa !5
  %34 = fneg double %33
  %35 = load double, ptr %14, align 8, !tbaa !5
  %36 = fmul double %34, %35
  %37 = load ptr, ptr %10, align 8, !tbaa !9
  store double %36, ptr %37, align 8, !tbaa !5
  %38 = load ptr, ptr %10, align 8, !tbaa !9
  %39 = load double, ptr %38, align 8, !tbaa !5
  %40 = load ptr, ptr %11, align 8, !tbaa !9
  store double %39, ptr %40, align 8, !tbaa !5
  store i32 1, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %58

41:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %42 = load double, ptr %12, align 8, !tbaa !5
  %43 = call double @fast_sqrt(double noundef %42)
  store double %43, ptr %15, align 8, !tbaa !5
  %44 = load double, ptr %8, align 8, !tbaa !5
  %45 = fneg double %44
  %46 = load double, ptr %15, align 8, !tbaa !5
  %47 = fadd double %45, %46
  %48 = load double, ptr %14, align 8, !tbaa !5
  %49 = fmul double %47, %48
  %50 = load ptr, ptr %10, align 8, !tbaa !9
  store double %49, ptr %50, align 8, !tbaa !5
  %51 = load double, ptr %8, align 8, !tbaa !5
  %52 = fneg double %51
  %53 = load double, ptr %15, align 8, !tbaa !5
  %54 = fsub double %52, %53
  %55 = load double, ptr %14, align 8, !tbaa !5
  %56 = fmul double %54, %55
  %57 = load ptr, ptr %11, align 8, !tbaa !9
  store double %56, ptr %57, align 8, !tbaa !5
  store i32 2, ptr %6, align 4
  store i32 1, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  br label %58

58:                                               ; preds = %41, %32
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  br label %59

59:                                               ; preds = %58, %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  %60 = load i32, ptr %6, align 4
  ret i32 %60
}

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

; Function Attrs: inlinehint nounwind uwtable
declare double @fast_sqrt(double noundef) #3

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 = { inlinehint 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !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: nounwind uwtable
define dso_local range(i32 0, 3) i32 @solve_deg2(double noundef %0, double noundef %1, double noundef %2, ptr nocapture noundef writeonly %3, ptr nocapture noundef writeonly %4) local_unnamed_addr #0 {
  %6 = fmul double %0, -4.000000e+00
  %7 = fmul double %6, %2
  %8 = tail call double @llvm.fmuladd.f64(double %1, double %1, double %7)
  %9 = fcmp olt double %8, 0.000000e+00
  br i1 %9, label %24, label %10

10:                                               ; preds = %5
  %11 = fdiv double 5.000000e-01, %0
  %12 = fcmp oeq double %8, 0.000000e+00
  br i1 %12, label %13, label %16

13:                                               ; preds = %10
  %14 = fneg double %1
  %15 = fmul double %11, %14
  br label %23

16:                                               ; preds = %10
  %17 = tail call double @fast_sqrt(double noundef %8)
  %18 = fneg double %1
  %19 = fsub double %17, %1
  %20 = fmul double %11, %19
  %21 = fsub double %18, %17
  %22 = fmul double %11, %21
  br label %23

23:                                               ; preds = %16, %13
  %.sink = phi double [ %15, %13 ], [ %20, %16 ]
  %storemerge = phi double [ %15, %13 ], [ %22, %16 ]
  %.0 = phi i32 [ 1, %13 ], [ 2, %16 ]
  store double %.sink, ptr %3, align 8
  store double %storemerge, ptr %4, align 8, !tbaa !5
  br label %24

24:                                               ; preds = %5, %23
  %.1 = phi i32 [ %.0, %23 ], [ 0, %5 ]
  ret i32 %.1
}

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

; Function Attrs: inlinehint nounwind uwtable
declare double @fast_sqrt(double noundef) local_unnamed_addr #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 = { inlinehint 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


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