; 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
declare double @sqrt(double noundef) #2

; Function Attrs: nounwind uwtable
define dso_local double @r8vec_std(i32 noundef %0, ptr noundef %1) #3 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  store i32 %0, ptr %3, align 4, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %8 = load i32, ptr %3, align 4, !tbaa !5
  %9 = icmp slt i32 %8, 2
  br i1 %9, label %10, label %11

10:                                               ; preds = %2
  store double 0.000000e+00, ptr %7, align 8, !tbaa !11
  br label %63

11:                                               ; preds = %2
  store double 0.000000e+00, ptr %6, align 8, !tbaa !11
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %24, %11
  %13 = load i32, ptr %5, align 4, !tbaa !5
  %14 = load i32, ptr %3, align 4, !tbaa !5
  %15 = icmp slt i32 %13, %14
  br i1 %15, label %16, label %27

16:                                               ; preds = %12
  %17 = load double, ptr %6, align 8, !tbaa !11
  %18 = load ptr, ptr %4, align 8, !tbaa !9
  %19 = load i32, ptr %5, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds double, ptr %18, i64 %20
  %22 = load double, ptr %21, align 8, !tbaa !11
  %23 = fadd double %17, %22
  store double %23, ptr %6, align 8, !tbaa !11
  br label %24

24:                                               ; preds = %16
  %25 = load i32, ptr %5, align 4, !tbaa !5
  %26 = add nsw i32 %25, 1
  store i32 %26, ptr %5, align 4, !tbaa !5
  br label %12, !llvm.loop !13

27:                                               ; preds = %12
  %28 = load double, ptr %6, align 8, !tbaa !11
  %29 = load i32, ptr %3, align 4, !tbaa !5
  %30 = sitofp i32 %29 to double
  %31 = fdiv double %28, %30
  store double %31, ptr %6, align 8, !tbaa !11
  store double 0.000000e+00, ptr %7, align 8, !tbaa !11
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %32

32:                                               ; preds = %53, %27
  %33 = load i32, ptr %5, align 4, !tbaa !5
  %34 = load i32, ptr %3, align 4, !tbaa !5
  %35 = icmp slt i32 %33, %34
  br i1 %35, label %36, label %56

36:                                               ; preds = %32
  %37 = load double, ptr %7, align 8, !tbaa !11
  %38 = load ptr, ptr %4, align 8, !tbaa !9
  %39 = load i32, ptr %5, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds double, ptr %38, i64 %40
  %42 = load double, ptr %41, align 8, !tbaa !11
  %43 = load double, ptr %6, align 8, !tbaa !11
  %44 = fsub double %42, %43
  %45 = load ptr, ptr %4, align 8, !tbaa !9
  %46 = load i32, ptr %5, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds double, ptr %45, i64 %47
  %49 = load double, ptr %48, align 8, !tbaa !11
  %50 = load double, ptr %6, align 8, !tbaa !11
  %51 = fsub double %49, %50
  %52 = call double @llvm.fmuladd.f64(double %44, double %51, double %37)
  store double %52, ptr %7, align 8, !tbaa !11
  br label %53

53:                                               ; preds = %36
  %54 = load i32, ptr %5, align 4, !tbaa !5
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %5, align 4, !tbaa !5
  br label %32, !llvm.loop !15

56:                                               ; preds = %32
  %57 = load double, ptr %7, align 8, !tbaa !11
  %58 = load i32, ptr %3, align 4, !tbaa !5
  %59 = sub nsw i32 %58, 1
  %60 = sitofp i32 %59 to double
  %61 = fdiv double %57, %60
  %62 = call double @sqrt(double noundef %61) #4
  store double %62, ptr %7, align 8, !tbaa !11
  br label %63

63:                                               ; preds = %56, %10
  %64 = load double, ptr %7, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  ret double %64
}

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


; 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: mustprogress nofree nounwind willreturn memory(write)
declare double @sqrt(double noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind memory(write, argmem: readwrite) uwtable
define dso_local double @r8vec_std(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #2 {
  %3 = icmp slt i32 %0, 2
  br i1 %3, label %59, label %.preheader.preheader

.preheader.preheader:                             ; preds = %2
  %wide.trip.count = zext nneg i32 %0 to i64
  %xtraiter = and i64 %wide.trip.count, 7
  %4 = icmp ult i32 %0, 8
  br i1 %4, label %.lr.ph.preheader.unr-lcssa, label %.preheader.preheader.new

.preheader.preheader.new:                         ; preds = %.preheader.preheader
  %unroll_iter = and i64 %wide.trip.count, 2147483640
  br label %.preheader

.preheader:                                       ; preds = %.preheader, %.preheader.preheader.new
  %indvars.iv = phi i64 [ 0, %.preheader.preheader.new ], [ %indvars.iv.next.7, %.preheader ]
  %.02126 = phi double [ 0.000000e+00, %.preheader.preheader.new ], [ %28, %.preheader ]
  %niter = phi i64 [ 0, %.preheader.preheader.new ], [ %niter.next.7, %.preheader ]
  %5 = getelementptr inbounds double, ptr %1, i64 %indvars.iv
  %6 = load double, ptr %5, align 8, !tbaa !5
  %7 = fadd double %.02126, %6
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %8 = getelementptr inbounds double, ptr %1, i64 %indvars.iv.next
  %9 = load double, ptr %8, align 8, !tbaa !5
  %10 = fadd double %7, %9
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %11 = getelementptr inbounds double, ptr %1, i64 %indvars.iv.next.1
  %12 = load double, ptr %11, align 8, !tbaa !5
  %13 = fadd double %10, %12
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %14 = getelementptr inbounds double, ptr %1, i64 %indvars.iv.next.2
  %15 = load double, ptr %14, align 8, !tbaa !5
  %16 = fadd double %13, %15
  %indvars.iv.next.3 = or disjoint i64 %indvars.iv, 4
  %17 = getelementptr inbounds double, ptr %1, i64 %indvars.iv.next.3
  %18 = load double, ptr %17, align 8, !tbaa !5
  %19 = fadd double %16, %18
  %indvars.iv.next.4 = or disjoint i64 %indvars.iv, 5
  %20 = getelementptr inbounds double, ptr %1, i64 %indvars.iv.next.4
  %21 = load double, ptr %20, align 8, !tbaa !5
  %22 = fadd double %19, %21
  %indvars.iv.next.5 = or disjoint i64 %indvars.iv, 6
  %23 = getelementptr inbounds double, ptr %1, i64 %indvars.iv.next.5
  %24 = load double, ptr %23, align 8, !tbaa !5
  %25 = fadd double %22, %24
  %indvars.iv.next.6 = or disjoint i64 %indvars.iv, 7
  %26 = getelementptr inbounds double, ptr %1, i64 %indvars.iv.next.6
  %27 = load double, ptr %26, align 8, !tbaa !5
  %28 = fadd double %25, %27
  %indvars.iv.next.7 = add nuw nsw i64 %indvars.iv, 8
  %niter.next.7 = add i64 %niter, 8
  %niter.ncmp.7 = icmp eq i64 %niter.next.7, %unroll_iter
  br i1 %niter.ncmp.7, label %.lr.ph.preheader.unr-lcssa, label %.preheader, !llvm.loop !9

.lr.ph.preheader.unr-lcssa:                       ; preds = %.preheader, %.preheader.preheader
  %.lcssa38.ph = phi double [ poison, %.preheader.preheader ], [ %28, %.preheader ]
  %indvars.iv.unr = phi i64 [ 0, %.preheader.preheader ], [ %indvars.iv.next.7, %.preheader ]
  %.02126.unr = phi double [ 0.000000e+00, %.preheader.preheader ], [ %28, %.preheader ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph.preheader, label %.preheader.epil

.preheader.epil:                                  ; preds = %.lr.ph.preheader.unr-lcssa, %.preheader.epil
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.preheader.epil ], [ %indvars.iv.unr, %.lr.ph.preheader.unr-lcssa ]
  %.02126.epil = phi double [ %31, %.preheader.epil ], [ %.02126.unr, %.lr.ph.preheader.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.preheader.epil ], [ 0, %.lr.ph.preheader.unr-lcssa ]
  %29 = getelementptr inbounds double, ptr %1, i64 %indvars.iv.epil
  %30 = load double, ptr %29, align 8, !tbaa !5
  %31 = fadd double %.02126.epil, %30
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.lr.ph.preheader, label %.preheader.epil, !llvm.loop !11

.lr.ph.preheader:                                 ; preds = %.preheader.epil, %.lr.ph.preheader.unr-lcssa
  %.lcssa38 = phi double [ %.lcssa38.ph, %.lr.ph.preheader.unr-lcssa ], [ %31, %.preheader.epil ]
  %32 = uitofp nneg i32 %0 to double
  %33 = fdiv double %.lcssa38, %32
  %xtraiter40 = and i64 %wide.trip.count, 3
  %34 = icmp ult i32 %0, 4
  br i1 %34, label %._crit_edge.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter44 = and i64 %wide.trip.count, 2147483644
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %indvars.iv31 = phi i64 [ 0, %.lr.ph.preheader.new ], [ %indvars.iv.next32.3, %.lr.ph ]
  %.028 = phi double [ 0.000000e+00, %.lr.ph.preheader.new ], [ %50, %.lr.ph ]
  %niter45 = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter45.next.3, %.lr.ph ]
  %35 = getelementptr inbounds double, ptr %1, i64 %indvars.iv31
  %36 = load double, ptr %35, align 8, !tbaa !5
  %37 = fsub double %36, %33
  %38 = tail call double @llvm.fmuladd.f64(double %37, double %37, double %.028)
  %indvars.iv.next32 = or disjoint i64 %indvars.iv31, 1
  %39 = getelementptr inbounds double, ptr %1, i64 %indvars.iv.next32
  %40 = load double, ptr %39, align 8, !tbaa !5
  %41 = fsub double %40, %33
  %42 = tail call double @llvm.fmuladd.f64(double %41, double %41, double %38)
  %indvars.iv.next32.1 = or disjoint i64 %indvars.iv31, 2
  %43 = getelementptr inbounds double, ptr %1, i64 %indvars.iv.next32.1
  %44 = load double, ptr %43, align 8, !tbaa !5
  %45 = fsub double %44, %33
  %46 = tail call double @llvm.fmuladd.f64(double %45, double %45, double %42)
  %indvars.iv.next32.2 = or disjoint i64 %indvars.iv31, 3
  %47 = getelementptr inbounds double, ptr %1, i64 %indvars.iv.next32.2
  %48 = load double, ptr %47, align 8, !tbaa !5
  %49 = fsub double %48, %33
  %50 = tail call double @llvm.fmuladd.f64(double %49, double %49, double %46)
  %indvars.iv.next32.3 = add nuw nsw i64 %indvars.iv31, 4
  %niter45.next.3 = add i64 %niter45, 4
  %niter45.ncmp.3 = icmp eq i64 %niter45.next.3, %unroll_iter44
  br i1 %niter45.ncmp.3, label %._crit_edge.unr-lcssa, label %.lr.ph, !llvm.loop !13

._crit_edge.unr-lcssa:                            ; preds = %.lr.ph, %.lr.ph.preheader
  %.lcssa.ph = phi double [ poison, %.lr.ph.preheader ], [ %50, %.lr.ph ]
  %indvars.iv31.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next32.3, %.lr.ph ]
  %.028.unr = phi double [ 0.000000e+00, %.lr.ph.preheader ], [ %50, %.lr.ph ]
  %lcmp.mod42.not = icmp eq i64 %xtraiter40, 0
  br i1 %lcmp.mod42.not, label %._crit_edge, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.unr-lcssa, %.lr.ph.epil
  %indvars.iv31.epil = phi i64 [ %indvars.iv.next32.epil, %.lr.ph.epil ], [ %indvars.iv31.unr, %._crit_edge.unr-lcssa ]
  %.028.epil = phi double [ %54, %.lr.ph.epil ], [ %.028.unr, %._crit_edge.unr-lcssa ]
  %epil.iter41 = phi i64 [ %epil.iter41.next, %.lr.ph.epil ], [ 0, %._crit_edge.unr-lcssa ]
  %51 = getelementptr inbounds double, ptr %1, i64 %indvars.iv31.epil
  %52 = load double, ptr %51, align 8, !tbaa !5
  %53 = fsub double %52, %33
  %54 = tail call double @llvm.fmuladd.f64(double %53, double %53, double %.028.epil)
  %indvars.iv.next32.epil = add nuw nsw i64 %indvars.iv31.epil, 1
  %epil.iter41.next = add i64 %epil.iter41, 1
  %epil.iter41.cmp.not = icmp eq i64 %epil.iter41.next, %xtraiter40
  br i1 %epil.iter41.cmp.not, label %._crit_edge, label %.lr.ph.epil, !llvm.loop !14

._crit_edge:                                      ; preds = %.lr.ph.epil, %._crit_edge.unr-lcssa
  %.lcssa = phi double [ %.lcssa.ph, %._crit_edge.unr-lcssa ], [ %54, %.lr.ph.epil ]
  %55 = add nsw i32 %0, -1
  %56 = uitofp nneg i32 %55 to double
  %57 = fdiv double %.lcssa, %56
  %58 = tail call double @sqrt(double noundef %57) #3
  br label %59

59:                                               ; preds = %2, %._crit_edge
  %.1 = phi double [ %58, %._crit_edge ], [ 0.000000e+00, %2 ]
  ret double %.1
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { 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 #2 = { nofree nounwind memory(write, 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" }
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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.unroll.disable"}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !12}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass