; LLVM IR from Syrocco/Graphical-EDMD :: quartic (solveP3)

; 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: nounwind uwtable
define dso_local i32 @solveP3(ptr noundef %0, double noundef %1, double noundef %2, double noundef %3) #0 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  %17 = alloca double, align 8
  %18 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store double %1, ptr %7, align 8, !tbaa !9
  store double %2, ptr %8, align 8, !tbaa !9
  store double %3, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %19 = load double, ptr %7, align 8, !tbaa !9
  %20 = load double, ptr %7, align 8, !tbaa !9
  %21 = fmul double %19, %20
  store double %21, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %22 = load double, ptr %10, align 8, !tbaa !9
  %23 = load double, ptr %8, align 8, !tbaa !9
  %24 = call double @llvm.fmuladd.f64(double -3.000000e+00, double %23, double %22)
  %25 = fdiv double %24, 9.000000e+00
  store double %25, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %26 = load double, ptr %7, align 8, !tbaa !9
  %27 = load double, ptr %10, align 8, !tbaa !9
  %28 = load double, ptr %8, align 8, !tbaa !9
  %29 = fmul double 9.000000e+00, %28
  %30 = fneg double %29
  %31 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %27, double %30)
  %32 = load double, ptr %9, align 8, !tbaa !9
  %33 = fmul double 2.700000e+01, %32
  %34 = call double @llvm.fmuladd.f64(double %26, double %31, double %33)
  %35 = fdiv double %34, 5.400000e+01
  store double %35, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %36 = load double, ptr %12, align 8, !tbaa !9
  %37 = load double, ptr %12, align 8, !tbaa !9
  %38 = fmul double %36, %37
  store double %38, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %39 = load double, ptr %11, align 8, !tbaa !9
  %40 = load double, ptr %11, align 8, !tbaa !9
  %41 = fmul double %39, %40
  %42 = load double, ptr %11, align 8, !tbaa !9
  %43 = fmul double %41, %42
  store double %43, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %44 = load double, ptr %13, align 8, !tbaa !9
  %45 = load double, ptr %14, align 8, !tbaa !9
  %46 = fcmp olt double %44, %45
  br i1 %46, label %47, label %96

47:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  %48 = load double, ptr %12, align 8, !tbaa !9
  %49 = load double, ptr %14, align 8, !tbaa !9
  %50 = call double @sqrt(double noundef %49) #4
  %51 = fdiv double %48, %50
  store double %51, ptr %17, align 8, !tbaa !9
  %52 = load double, ptr %17, align 8, !tbaa !9
  %53 = fcmp olt double %52, -1.000000e+00
  br i1 %53, label %54, label %55

54:                                               ; preds = %47
  store double -1.000000e+00, ptr %17, align 8, !tbaa !9
  br label %55

55:                                               ; preds = %54, %47
  %56 = load double, ptr %17, align 8, !tbaa !9
  %57 = fcmp ogt double %56, 1.000000e+00
  br i1 %57, label %58, label %59

58:                                               ; preds = %55
  store double 1.000000e+00, ptr %17, align 8, !tbaa !9
  br label %59

59:                                               ; preds = %58, %55
  %60 = load double, ptr %17, align 8, !tbaa !9
  %61 = call double @acos(double noundef %60) #4
  store double %61, ptr %17, align 8, !tbaa !9
  %62 = load double, ptr %7, align 8, !tbaa !9
  %63 = fdiv double %62, 3.000000e+00
  store double %63, ptr %7, align 8, !tbaa !9
  %64 = load double, ptr %11, align 8, !tbaa !9
  %65 = call double @sqrt(double noundef %64) #4
  %66 = fmul double -2.000000e+00, %65
  store double %66, ptr %11, align 8, !tbaa !9
  %67 = load double, ptr %11, align 8, !tbaa !9
  %68 = load double, ptr %17, align 8, !tbaa !9
  %69 = fdiv double %68, 3.000000e+00
  %70 = call double @cos(double noundef %69) #4
  %71 = load double, ptr %7, align 8, !tbaa !9
  %72 = fneg double %71
  %73 = call double @llvm.fmuladd.f64(double %67, double %70, double %72)
  %74 = load ptr, ptr %6, align 8, !tbaa !5
  %75 = getelementptr inbounds double, ptr %74, i64 0
  store double %73, ptr %75, align 8, !tbaa !9
  %76 = load double, ptr %11, align 8, !tbaa !9
  %77 = load double, ptr %17, align 8, !tbaa !9
  %78 = fadd double %77, 0x401921FB54442D18
  %79 = fdiv double %78, 3.000000e+00
  %80 = call double @cos(double noundef %79) #4
  %81 = load double, ptr %7, align 8, !tbaa !9
  %82 = fneg double %81
  %83 = call double @llvm.fmuladd.f64(double %76, double %80, double %82)
  %84 = load ptr, ptr %6, align 8, !tbaa !5
  %85 = getelementptr inbounds double, ptr %84, i64 1
  store double %83, ptr %85, align 8, !tbaa !9
  %86 = load double, ptr %11, align 8, !tbaa !9
  %87 = load double, ptr %17, align 8, !tbaa !9
  %88 = fsub double %87, 0x401921FB54442D18
  %89 = fdiv double %88, 3.000000e+00
  %90 = call double @cos(double noundef %89) #4
  %91 = load double, ptr %7, align 8, !tbaa !9
  %92 = fneg double %91
  %93 = call double @llvm.fmuladd.f64(double %86, double %90, double %92)
  %94 = load ptr, ptr %6, align 8, !tbaa !5
  %95 = getelementptr inbounds double, ptr %94, i64 2
  store double %93, ptr %95, align 8, !tbaa !9
  store i32 3, ptr %5, align 4
  store i32 1, ptr %18, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  br label %158

96:                                               ; preds = %4
  %97 = load double, ptr %12, align 8, !tbaa !9
  %98 = call double @llvm.fabs.f64(double %97)
  %99 = load double, ptr %13, align 8, !tbaa !9
  %100 = load double, ptr %14, align 8, !tbaa !9
  %101 = fsub double %99, %100
  %102 = call double @sqrt(double noundef %101) #4
  %103 = fadd double %98, %102
  %104 = call double @pow(double noundef %103, double noundef 0x3FD5555555555555) #4
  %105 = fneg double %104
  store double %105, ptr %15, align 8, !tbaa !9
  %106 = load double, ptr %12, align 8, !tbaa !9
  %107 = fcmp olt double %106, 0.000000e+00
  br i1 %107, label %108, label %111

108:                                              ; preds = %96
  %109 = load double, ptr %15, align 8, !tbaa !9
  %110 = fneg double %109
  store double %110, ptr %15, align 8, !tbaa !9
  br label %111

111:                                              ; preds = %108, %96
  %112 = load double, ptr %15, align 8, !tbaa !9
  %113 = fcmp oeq double 0.000000e+00, %112
  br i1 %113, label %114, label %115

114:                                              ; preds = %111
  br label %119

115:                                              ; preds = %111
  %116 = load double, ptr %11, align 8, !tbaa !9
  %117 = load double, ptr %15, align 8, !tbaa !9
  %118 = fdiv double %116, %117
  br label %119

119:                                              ; preds = %115, %114
  %120 = phi double [ 0.000000e+00, %114 ], [ %118, %115 ]
  store double %120, ptr %16, align 8, !tbaa !9
  %121 = load double, ptr %7, align 8, !tbaa !9
  %122 = fdiv double %121, 3.000000e+00
  store double %122, ptr %7, align 8, !tbaa !9
  %123 = load double, ptr %15, align 8, !tbaa !9
  %124 = load double, ptr %16, align 8, !tbaa !9
  %125 = fadd double %123, %124
  %126 = load double, ptr %7, align 8, !tbaa !9
  %127 = fsub double %125, %126
  %128 = load ptr, ptr %6, align 8, !tbaa !5
  %129 = getelementptr inbounds double, ptr %128, i64 0
  store double %127, ptr %129, align 8, !tbaa !9
  %130 = load double, ptr %15, align 8, !tbaa !9
  %131 = load double, ptr %16, align 8, !tbaa !9
  %132 = fadd double %130, %131
  %133 = load double, ptr %7, align 8, !tbaa !9
  %134 = fneg double %133
  %135 = call double @llvm.fmuladd.f64(double -5.000000e-01, double %132, double %134)
  %136 = load ptr, ptr %6, align 8, !tbaa !5
  %137 = getelementptr inbounds double, ptr %136, i64 1
  store double %135, ptr %137, align 8, !tbaa !9
  %138 = call double @sqrt(double noundef 3.000000e+00) #4
  %139 = fmul double 5.000000e-01, %138
  %140 = load double, ptr %15, align 8, !tbaa !9
  %141 = load double, ptr %16, align 8, !tbaa !9
  %142 = fsub double %140, %141
  %143 = fmul double %139, %142
  %144 = load ptr, ptr %6, align 8, !tbaa !5
  %145 = getelementptr inbounds double, ptr %144, i64 2
  store double %143, ptr %145, align 8, !tbaa !9
  %146 = load ptr, ptr %6, align 8, !tbaa !5
  %147 = getelementptr inbounds double, ptr %146, i64 2
  %148 = load double, ptr %147, align 8, !tbaa !9
  %149 = call double @llvm.fabs.f64(double %148)
  %150 = fcmp olt double %149, 0x3D719799812DEA11
  br i1 %150, label %151, label %157

151:                                              ; preds = %119
  %152 = load ptr, ptr %6, align 8, !tbaa !5
  %153 = getelementptr inbounds double, ptr %152, i64 1
  %154 = load double, ptr %153, align 8, !tbaa !9
  %155 = load ptr, ptr %6, align 8, !tbaa !5
  %156 = getelementptr inbounds double, ptr %155, i64 2
  store double %154, ptr %156, align 8, !tbaa !9
  store i32 2, ptr %5, align 4
  store i32 1, ptr %18, align 4
  br label %158

157:                                              ; preds = %119
  store i32 1, ptr %5, align 4
  store i32 1, ptr %18, align 4
  br label %158

158:                                              ; preds = %157, %151, %59
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  %159 = load i32, ptr %5, align 4
  ret i32 %159
}

; 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 double @llvm.fmuladd.f64(double, double, double) #2

; Function Attrs: nounwind
declare double @sqrt(double noundef) #3

; Function Attrs: nounwind
declare double @acos(double noundef) #3

; Function Attrs: nounwind
declare double @cos(double noundef) #3

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

; Function Attrs: nounwind
declare double @pow(double noundef, double noundef) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nounwind "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !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 nounwind willreturn memory(write) uwtable
define dso_local range(i32 1, 4) i32 @solveP3(ptr nocapture noundef writeonly %0, double noundef %1, double noundef %2, double noundef %3) local_unnamed_addr #0 {
  %5 = insertelement <2 x double> poison, double %3, i64 0
  %6 = insertelement <2 x double> %5, double %1, i64 1
  %7 = insertelement <2 x double> %6, double 2.700000e+01, i64 0
  %8 = fmul <2 x double> %6, %7
  %9 = fmul double %2, -9.000000e+00
  %10 = extractelement <2 x double> %8, i64 1
  %11 = tail call double @llvm.fmuladd.f64(double %10, double 2.000000e+00, double %9)
  %12 = insertelement <2 x double> poison, double %1, i64 0
  %13 = insertelement <2 x double> %12, double %2, i64 1
  %14 = insertelement <2 x double> <double poison, double -3.000000e+00>, double %11, i64 0
  %15 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %13, <2 x double> %14, <2 x double> %8)
  %16 = fdiv <2 x double> %15, <double 5.400000e+01, double 9.000000e+00>
  %17 = extractelement <2 x double> %16, i64 1
  %18 = fmul double %17, %17
  %19 = insertelement <2 x double> %16, double %18, i64 1
  %20 = fmul <2 x double> %16, %19
  %21 = extractelement <2 x double> %20, i64 0
  %22 = extractelement <2 x double> %20, i64 1
  %23 = fcmp olt double %21, %22
  br i1 %23, label %24, label %47

24:                                               ; preds = %4
  %25 = tail call double @sqrt(double noundef %22) #4
  %26 = extractelement <2 x double> %16, i64 0
  %27 = fdiv double %26, %25
  %28 = fcmp olt double %27, -1.000000e+00
  %.0 = select i1 %28, double -1.000000e+00, double %27
  %29 = fcmp ogt double %.0, 1.000000e+00
  %.1 = select i1 %29, double 1.000000e+00, double %.0
  %30 = tail call double @acos(double noundef %.1) #4
  %31 = tail call double @sqrt(double noundef %17) #4
  %32 = fmul double %31, -2.000000e+00
  %33 = fdiv double %30, 3.000000e+00
  %34 = tail call double @cos(double noundef %33) #4
  %35 = fdiv double %1, -3.000000e+00
  %36 = tail call double @llvm.fmuladd.f64(double %32, double %34, double %35)
  store double %36, ptr %0, align 8, !tbaa !5
  %37 = fadd double %30, 0x401921FB54442D18
  %38 = fdiv double %37, 3.000000e+00
  %39 = tail call double @cos(double noundef %38) #4
  %40 = tail call double @llvm.fmuladd.f64(double %32, double %39, double %35)
  %41 = getelementptr inbounds i8, ptr %0, i64 8
  store double %40, ptr %41, align 8, !tbaa !5
  %42 = fadd double %30, 0xC01921FB54442D18
  %43 = fdiv double %42, 3.000000e+00
  %44 = tail call double @cos(double noundef %43) #4
  %45 = tail call double @llvm.fmuladd.f64(double %32, double %44, double %35)
  %46 = getelementptr inbounds i8, ptr %0, i64 16
  store double %45, ptr %46, align 8, !tbaa !5
  br label %71

47:                                               ; preds = %4
  %48 = extractelement <2 x double> %16, i64 0
  %49 = tail call double @llvm.fabs.f64(double %48)
  %50 = fsub double %21, %22
  %51 = tail call double @sqrt(double noundef %50) #4
  %52 = fadd double %49, %51
  %53 = tail call double @pow(double noundef %52, double noundef 0x3FD5555555555555) #4
  %54 = fneg double %53
  %55 = fcmp olt double %48, 0.000000e+00
  %.058 = select i1 %55, double %53, double %54
  %56 = fcmp oeq double %53, 0.000000e+00
  %57 = fdiv double %17, %.058
  %58 = select i1 %56, double 0.000000e+00, double %57
  %59 = fdiv double %1, 3.000000e+00
  %60 = fadd double %.058, %58
  %61 = fsub double %60, %59
  store double %61, ptr %0, align 8, !tbaa !5
  %62 = fneg double %59
  %63 = tail call double @llvm.fmuladd.f64(double %60, double -5.000000e-01, double %62)
  %64 = getelementptr inbounds i8, ptr %0, i64 8
  store double %63, ptr %64, align 8, !tbaa !5
  %65 = fsub double %.058, %58
  %66 = fmul double %65, 0x3FEBB67AE8584CAA
  %67 = getelementptr inbounds i8, ptr %0, i64 16
  store double %66, ptr %67, align 8, !tbaa !5
  %68 = tail call double @llvm.fabs.f64(double %66)
  %69 = fcmp olt double %68, 0x3D719799812DEA11
  br i1 %69, label %70, label %71

70:                                               ; preds = %47
  store double %63, ptr %67, align 8, !tbaa !5
  br label %71

71:                                               ; preds = %47, %70, %24
  %.057 = phi i32 [ 3, %24 ], [ 2, %70 ], [ 1, %47 ]
  ret i32 %.057
}

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sqrt(double noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @acos(double noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @cos(double noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @pow(double noundef, double noundef) local_unnamed_addr #2

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #3

attributes #0 = { mustprogress nofree nounwind willreturn memory(write) 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 = { mustprogress nofree nounwind willreturn memory(write) "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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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"}


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