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

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

; Function Attrs: nounwind
declare double @sin(double noundef) #2

; Function Attrs: nounwind uwtable
define dso_local double @r8vec_circular_variance(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
  %8 = alloca double, align 8
  %9 = 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
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %10 = load i32, ptr %3, align 4, !tbaa !5
  %11 = load ptr, ptr %4, align 8, !tbaa !9
  %12 = call double @r8vec_mean(i32 noundef %10, ptr noundef %11)
  store double %12, 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 %13

13:                                               ; preds = %28, %2
  %14 = load i32, ptr %5, align 4, !tbaa !5
  %15 = load i32, ptr %3, align 4, !tbaa !5
  %16 = icmp slt i32 %14, %15
  br i1 %16, label %17, label %31

17:                                               ; preds = %13
  %18 = load double, ptr %7, align 8, !tbaa !11
  %19 = load ptr, ptr %4, align 8, !tbaa !9
  %20 = load i32, ptr %5, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds double, ptr %19, i64 %21
  %23 = load double, ptr %22, align 8, !tbaa !11
  %24 = load double, ptr %6, align 8, !tbaa !11
  %25 = fsub double %23, %24
  %26 = call double @cos(double noundef %25) #4
  %27 = fadd double %18, %26
  store double %27, ptr %7, align 8, !tbaa !11
  br label %28

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

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

32:                                               ; preds = %47, %31
  %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 %50

36:                                               ; preds = %32
  %37 = load double, ptr %8, 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 = call double @sin(double noundef %44) #4
  %46 = fadd double %37, %45
  store double %46, ptr %8, align 8, !tbaa !11
  br label %47

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

50:                                               ; preds = %32
  %51 = load double, ptr %7, align 8, !tbaa !11
  %52 = load double, ptr %7, align 8, !tbaa !11
  %53 = load double, ptr %8, align 8, !tbaa !11
  %54 = load double, ptr %8, align 8, !tbaa !11
  %55 = fmul double %53, %54
  %56 = call double @llvm.fmuladd.f64(double %51, double %52, double %55)
  %57 = call double @sqrt(double noundef %56) #4
  %58 = load i32, ptr %3, align 4, !tbaa !5
  %59 = sitofp i32 %58 to double
  %60 = fdiv double %57, %59
  store double %60, ptr %9, align 8, !tbaa !11
  %61 = load double, ptr %9, align 8, !tbaa !11
  %62 = fsub double 1.000000e+00, %61
  store double %62, ptr %9, align 8, !tbaa !11
  %63 = load double, ptr %9, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  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 %63
}

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

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 @cos(double noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local double @r8vec_circular_variance(i32 noundef %0, ptr noundef %1) local_unnamed_addr #2 {
  %3 = tail call double @r8vec_mean(i32 noundef %0, ptr noundef %1)
  %4 = icmp sgt i32 %0, 0
  br i1 %4, label %.lr.ph.preheader, label %._crit_edge

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

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

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

.lr.ph.epil:                                      ; preds = %.preheader.unr-lcssa, %.lr.ph.epil
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.lr.ph.epil ], [ %indvars.iv.unr, %.preheader.unr-lcssa ]
  %.02325.epil = phi double [ %10, %.lr.ph.epil ], [ %.02325.unr, %.preheader.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %.preheader.unr-lcssa ]
  %6 = getelementptr inbounds double, ptr %1, i64 %indvars.iv.epil
  %7 = load double, ptr %6, align 8, !tbaa !5
  %8 = fsub double %7, %3
  %9 = tail call double @cos(double noundef %8) #4
  %10 = fadd double %.02325.epil, %9
  %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 %.preheader, label %.lr.ph.epil, !llvm.loop !9

.preheader:                                       ; preds = %.lr.ph.epil, %.preheader.unr-lcssa
  %.lcssa42 = phi double [ %.lcssa42.ph, %.preheader.unr-lcssa ], [ %10, %.lr.ph.epil ]
  br i1 %4, label %.lr.ph29.preheader, label %._crit_edge

.lr.ph29.preheader:                               ; preds = %.preheader
  %xtraiter44 = and i64 %wide.trip.count, 3
  %11 = icmp ult i32 %0, 4
  br i1 %11, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph29.preheader.new

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

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

.lr.ph29:                                         ; preds = %.lr.ph29, %.lr.ph29.preheader.new
  %indvars.iv33 = phi i64 [ 0, %.lr.ph29.preheader.new ], [ %indvars.iv.next34.3, %.lr.ph29 ]
  %.02227 = phi double [ 0.000000e+00, %.lr.ph29.preheader.new ], [ %51, %.lr.ph29 ]
  %niter49 = phi i64 [ 0, %.lr.ph29.preheader.new ], [ %niter49.next.3, %.lr.ph29 ]
  %32 = getelementptr inbounds double, ptr %1, i64 %indvars.iv33
  %33 = load double, ptr %32, align 8, !tbaa !5
  %34 = fsub double %33, %3
  %35 = tail call double @sin(double noundef %34) #4
  %36 = fadd double %.02227, %35
  %indvars.iv.next34 = or disjoint i64 %indvars.iv33, 1
  %37 = getelementptr inbounds double, ptr %1, i64 %indvars.iv.next34
  %38 = load double, ptr %37, align 8, !tbaa !5
  %39 = fsub double %38, %3
  %40 = tail call double @sin(double noundef %39) #4
  %41 = fadd double %36, %40
  %indvars.iv.next34.1 = or disjoint i64 %indvars.iv33, 2
  %42 = getelementptr inbounds double, ptr %1, i64 %indvars.iv.next34.1
  %43 = load double, ptr %42, align 8, !tbaa !5
  %44 = fsub double %43, %3
  %45 = tail call double @sin(double noundef %44) #4
  %46 = fadd double %41, %45
  %indvars.iv.next34.2 = or disjoint i64 %indvars.iv33, 3
  %47 = getelementptr inbounds double, ptr %1, i64 %indvars.iv.next34.2
  %48 = load double, ptr %47, align 8, !tbaa !5
  %49 = fsub double %48, %3
  %50 = tail call double @sin(double noundef %49) #4
  %51 = fadd double %46, %50
  %indvars.iv.next34.3 = add nuw nsw i64 %indvars.iv33, 4
  %niter49.next.3 = add i64 %niter49, 4
  %niter49.ncmp.3 = icmp eq i64 %niter49.next.3, %unroll_iter48
  br i1 %niter49.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph29, !llvm.loop !13

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph29, %.lr.ph29.preheader
  %.lcssa.ph = phi double [ poison, %.lr.ph29.preheader ], [ %51, %.lr.ph29 ]
  %indvars.iv33.unr = phi i64 [ 0, %.lr.ph29.preheader ], [ %indvars.iv.next34.3, %.lr.ph29 ]
  %.02227.unr = phi double [ 0.000000e+00, %.lr.ph29.preheader ], [ %51, %.lr.ph29 ]
  %lcmp.mod46.not = icmp eq i64 %xtraiter44, 0
  br i1 %lcmp.mod46.not, label %._crit_edge, label %.lr.ph29.epil

.lr.ph29.epil:                                    ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph29.epil
  %indvars.iv33.epil = phi i64 [ %indvars.iv.next34.epil, %.lr.ph29.epil ], [ %indvars.iv33.unr, %._crit_edge.loopexit.unr-lcssa ]
  %.02227.epil = phi double [ %56, %.lr.ph29.epil ], [ %.02227.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter45 = phi i64 [ %epil.iter45.next, %.lr.ph29.epil ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %52 = getelementptr inbounds double, ptr %1, i64 %indvars.iv33.epil
  %53 = load double, ptr %52, align 8, !tbaa !5
  %54 = fsub double %53, %3
  %55 = tail call double @sin(double noundef %54) #4
  %56 = fadd double %.02227.epil, %55
  %indvars.iv.next34.epil = add nuw nsw i64 %indvars.iv33.epil, 1
  %epil.iter45.next = add i64 %epil.iter45, 1
  %epil.iter45.cmp.not = icmp eq i64 %epil.iter45.next, %xtraiter44
  br i1 %epil.iter45.cmp.not, label %._crit_edge, label %.lr.ph29.epil, !llvm.loop !14

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph29.epil, %2, %.preheader
  %.023.lcssa39 = phi double [ %.lcssa42, %.preheader ], [ 0.000000e+00, %2 ], [ %.lcssa42, %.lr.ph29.epil ], [ %.lcssa42, %._crit_edge.loopexit.unr-lcssa ]
  %.022.lcssa = phi double [ 0.000000e+00, %.preheader ], [ 0.000000e+00, %2 ], [ %.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %56, %.lr.ph29.epil ]
  %57 = fmul double %.022.lcssa, %.022.lcssa
  %58 = tail call double @llvm.fmuladd.f64(double %.023.lcssa39, double %.023.lcssa39, double %57)
  %sqrt = tail call double @llvm.sqrt.f64(double %58)
  %59 = sitofp i32 %0 to double
  %60 = fdiv double %sqrt, %59
  %61 = fsub double 1.000000e+00, %60
  ret double %61
}

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

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

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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.unroll.disable"}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !10}


; Effective O3 passes: AggressiveInstCombinePass,CorrelatedValuePropagationPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass