; LLVM IR from CactiLab/Sherloc-Cortex-M-CFVD :: Sherloc_runtime/evaluation/src/cubic (libcubic)

; 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 void @SolveCubic(double noundef %0, double noundef %1, double noundef %2, double noundef %3, ptr noundef %4, ptr noundef %5) #0 {
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca x86_fp80, align 16
  %14 = alloca x86_fp80, align 16
  %15 = alloca x86_fp80, align 16
  %16 = alloca x86_fp80, align 16
  %17 = alloca x86_fp80, align 16
  %18 = alloca double, align 8
  %19 = 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 double %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !9
  store ptr %5, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #4
  %20 = load double, ptr %8, align 8, !tbaa !5
  %21 = load double, ptr %7, align 8, !tbaa !5
  %22 = fdiv double %20, %21
  %23 = fpext double %22 to x86_fp80
  store x86_fp80 %23, ptr %13, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 16, ptr %14) #4
  %24 = load double, ptr %9, align 8, !tbaa !5
  %25 = load double, ptr %7, align 8, !tbaa !5
  %26 = fdiv double %24, %25
  %27 = fpext double %26 to x86_fp80
  store x86_fp80 %27, ptr %14, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 16, ptr %15) #4
  %28 = load double, ptr %10, align 8, !tbaa !5
  %29 = load double, ptr %7, align 8, !tbaa !5
  %30 = fdiv double %28, %29
  %31 = fpext double %30 to x86_fp80
  store x86_fp80 %31, ptr %15, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 16, ptr %16) #4
  %32 = load x86_fp80, ptr %13, align 16, !tbaa !11
  %33 = load x86_fp80, ptr %13, align 16, !tbaa !11
  %34 = load x86_fp80, ptr %14, align 16, !tbaa !11
  %35 = fmul x86_fp80 0xK4000C000000000000000, %34
  %36 = fneg x86_fp80 %35
  %37 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %32, x86_fp80 %33, x86_fp80 %36)
  %38 = fdiv x86_fp80 %37, 0xK40029000000000000000
  store x86_fp80 %38, ptr %16, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 16, ptr %17) #4
  %39 = load x86_fp80, ptr %13, align 16, !tbaa !11
  %40 = fmul x86_fp80 0xK40008000000000000000, %39
  %41 = load x86_fp80, ptr %13, align 16, !tbaa !11
  %42 = fmul x86_fp80 %40, %41
  %43 = load x86_fp80, ptr %13, align 16, !tbaa !11
  %44 = load x86_fp80, ptr %13, align 16, !tbaa !11
  %45 = fmul x86_fp80 0xK40029000000000000000, %44
  %46 = load x86_fp80, ptr %14, align 16, !tbaa !11
  %47 = fmul x86_fp80 %45, %46
  %48 = fneg x86_fp80 %47
  %49 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %42, x86_fp80 %43, x86_fp80 %48)
  %50 = load x86_fp80, ptr %15, align 16, !tbaa !11
  %51 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 0xK4003D800000000000000, x86_fp80 %50, x86_fp80 %49)
  %52 = fdiv x86_fp80 %51, 0xK4004D800000000000000
  store x86_fp80 %52, ptr %17, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #4
  %53 = load x86_fp80, ptr %17, align 16, !tbaa !11
  %54 = load x86_fp80, ptr %17, align 16, !tbaa !11
  %55 = load x86_fp80, ptr %16, align 16, !tbaa !11
  %56 = load x86_fp80, ptr %16, align 16, !tbaa !11
  %57 = fmul x86_fp80 %55, %56
  %58 = load x86_fp80, ptr %16, align 16, !tbaa !11
  %59 = fmul x86_fp80 %57, %58
  %60 = fneg x86_fp80 %59
  %61 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %53, x86_fp80 %54, x86_fp80 %60)
  %62 = fptrunc x86_fp80 %61 to double
  store double %62, ptr %18, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #4
  %63 = load double, ptr %18, align 8, !tbaa !5
  %64 = fcmp ole double %63, 0.000000e+00
  br i1 %64, label %65, label %130

65:                                               ; preds = %6
  %66 = load ptr, ptr %11, align 8, !tbaa !9
  store i32 3, ptr %66, align 4, !tbaa !13
  %67 = load x86_fp80, ptr %17, align 16, !tbaa !11
  %68 = load x86_fp80, ptr %16, align 16, !tbaa !11
  %69 = load x86_fp80, ptr %16, align 16, !tbaa !11
  %70 = fmul x86_fp80 %68, %69
  %71 = load x86_fp80, ptr %16, align 16, !tbaa !11
  %72 = fmul x86_fp80 %70, %71
  %73 = fptrunc x86_fp80 %72 to double
  %74 = call double @sqrt(double noundef %73) #4
  %75 = fpext double %74 to x86_fp80
  %76 = fdiv x86_fp80 %67, %75
  %77 = fptrunc x86_fp80 %76 to double
  %78 = call double @acos(double noundef %77) #4
  store double %78, ptr %19, align 8, !tbaa !5
  %79 = load x86_fp80, ptr %16, align 16, !tbaa !11
  %80 = fptrunc x86_fp80 %79 to double
  %81 = call double @sqrt(double noundef %80) #4
  %82 = fmul double -2.000000e+00, %81
  %83 = load double, ptr %19, align 8, !tbaa !5
  %84 = fdiv double %83, 3.000000e+00
  %85 = call double @cos(double noundef %84) #4
  %86 = fmul double %82, %85
  %87 = fpext double %86 to x86_fp80
  %88 = load x86_fp80, ptr %13, align 16, !tbaa !11
  %89 = fdiv x86_fp80 %88, 0xK4000C000000000000000
  %90 = fsub x86_fp80 %87, %89
  %91 = fptrunc x86_fp80 %90 to double
  %92 = load ptr, ptr %12, align 8, !tbaa !9
  %93 = getelementptr inbounds double, ptr %92, i64 0
  store double %91, ptr %93, align 8, !tbaa !5
  %94 = load x86_fp80, ptr %16, align 16, !tbaa !11
  %95 = fptrunc x86_fp80 %94 to double
  %96 = call double @sqrt(double noundef %95) #4
  %97 = fmul double -2.000000e+00, %96
  %98 = load double, ptr %19, align 8, !tbaa !5
  %99 = call double @atan(double noundef 1.000000e+00) #4
  %100 = fmul double 4.000000e+00, %99
  %101 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %100, double %98)
  %102 = fdiv double %101, 3.000000e+00
  %103 = call double @cos(double noundef %102) #4
  %104 = fmul double %97, %103
  %105 = fpext double %104 to x86_fp80
  %106 = load x86_fp80, ptr %13, align 16, !tbaa !11
  %107 = fdiv x86_fp80 %106, 0xK4000C000000000000000
  %108 = fsub x86_fp80 %105, %107
  %109 = fptrunc x86_fp80 %108 to double
  %110 = load ptr, ptr %12, align 8, !tbaa !9
  %111 = getelementptr inbounds double, ptr %110, i64 1
  store double %109, ptr %111, align 8, !tbaa !5
  %112 = load x86_fp80, ptr %16, align 16, !tbaa !11
  %113 = fptrunc x86_fp80 %112 to double
  %114 = call double @sqrt(double noundef %113) #4
  %115 = fmul double -2.000000e+00, %114
  %116 = load double, ptr %19, align 8, !tbaa !5
  %117 = call double @atan(double noundef 1.000000e+00) #4
  %118 = fmul double 4.000000e+00, %117
  %119 = call double @llvm.fmuladd.f64(double 4.000000e+00, double %118, double %116)
  %120 = fdiv double %119, 3.000000e+00
  %121 = call double @cos(double noundef %120) #4
  %122 = fmul double %115, %121
  %123 = fpext double %122 to x86_fp80
  %124 = load x86_fp80, ptr %13, align 16, !tbaa !11
  %125 = fdiv x86_fp80 %124, 0xK4000C000000000000000
  %126 = fsub x86_fp80 %123, %125
  %127 = fptrunc x86_fp80 %126 to double
  %128 = load ptr, ptr %12, align 8, !tbaa !9
  %129 = getelementptr inbounds double, ptr %128, i64 2
  store double %127, ptr %129, align 8, !tbaa !5
  br label %170

130:                                              ; preds = %6
  %131 = load ptr, ptr %11, align 8, !tbaa !9
  store i32 1, ptr %131, align 4, !tbaa !13
  %132 = load double, ptr %18, align 8, !tbaa !5
  %133 = call double @sqrt(double noundef %132) #4
  %134 = load x86_fp80, ptr %17, align 16, !tbaa !11
  %135 = fptrunc x86_fp80 %134 to double
  %136 = call double @llvm.fabs.f64(double %135)
  %137 = fadd double %133, %136
  %138 = call double @pow(double noundef %137, double noundef 0x3FD5555555555555) #4
  %139 = load ptr, ptr %12, align 8, !tbaa !9
  %140 = getelementptr inbounds double, ptr %139, i64 0
  store double %138, ptr %140, align 8, !tbaa !5
  %141 = load x86_fp80, ptr %16, align 16, !tbaa !11
  %142 = load ptr, ptr %12, align 8, !tbaa !9
  %143 = getelementptr inbounds double, ptr %142, i64 0
  %144 = load double, ptr %143, align 8, !tbaa !5
  %145 = fpext double %144 to x86_fp80
  %146 = fdiv x86_fp80 %141, %145
  %147 = load ptr, ptr %12, align 8, !tbaa !9
  %148 = getelementptr inbounds double, ptr %147, i64 0
  %149 = load double, ptr %148, align 8, !tbaa !5
  %150 = fpext double %149 to x86_fp80
  %151 = fadd x86_fp80 %150, %146
  %152 = fptrunc x86_fp80 %151 to double
  store double %152, ptr %148, align 8, !tbaa !5
  %153 = load x86_fp80, ptr %17, align 16, !tbaa !11
  %154 = fcmp olt x86_fp80 %153, 0xK00000000000000000000
  %155 = zext i1 %154 to i64
  %156 = select i1 %154, i32 1, i32 -1
  %157 = sitofp i32 %156 to double
  %158 = load ptr, ptr %12, align 8, !tbaa !9
  %159 = getelementptr inbounds double, ptr %158, i64 0
  %160 = load double, ptr %159, align 8, !tbaa !5
  %161 = fmul double %160, %157
  store double %161, ptr %159, align 8, !tbaa !5
  %162 = load x86_fp80, ptr %13, align 16, !tbaa !11
  %163 = fdiv x86_fp80 %162, 0xK4000C000000000000000
  %164 = load ptr, ptr %12, align 8, !tbaa !9
  %165 = getelementptr inbounds double, ptr %164, i64 0
  %166 = load double, ptr %165, align 8, !tbaa !5
  %167 = fpext double %166 to x86_fp80
  %168 = fsub x86_fp80 %167, %163
  %169 = fptrunc x86_fp80 %168 to double
  store double %169, ptr %165, align 8, !tbaa !5
  br label %170

170:                                              ; preds = %130, %65
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #4
  ret void
}

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

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

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

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

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

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

; 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

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

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 = !{!"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}
!11 = !{!12, !12, i64 0}
!12 = !{!"long double", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"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 nofree nounwind willreturn memory(write) uwtable
define dso_local void @SolveCubic(double noundef %0, double noundef %1, double noundef %2, double noundef %3, ptr nocapture noundef writeonly %4, ptr nocapture noundef writeonly %5) local_unnamed_addr #0 {
  %7 = fdiv double %1, %0
  %8 = fpext double %7 to x86_fp80
  %9 = fdiv double %2, %0
  %10 = fpext double %9 to x86_fp80
  %11 = fdiv double %3, %0
  %12 = fpext double %11 to x86_fp80
  %13 = fmul x86_fp80 %10, 0xKC000C000000000000000
  %14 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %8, x86_fp80 %8, x86_fp80 %13)
  %15 = fdiv x86_fp80 %14, 0xK40029000000000000000
  %16 = fmul x86_fp80 %8, 0xK40008000000000000000
  %17 = fmul x86_fp80 %16, %8
  %18 = fmul x86_fp80 %8, 0xKC0029000000000000000
  %19 = fmul x86_fp80 %18, %10
  %20 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %17, x86_fp80 %8, x86_fp80 %19)
  %21 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %12, x86_fp80 0xK4003D800000000000000, x86_fp80 %20)
  %22 = fdiv x86_fp80 %21, 0xK4004D800000000000000
  %23 = fmul x86_fp80 %15, %15
  %24 = fmul x86_fp80 %15, %23
  %25 = fneg x86_fp80 %24
  %26 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %22, x86_fp80 %22, x86_fp80 %25)
  %27 = fptrunc x86_fp80 %26 to double
  %28 = fcmp ugt double %27, 0.000000e+00
  br i1 %28, label %66, label %29

29:                                               ; preds = %6
  store i32 3, ptr %4, align 4, !tbaa !5
  %30 = fptrunc x86_fp80 %24 to double
  %31 = tail call double @sqrt(double noundef %30) #3
  %32 = fpext double %31 to x86_fp80
  %33 = fdiv x86_fp80 %22, %32
  %34 = fptrunc x86_fp80 %33 to double
  %35 = tail call double @acos(double noundef %34) #3
  %36 = fptrunc x86_fp80 %15 to double
  %37 = tail call double @sqrt(double noundef %36) #3
  %38 = fmul double %37, -2.000000e+00
  %39 = fdiv double %35, 3.000000e+00
  %40 = tail call double @cos(double noundef %39) #3
  %41 = fmul double %38, %40
  %42 = fpext double %41 to x86_fp80
  %43 = fdiv x86_fp80 %8, 0xK4000C000000000000000
  %44 = fsub x86_fp80 %42, %43
  %45 = fptrunc x86_fp80 %44 to double
  store double %45, ptr %5, align 8, !tbaa !9
  %46 = tail call double @sqrt(double noundef %36) #3
  %47 = fmul double %46, -2.000000e+00
  %48 = fadd double %35, 0x401921FB54442D18
  %49 = fdiv double %48, 3.000000e+00
  %50 = tail call double @cos(double noundef %49) #3
  %51 = fmul double %47, %50
  %52 = fpext double %51 to x86_fp80
  %53 = fsub x86_fp80 %52, %43
  %54 = fptrunc x86_fp80 %53 to double
  %55 = getelementptr inbounds i8, ptr %5, i64 8
  store double %54, ptr %55, align 8, !tbaa !9
  %56 = tail call double @sqrt(double noundef %36) #3
  %57 = fmul double %56, -2.000000e+00
  %58 = fadd double %35, 0x402921FB54442D18
  %59 = fdiv double %58, 3.000000e+00
  %60 = tail call double @cos(double noundef %59) #3
  %61 = fmul double %57, %60
  %62 = fpext double %61 to x86_fp80
  %63 = fsub x86_fp80 %62, %43
  %64 = fptrunc x86_fp80 %63 to double
  %65 = getelementptr inbounds i8, ptr %5, i64 16
  store double %64, ptr %65, align 8, !tbaa !9
  br label %83

66:                                               ; preds = %6
  store i32 1, ptr %4, align 4, !tbaa !5
  %67 = tail call double @sqrt(double noundef %27) #3
  %68 = fptrunc x86_fp80 %22 to double
  %69 = tail call double @llvm.fabs.f64(double %68)
  %70 = fadd double %69, %67
  %71 = tail call double @pow(double noundef %70, double noundef 0x3FD5555555555555) #3
  %72 = fpext double %71 to x86_fp80
  %73 = fdiv x86_fp80 %15, %72
  %74 = fadd x86_fp80 %73, %72
  %75 = fptrunc x86_fp80 %74 to double
  %76 = fcmp olt x86_fp80 %22, 0xK00000000000000000000
  %77 = fneg double %75
  %78 = select i1 %76, double %75, double %77
  %79 = fdiv x86_fp80 %8, 0xK4000C000000000000000
  %80 = fpext double %78 to x86_fp80
  %81 = fsub x86_fp80 %80, %79
  %82 = fptrunc x86_fp80 %81 to double
  store double %82, ptr %5, align 8, !tbaa !9
  br label %83

83:                                               ; preds = %66, %29
  ret void
}

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

; 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 @sqrt(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

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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}


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