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

; 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; Function Attrs: nounwind uwtable
declare dso_local double @r8_max(double noundef, double noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local double @r8_min(double noundef, double noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local double @r8vec_max(i32 noundef, ptr noundef) #2

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

18:                                               ; preds = %4
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %29, %18
  %20 = load i32, ptr %13, align 4, !tbaa !5
  %21 = load i32, ptr %5, align 4, !tbaa !5
  %22 = icmp slt i32 %20, %21
  br i1 %22, label %23, label %32

23:                                               ; preds = %19
  %24 = load double, ptr %8, align 8, !tbaa !11
  %25 = load ptr, ptr %6, align 8, !tbaa !9
  %26 = load i32, ptr %13, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds double, ptr %25, i64 %27
  store double %24, ptr %28, align 8, !tbaa !11
  br label %29

29:                                               ; preds = %23
  %30 = load i32, ptr %13, align 4, !tbaa !5
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %13, align 4, !tbaa !5
  br label %19, !llvm.loop !13

32:                                               ; preds = %19
  store i32 1, ptr %14, align 4
  br label %104

33:                                               ; preds = %4
  %34 = load double, ptr %7, align 8, !tbaa !11
  %35 = load double, ptr %8, align 8, !tbaa !11
  %36 = call double @r8_max(double noundef %34, double noundef %35)
  store double %36, ptr %9, align 8, !tbaa !11
  %37 = load double, ptr %7, align 8, !tbaa !11
  %38 = load double, ptr %8, align 8, !tbaa !11
  %39 = call double @r8_min(double noundef %37, double noundef %38)
  store double %39, ptr %11, align 8, !tbaa !11
  %40 = load i32, ptr %5, align 4, !tbaa !5
  %41 = load ptr, ptr %6, align 8, !tbaa !9
  %42 = call double @r8vec_min(i32 noundef %40, ptr noundef %41)
  store double %42, ptr %12, align 8, !tbaa !11
  %43 = load i32, ptr %5, align 4, !tbaa !5
  %44 = load ptr, ptr %6, align 8, !tbaa !9
  %45 = call double @r8vec_max(i32 noundef %43, ptr noundef %44)
  store double %45, ptr %10, align 8, !tbaa !11
  %46 = load double, ptr %10, align 8, !tbaa !11
  %47 = load double, ptr %12, align 8, !tbaa !11
  %48 = fcmp une double %46, %47
  br i1 %48, label %49, label %85

49:                                               ; preds = %33
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %50

50:                                               ; preds = %81, %49
  %51 = load i32, ptr %13, align 4, !tbaa !5
  %52 = load i32, ptr %5, align 4, !tbaa !5
  %53 = icmp slt i32 %51, %52
  br i1 %53, label %54, label %84

54:                                               ; preds = %50
  %55 = load double, ptr %10, align 8, !tbaa !11
  %56 = load ptr, ptr %6, align 8, !tbaa !9
  %57 = load i32, ptr %13, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds double, ptr %56, i64 %58
  %60 = load double, ptr %59, align 8, !tbaa !11
  %61 = fsub double %55, %60
  %62 = load double, ptr %11, align 8, !tbaa !11
  %63 = load ptr, ptr %6, align 8, !tbaa !9
  %64 = load i32, ptr %13, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds double, ptr %63, i64 %65
  %67 = load double, ptr %66, align 8, !tbaa !11
  %68 = load double, ptr %12, align 8, !tbaa !11
  %69 = fsub double %67, %68
  %70 = load double, ptr %9, align 8, !tbaa !11
  %71 = fmul double %69, %70
  %72 = call double @llvm.fmuladd.f64(double %61, double %62, double %71)
  %73 = load double, ptr %10, align 8, !tbaa !11
  %74 = load double, ptr %12, align 8, !tbaa !11
  %75 = fsub double %73, %74
  %76 = fdiv double %72, %75
  %77 = load ptr, ptr %6, align 8, !tbaa !9
  %78 = load i32, ptr %13, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds double, ptr %77, i64 %79
  store double %76, ptr %80, align 8, !tbaa !11
  br label %81

81:                                               ; preds = %54
  %82 = load i32, ptr %13, align 4, !tbaa !5
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %13, align 4, !tbaa !5
  br label %50, !llvm.loop !15

84:                                               ; preds = %50
  br label %103

85:                                               ; preds = %33
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %86

86:                                               ; preds = %99, %85
  %87 = load i32, ptr %13, align 4, !tbaa !5
  %88 = load i32, ptr %5, align 4, !tbaa !5
  %89 = icmp slt i32 %87, %88
  br i1 %89, label %90, label %102

90:                                               ; preds = %86
  %91 = load double, ptr %9, align 8, !tbaa !11
  %92 = load double, ptr %11, align 8, !tbaa !11
  %93 = fadd double %91, %92
  %94 = fmul double 5.000000e-01, %93
  %95 = load ptr, ptr %6, align 8, !tbaa !9
  %96 = load i32, ptr %13, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds double, ptr %95, i64 %97
  store double %94, ptr %98, align 8, !tbaa !11
  br label %99

99:                                               ; preds = %90
  %100 = load i32, ptr %13, align 4, !tbaa !5
  %101 = add nsw i32 %100, 1
  store i32 %101, ptr %13, align 4, !tbaa !5
  br label %86, !llvm.loop !16

102:                                              ; preds = %86
  br label %103

103:                                              ; preds = %102, %84
  store i32 1, ptr %14, align 4
  br label %104

104:                                              ; preds = %103, %32
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local double @r8vec_min(i32 noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #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 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


; 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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

; Function Attrs: nounwind uwtable
declare dso_local double @r8_max(double noundef, double noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local double @r8_min(double noundef, double noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local double @r8vec_max(i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @r8vec_01_to_ab(i32 noundef %0, ptr noundef %1, double noundef %2, double noundef %3) local_unnamed_addr #1 {
  %5 = fcmp oeq double %2, %3
  br i1 %5, label %.preheader, label %11

.preheader:                                       ; preds = %4
  %6 = icmp sgt i32 %0, 0
  br i1 %6, label %.lr.ph52.preheader, label %.loopexit

.lr.ph52.preheader:                               ; preds = %.preheader
  %wide.trip.count64 = zext nneg i32 %0 to i64
  %min.iters.check93 = icmp ult i32 %0, 4
  br i1 %min.iters.check93, label %.lr.ph52.preheader104, label %vector.ph94

vector.ph94:                                      ; preds = %.lr.ph52.preheader
  %n.vec96 = and i64 %wide.trip.count64, 2147483644
  %broadcast.splatinsert100 = insertelement <2 x double> poison, double %3, i64 0
  %broadcast.splat101 = shufflevector <2 x double> %broadcast.splatinsert100, <2 x double> poison, <2 x i32> zeroinitializer
  br label %vector.body98

vector.body98:                                    ; preds = %vector.body98, %vector.ph94
  %index99 = phi i64 [ 0, %vector.ph94 ], [ %index.next102, %vector.body98 ]
  %7 = getelementptr inbounds double, ptr %1, i64 %index99
  %8 = getelementptr inbounds i8, ptr %7, i64 16
  store <2 x double> %broadcast.splat101, ptr %7, align 8, !tbaa !5
  store <2 x double> %broadcast.splat101, ptr %8, align 8, !tbaa !5
  %index.next102 = add nuw i64 %index99, 4
  %9 = icmp eq i64 %index.next102, %n.vec96
  br i1 %9, label %middle.block91, label %vector.body98, !llvm.loop !9

middle.block91:                                   ; preds = %vector.body98
  %cmp.n103 = icmp eq i64 %n.vec96, %wide.trip.count64
  br i1 %cmp.n103, label %.loopexit, label %.lr.ph52.preheader104

.lr.ph52.preheader104:                            ; preds = %middle.block91, %.lr.ph52.preheader
  %indvars.iv61.ph = phi i64 [ 0, %.lr.ph52.preheader ], [ %n.vec96, %middle.block91 ]
  br label %.lr.ph52

.lr.ph52:                                         ; preds = %.lr.ph52.preheader104, %.lr.ph52
  %indvars.iv61 = phi i64 [ %indvars.iv.next62, %.lr.ph52 ], [ %indvars.iv61.ph, %.lr.ph52.preheader104 ]
  %10 = getelementptr inbounds double, ptr %1, i64 %indvars.iv61
  store double %3, ptr %10, align 8, !tbaa !5
  %indvars.iv.next62 = add nuw nsw i64 %indvars.iv61, 1
  %exitcond65.not = icmp eq i64 %indvars.iv.next62, %wide.trip.count64
  br i1 %exitcond65.not, label %.loopexit, label %.lr.ph52, !llvm.loop !13

11:                                               ; preds = %4
  %12 = tail call double @r8_max(double noundef %2, double noundef %3)
  %13 = tail call double @r8_min(double noundef %2, double noundef %3)
  %14 = tail call double @r8vec_min(i32 noundef %0, ptr noundef %1)
  %15 = tail call double @r8vec_max(i32 noundef %0, ptr noundef %1)
  %16 = fcmp une double %15, %14
  %17 = icmp sgt i32 %0, 0
  br i1 %16, label %.preheader44, label %.preheader46

.preheader46:                                     ; preds = %11
  br i1 %17, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %.preheader46
  %18 = fadd double %12, %13
  %19 = fmul double %18, 5.000000e-01
  %wide.trip.count = zext nneg i32 %0 to i64
  %min.iters.check = icmp ult i32 %0, 4
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

scalar.ph.preheader:                              ; preds = %middle.block, %.lr.ph
  %indvars.iv.ph = phi i64 [ 0, %.lr.ph ], [ %n.vec, %middle.block ]
  br label %scalar.ph

vector.ph:                                        ; preds = %.lr.ph
  %n.vec = and i64 %wide.trip.count, 2147483644
  %broadcast.splatinsert = insertelement <2 x double> poison, double %19, i64 0
  %broadcast.splat = shufflevector <2 x double> %broadcast.splatinsert, <2 x double> poison, <2 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %20 = getelementptr inbounds double, ptr %1, i64 %index
  %21 = getelementptr inbounds i8, ptr %20, i64 16
  store <2 x double> %broadcast.splat, ptr %20, align 8, !tbaa !5
  store <2 x double> %broadcast.splat, ptr %21, align 8, !tbaa !5
  %index.next = add nuw i64 %index, 4
  %22 = icmp eq i64 %index.next, %n.vec
  br i1 %22, label %middle.block, label %vector.body, !llvm.loop !14

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %.loopexit, label %scalar.ph.preheader

.preheader44:                                     ; preds = %11
  br i1 %17, label %.lr.ph50, label %.loopexit

.lr.ph50:                                         ; preds = %.preheader44
  %23 = fsub double %15, %14
  %wide.trip.count59 = zext nneg i32 %0 to i64
  %min.iters.check72 = icmp eq i32 %0, 1
  br i1 %min.iters.check72, label %scalar.ph71.preheader, label %vector.ph73

vector.ph73:                                      ; preds = %.lr.ph50
  %n.vec75 = and i64 %wide.trip.count59, 2147483646
  %broadcast.splatinsert79 = insertelement <2 x double> poison, double %15, i64 0
  %broadcast.splat80 = shufflevector <2 x double> %broadcast.splatinsert79, <2 x double> poison, <2 x i32> zeroinitializer
  %broadcast.splatinsert81 = insertelement <2 x double> poison, double %14, i64 0
  %broadcast.splat82 = shufflevector <2 x double> %broadcast.splatinsert81, <2 x double> poison, <2 x i32> zeroinitializer
  %broadcast.splatinsert83 = insertelement <2 x double> poison, double %12, i64 0
  %broadcast.splat84 = shufflevector <2 x double> %broadcast.splatinsert83, <2 x double> poison, <2 x i32> zeroinitializer
  %broadcast.splatinsert85 = insertelement <2 x double> poison, double %13, i64 0
  %broadcast.splat86 = shufflevector <2 x double> %broadcast.splatinsert85, <2 x double> poison, <2 x i32> zeroinitializer
  %broadcast.splatinsert87 = insertelement <2 x double> poison, double %23, i64 0
  %broadcast.splat88 = shufflevector <2 x double> %broadcast.splatinsert87, <2 x double> poison, <2 x i32> zeroinitializer
  br label %vector.body77

vector.body77:                                    ; preds = %vector.body77, %vector.ph73
  %index78 = phi i64 [ 0, %vector.ph73 ], [ %index.next89, %vector.body77 ]
  %24 = getelementptr inbounds double, ptr %1, i64 %index78
  %wide.load = load <2 x double>, ptr %24, align 8, !tbaa !5
  %25 = fsub <2 x double> %broadcast.splat80, %wide.load
  %26 = fsub <2 x double> %wide.load, %broadcast.splat82
  %27 = fmul <2 x double> %broadcast.splat84, %26
  %28 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %25, <2 x double> %broadcast.splat86, <2 x double> %27)
  %29 = fdiv <2 x double> %28, %broadcast.splat88
  store <2 x double> %29, ptr %24, align 8, !tbaa !5
  %index.next89 = add nuw i64 %index78, 2
  %30 = icmp eq i64 %index.next89, %n.vec75
  br i1 %30, label %middle.block70, label %vector.body77, !llvm.loop !15

middle.block70:                                   ; preds = %vector.body77
  %cmp.n90 = icmp eq i64 %n.vec75, %wide.trip.count59
  br i1 %cmp.n90, label %.loopexit, label %scalar.ph71.preheader

scalar.ph71.preheader:                            ; preds = %middle.block70, %.lr.ph50
  %indvars.iv56.ph = phi i64 [ 0, %.lr.ph50 ], [ %n.vec75, %middle.block70 ]
  br label %scalar.ph71

scalar.ph71:                                      ; preds = %scalar.ph71.preheader, %scalar.ph71
  %indvars.iv56 = phi i64 [ %indvars.iv.next57, %scalar.ph71 ], [ %indvars.iv56.ph, %scalar.ph71.preheader ]
  %31 = getelementptr inbounds double, ptr %1, i64 %indvars.iv56
  %32 = load double, ptr %31, align 8, !tbaa !5
  %33 = fsub double %15, %32
  %34 = fsub double %32, %14
  %35 = fmul double %12, %34
  %36 = tail call double @llvm.fmuladd.f64(double %33, double %13, double %35)
  %37 = fdiv double %36, %23
  store double %37, ptr %31, align 8, !tbaa !5
  %indvars.iv.next57 = add nuw nsw i64 %indvars.iv56, 1
  %exitcond60.not = icmp eq i64 %indvars.iv.next57, %wide.trip.count59
  br i1 %exitcond60.not, label %.loopexit, label %scalar.ph71, !llvm.loop !16

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %scalar.ph ], [ %indvars.iv.ph, %scalar.ph.preheader ]
  %38 = getelementptr inbounds double, ptr %1, i64 %indvars.iv
  store double %19, ptr %38, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.loopexit, label %scalar.ph, !llvm.loop !17

.loopexit:                                        ; preds = %scalar.ph, %scalar.ph71, %.lr.ph52, %middle.block, %middle.block70, %middle.block91, %.preheader46, %.preheader44, %.preheader
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local double @r8vec_min(i32 noundef, ptr noundef) local_unnamed_addr #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>) #2

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

!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 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10, !12, !11}
!14 = distinct !{!14, !10, !11, !12}
!15 = distinct !{!15, !10, !11, !12}
!16 = distinct !{!16, !10, !12, !11}
!17 = distinct !{!17, !10, !12, !11}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass