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

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

@retval = external dso_local global [4 x %struct.DComplex], align 16

; 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
declare dso_local void @solve_quartic(double noundef, double noundef, double noundef, double noundef) #1

; Function Attrs: nounwind uwtable
define dso_local double @smallestRoot(double noundef %0, double noundef %1, double noundef %2, double noundef %3, double noundef %4) #1 {
  %6 = alloca double, 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 i32, align 4
  store double %0, ptr %6, align 8, !tbaa !5
  store double %1, ptr %7, align 8, !tbaa !5
  store double %2, ptr %8, align 8, !tbaa !5
  store double %3, ptr %9, align 8, !tbaa !5
  store double %4, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #2
  %17 = load double, ptr %7, align 8, !tbaa !5
  %18 = load double, ptr %6, align 8, !tbaa !5
  %19 = fdiv double %17, %18
  store double %19, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #2
  %20 = load double, ptr %8, align 8, !tbaa !5
  %21 = load double, ptr %6, align 8, !tbaa !5
  %22 = fdiv double %20, %21
  store double %22, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #2
  %23 = load double, ptr %9, align 8, !tbaa !5
  %24 = load double, ptr %6, align 8, !tbaa !5
  %25 = fdiv double %23, %24
  store double %25, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #2
  %26 = load double, ptr %10, align 8, !tbaa !5
  %27 = load double, ptr %6, align 8, !tbaa !5
  %28 = fdiv double %26, %27
  store double %28, ptr %14, align 8, !tbaa !5
  %29 = load double, ptr %11, align 8, !tbaa !5
  %30 = load double, ptr %12, align 8, !tbaa !5
  %31 = load double, ptr %13, align 8, !tbaa !5
  %32 = load double, ptr %14, align 8, !tbaa !5
  call void @solve_quartic(double noundef %29, double noundef %30, double noundef %31, double noundef %32)
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #2
  store double 1.000000e+10, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #2
  store i32 0, ptr %16, align 4, !tbaa !9
  br label %33

33:                                               ; preds = %66, %5
  %34 = load i32, ptr %16, align 4, !tbaa !9
  %35 = icmp slt i32 %34, 4
  br i1 %35, label %37, label %36

36:                                               ; preds = %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #2
  br label %69

37:                                               ; preds = %33
  %38 = load i32, ptr %16, align 4, !tbaa !9
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [4 x %struct.DComplex], ptr @retval, i64 0, i64 %39
  %41 = getelementptr inbounds %struct.DComplex, ptr %40, i32 0, i32 1
  %42 = load double, ptr %41, align 8, !tbaa !11
  %43 = fcmp oeq double %42, 0.000000e+00
  br i1 %43, label %44, label %65

44:                                               ; preds = %37
  %45 = load i32, ptr %16, align 4, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [4 x %struct.DComplex], ptr @retval, i64 0, i64 %46
  %48 = getelementptr inbounds %struct.DComplex, ptr %47, i32 0, i32 0
  %49 = load double, ptr %48, align 16, !tbaa !13
  %50 = fcmp ogt double %49, 1.000000e-09
  br i1 %50, label %51, label %65

51:                                               ; preds = %44
  %52 = load i32, ptr %16, align 4, !tbaa !9
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [4 x %struct.DComplex], ptr @retval, i64 0, i64 %53
  %55 = getelementptr inbounds %struct.DComplex, ptr %54, i32 0, i32 0
  %56 = load double, ptr %55, align 16, !tbaa !13
  %57 = load double, ptr %15, align 8, !tbaa !5
  %58 = fcmp olt double %56, %57
  br i1 %58, label %59, label %65

59:                                               ; preds = %51
  %60 = load i32, ptr %16, align 4, !tbaa !9
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [4 x %struct.DComplex], ptr @retval, i64 0, i64 %61
  %63 = getelementptr inbounds %struct.DComplex, ptr %62, i32 0, i32 0
  %64 = load double, ptr %63, align 16, !tbaa !13
  store double %64, ptr %15, align 8, !tbaa !5
  br label %65

65:                                               ; preds = %59, %51, %44, %37
  br label %66

66:                                               ; preds = %65
  %67 = load i32, ptr %16, align 4, !tbaa !9
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %16, align 4, !tbaa !9
  br label %33, !llvm.loop !14

69:                                               ; preds = %36
  %70 = load double, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  ret double %70
}

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 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"DComplex", !6, i64 0, !6, i64 8}
!13 = !{!12, !6, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


; 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"

%struct.DComplex = type { double, double }

@retval = external dso_local local_unnamed_addr global [4 x %struct.DComplex], align 16

; Function Attrs: nounwind uwtable
declare dso_local void @solve_quartic(double noundef, double noundef, double noundef, double noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local double @smallestRoot(double noundef %0, double noundef %1, double noundef %2, double noundef %3, double noundef %4) local_unnamed_addr #0 {
  %6 = fdiv double %1, %0
  %7 = fdiv double %2, %0
  %8 = fdiv double %3, %0
  %9 = fdiv double %4, %0
  tail call void @solve_quartic(double noundef %6, double noundef %7, double noundef %8, double noundef %9)
  %10 = load double, ptr getelementptr inbounds (i8, ptr @retval, i64 8), align 8, !tbaa !5
  %11 = fcmp oeq double %10, 0.000000e+00
  br i1 %11, label %12, label %17

12:                                               ; preds = %5
  %13 = load double, ptr @retval, align 16, !tbaa !10
  %14 = fcmp ogt double %13, 1.000000e-09
  %15 = fcmp olt double %13, 1.000000e+10
  %or.cond = and i1 %14, %15
  br i1 %or.cond, label %16, label %17

16:                                               ; preds = %12
  br label %17

17:                                               ; preds = %5, %12, %16
  %.1 = phi double [ %13, %16 ], [ 1.000000e+10, %12 ], [ 1.000000e+10, %5 ]
  %18 = load double, ptr getelementptr inbounds (i8, ptr @retval, i64 24), align 8, !tbaa !5
  %19 = fcmp oeq double %18, 0.000000e+00
  br i1 %19, label %20, label %25

20:                                               ; preds = %17
  %21 = load double, ptr getelementptr inbounds (i8, ptr @retval, i64 16), align 16, !tbaa !10
  %22 = fcmp ogt double %21, 1.000000e-09
  %23 = fcmp olt double %21, %.1
  %or.cond.1 = and i1 %22, %23
  br i1 %or.cond.1, label %24, label %25

24:                                               ; preds = %20
  br label %25

25:                                               ; preds = %24, %20, %17
  %.1.1 = phi double [ %21, %24 ], [ %.1, %20 ], [ %.1, %17 ]
  %26 = load double, ptr getelementptr inbounds (i8, ptr @retval, i64 40), align 8, !tbaa !5
  %27 = fcmp oeq double %26, 0.000000e+00
  br i1 %27, label %28, label %33

28:                                               ; preds = %25
  %29 = load double, ptr getelementptr inbounds (i8, ptr @retval, i64 32), align 16, !tbaa !10
  %30 = fcmp ogt double %29, 1.000000e-09
  %31 = fcmp olt double %29, %.1.1
  %or.cond.2 = and i1 %30, %31
  br i1 %or.cond.2, label %32, label %33

32:                                               ; preds = %28
  br label %33

33:                                               ; preds = %32, %28, %25
  %.1.2 = phi double [ %29, %32 ], [ %.1.1, %28 ], [ %.1.1, %25 ]
  %34 = load double, ptr getelementptr inbounds (i8, ptr @retval, i64 56), align 8, !tbaa !5
  %35 = fcmp oeq double %34, 0.000000e+00
  br i1 %35, label %36, label %41

36:                                               ; preds = %33
  %37 = load double, ptr getelementptr inbounds (i8, ptr @retval, i64 48), align 16, !tbaa !10
  %38 = fcmp ogt double %37, 1.000000e-09
  %39 = fcmp olt double %37, %.1.2
  %or.cond.3 = and i1 %38, %39
  br i1 %or.cond.3, label %40, label %41

40:                                               ; preds = %36
  br label %41

41:                                               ; preds = %40, %36, %33
  %.1.3 = phi double [ %37, %40 ], [ %.1.2, %36 ], [ %.1.2, %33 ]
  ret double %.1.3
}

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" }

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,SROAPass,SimplifyCFGPass,TailCallElimPass