; LLVM IR from simbody/simbody :: SimTKmath/Integrators/src/CPodes/sundials/src/sundials (sundials_band)

; 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: nounwind uwtable
define dso_local void @bandZero(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) #0 {
  %6 = alloca ptr, 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 ptr, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !9
  store i32 %4, ptr %10, align 4, !tbaa !9
  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 8, ptr %14) #2
  %15 = load i32, ptr %8, align 4, !tbaa !9
  %16 = load i32, ptr %9, align 4, !tbaa !9
  %17 = add nsw i32 %15, %16
  %18 = add nsw i32 %17, 1
  store i32 %18, ptr %13, align 4, !tbaa !9
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %49, %5
  %20 = load i32, ptr %12, align 4, !tbaa !9
  %21 = load i32, ptr %7, align 4, !tbaa !9
  %22 = icmp slt i32 %20, %21
  br i1 %22, label %23, label %52

23:                                               ; preds = %19
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = load i32, ptr %12, align 4, !tbaa !9
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds ptr, ptr %24, i64 %26
  %28 = load ptr, ptr %27, align 8, !tbaa !5
  %29 = load i32, ptr %10, align 4, !tbaa !9
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds double, ptr %28, i64 %30
  %32 = load i32, ptr %8, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = sub i64 0, %33
  %35 = getelementptr inbounds double, ptr %31, i64 %34
  store ptr %35, ptr %14, align 8, !tbaa !5
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %36

36:                                               ; preds = %45, %23
  %37 = load i32, ptr %11, align 4, !tbaa !9
  %38 = load i32, ptr %13, align 4, !tbaa !9
  %39 = icmp slt i32 %37, %38
  br i1 %39, label %40, label %48

40:                                               ; preds = %36
  %41 = load ptr, ptr %14, align 8, !tbaa !5
  %42 = load i32, ptr %11, align 4, !tbaa !9
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds double, ptr %41, i64 %43
  store double 0.000000e+00, ptr %44, align 8, !tbaa !11
  br label %45

45:                                               ; preds = %40
  %46 = load i32, ptr %11, align 4, !tbaa !9
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %11, align 4, !tbaa !9
  br label %36, !llvm.loop !13

48:                                               ; preds = %36
  br label %49

49:                                               ; preds = %48
  %50 = load i32, ptr %12, align 4, !tbaa !9
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %12, align 4, !tbaa !9
  br label %19, !llvm.loop !15

52:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 8, 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
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !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: nofree norecurse nosync nounwind memory(write, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @bandZero(ptr nocapture noundef readonly %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = add i32 %3, %2
  %7 = icmp sgt i32 %1, 0
  br i1 %7, label %.lr.ph18, label %._crit_edge19

.lr.ph18:                                         ; preds = %5
  %8 = sext i32 %4 to i64
  %9 = sext i32 %2 to i64
  %10 = sub nsw i64 0, %9
  %.not14 = icmp slt i32 %6, 0
  br i1 %.not14, label %._crit_edge19, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.lr.ph18
  %11 = add nuw i32 %6, 1
  %12 = zext i32 %11 to i64
  %13 = shl nuw nsw i64 %12, 3
  %wide.trip.count = zext nneg i32 %1 to i64
  %xtraiter = and i64 %wide.trip.count, 7
  %14 = icmp ult i32 %1, 8
  br i1 %14, label %._crit_edge19.loopexit.unr-lcssa, label %.lr.ph.preheader.new

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

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader.new ], [ %indvars.iv.next.7, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.7, %.lr.ph ]
  %15 = getelementptr inbounds ptr, ptr %0, i64 %indvars.iv
  %16 = load ptr, ptr %15, align 8, !tbaa !5
  %17 = getelementptr inbounds double, ptr %16, i64 %8
  %18 = getelementptr inbounds double, ptr %17, i64 %10
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(1) %18, i8 0, i64 %13, i1 false), !tbaa !9
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %19 = getelementptr inbounds ptr, ptr %0, i64 %indvars.iv.next
  %20 = load ptr, ptr %19, align 8, !tbaa !5
  %21 = getelementptr inbounds double, ptr %20, i64 %8
  %22 = getelementptr inbounds double, ptr %21, i64 %10
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(1) %22, i8 0, i64 %13, i1 false), !tbaa !9
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %23 = getelementptr inbounds ptr, ptr %0, i64 %indvars.iv.next.1
  %24 = load ptr, ptr %23, align 8, !tbaa !5
  %25 = getelementptr inbounds double, ptr %24, i64 %8
  %26 = getelementptr inbounds double, ptr %25, i64 %10
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(1) %26, i8 0, i64 %13, i1 false), !tbaa !9
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %27 = getelementptr inbounds ptr, ptr %0, i64 %indvars.iv.next.2
  %28 = load ptr, ptr %27, align 8, !tbaa !5
  %29 = getelementptr inbounds double, ptr %28, i64 %8
  %30 = getelementptr inbounds double, ptr %29, i64 %10
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(1) %30, i8 0, i64 %13, i1 false), !tbaa !9
  %indvars.iv.next.3 = or disjoint i64 %indvars.iv, 4
  %31 = getelementptr inbounds ptr, ptr %0, i64 %indvars.iv.next.3
  %32 = load ptr, ptr %31, align 8, !tbaa !5
  %33 = getelementptr inbounds double, ptr %32, i64 %8
  %34 = getelementptr inbounds double, ptr %33, i64 %10
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(1) %34, i8 0, i64 %13, i1 false), !tbaa !9
  %indvars.iv.next.4 = or disjoint i64 %indvars.iv, 5
  %35 = getelementptr inbounds ptr, ptr %0, i64 %indvars.iv.next.4
  %36 = load ptr, ptr %35, align 8, !tbaa !5
  %37 = getelementptr inbounds double, ptr %36, i64 %8
  %38 = getelementptr inbounds double, ptr %37, i64 %10
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(1) %38, i8 0, i64 %13, i1 false), !tbaa !9
  %indvars.iv.next.5 = or disjoint i64 %indvars.iv, 6
  %39 = getelementptr inbounds ptr, ptr %0, i64 %indvars.iv.next.5
  %40 = load ptr, ptr %39, align 8, !tbaa !5
  %41 = getelementptr inbounds double, ptr %40, i64 %8
  %42 = getelementptr inbounds double, ptr %41, i64 %10
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(1) %42, i8 0, i64 %13, i1 false), !tbaa !9
  %indvars.iv.next.6 = or disjoint i64 %indvars.iv, 7
  %43 = getelementptr inbounds ptr, ptr %0, i64 %indvars.iv.next.6
  %44 = load ptr, ptr %43, align 8, !tbaa !5
  %45 = getelementptr inbounds double, ptr %44, i64 %8
  %46 = getelementptr inbounds double, ptr %45, i64 %10
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(1) %46, i8 0, i64 %13, i1 false), !tbaa !9
  %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 %._crit_edge19.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !11

._crit_edge19.loopexit.unr-lcssa:                 ; preds = %.lr.ph, %.lr.ph.preheader
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next.7, %.lr.ph ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge19, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge19.loopexit.unr-lcssa, %.lr.ph.epil
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.lr.ph.epil ], [ %indvars.iv.unr, %._crit_edge19.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %._crit_edge19.loopexit.unr-lcssa ]
  %47 = getelementptr inbounds ptr, ptr %0, i64 %indvars.iv.epil
  %48 = load ptr, ptr %47, align 8, !tbaa !5
  %49 = getelementptr inbounds double, ptr %48, i64 %8
  %50 = getelementptr inbounds double, ptr %49, i64 %10
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(1) %50, i8 0, i64 %13, i1 false), !tbaa !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 %._crit_edge19, label %.lr.ph.epil, !llvm.loop !13

._crit_edge19:                                    ; preds = %._crit_edge19.loopexit.unr-lcssa, %.lr.ph.epil, %.lr.ph18, %5
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

attributes #0 = { nofree norecurse nosync nounwind memory(write, argmem: readwrite, inaccessiblemem: none) 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 #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }

!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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.unroll.disable"}


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