; 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 allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

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

18:                                               ; preds = %86, %4
  %19 = load i32, ptr %10, align 4, !tbaa !5
  %20 = load i32, ptr %7, align 4, !tbaa !5
  %21 = icmp slt i32 %19, %20
  br i1 %21, label %22, label %89

22:                                               ; preds = %18
  %23 = load ptr, ptr %8, align 8, !tbaa !9
  %24 = load i32, ptr %10, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds double, ptr %23, i64 %25
  %27 = load double, ptr %26, align 8, !tbaa !11
  %28 = load ptr, ptr %6, align 8, !tbaa !9
  %29 = getelementptr inbounds double, ptr %28, i64 0
  %30 = load double, ptr %29, align 8, !tbaa !11
  %31 = fcmp olt double %27, %30
  br i1 %31, label %45, label %32

32:                                               ; preds = %22
  %33 = load ptr, ptr %6, align 8, !tbaa !9
  %34 = load i32, ptr %5, align 4, !tbaa !5
  %35 = sub nsw i32 %34, 1
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds double, ptr %33, i64 %36
  %38 = load double, ptr %37, align 8, !tbaa !11
  %39 = load ptr, ptr %8, align 8, !tbaa !9
  %40 = load i32, ptr %10, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds double, ptr %39, i64 %41
  %43 = load double, ptr %42, align 8, !tbaa !11
  %44 = fcmp olt double %38, %43
  br i1 %44, label %45, label %50

45:                                               ; preds = %32, %22
  %46 = load ptr, ptr %9, align 8, !tbaa !9
  %47 = load i32, ptr %10, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds i32, ptr %46, i64 %48
  store i32 -1, ptr %49, align 4, !tbaa !5
  br label %85

50:                                               ; preds = %32
  store i32 0, ptr %11, align 4, !tbaa !5
  %51 = load i32, ptr %5, align 4, !tbaa !5
  %52 = sub nsw i32 %51, 1
  store i32 %52, ptr %13, align 4, !tbaa !5
  br label %53

53:                                               ; preds = %78, %50
  %54 = load i32, ptr %11, align 4, !tbaa !5
  %55 = add nsw i32 %54, 1
  %56 = load i32, ptr %13, align 4, !tbaa !5
  %57 = icmp slt i32 %55, %56
  br i1 %57, label %58, label %79

58:                                               ; preds = %53
  %59 = load i32, ptr %11, align 4, !tbaa !5
  %60 = load i32, ptr %13, align 4, !tbaa !5
  %61 = add nsw i32 %59, %60
  %62 = sdiv i32 %61, 2
  store i32 %62, ptr %12, align 4, !tbaa !5
  %63 = load ptr, ptr %8, align 8, !tbaa !9
  %64 = load i32, ptr %10, 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 ptr, ptr %6, align 8, !tbaa !9
  %69 = load i32, ptr %12, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds double, ptr %68, i64 %70
  %72 = load double, ptr %71, align 8, !tbaa !11
  %73 = fcmp olt double %67, %72
  br i1 %73, label %74, label %76

74:                                               ; preds = %58
  %75 = load i32, ptr %12, align 4, !tbaa !5
  store i32 %75, ptr %13, align 4, !tbaa !5
  br label %78

76:                                               ; preds = %58
  %77 = load i32, ptr %12, align 4, !tbaa !5
  store i32 %77, ptr %11, align 4, !tbaa !5
  br label %78

78:                                               ; preds = %76, %74
  br label %53, !llvm.loop !13

79:                                               ; preds = %53
  %80 = load i32, ptr %11, align 4, !tbaa !5
  %81 = load ptr, ptr %9, align 8, !tbaa !9
  %82 = load i32, ptr %10, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds i32, ptr %81, i64 %83
  store i32 %80, ptr %84, align 4, !tbaa !5
  br label %85

85:                                               ; preds = %79, %45
  br label %86

86:                                               ; preds = %85
  %87 = load i32, ptr %10, align 4, !tbaa !5
  %88 = add nsw i32 %87, 1
  store i32 %88, ptr %10, align 4, !tbaa !5
  br label %18, !llvm.loop !15

89:                                               ; preds = %18
  %90 = load ptr, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret ptr %90
}

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

!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 nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

; Function Attrs: nofree nounwind memory(write, argmem: read, inaccessiblemem: readwrite) uwtable
define dso_local noalias noundef ptr @r8vec_bracket6(i32 noundef %0, ptr nocapture noundef readonly %1, i32 noundef %2, ptr nocapture noundef readonly %3) local_unnamed_addr #1 {
  %5 = sext i32 %2 to i64
  %6 = shl nsw i64 %5, 2
  %7 = tail call noalias ptr @malloc(i64 noundef %6) #2
  %8 = icmp sgt i32 %2, 0
  br i1 %8, label %.lr.ph35, label %._crit_edge36

.lr.ph35:                                         ; preds = %4
  %9 = load double, ptr %1, align 8, !tbaa !5
  %10 = add nsw i32 %0, -1
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds double, ptr %1, i64 %11
  %13 = icmp sgt i32 %0, 2
  %wide.trip.count42 = zext nneg i32 %2 to i64
  br i1 %13, label %.lr.ph35.split.us, label %.lr.ph35.split.preheader

.lr.ph35.split.preheader:                         ; preds = %.lr.ph35
  %xtraiter = and i64 %wide.trip.count42, 1
  %14 = icmp eq i32 %2, 1
  br i1 %14, label %._crit_edge36.loopexit49.unr-lcssa, label %.lr.ph35.split.preheader.new

.lr.ph35.split.preheader.new:                     ; preds = %.lr.ph35.split.preheader
  %unroll_iter = and i64 %wide.trip.count42, 2147483646
  br label %.lr.ph35.split

.lr.ph35.split.us:                                ; preds = %.lr.ph35, %._crit_edge.us
  %indvars.iv39 = phi i64 [ %indvars.iv.next40, %._crit_edge.us ], [ 0, %.lr.ph35 ]
  %15 = getelementptr inbounds double, ptr %3, i64 %indvars.iv39
  %16 = load double, ptr %15, align 8, !tbaa !5
  %17 = fcmp olt double %16, %9
  br i1 %17, label %._crit_edge.us, label %18

18:                                               ; preds = %.lr.ph35.split.us
  %19 = load double, ptr %12, align 8, !tbaa !5
  %20 = fcmp olt double %19, %16
  br i1 %20, label %._crit_edge.us, label %.preheader.us

.preheader.us:                                    ; preds = %18, %.preheader.us
  %.032.us = phi i32 [ %..0.us, %.preheader.us ], [ %10, %18 ]
  %.02831.us = phi i32 [ %.028..us, %.preheader.us ], [ 0, %18 ]
  %21 = add nuw nsw i32 %.032.us, %.02831.us
  %22 = lshr i32 %21, 1
  %23 = zext nneg i32 %22 to i64
  %24 = getelementptr inbounds double, ptr %1, i64 %23
  %25 = load double, ptr %24, align 8, !tbaa !5
  %26 = fcmp olt double %16, %25
  %.028..us = select i1 %26, i32 %.02831.us, i32 %22
  %..0.us = select i1 %26, i32 %22, i32 %.032.us
  %27 = add nuw nsw i32 %.028..us, 1
  %28 = icmp slt i32 %27, %..0.us
  br i1 %28, label %.preheader.us, label %._crit_edge.us, !llvm.loop !9

._crit_edge.us:                                   ; preds = %.preheader.us, %.lr.ph35.split.us, %18
  %.sink = phi i32 [ -1, %18 ], [ -1, %.lr.ph35.split.us ], [ %.028..us, %.preheader.us ]
  %29 = getelementptr inbounds i32, ptr %7, i64 %indvars.iv39
  store i32 %.sink, ptr %29, align 4, !tbaa !11
  %indvars.iv.next40 = add nuw nsw i64 %indvars.iv39, 1
  %exitcond43.not = icmp eq i64 %indvars.iv.next40, %wide.trip.count42
  br i1 %exitcond43.not, label %._crit_edge36, label %.lr.ph35.split.us, !llvm.loop !13

.lr.ph35.split:                                   ; preds = %.preheader.1, %.lr.ph35.split.preheader.new
  %indvars.iv = phi i64 [ 0, %.lr.ph35.split.preheader.new ], [ %indvars.iv.next.1, %.preheader.1 ]
  %niter = phi i64 [ 0, %.lr.ph35.split.preheader.new ], [ %niter.next.1, %.preheader.1 ]
  %30 = getelementptr inbounds double, ptr %3, i64 %indvars.iv
  %31 = load double, ptr %30, align 8, !tbaa !5
  %32 = fcmp olt double %31, %9
  br i1 %32, label %36, label %33

33:                                               ; preds = %.lr.ph35.split
  %34 = load double, ptr %12, align 8, !tbaa !5
  %35 = fcmp olt double %34, %31
  br i1 %35, label %36, label %.preheader

36:                                               ; preds = %33, %.lr.ph35.split
  br label %.preheader

.preheader:                                       ; preds = %33, %36
  %.sink46 = phi i32 [ -1, %36 ], [ 0, %33 ]
  %37 = getelementptr inbounds i32, ptr %7, i64 %indvars.iv
  store i32 %.sink46, ptr %37, align 4, !tbaa !11
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %38 = getelementptr inbounds double, ptr %3, i64 %indvars.iv.next
  %39 = load double, ptr %38, align 8, !tbaa !5
  %40 = fcmp olt double %39, %9
  br i1 %40, label %44, label %41

41:                                               ; preds = %.preheader
  %42 = load double, ptr %12, align 8, !tbaa !5
  %43 = fcmp olt double %42, %39
  br i1 %43, label %44, label %.preheader.1

44:                                               ; preds = %41, %.preheader
  br label %.preheader.1

.preheader.1:                                     ; preds = %44, %41
  %.sink46.1 = phi i32 [ -1, %44 ], [ 0, %41 ]
  %45 = getelementptr inbounds i32, ptr %7, i64 %indvars.iv.next
  store i32 %.sink46.1, ptr %45, align 4, !tbaa !11
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 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_edge36.loopexit49.unr-lcssa, label %.lr.ph35.split, !llvm.loop !13

._crit_edge36.loopexit49.unr-lcssa:               ; preds = %.preheader.1, %.lr.ph35.split.preheader
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph35.split.preheader ], [ %indvars.iv.next.1, %.preheader.1 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge36, label %.lr.ph35.split.epil

.lr.ph35.split.epil:                              ; preds = %._crit_edge36.loopexit49.unr-lcssa
  %46 = getelementptr inbounds double, ptr %3, i64 %indvars.iv.unr
  %47 = load double, ptr %46, align 8, !tbaa !5
  %48 = fcmp olt double %47, %9
  br i1 %48, label %52, label %49

49:                                               ; preds = %.lr.ph35.split.epil
  %50 = load double, ptr %12, align 8, !tbaa !5
  %51 = fcmp olt double %50, %47
  br i1 %51, label %52, label %.preheader.epil

52:                                               ; preds = %49, %.lr.ph35.split.epil
  br label %.preheader.epil

.preheader.epil:                                  ; preds = %52, %49
  %.sink46.epil = phi i32 [ -1, %52 ], [ 0, %49 ]
  %53 = getelementptr inbounds i32, ptr %7, i64 %indvars.iv.unr
  store i32 %.sink46.epil, ptr %53, align 4, !tbaa !11
  br label %._crit_edge36

._crit_edge36:                                    ; preds = %.preheader.epil, %._crit_edge36.loopexit49.unr-lcssa, %._crit_edge.us, %4
  ret ptr %7
}

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #1 = { nofree nounwind memory(write, argmem: read, inaccessiblemem: 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 #2 = { nounwind allocsize(0) }

!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 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !10}


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