; LLVM IR from JessonYue/LeetCodeLearning :: Array/wuchao/array/7-14 数组相对排序 (RelativeSortArray)

; 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 ptr @relativeSortArray(ptr noundef %0, i32 noundef %1, ptr noundef %2, i32 noundef %3, ptr noundef %4) #0 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !9
  store ptr %4, ptr %10, align 8, !tbaa !5
  %17 = load i32, ptr %7, align 4, !tbaa !9
  %18 = load ptr, ptr %10, align 8, !tbaa !5
  store i32 %17, ptr %18, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %19 = load i32, ptr %7, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = mul i64 %20, 4
  %22 = call noalias ptr @malloc(i64 noundef %21) #5
  store ptr %22, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %23 = call noalias ptr @calloc(i64 noundef 1001, i64 noundef 4) #6
  store ptr %23, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  store i32 0, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  store i32 0, ptr %14, align 4, !tbaa !9
  br label %24

24:                                               ; preds = %40, %5
  %25 = load i32, ptr %14, align 4, !tbaa !9
  %26 = load i32, ptr %7, align 4, !tbaa !9
  %27 = icmp slt i32 %25, %26
  br i1 %27, label %29, label %28

28:                                               ; preds = %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  br label %43

29:                                               ; preds = %24
  %30 = load ptr, ptr %12, align 8, !tbaa !5
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = load i32, ptr %14, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds i32, ptr %31, i64 %33
  %35 = load i32, ptr %34, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds i32, ptr %30, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !9
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %37, align 4, !tbaa !9
  br label %40

40:                                               ; preds = %29
  %41 = load i32, ptr %14, align 4, !tbaa !9
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %14, align 4, !tbaa !9
  br label %24, !llvm.loop !11

43:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  store i32 0, ptr %15, align 4, !tbaa !9
  br label %44

44:                                               ; preds = %74, %43
  %45 = load i32, ptr %15, align 4, !tbaa !9
  %46 = load i32, ptr %9, align 4, !tbaa !9
  %47 = icmp slt i32 %45, %46
  br i1 %47, label %49, label %48

48:                                               ; preds = %44
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  br label %77

49:                                               ; preds = %44
  br label %50

50:                                               ; preds = %62, %49
  %51 = load ptr, ptr %12, align 8, !tbaa !5
  %52 = load ptr, ptr %8, align 8, !tbaa !5
  %53 = load i32, ptr %15, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds i32, ptr %52, i64 %54
  %56 = load i32, ptr %55, align 4, !tbaa !9
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds i32, ptr %51, i64 %57
  %59 = load i32, ptr %58, align 4, !tbaa !9
  %60 = add nsw i32 %59, -1
  store i32 %60, ptr %58, align 4, !tbaa !9
  %61 = icmp sgt i32 %59, 0
  br i1 %61, label %62, label %73

62:                                               ; preds = %50
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  %64 = load i32, ptr %15, align 4, !tbaa !9
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds i32, ptr %63, i64 %65
  %67 = load i32, ptr %66, align 4, !tbaa !9
  %68 = load ptr, ptr %11, align 8, !tbaa !5
  %69 = load i32, ptr %13, align 4, !tbaa !9
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr %13, align 4, !tbaa !9
  %71 = sext i32 %69 to i64
  %72 = getelementptr inbounds i32, ptr %68, i64 %71
  store i32 %67, ptr %72, align 4, !tbaa !9
  br label %50, !llvm.loop !13

73:                                               ; preds = %50
  br label %74

74:                                               ; preds = %73
  %75 = load i32, ptr %15, align 4, !tbaa !9
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %15, align 4, !tbaa !9
  br label %44, !llvm.loop !14

77:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  store i32 0, ptr %16, align 4, !tbaa !9
  br label %78

78:                                               ; preds = %99, %77
  %79 = load i32, ptr %16, align 4, !tbaa !9
  %80 = icmp slt i32 %79, 1001
  br i1 %80, label %82, label %81

81:                                               ; preds = %78
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  br label %102

82:                                               ; preds = %78
  br label %83

83:                                               ; preds = %91, %82
  %84 = load ptr, ptr %12, align 8, !tbaa !5
  %85 = load i32, ptr %16, align 4, !tbaa !9
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds i32, ptr %84, i64 %86
  %88 = load i32, ptr %87, align 4, !tbaa !9
  %89 = add nsw i32 %88, -1
  store i32 %89, ptr %87, align 4, !tbaa !9
  %90 = icmp sgt i32 %88, 0
  br i1 %90, label %91, label %98

91:                                               ; preds = %83
  %92 = load i32, ptr %16, align 4, !tbaa !9
  %93 = load ptr, ptr %11, align 8, !tbaa !5
  %94 = load i32, ptr %13, align 4, !tbaa !9
  %95 = add nsw i32 %94, 1
  store i32 %95, ptr %13, align 4, !tbaa !9
  %96 = sext i32 %94 to i64
  %97 = getelementptr inbounds i32, ptr %93, i64 %96
  store i32 %92, ptr %97, align 4, !tbaa !9
  br label %83, !llvm.loop !15

98:                                               ; preds = %83
  br label %99

99:                                               ; preds = %98
  %100 = load i32, ptr %16, align 4, !tbaa !9
  %101 = add nsw i32 %100, 1
  store i32 %101, ptr %16, align 4, !tbaa !9
  br label %78, !llvm.loop !16

102:                                              ; preds = %81
  %103 = load ptr, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  ret ptr %103
}

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #3

; 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 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 #3 = { nounwind allocsize(0,1) "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 }
attributes #5 = { nounwind allocsize(0) }
attributes #6 = { nounwind allocsize(0,1) }

!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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}


; 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 nounwind uwtable
define dso_local noalias noundef ptr @relativeSortArray(ptr nocapture noundef readonly %0, i32 noundef %1, ptr nocapture noundef readonly %2, i32 noundef %3, ptr nocapture noundef writeonly %4) local_unnamed_addr #0 {
  store i32 %1, ptr %4, align 4, !tbaa !5
  %6 = sext i32 %1 to i64
  %7 = shl nsw i64 %6, 2
  %8 = tail call noalias ptr @malloc(i64 noundef %7) #3
  %9 = tail call noalias dereferenceable_or_null(4004) ptr @calloc(i64 noundef 1001, i64 noundef 4) #4
  %10 = icmp sgt i32 %1, 0
  br i1 %10, label %.lr.ph.preheader, label %.preheader31

.lr.ph.preheader:                                 ; preds = %5
  %wide.trip.count = zext nneg i32 %1 to i64
  %xtraiter = and i64 %wide.trip.count, 3
  %11 = icmp ult i32 %1, 4
  br i1 %11, label %.preheader31.loopexit.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

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

.lr.ph.epil:                                      ; preds = %.preheader31.loopexit.unr-lcssa, %.lr.ph.epil
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.lr.ph.epil ], [ %indvars.iv.unr, %.preheader31.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %.preheader31.loopexit.unr-lcssa ]
  %12 = getelementptr inbounds i32, ptr %0, i64 %indvars.iv.epil
  %13 = load i32, ptr %12, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds i32, ptr %9, i64 %14
  %16 = load i32, ptr %15, align 4, !tbaa !5
  %17 = add nsw i32 %16, 1
  store i32 %17, ptr %15, align 4, !tbaa !5
  %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 %.preheader31, label %.lr.ph.epil, !llvm.loop !9

.preheader31:                                     ; preds = %.preheader31.loopexit.unr-lcssa, %.lr.ph.epil, %5
  %18 = icmp sgt i32 %3, 0
  br i1 %18, label %.preheader30.preheader, label %.preheader.preheader

.preheader30.preheader:                           ; preds = %.preheader31
  %wide.trip.count59 = zext nneg i32 %3 to i64
  br label %.preheader30

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader.new ], [ %indvars.iv.next.3, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.3, %.lr.ph ]
  %19 = getelementptr inbounds i32, ptr %0, i64 %indvars.iv
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds i32, ptr %9, i64 %21
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr %22, align 4, !tbaa !5
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %25 = getelementptr inbounds i32, ptr %0, i64 %indvars.iv.next
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds i32, ptr %9, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %28, align 4, !tbaa !5
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %31 = getelementptr inbounds i32, ptr %0, i64 %indvars.iv.next.1
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds i32, ptr %9, i64 %33
  %35 = load i32, ptr %34, align 4, !tbaa !5
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %34, align 4, !tbaa !5
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %37 = getelementptr inbounds i32, ptr %0, i64 %indvars.iv.next.2
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds i32, ptr %9, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !5
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %40, align 4, !tbaa !5
  %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 %.preheader31.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !11

.preheader30:                                     ; preds = %.preheader30.preheader, %._crit_edge
  %indvars.iv56 = phi i64 [ 0, %.preheader30.preheader ], [ %indvars.iv.next57, %._crit_edge ]
  %.02836 = phi i32 [ 0, %.preheader30.preheader ], [ %.1.lcssa, %._crit_edge ]
  %43 = getelementptr inbounds i32, ptr %2, i64 %indvars.iv56
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds i32, ptr %9, i64 %45
  %.promoted = load i32, ptr %46, align 4, !tbaa !5
  %47 = add nsw i32 %.promoted, -1
  %48 = icmp sgt i32 %.promoted, 0
  br i1 %48, label %.lr.ph34.preheader, label %._crit_edge

.lr.ph34.preheader:                               ; preds = %.preheader30
  %49 = sext i32 %.02836 to i64
  %50 = zext nneg i32 %.promoted to i64
  %min.iters.check = icmp ult i32 %.promoted, 8
  br i1 %min.iters.check, label %.lr.ph34.preheader91, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph34.preheader
  %n.vec = and i64 %50, 2147483640
  %ind.end = add nsw i64 %n.vec, %49
  %.cast = trunc nuw nsw i64 %n.vec to i32
  %ind.end69 = sub i32 %47, %.cast
  %broadcast.splatinsert = insertelement <4 x i32> poison, i32 %44, i64 0
  %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
  %invariant.gep = getelementptr i32, ptr %8, i64 %49
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %gep = getelementptr i32, ptr %invariant.gep, i64 %index
  %51 = getelementptr inbounds i8, ptr %gep, i64 16
  store <4 x i32> %broadcast.splat, ptr %gep, align 4, !tbaa !5
  store <4 x i32> %broadcast.splat, ptr %51, align 4, !tbaa !5
  %index.next = add nuw i64 %index, 8
  %52 = icmp eq i64 %index.next, %n.vec
  br i1 %52, label %middle.block, label %vector.body, !llvm.loop !13

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %50
  br i1 %cmp.n, label %._crit_edge.loopexit, label %.lr.ph34.preheader91

.lr.ph34.preheader91:                             ; preds = %middle.block, %.lr.ph34.preheader
  %indvars.iv53.ph = phi i64 [ %49, %.lr.ph34.preheader ], [ %ind.end, %middle.block ]
  %.ph92 = phi i32 [ %47, %.lr.ph34.preheader ], [ %ind.end69, %middle.block ]
  br label %.lr.ph34

.lr.ph34:                                         ; preds = %.lr.ph34.preheader91, %.lr.ph34
  %indvars.iv53 = phi i64 [ %indvars.iv.next54, %.lr.ph34 ], [ %indvars.iv53.ph, %.lr.ph34.preheader91 ]
  %53 = phi i32 [ %55, %.lr.ph34 ], [ %.ph92, %.lr.ph34.preheader91 ]
  %indvars.iv.next54 = add nsw i64 %indvars.iv53, 1
  %54 = getelementptr inbounds i32, ptr %8, i64 %indvars.iv53
  store i32 %44, ptr %54, align 4, !tbaa !5
  %55 = add nsw i32 %53, -1
  %.not = icmp eq i32 %53, 0
  br i1 %.not, label %._crit_edge.loopexit, label %.lr.ph34, !llvm.loop !16

._crit_edge.loopexit:                             ; preds = %.lr.ph34, %middle.block
  %indvars.iv.next54.lcssa = phi i64 [ %ind.end, %middle.block ], [ %indvars.iv.next54, %.lr.ph34 ]
  %56 = trunc nsw i64 %indvars.iv.next54.lcssa to i32
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader30
  %.lcssa = phi i32 [ %47, %.preheader30 ], [ -1, %._crit_edge.loopexit ]
  %.1.lcssa = phi i32 [ %.02836, %.preheader30 ], [ %56, %._crit_edge.loopexit ]
  store i32 %.lcssa, ptr %46, align 4, !tbaa !5
  %indvars.iv.next57 = add nuw nsw i64 %indvars.iv56, 1
  %exitcond60.not = icmp eq i64 %indvars.iv.next57, %wide.trip.count59
  br i1 %exitcond60.not, label %.preheader.preheader, label %.preheader30, !llvm.loop !17

.preheader.preheader:                             ; preds = %._crit_edge, %.preheader31
  %.246.ph = phi i32 [ 0, %.preheader31 ], [ %.1.lcssa, %._crit_edge ]
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %._crit_edge43
  %indvars.iv64 = phi i64 [ %indvars.iv.next65, %._crit_edge43 ], [ 0, %.preheader.preheader ]
  %.246 = phi i32 [ %.3.lcssa, %._crit_edge43 ], [ %.246.ph, %.preheader.preheader ]
  %57 = getelementptr inbounds i32, ptr %9, i64 %indvars.iv64
  %.promoted39 = load i32, ptr %57, align 4, !tbaa !5
  %58 = add nsw i32 %.promoted39, -1
  %59 = icmp sgt i32 %.promoted39, 0
  br i1 %59, label %.lr.ph42.preheader, label %._crit_edge43

.lr.ph42.preheader:                               ; preds = %.preheader
  %60 = sext i32 %.246 to i64
  %61 = trunc nuw nsw i64 %indvars.iv64 to i32
  %62 = zext nneg i32 %.promoted39 to i64
  %min.iters.check73 = icmp ult i32 %.promoted39, 8
  br i1 %min.iters.check73, label %.lr.ph42.preheader89, label %vector.ph74

.lr.ph42.preheader89:                             ; preds = %middle.block71, %.lr.ph42.preheader
  %indvars.iv61.ph = phi i64 [ %60, %.lr.ph42.preheader ], [ %ind.end77, %middle.block71 ]
  %.ph = phi i32 [ %58, %.lr.ph42.preheader ], [ %ind.end80, %middle.block71 ]
  br label %.lr.ph42

vector.ph74:                                      ; preds = %.lr.ph42.preheader
  %n.vec76 = and i64 %62, 2147483640
  %ind.end77 = add nsw i64 %n.vec76, %60
  %.cast79 = trunc nuw nsw i64 %n.vec76 to i32
  %ind.end80 = sub i32 %58, %.cast79
  %broadcast.splatinsert85 = insertelement <4 x i32> poison, i32 %61, i64 0
  %broadcast.splat86 = shufflevector <4 x i32> %broadcast.splatinsert85, <4 x i32> poison, <4 x i32> zeroinitializer
  %invariant.gep96 = getelementptr i32, ptr %8, i64 %60
  br label %vector.body82

vector.body82:                                    ; preds = %vector.body82, %vector.ph74
  %index83 = phi i64 [ 0, %vector.ph74 ], [ %index.next87, %vector.body82 ]
  %gep97 = getelementptr i32, ptr %invariant.gep96, i64 %index83
  %63 = getelementptr inbounds i8, ptr %gep97, i64 16
  store <4 x i32> %broadcast.splat86, ptr %gep97, align 4, !tbaa !5
  store <4 x i32> %broadcast.splat86, ptr %63, align 4, !tbaa !5
  %index.next87 = add nuw i64 %index83, 8
  %64 = icmp eq i64 %index.next87, %n.vec76
  br i1 %64, label %middle.block71, label %vector.body82, !llvm.loop !18

middle.block71:                                   ; preds = %vector.body82
  %cmp.n88 = icmp eq i64 %n.vec76, %62
  br i1 %cmp.n88, label %._crit_edge43.loopexit, label %.lr.ph42.preheader89

65:                                               ; preds = %._crit_edge43
  ret ptr %8

.lr.ph42:                                         ; preds = %.lr.ph42.preheader89, %.lr.ph42
  %indvars.iv61 = phi i64 [ %indvars.iv.next62, %.lr.ph42 ], [ %indvars.iv61.ph, %.lr.ph42.preheader89 ]
  %66 = phi i32 [ %68, %.lr.ph42 ], [ %.ph, %.lr.ph42.preheader89 ]
  %indvars.iv.next62 = add nsw i64 %indvars.iv61, 1
  %67 = getelementptr inbounds i32, ptr %8, i64 %indvars.iv61
  store i32 %61, ptr %67, align 4, !tbaa !5
  %68 = add nsw i32 %66, -1
  %.not68 = icmp eq i32 %66, 0
  br i1 %.not68, label %._crit_edge43.loopexit, label %.lr.ph42, !llvm.loop !19

._crit_edge43.loopexit:                           ; preds = %.lr.ph42, %middle.block71
  %indvars.iv.next62.lcssa = phi i64 [ %ind.end77, %middle.block71 ], [ %indvars.iv.next62, %.lr.ph42 ]
  %69 = trunc nsw i64 %indvars.iv.next62.lcssa to i32
  br label %._crit_edge43

._crit_edge43:                                    ; preds = %._crit_edge43.loopexit, %.preheader
  %.lcssa40 = phi i32 [ %58, %.preheader ], [ -1, %._crit_edge43.loopexit ]
  %.3.lcssa = phi i32 [ %.246, %.preheader ], [ %69, %._crit_edge43.loopexit ]
  store i32 %.lcssa40, ptr %57, align 4, !tbaa !5
  %indvars.iv.next65 = add nuw nsw i64 %indvars.iv64, 1
  %exitcond67.not = icmp eq i64 %indvars.iv.next65, 1001
  br i1 %exitcond67.not, label %65, label %.preheader, !llvm.loop !20
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #2

attributes #0 = { nofree 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 = { 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 #2 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) 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 #3 = { nounwind allocsize(0) }
attributes #4 = { nounwind allocsize(0,1) }

!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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.unroll.disable"}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12, !14, !15}
!14 = !{!"llvm.loop.isvectorized", i32 1}
!15 = !{!"llvm.loop.unroll.runtime.disable"}
!16 = distinct !{!16, !12, !15, !14}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12, !14, !15}
!19 = distinct !{!19, !12, !15, !14}
!20 = distinct !{!20, !12}


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