; 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: nounwind uwtable
declare dso_local double @r8_max(double noundef, double noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @r8vec_range(i32 noundef %0, ptr noundef %1, double noundef %2, double noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6) #1 {
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca double, align 8
  store i32 %0, ptr %8, align 4, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !9
  store double %2, ptr %10, align 8, !tbaa !11
  store double %3, ptr %11, align 8, !tbaa !11
  store ptr %4, ptr %12, align 8, !tbaa !9
  store ptr %5, ptr %13, align 8, !tbaa !9
  store ptr %6, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #2
  store double 0x7FEFFFFFFFFFFFFF, ptr %16, align 8, !tbaa !11
  %17 = load ptr, ptr %13, align 8, !tbaa !9
  store double 0x7FEFFFFFFFFFFFFF, ptr %17, align 8, !tbaa !11
  %18 = load ptr, ptr %14, align 8, !tbaa !9
  store double 0xFFEFFFFFFFFFFFFF, ptr %18, align 8, !tbaa !11
  store i32 0, ptr %15, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %59, %7
  %20 = load i32, ptr %15, align 4, !tbaa !5
  %21 = load i32, ptr %8, align 4, !tbaa !5
  %22 = icmp slt i32 %20, %21
  br i1 %22, label %23, label %62

23:                                               ; preds = %19
  %24 = load double, ptr %10, align 8, !tbaa !11
  %25 = load ptr, ptr %9, align 8, !tbaa !9
  %26 = load i32, ptr %15, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds double, ptr %25, i64 %27
  %29 = load double, ptr %28, align 8, !tbaa !11
  %30 = fcmp ole double %24, %29
  br i1 %30, label %31, label %58

31:                                               ; preds = %23
  %32 = load ptr, ptr %9, align 8, !tbaa !9
  %33 = load i32, ptr %15, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds double, ptr %32, i64 %34
  %36 = load double, ptr %35, align 8, !tbaa !11
  %37 = load double, ptr %11, align 8, !tbaa !11
  %38 = fcmp ole double %36, %37
  br i1 %38, label %39, label %58

39:                                               ; preds = %31
  %40 = load ptr, ptr %13, align 8, !tbaa !9
  %41 = load double, ptr %40, align 8, !tbaa !11
  %42 = load ptr, ptr %12, align 8, !tbaa !9
  %43 = load i32, ptr %15, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds double, ptr %42, i64 %44
  %46 = load double, ptr %45, align 8, !tbaa !11
  %47 = call double @r8_min(double noundef %41, double noundef %46)
  %48 = load ptr, ptr %13, align 8, !tbaa !9
  store double %47, ptr %48, align 8, !tbaa !11
  %49 = load ptr, ptr %14, align 8, !tbaa !9
  %50 = load double, ptr %49, align 8, !tbaa !11
  %51 = load ptr, ptr %12, align 8, !tbaa !9
  %52 = load i32, ptr %15, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds double, ptr %51, i64 %53
  %55 = load double, ptr %54, align 8, !tbaa !11
  %56 = call double @r8_max(double noundef %50, double noundef %55)
  %57 = load ptr, ptr %14, align 8, !tbaa !9
  store double %56, ptr %57, align 8, !tbaa !11
  br label %58

58:                                               ; preds = %39, %31, %23
  br label %59

59:                                               ; preds = %58
  %60 = load i32, ptr %15, align 4, !tbaa !5
  %61 = add nsw i32 %60, 1
  store i32 %61, ptr %15, align 4, !tbaa !5
  br label %19, !llvm.loop !13

62:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #2
  ret void
}

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


; 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: nounwind uwtable
declare dso_local double @r8_max(double noundef, double noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local void @r8vec_range(i32 noundef %0, ptr nocapture noundef readonly %1, double noundef %2, double noundef %3, ptr nocapture noundef readonly %4, ptr nocapture noundef %5, ptr nocapture noundef %6) local_unnamed_addr #0 {
  store double 0x7FEFFFFFFFFFFFFF, ptr %5, align 8, !tbaa !5
  store double 0xFFEFFFFFFFFFFFFF, ptr %6, align 8, !tbaa !5
  %8 = icmp sgt i32 %0, 0
  br i1 %8, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %7
  %wide.trip.count = zext nneg i32 %0 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %21
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %21 ]
  %9 = getelementptr inbounds double, ptr %1, i64 %indvars.iv
  %10 = load double, ptr %9, align 8, !tbaa !5
  %11 = fcmp ult double %10, %2
  %12 = fcmp ugt double %10, %3
  %or.cond = or i1 %11, %12
  br i1 %or.cond, label %21, label %13

13:                                               ; preds = %.lr.ph
  %14 = load double, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds double, ptr %4, i64 %indvars.iv
  %16 = load double, ptr %15, align 8, !tbaa !5
  %17 = tail call double @r8_min(double noundef %14, double noundef %16)
  store double %17, ptr %5, align 8, !tbaa !5
  %18 = load double, ptr %6, align 8, !tbaa !5
  %19 = load double, ptr %15, align 8, !tbaa !5
  %20 = tail call double @r8_max(double noundef %18, double noundef %19)
  store double %20, ptr %6, align 8, !tbaa !5
  br label %21

21:                                               ; preds = %.lr.ph, %13
  %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 %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %21, %7
  ret void
}

attributes #0 = { 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" }

!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"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass