; 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
define dso_local void @r8poly_shift(double noundef %0, double noundef %1, i32 noundef %2, ptr noundef %3) #2 {
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store double %0, ptr %5, align 8, !tbaa !5
  store double %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 1, ptr %9, align 4, !tbaa !9
  br label %11

11:                                               ; preds = %37, %4
  %12 = load i32, ptr %9, align 4, !tbaa !9
  %13 = load i32, ptr %7, align 4, !tbaa !9
  %14 = icmp sle i32 %12, %13
  br i1 %14, label %15, label %40

15:                                               ; preds = %11
  %16 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %16, ptr %10, align 4, !tbaa !9
  br label %17

17:                                               ; preds = %33, %15
  %18 = load i32, ptr %10, align 4, !tbaa !9
  %19 = load i32, ptr %7, align 4, !tbaa !9
  %20 = icmp sle i32 %18, %19
  br i1 %20, label %21, label %36

21:                                               ; preds = %17
  %22 = load ptr, ptr %8, align 8, !tbaa !11
  %23 = load i32, ptr %10, align 4, !tbaa !9
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds double, ptr %22, i64 %24
  %26 = load double, ptr %25, align 8, !tbaa !5
  %27 = load double, ptr %5, align 8, !tbaa !5
  %28 = fdiv double %26, %27
  %29 = load ptr, ptr %8, align 8, !tbaa !11
  %30 = load i32, ptr %10, align 4, !tbaa !9
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds double, ptr %29, i64 %31
  store double %28, ptr %32, align 8, !tbaa !5
  br label %33

33:                                               ; preds = %21
  %34 = load i32, ptr %10, align 4, !tbaa !9
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %10, align 4, !tbaa !9
  br label %17, !llvm.loop !13

36:                                               ; preds = %17
  br label %37

37:                                               ; preds = %36
  %38 = load i32, ptr %9, align 4, !tbaa !9
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %9, align 4, !tbaa !9
  br label %11, !llvm.loop !15

40:                                               ; preds = %11
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %41

41:                                               ; preds = %76, %40
  %42 = load i32, ptr %9, align 4, !tbaa !9
  %43 = load i32, ptr %7, align 4, !tbaa !9
  %44 = sub nsw i32 %43, 1
  %45 = icmp sle i32 %42, %44
  br i1 %45, label %46, label %79

46:                                               ; preds = %41
  %47 = load i32, ptr %7, align 4, !tbaa !9
  %48 = sub nsw i32 %47, 1
  store i32 %48, ptr %10, align 4, !tbaa !9
  br label %49

49:                                               ; preds = %72, %46
  %50 = load i32, ptr %9, align 4, !tbaa !9
  %51 = load i32, ptr %10, align 4, !tbaa !9
  %52 = icmp sle i32 %50, %51
  br i1 %52, label %53, label %75

53:                                               ; preds = %49
  %54 = load ptr, ptr %8, align 8, !tbaa !11
  %55 = load i32, ptr %10, align 4, !tbaa !9
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds double, ptr %54, i64 %56
  %58 = load double, ptr %57, align 8, !tbaa !5
  %59 = load double, ptr %6, align 8, !tbaa !5
  %60 = load ptr, ptr %8, align 8, !tbaa !11
  %61 = load i32, ptr %10, align 4, !tbaa !9
  %62 = add nsw i32 %61, 1
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds double, ptr %60, i64 %63
  %65 = load double, ptr %64, align 8, !tbaa !5
  %66 = fneg double %59
  %67 = call double @llvm.fmuladd.f64(double %66, double %65, double %58)
  %68 = load ptr, ptr %8, align 8, !tbaa !11
  %69 = load i32, ptr %10, align 4, !tbaa !9
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds double, ptr %68, i64 %70
  store double %67, ptr %71, align 8, !tbaa !5
  br label %72

72:                                               ; preds = %53
  %73 = load i32, ptr %10, align 4, !tbaa !9
  %74 = add nsw i32 %73, -1
  store i32 %74, ptr %10, align 4, !tbaa !9
  br label %49, !llvm.loop !16

75:                                               ; preds = %49
  br label %76

76:                                               ; preds = %75
  %77 = load i32, ptr %9, align 4, !tbaa !9
  %78 = add nsw i32 %77, 1
  store i32 %78, ptr %9, align 4, !tbaa !9
  br label %41, !llvm.loop !17

79:                                               ; preds = %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  ret void
}

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 = !{!"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, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !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: nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local void @r8poly_shift(double noundef %0, double noundef %1, i32 noundef %2, ptr nocapture noundef %3) local_unnamed_addr #1 {
  %.not36 = icmp slt i32 %2, 1
  br i1 %.not36, label %._crit_edge, label %.preheader34.preheader

.preheader34.preheader:                           ; preds = %4
  %5 = add nuw i32 %2, 1
  %wide.trip.count45 = zext i32 %5 to i64
  %6 = zext nneg i32 %2 to i64
  %broadcast.splatinsert = insertelement <2 x double> poison, double %0, i64 0
  %broadcast.splat = shufflevector <2 x double> %broadcast.splatinsert, <2 x double> poison, <2 x i32> zeroinitializer
  br label %.preheader34

.preheader34:                                     ; preds = %.preheader34.preheader, %.loopexit
  %indvar = phi i64 [ 0, %.preheader34.preheader ], [ %indvar.next, %.loopexit ]
  %indvars.iv = phi i64 [ 1, %.preheader34.preheader ], [ %indvars.iv.next, %.loopexit ]
  %7 = sub i64 %6, %indvar
  %min.iters.check = icmp ult i64 %7, 2
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

scalar.ph.preheader:                              ; preds = %middle.block, %.preheader34
  %indvars.iv41.ph = phi i64 [ %indvars.iv, %.preheader34 ], [ %ind.end, %middle.block ]
  br label %scalar.ph

vector.ph:                                        ; preds = %.preheader34
  %n.vec = and i64 %7, -2
  %ind.end = add i64 %indvars.iv, %n.vec
  %8 = getelementptr double, ptr %3, i64 %indvars.iv
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %9 = getelementptr double, ptr %8, i64 %index
  %wide.load = load <2 x double>, ptr %9, align 8, !tbaa !5
  %10 = fdiv <2 x double> %wide.load, %broadcast.splat
  store <2 x double> %10, ptr %9, align 8, !tbaa !5
  %index.next = add nuw i64 %index, 2
  %11 = icmp eq i64 %index.next, %n.vec
  br i1 %11, label %middle.block, label %vector.body, !llvm.loop !9

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

.preheader.lr.ph:                                 ; preds = %.loopexit
  %12 = fneg double %1
  %13 = zext nneg i32 %2 to i64
  %.phi.trans.insert = getelementptr inbounds double, ptr %3, i64 %13
  %xtraiter = and i64 %6, 1
  %14 = icmp eq i32 %2, 1
  br i1 %14, label %._crit_edge.loopexit.unr-lcssa, label %.preheader.lr.ph.new

.preheader.lr.ph.new:                             ; preds = %.preheader.lr.ph
  %unroll_iter = and i64 %6, 2147483646
  br label %.preheader

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv41 = phi i64 [ %indvars.iv.next42, %scalar.ph ], [ %indvars.iv41.ph, %scalar.ph.preheader ]
  %15 = getelementptr inbounds double, ptr %3, i64 %indvars.iv41
  %16 = load double, ptr %15, align 8, !tbaa !5
  %17 = fdiv double %16, %0
  store double %17, ptr %15, align 8, !tbaa !5
  %indvars.iv.next42 = add nuw nsw i64 %indvars.iv41, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next42, %wide.trip.count45
  br i1 %exitcond.not, label %.loopexit, label %scalar.ph, !llvm.loop !13

.loopexit:                                        ; preds = %scalar.ph, %middle.block
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond46.not = icmp eq i64 %indvars.iv.next, %wide.trip.count45
  %indvar.next = add i64 %indvar, 1
  br i1 %exitcond46.not, label %.preheader.lr.ph, label %.preheader34, !llvm.loop !14

.preheader:                                       ; preds = %28, %.preheader.lr.ph.new
  %indvars.iv50 = phi i64 [ 0, %.preheader.lr.ph.new ], [ %indvars.iv.next51.1, %28 ]
  %niter = phi i64 [ 0, %.preheader.lr.ph.new ], [ %niter.next.1, %28 ]
  %.pre = load double, ptr %.phi.trans.insert, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %.preheader, %18
  %19 = phi double [ %.pre, %.preheader ], [ %22, %18 ]
  %indvars.iv47 = phi i64 [ %13, %.preheader ], [ %indvars.iv.next48, %18 ]
  %indvars.iv.next48 = add nsw i64 %indvars.iv47, -1
  %20 = getelementptr inbounds double, ptr %3, i64 %indvars.iv.next48
  %21 = load double, ptr %20, align 8, !tbaa !5
  %22 = tail call double @llvm.fmuladd.f64(double %12, double %19, double %21)
  store double %22, ptr %20, align 8, !tbaa !5
  %.not31.not = icmp slt i64 %indvars.iv50, %indvars.iv.next48
  br i1 %.not31.not, label %18, label %.preheader.1, !llvm.loop !15

.preheader.1:                                     ; preds = %18
  %indvars.iv.next51 = or disjoint i64 %indvars.iv50, 1
  %.pre.1 = load double, ptr %.phi.trans.insert, align 8, !tbaa !5
  br label %23

23:                                               ; preds = %23, %.preheader.1
  %24 = phi double [ %.pre.1, %.preheader.1 ], [ %27, %23 ]
  %indvars.iv47.1 = phi i64 [ %13, %.preheader.1 ], [ %indvars.iv.next48.1, %23 ]
  %indvars.iv.next48.1 = add nsw i64 %indvars.iv47.1, -1
  %25 = getelementptr inbounds double, ptr %3, i64 %indvars.iv.next48.1
  %26 = load double, ptr %25, align 8, !tbaa !5
  %27 = tail call double @llvm.fmuladd.f64(double %12, double %24, double %26)
  store double %27, ptr %25, align 8, !tbaa !5
  %.not31.not.1 = icmp slt i64 %indvars.iv.next51, %indvars.iv.next48.1
  br i1 %.not31.not.1, label %23, label %28, !llvm.loop !15

28:                                               ; preds = %23
  %indvars.iv.next51.1 = add nuw nsw i64 %indvars.iv50, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %.preheader, !llvm.loop !16

._crit_edge.loopexit.unr-lcssa:                   ; preds = %28, %.preheader.lr.ph
  %indvars.iv50.unr = phi i64 [ 0, %.preheader.lr.ph ], [ %indvars.iv.next51.1, %28 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.preheader.epil

.preheader.epil:                                  ; preds = %._crit_edge.loopexit.unr-lcssa
  %.pre.epil = load double, ptr %.phi.trans.insert, align 8, !tbaa !5
  br label %29

29:                                               ; preds = %29, %.preheader.epil
  %30 = phi double [ %.pre.epil, %.preheader.epil ], [ %33, %29 ]
  %indvars.iv47.epil = phi i64 [ %13, %.preheader.epil ], [ %indvars.iv.next48.epil, %29 ]
  %indvars.iv.next48.epil = add nsw i64 %indvars.iv47.epil, -1
  %31 = getelementptr inbounds double, ptr %3, i64 %indvars.iv.next48.epil
  %32 = load double, ptr %31, align 8, !tbaa !5
  %33 = tail call double @llvm.fmuladd.f64(double %12, double %30, double %32)
  store double %33, ptr %31, align 8, !tbaa !5
  %.not31.not.epil = icmp slt i64 %indvars.iv50.unr, %indvars.iv.next48.epil
  br i1 %.not31.not.epil, label %29, label %._crit_edge, !llvm.loop !15

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %29, %4
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nofree norecurse nosync nounwind memory(argmem: readwrite) 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, !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}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass