; 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
define dso_local i32 @r8vec_split(i32 noundef %0, ptr noundef %1, double noundef %2) #1 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca double, align 8
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  store double %2, ptr %6, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #2
  store i32 1, ptr %8, align 4, !tbaa !5
  store i32 0, ptr %12, align 4, !tbaa !5
  store i32 1, ptr %9, align 4, !tbaa !5
  %16 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %16, ptr %13, align 4, !tbaa !5
  %17 = load i32, ptr %4, align 4, !tbaa !5
  %18 = add nsw i32 %17, 1
  store i32 %18, ptr %10, align 4, !tbaa !5
  %19 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %19, ptr %14, align 4, !tbaa !5
  store i32 1, ptr %7, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %67, %3
  %21 = load i32, ptr %7, align 4, !tbaa !5
  %22 = load i32, ptr %4, align 4, !tbaa !5
  %23 = icmp sle i32 %21, %22
  br i1 %23, label %24, label %70

24:                                               ; preds = %20
  %25 = load ptr, ptr %5, align 8, !tbaa !9
  %26 = load i32, ptr %9, align 4, !tbaa !5
  %27 = sub nsw i32 %26, 1
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds double, ptr %25, i64 %28
  %30 = load double, ptr %29, align 8, !tbaa !11
  %31 = load double, ptr %6, align 8, !tbaa !11
  %32 = fcmp ole double %30, %31
  br i1 %32, label %33, label %38

33:                                               ; preds = %24
  %34 = load i32, ptr %9, align 4, !tbaa !5
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %9, align 4, !tbaa !5
  %36 = load i32, ptr %12, align 4, !tbaa !5
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %12, align 4, !tbaa !5
  br label %66

38:                                               ; preds = %24
  %39 = load ptr, ptr %5, align 8, !tbaa !9
  %40 = load i32, ptr %9, align 4, !tbaa !5
  %41 = sub nsw i32 %40, 1
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds double, ptr %39, i64 %42
  %44 = load double, ptr %43, align 8, !tbaa !11
  store double %44, ptr %15, align 8, !tbaa !11
  %45 = load ptr, ptr %5, align 8, !tbaa !9
  %46 = load i32, ptr %10, align 4, !tbaa !5
  %47 = sub nsw i32 %46, 2
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds double, ptr %45, i64 %48
  %50 = load double, ptr %49, align 8, !tbaa !11
  %51 = load ptr, ptr %5, align 8, !tbaa !9
  %52 = load i32, ptr %9, align 4, !tbaa !5
  %53 = sub nsw i32 %52, 1
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds double, ptr %51, i64 %54
  store double %50, ptr %55, align 8, !tbaa !11
  %56 = load double, ptr %15, align 8, !tbaa !11
  %57 = load ptr, ptr %5, align 8, !tbaa !9
  %58 = load i32, ptr %10, align 4, !tbaa !5
  %59 = sub nsw i32 %58, 2
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds double, ptr %57, i64 %60
  store double %56, ptr %61, align 8, !tbaa !11
  %62 = load i32, ptr %10, align 4, !tbaa !5
  %63 = sub nsw i32 %62, 1
  store i32 %63, ptr %10, align 4, !tbaa !5
  %64 = load i32, ptr %13, align 4, !tbaa !5
  %65 = sub nsw i32 %64, 1
  store i32 %65, ptr %13, align 4, !tbaa !5
  br label %66

66:                                               ; preds = %38, %33
  br label %67

67:                                               ; preds = %66
  %68 = load i32, ptr %7, align 4, !tbaa !5
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %7, align 4, !tbaa !5
  br label %20, !llvm.loop !13

70:                                               ; preds = %20
  %71 = load i32, ptr %12, align 4, !tbaa !5
  store i32 %71, ptr %11, align 4, !tbaa !5
  %72 = load i32, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  ret i32 %72
}

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: nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local i32 @r8vec_split(i32 noundef %0, ptr nocapture noundef %1, double noundef %2) local_unnamed_addr #0 {
  %invariant.gep = getelementptr i8, ptr %1, i64 -8
  %invariant.gep31 = getelementptr i8, ptr %1, i64 -16
  %.not33 = icmp slt i32 %0, 1
  br i1 %.not33, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %3
  %4 = add nuw i32 %0, 1
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %15
  %.038 = phi i32 [ %16, %15 ], [ 1, %.lr.ph.preheader ]
  %.02337 = phi i32 [ %.1, %15 ], [ 1, %.lr.ph.preheader ]
  %.02635 = phi i32 [ %.127, %15 ], [ 0, %.lr.ph.preheader ]
  %.02834 = phi i32 [ %.129, %15 ], [ %4, %.lr.ph.preheader ]
  %5 = sext i32 %.02337 to i64
  %gep = getelementptr double, ptr %invariant.gep, i64 %5
  %6 = load double, ptr %gep, align 8, !tbaa !5
  %7 = fcmp ugt double %6, %2
  br i1 %7, label %11, label %8

8:                                                ; preds = %.lr.ph
  %9 = add nsw i32 %.02337, 1
  %10 = add nsw i32 %.02635, 1
  br label %15

11:                                               ; preds = %.lr.ph
  %12 = sext i32 %.02834 to i64
  %gep32 = getelementptr double, ptr %invariant.gep31, i64 %12
  %13 = load double, ptr %gep32, align 8, !tbaa !5
  store double %13, ptr %gep, align 8, !tbaa !5
  store double %6, ptr %gep32, align 8, !tbaa !5
  %14 = add nsw i32 %.02834, -1
  br label %15

15:                                               ; preds = %8, %11
  %.129 = phi i32 [ %.02834, %8 ], [ %14, %11 ]
  %.127 = phi i32 [ %10, %8 ], [ %.02635, %11 ]
  %.1 = phi i32 [ %9, %8 ], [ %.02337, %11 ]
  %16 = add nuw i32 %.038, 1
  %exitcond.not = icmp eq i32 %.038, %0
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %15, %3
  %.026.lcssa = phi i32 [ 0, %3 ], [ %.127, %15 ]
  ret i32 %.026.lcssa
}

attributes #0 = { 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}
!10 = !{!"llvm.loop.mustprogress"}


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