; LLVM IR from CLASS-SZ/class_sz :: class-sz/tools (r8lib)

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

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [2 x i8], align 1
@.str.143 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.144 = external hidden unnamed_addr constant [30 x i8], align 1

; 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
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #2

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

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

; Function Attrs: nounwind uwtable
declare dso_local double @r8_sign(double noundef) #4

; Function Attrs: nounwind uwtable
define dso_local void @r8poly2_rroot(double noundef %0, double noundef %1, double noundef %2, ptr noundef %3, ptr noundef %4) #4 {
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  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 ptr %3, ptr %9, align 8, !tbaa !9
  store ptr %4, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %13 = load double, ptr %6, align 8, !tbaa !5
  %14 = fcmp oeq double %13, 0.000000e+00
  br i1 %14, label %15, label %22

15:                                               ; preds = %5
  %16 = load ptr, ptr @stderr, align 8, !tbaa !9
  %17 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef @.str) #5
  %18 = load ptr, ptr @stderr, align 8, !tbaa !9
  %19 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef @.str.143) #5
  %20 = load ptr, ptr @stderr, align 8, !tbaa !9
  %21 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %20, ptr noundef @.str.144) #5
  call void @exit(i32 noundef 1) #6
  unreachable

22:                                               ; preds = %5
  %23 = load double, ptr %7, align 8, !tbaa !5
  %24 = load double, ptr %7, align 8, !tbaa !5
  %25 = load double, ptr %6, align 8, !tbaa !5
  %26 = fmul double 4.000000e+00, %25
  %27 = load double, ptr %8, align 8, !tbaa !5
  %28 = fmul double %26, %27
  %29 = fneg double %28
  %30 = call double @llvm.fmuladd.f64(double %23, double %24, double %29)
  store double %30, ptr %11, align 8, !tbaa !5
  %31 = load double, ptr %11, align 8, !tbaa !5
  %32 = fcmp ole double 0.000000e+00, %31
  br i1 %32, label %33, label %50

33:                                               ; preds = %22
  %34 = load double, ptr %7, align 8, !tbaa !5
  %35 = load double, ptr %7, align 8, !tbaa !5
  %36 = call double @r8_sign(double noundef %35)
  %37 = load double, ptr %11, align 8, !tbaa !5
  %38 = call double @sqrt(double noundef %37) #5
  %39 = call double @llvm.fmuladd.f64(double %36, double %38, double %34)
  store double %39, ptr %12, align 8, !tbaa !5
  %40 = load double, ptr %12, align 8, !tbaa !5
  %41 = fmul double -5.000000e-01, %40
  %42 = load double, ptr %6, align 8, !tbaa !5
  %43 = fdiv double %41, %42
  %44 = load ptr, ptr %9, align 8, !tbaa !9
  store double %43, ptr %44, align 8, !tbaa !5
  %45 = load double, ptr %8, align 8, !tbaa !5
  %46 = fmul double -2.000000e+00, %45
  %47 = load double, ptr %12, align 8, !tbaa !5
  %48 = fdiv double %46, %47
  %49 = load ptr, ptr %10, align 8, !tbaa !9
  store double %48, ptr %49, align 8, !tbaa !5
  br label %61

50:                                               ; preds = %22
  %51 = load double, ptr %7, align 8, !tbaa !5
  %52 = fdiv double %51, 2.000000e+00
  %53 = load double, ptr %6, align 8, !tbaa !5
  %54 = fdiv double %52, %53
  %55 = load ptr, ptr %9, align 8, !tbaa !9
  store double %54, ptr %55, align 8, !tbaa !5
  %56 = load double, ptr %7, align 8, !tbaa !5
  %57 = fdiv double %56, 2.000000e+00
  %58 = load double, ptr %6, align 8, !tbaa !5
  %59 = fdiv double %57, %58
  %60 = load ptr, ptr %10, align 8, !tbaa !9
  store double %59, ptr %60, align 8, !tbaa !5
  br label %61

61:                                               ; preds = %50, %33
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { noreturn 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 = { nounwind }
attributes #6 = { noreturn 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"

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [2 x i8], align 1
@.str.143 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.144 = external hidden unnamed_addr constant [30 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #0

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #1

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

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

; Function Attrs: nounwind uwtable
declare dso_local double @r8_sign(double noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
define dso_local void @r8poly2_rroot(double noundef %0, double noundef %1, double noundef %2, ptr nocapture noundef writeonly %3, ptr nocapture noundef writeonly %4) local_unnamed_addr #4 {
  %6 = fcmp oeq double %0, 0.000000e+00
  br i1 %6, label %7, label %14

7:                                                ; preds = %5
  %8 = load ptr, ptr @stderr, align 8, !tbaa !5
  %9 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %8, ptr noundef nonnull @.str) #5
  %10 = load ptr, ptr @stderr, align 8, !tbaa !5
  %11 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %10, ptr noundef nonnull @.str.143) #5
  %12 = load ptr, ptr @stderr, align 8, !tbaa !5
  %13 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.144) #5
  tail call void @exit(i32 noundef 1) #6
  unreachable

14:                                               ; preds = %5
  %15 = fmul double %0, -4.000000e+00
  %16 = fmul double %15, %2
  %17 = tail call double @llvm.fmuladd.f64(double %1, double %1, double %16)
  %18 = fcmp ult double %17, 0.000000e+00
  br i1 %18, label %29, label %19

19:                                               ; preds = %14
  %20 = tail call double @r8_sign(double noundef %1)
  %21 = tail call double @sqrt(double noundef %17) #7
  %22 = tail call double @llvm.fmuladd.f64(double %20, double %21, double %1)
  %23 = insertelement <2 x double> poison, double %22, i64 0
  %24 = insertelement <2 x double> %23, double %2, i64 1
  %25 = fmul <2 x double> %24, <double -5.000000e-01, double -2.000000e+00>
  %26 = insertelement <2 x double> poison, double %0, i64 0
  %27 = insertelement <2 x double> %26, double %22, i64 1
  %28 = fdiv <2 x double> %25, %27
  br label %34

29:                                               ; preds = %14
  %30 = fmul double %1, 5.000000e-01
  %31 = fdiv double %30, %0
  %32 = insertelement <2 x double> poison, double %31, i64 0
  %33 = shufflevector <2 x double> %32, <2 x double> poison, <2 x i32> zeroinitializer
  br label %34

34:                                               ; preds = %29, %19
  %35 = phi <2 x double> [ %33, %29 ], [ %28, %19 ]
  %36 = extractelement <2 x double> %35, i64 0
  store double %36, ptr %3, align 8
  %37 = extractelement <2 x double> %35, i64 1
  store double %37, ptr %4, align 8, !tbaa !9
  ret void
}

attributes #0 = { nofree 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 #1 = { noreturn 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 #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #4 = { 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 = { cold nounwind }
attributes #6 = { noreturn nounwind }
attributes #7 = { 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}


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