; LLVM IR from LeetCode-in-C/LeetCode-in-C :: src/main/c/g0301_0400/s0347_top_k_frequent_elements (Solution)

; 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 @topKFrequent(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %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
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !5
  %23 = load i32, ptr %6, align 4, !tbaa !9
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %28, label %25

25:                                               ; preds = %4
  %26 = load i32, ptr %7, align 4, !tbaa !9
  %27 = icmp eq i32 %26, 0
  br i1 %27, label %28, label %30

28:                                               ; preds = %25, %4
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  store i32 0, ptr %29, align 4, !tbaa !9
  br label %30

30:                                               ; preds = %28, %25
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 2147483647, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 -2147483648, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %31

31:                                               ; preds = %65, %30
  %32 = load i32, ptr %11, align 4, !tbaa !9
  %33 = load i32, ptr %6, align 4, !tbaa !9
  %34 = icmp slt i32 %32, %33
  br i1 %34, label %36, label %35

35:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %68

36:                                               ; preds = %31
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = load i32, ptr %11, align 4, !tbaa !9
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds i32, ptr %37, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !9
  %42 = load i32, ptr %9, align 4, !tbaa !9
  %43 = icmp slt i32 %41, %42
  br i1 %43, label %44, label %50

44:                                               ; preds = %36
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = load i32, ptr %11, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds i32, ptr %45, i64 %47
  %49 = load i32, ptr %48, align 4, !tbaa !9
  store i32 %49, ptr %9, align 4, !tbaa !9
  br label %50

50:                                               ; preds = %44, %36
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = load i32, ptr %11, align 4, !tbaa !9
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds i32, ptr %51, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !9
  %56 = load i32, ptr %10, align 4, !tbaa !9
  %57 = icmp sgt i32 %55, %56
  br i1 %57, label %58, label %64

58:                                               ; preds = %50
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = load i32, ptr %11, align 4, !tbaa !9
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds i32, ptr %59, i64 %61
  %63 = load i32, ptr %62, align 4, !tbaa !9
  store i32 %63, ptr %10, align 4, !tbaa !9
  br label %64

64:                                               ; preds = %58, %50
  br label %65

65:                                               ; preds = %64
  %66 = load i32, ptr %11, align 4, !tbaa !9
  %67 = add nsw i32 %66, 1
  store i32 %67, ptr %11, align 4, !tbaa !9
  br label %31, !llvm.loop !11

68:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %69 = load i32, ptr %10, align 4, !tbaa !9
  %70 = load i32, ptr %9, align 4, !tbaa !9
  %71 = sub nsw i32 %69, %70
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %73 = load i32, ptr %9, align 4, !tbaa !9
  %74 = sub nsw i32 0, %73
  store i32 %74, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %75 = load i32, ptr %12, align 4, !tbaa !9
  %76 = sext i32 %75 to i64
  %77 = mul i64 %76, 4
  %78 = call noalias ptr @malloc(i64 noundef %77) #5
  store ptr %78, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  store i32 0, ptr %15, align 4, !tbaa !9
  br label %79

79:                                               ; preds = %89, %68
  %80 = load i32, ptr %15, align 4, !tbaa !9
  %81 = load i32, ptr %12, align 4, !tbaa !9
  %82 = icmp slt i32 %80, %81
  br i1 %82, label %84, label %83

83:                                               ; preds = %79
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  br label %92

84:                                               ; preds = %79
  %85 = load ptr, ptr %14, align 8, !tbaa !5
  %86 = load i32, ptr %15, align 4, !tbaa !9
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds i32, ptr %85, i64 %87
  store i32 0, ptr %88, align 4, !tbaa !9
  br label %89

89:                                               ; preds = %84
  %90 = load i32, ptr %15, align 4, !tbaa !9
  %91 = add nsw i32 %90, 1
  store i32 %91, ptr %15, align 4, !tbaa !9
  br label %79, !llvm.loop !13

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

93:                                               ; preds = %111, %92
  %94 = load i32, ptr %16, align 4, !tbaa !9
  %95 = load i32, ptr %6, align 4, !tbaa !9
  %96 = icmp slt i32 %94, %95
  br i1 %96, label %98, label %97

97:                                               ; preds = %93
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  br label %114

98:                                               ; preds = %93
  %99 = load ptr, ptr %14, align 8, !tbaa !5
  %100 = load ptr, ptr %5, align 8, !tbaa !5
  %101 = load i32, ptr %16, align 4, !tbaa !9
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds i32, ptr %100, i64 %102
  %104 = load i32, ptr %103, align 4, !tbaa !9
  %105 = load i32, ptr %13, align 4, !tbaa !9
  %106 = add nsw i32 %104, %105
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds i32, ptr %99, i64 %107
  %109 = load i32, ptr %108, align 4, !tbaa !9
  %110 = add nsw i32 %109, 1
  store i32 %110, ptr %108, align 4, !tbaa !9
  br label %111

111:                                              ; preds = %98
  %112 = load i32, ptr %16, align 4, !tbaa !9
  %113 = add nsw i32 %112, 1
  store i32 %113, ptr %16, align 4, !tbaa !9
  br label %93, !llvm.loop !14

114:                                              ; preds = %97
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  %115 = load i32, ptr %7, align 4, !tbaa !9
  %116 = sext i32 %115 to i64
  %117 = mul i64 %116, 4
  %118 = call noalias ptr @malloc(i64 noundef %117) #5
  store ptr %118, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  store i32 0, ptr %18, align 4, !tbaa !9
  br label %119

119:                                              ; preds = %161, %114
  %120 = load i32, ptr %18, align 4, !tbaa !9
  %121 = load i32, ptr %7, align 4, !tbaa !9
  %122 = icmp slt i32 %120, %121
  br i1 %122, label %124, label %123

123:                                              ; preds = %119
  store i32 11, ptr %19, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  br label %164

124:                                              ; preds = %119
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #4
  store i32 -1, ptr %20, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #4
  store i32 -1, ptr %21, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #4
  store i32 0, ptr %22, align 4, !tbaa !9
  br label %125

125:                                              ; preds = %146, %124
  %126 = load i32, ptr %22, align 4, !tbaa !9
  %127 = load i32, ptr %12, align 4, !tbaa !9
  %128 = icmp slt i32 %126, %127
  br i1 %128, label %130, label %129

129:                                              ; preds = %125
  store i32 14, ptr %19, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #4
  br label %149

130:                                              ; preds = %125
  %131 = load ptr, ptr %14, align 8, !tbaa !5
  %132 = load i32, ptr %22, align 4, !tbaa !9
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds i32, ptr %131, i64 %133
  %135 = load i32, ptr %134, align 4, !tbaa !9
  %136 = load i32, ptr %20, align 4, !tbaa !9
  %137 = icmp sgt i32 %135, %136
  br i1 %137, label %138, label %145

138:                                              ; preds = %130
  %139 = load ptr, ptr %14, align 8, !tbaa !5
  %140 = load i32, ptr %22, align 4, !tbaa !9
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds i32, ptr %139, i64 %141
  %143 = load i32, ptr %142, align 4, !tbaa !9
  store i32 %143, ptr %20, align 4, !tbaa !9
  %144 = load i32, ptr %22, align 4, !tbaa !9
  store i32 %144, ptr %21, align 4, !tbaa !9
  br label %145

145:                                              ; preds = %138, %130
  br label %146

146:                                              ; preds = %145
  %147 = load i32, ptr %22, align 4, !tbaa !9
  %148 = add nsw i32 %147, 1
  store i32 %148, ptr %22, align 4, !tbaa !9
  br label %125, !llvm.loop !15

149:                                              ; preds = %129
  %150 = load i32, ptr %21, align 4, !tbaa !9
  %151 = load i32, ptr %13, align 4, !tbaa !9
  %152 = sub nsw i32 %150, %151
  %153 = load ptr, ptr %17, align 8, !tbaa !5
  %154 = load i32, ptr %18, align 4, !tbaa !9
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds i32, ptr %153, i64 %155
  store i32 %152, ptr %156, align 4, !tbaa !9
  %157 = load ptr, ptr %14, align 8, !tbaa !5
  %158 = load i32, ptr %21, align 4, !tbaa !9
  %159 = sext i32 %158 to i64
  %160 = getelementptr inbounds i32, ptr %157, i64 %159
  store i32 -1, ptr %160, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #4
  br label %161

161:                                              ; preds = %149
  %162 = load i32, ptr %18, align 4, !tbaa !9
  %163 = add nsw i32 %162, 1
  store i32 %163, ptr %18, align 4, !tbaa !9
  br label %119, !llvm.loop !16

164:                                              ; preds = %123
  %165 = load i32, ptr %7, align 4, !tbaa !9
  %166 = load ptr, ptr %8, align 8, !tbaa !5
  store i32 %165, ptr %166, align 4, !tbaa !9
  %167 = load ptr, ptr %14, align 8, !tbaa !5
  call void @free(ptr noundef %167) #4
  %168 = load ptr, ptr %17, align 8, !tbaa !5
  store i32 1, ptr %19, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  ret ptr %168
}

; 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

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

; Function Attrs: nounwind
declare void @free(ptr noundef) #3

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

!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: nounwind uwtable
define dso_local noalias noundef ptr @topKFrequent(ptr nocapture noundef readonly %0, i32 noundef %1, i32 noundef %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #0 {
  %5 = icmp eq i32 %1, 0
  %6 = icmp eq i32 %2, 0
  %or.cond = or i1 %5, %6
  br i1 %or.cond, label %7, label %8

7:                                                ; preds = %4
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %4, %7
  %9 = icmp sgt i32 %1, 0
  br i1 %9, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %8
  %wide.trip.count = zext nneg i32 %1 to i64
  %min.iters.check = icmp ult i32 %1, 8
  br i1 %min.iters.check, label %.lr.ph.preheader139, label %vector.ph

.lr.ph.preheader139:                              ; preds = %middle.block, %.lr.ph.preheader
  %indvars.iv.ph = phi i64 [ 0, %.lr.ph.preheader ], [ %n.vec, %middle.block ]
  %.05978.ph = phi i32 [ 2147483647, %.lr.ph.preheader ], [ %17, %middle.block ]
  %.06377.ph = phi i32 [ -2147483648, %.lr.ph.preheader ], [ %18, %middle.block ]
  br label %.lr.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %wide.trip.count, 2147483640
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <4 x i32> [ <i32 2147483647, i32 2147483647, i32 2147483647, i32 2147483647>, %vector.ph ], [ %12, %vector.body ]
  %vec.phi121 = phi <4 x i32> [ <i32 2147483647, i32 2147483647, i32 2147483647, i32 2147483647>, %vector.ph ], [ %13, %vector.body ]
  %vec.phi122 = phi <4 x i32> [ <i32 -2147483648, i32 -2147483648, i32 -2147483648, i32 -2147483648>, %vector.ph ], [ %14, %vector.body ]
  %vec.phi123 = phi <4 x i32> [ <i32 -2147483648, i32 -2147483648, i32 -2147483648, i32 -2147483648>, %vector.ph ], [ %15, %vector.body ]
  %10 = getelementptr inbounds i32, ptr %0, i64 %index
  %11 = getelementptr inbounds i8, ptr %10, i64 16
  %wide.load = load <4 x i32>, ptr %10, align 4, !tbaa !5
  %wide.load124 = load <4 x i32>, ptr %11, align 4, !tbaa !5
  %12 = tail call <4 x i32> @llvm.smin.v4i32(<4 x i32> %wide.load, <4 x i32> %vec.phi)
  %13 = tail call <4 x i32> @llvm.smin.v4i32(<4 x i32> %wide.load124, <4 x i32> %vec.phi121)
  %14 = tail call <4 x i32> @llvm.smax.v4i32(<4 x i32> %wide.load, <4 x i32> %vec.phi122)
  %15 = tail call <4 x i32> @llvm.smax.v4i32(<4 x i32> %wide.load124, <4 x i32> %vec.phi123)
  %index.next = add nuw i64 %index, 8
  %16 = icmp eq i64 %index.next, %n.vec
  br i1 %16, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %rdx.minmax = tail call <4 x i32> @llvm.smin.v4i32(<4 x i32> %12, <4 x i32> %13)
  %17 = tail call i32 @llvm.vector.reduce.smin.v4i32(<4 x i32> %rdx.minmax)
  %rdx.minmax125 = tail call <4 x i32> @llvm.smax.v4i32(<4 x i32> %14, <4 x i32> %15)
  %18 = tail call i32 @llvm.vector.reduce.smax.v4i32(<4 x i32> %rdx.minmax125)
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph.preheader139

._crit_edge:                                      ; preds = %.lr.ph, %middle.block, %8
  %.063.lcssa = phi i32 [ -2147483648, %8 ], [ %18, %middle.block ], [ %.164, %.lr.ph ]
  %.059.lcssa = phi i32 [ 2147483647, %8 ], [ %17, %middle.block ], [ %spec.select, %.lr.ph ]
  %19 = sub nsw i32 %.063.lcssa, %.059.lcssa
  %20 = add nsw i32 %19, 1
  %21 = sext i32 %20 to i64
  %22 = shl nsw i64 %21, 2
  %23 = tail call noalias ptr @malloc(i64 noundef %22) #5
  %.not80 = icmp slt i32 %19, 0
  br i1 %.not80, label %.preheader75, label %.lr.ph83.preheader

.lr.ph83.preheader:                               ; preds = %._crit_edge
  %24 = add i32 %.063.lcssa, 1
  %25 = sub i32 %24, %.059.lcssa
  %26 = zext i32 %25 to i64
  %27 = shl nuw nsw i64 %26, 2
  tail call void @llvm.memset.p0.i64(ptr align 4 %23, i8 0, i64 %27, i1 false), !tbaa !5
  br label %.preheader75

.lr.ph:                                           ; preds = %.lr.ph.preheader139, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %indvars.iv.ph, %.lr.ph.preheader139 ]
  %.05978 = phi i32 [ %spec.select, %.lr.ph ], [ %.05978.ph, %.lr.ph.preheader139 ]
  %.06377 = phi i32 [ %.164, %.lr.ph ], [ %.06377.ph, %.lr.ph.preheader139 ]
  %28 = getelementptr inbounds i32, ptr %0, i64 %indvars.iv
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %spec.select = tail call i32 @llvm.smin.i32(i32 %29, i32 %.05978)
  %.164 = tail call i32 @llvm.smax.i32(i32 %29, i32 %.06377)
  %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 !13

.preheader75:                                     ; preds = %.lr.ph83.preheader, %._crit_edge
  br i1 %9, label %.lr.ph85.preheader, label %._crit_edge86

.lr.ph85.preheader:                               ; preds = %.preheader75
  %wide.trip.count103 = zext nneg i32 %1 to i64
  %xtraiter = and i64 %wide.trip.count103, 1
  %30 = icmp eq i32 %1, 1
  br i1 %30, label %._crit_edge86.loopexit.unr-lcssa, label %.lr.ph85.preheader.new

.lr.ph85.preheader.new:                           ; preds = %.lr.ph85.preheader
  %unroll_iter = and i64 %wide.trip.count103, 2147483646
  br label %.lr.ph85

._crit_edge86.loopexit.unr-lcssa:                 ; preds = %.lr.ph85, %.lr.ph85.preheader
  %indvars.iv100.unr = phi i64 [ 0, %.lr.ph85.preheader ], [ %indvars.iv.next101.1, %.lr.ph85 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge86, label %.lr.ph85.epil

.lr.ph85.epil:                                    ; preds = %._crit_edge86.loopexit.unr-lcssa
  %31 = getelementptr inbounds i32, ptr %0, i64 %indvars.iv100.unr
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %33 = sub i32 %32, %.059.lcssa
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds i32, ptr %23, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %35, align 4, !tbaa !5
  br label %._crit_edge86

._crit_edge86:                                    ; preds = %.lr.ph85.epil, %._crit_edge86.loopexit.unr-lcssa, %.preheader75
  %38 = sext i32 %2 to i64
  %39 = shl nsw i64 %38, 2
  %40 = tail call noalias ptr @malloc(i64 noundef %39) #5
  %41 = icmp sgt i32 %2, 0
  br i1 %41, label %.preheader.lr.ph, label %._crit_edge95

.preheader.lr.ph:                                 ; preds = %._crit_edge86
  br i1 %.not80, label %.preheader.lr.ph.split.us, label %.preheader.preheader

.preheader.preheader:                             ; preds = %.preheader.lr.ph
  %42 = add i32 %.063.lcssa, 1
  %43 = sub i32 %42, %.059.lcssa
  %wide.trip.count113 = zext nneg i32 %2 to i64
  %wide.trip.count108 = zext i32 %43 to i64
  %44 = add nsw i64 %wide.trip.count108, -1
  %xtraiter143 = and i64 %wide.trip.count108, 3
  %45 = icmp ult i64 %44, 3
  %unroll_iter146 = and i64 %wide.trip.count108, 4294967292
  %lcmp.mod144.not = icmp eq i64 %xtraiter143, 0
  br label %.preheader

.preheader.lr.ph.split.us:                        ; preds = %.preheader.lr.ph
  %46 = add nsw i32 %.059.lcssa, -1
  %wide.trip.count118 = zext nneg i32 %2 to i64
  %min.iters.check129 = icmp ult i32 %2, 8
  br i1 %min.iters.check129, label %.preheader.us.preheader, label %vector.ph130

vector.ph130:                                     ; preds = %.preheader.lr.ph.split.us
  %n.vec132 = and i64 %wide.trip.count118, 2147483640
  %broadcast.splatinsert = insertelement <4 x i32> poison, i32 %46, i64 0
  %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
  br label %vector.body134

vector.body134:                                   ; preds = %vector.body134, %vector.ph130
  %index135 = phi i64 [ 0, %vector.ph130 ], [ %index.next136, %vector.body134 ]
  %47 = getelementptr inbounds i32, ptr %40, i64 %index135
  %48 = getelementptr inbounds i8, ptr %47, i64 16
  store <4 x i32> %broadcast.splat, ptr %47, align 4, !tbaa !5
  store <4 x i32> %broadcast.splat, ptr %48, align 4, !tbaa !5
  %index.next136 = add nuw i64 %index135, 8
  %49 = icmp eq i64 %index.next136, %n.vec132
  br i1 %49, label %middle.block127, label %vector.body134, !llvm.loop !14

middle.block127:                                  ; preds = %vector.body134
  %cmp.n137 = icmp eq i64 %n.vec132, %wide.trip.count118
  br i1 %cmp.n137, label %._crit_edge95, label %.preheader.us.preheader

.preheader.us.preheader:                          ; preds = %middle.block127, %.preheader.lr.ph.split.us
  %indvars.iv115.ph = phi i64 [ 0, %.preheader.lr.ph.split.us ], [ %n.vec132, %middle.block127 ]
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %.preheader.us
  %indvars.iv115 = phi i64 [ %indvars.iv.next116, %.preheader.us ], [ %indvars.iv115.ph, %.preheader.us.preheader ]
  %50 = getelementptr inbounds i32, ptr %40, i64 %indvars.iv115
  store i32 %46, ptr %50, align 4, !tbaa !5
  %indvars.iv.next116 = add nuw nsw i64 %indvars.iv115, 1
  %exitcond119.not = icmp eq i64 %indvars.iv.next116, %wide.trip.count118
  br i1 %exitcond119.not, label %._crit_edge95, label %.preheader.us, !llvm.loop !15

.lr.ph85:                                         ; preds = %.lr.ph85, %.lr.ph85.preheader.new
  %indvars.iv100 = phi i64 [ 0, %.lr.ph85.preheader.new ], [ %indvars.iv.next101.1, %.lr.ph85 ]
  %niter = phi i64 [ 0, %.lr.ph85.preheader.new ], [ %niter.next.1, %.lr.ph85 ]
  %51 = getelementptr inbounds i32, ptr %0, i64 %indvars.iv100
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = sub i32 %52, %.059.lcssa
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds i32, ptr %23, i64 %54
  %56 = load i32, ptr %55, align 4, !tbaa !5
  %57 = add nsw i32 %56, 1
  store i32 %57, ptr %55, align 4, !tbaa !5
  %indvars.iv.next101 = or disjoint i64 %indvars.iv100, 1
  %58 = getelementptr inbounds i32, ptr %0, i64 %indvars.iv.next101
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %60 = sub i32 %59, %.059.lcssa
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds i32, ptr %23, i64 %61
  %63 = load i32, ptr %62, align 4, !tbaa !5
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %62, align 4, !tbaa !5
  %indvars.iv.next101.1 = add nuw nsw i64 %indvars.iv100, 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_edge86.loopexit.unr-lcssa, label %.lr.ph85, !llvm.loop !16

.preheader:                                       ; preds = %.preheader.preheader, %._crit_edge92
  %indvars.iv110 = phi i64 [ 0, %.preheader.preheader ], [ %indvars.iv.next111, %._crit_edge92 ]
  br i1 %45, label %._crit_edge92.unr-lcssa, label %.preheader.new

._crit_edge95:                                    ; preds = %._crit_edge92, %.preheader.us, %middle.block127, %._crit_edge86
  store i32 %2, ptr %3, align 4, !tbaa !5
  tail call void @free(ptr noundef %23) #6
  ret ptr %40

._crit_edge92.unr-lcssa:                          ; preds = %.preheader.new, %.preheader
  %spec.select74.lcssa.ph = phi i32 [ poison, %.preheader ], [ %spec.select74.3, %.preheader.new ]
  %indvars.iv105.unr = phi i64 [ 0, %.preheader ], [ %indvars.iv.next106.3, %.preheader.new ]
  %.05589.unr = phi i32 [ -1, %.preheader ], [ %spec.select74.3, %.preheader.new ]
  %.05688.unr = phi i32 [ -1, %.preheader ], [ %spec.select73.3, %.preheader.new ]
  br i1 %lcmp.mod144.not, label %._crit_edge92, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge92.unr-lcssa, %.epil.preheader
  %indvars.iv105.epil = phi i64 [ %indvars.iv.next106.epil, %.epil.preheader ], [ %indvars.iv105.unr, %._crit_edge92.unr-lcssa ]
  %.05589.epil = phi i32 [ %spec.select74.epil, %.epil.preheader ], [ %.05589.unr, %._crit_edge92.unr-lcssa ]
  %.05688.epil = phi i32 [ %spec.select73.epil, %.epil.preheader ], [ %.05688.unr, %._crit_edge92.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.epil.preheader ], [ 0, %._crit_edge92.unr-lcssa ]
  %65 = getelementptr inbounds i32, ptr %23, i64 %indvars.iv105.epil
  %66 = load i32, ptr %65, align 4, !tbaa !5
  %67 = icmp sgt i32 %66, %.05688.epil
  %spec.select73.epil = tail call i32 @llvm.smax.i32(i32 %66, i32 %.05688.epil)
  %68 = trunc nuw nsw i64 %indvars.iv105.epil to i32
  %spec.select74.epil = select i1 %67, i32 %68, i32 %.05589.epil
  %indvars.iv.next106.epil = add nuw nsw i64 %indvars.iv105.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter143
  br i1 %epil.iter.cmp.not, label %._crit_edge92, label %.epil.preheader, !llvm.loop !17

._crit_edge92:                                    ; preds = %.epil.preheader, %._crit_edge92.unr-lcssa
  %spec.select74.lcssa = phi i32 [ %spec.select74.lcssa.ph, %._crit_edge92.unr-lcssa ], [ %spec.select74.epil, %.epil.preheader ]
  %69 = add nsw i32 %spec.select74.lcssa, %.059.lcssa
  %70 = getelementptr inbounds i32, ptr %40, i64 %indvars.iv110
  store i32 %69, ptr %70, align 4, !tbaa !5
  %71 = sext i32 %spec.select74.lcssa to i64
  %72 = getelementptr inbounds i32, ptr %23, i64 %71
  store i32 -1, ptr %72, align 4, !tbaa !5
  %indvars.iv.next111 = add nuw nsw i64 %indvars.iv110, 1
  %exitcond114.not = icmp eq i64 %indvars.iv.next111, %wide.trip.count113
  br i1 %exitcond114.not, label %._crit_edge95, label %.preheader, !llvm.loop !19

.preheader.new:                                   ; preds = %.preheader, %.preheader.new
  %indvars.iv105 = phi i64 [ %indvars.iv.next106.3, %.preheader.new ], [ 0, %.preheader ]
  %.05589 = phi i32 [ %spec.select74.3, %.preheader.new ], [ -1, %.preheader ]
  %.05688 = phi i32 [ %spec.select73.3, %.preheader.new ], [ -1, %.preheader ]
  %niter147 = phi i64 [ %niter147.next.3, %.preheader.new ], [ 0, %.preheader ]
  %73 = getelementptr inbounds i32, ptr %23, i64 %indvars.iv105
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %75 = icmp sgt i32 %74, %.05688
  %spec.select73 = tail call i32 @llvm.smax.i32(i32 %74, i32 %.05688)
  %76 = trunc nuw nsw i64 %indvars.iv105 to i32
  %spec.select74 = select i1 %75, i32 %76, i32 %.05589
  %indvars.iv.next106 = or disjoint i64 %indvars.iv105, 1
  %77 = getelementptr inbounds i32, ptr %23, i64 %indvars.iv.next106
  %78 = load i32, ptr %77, align 4, !tbaa !5
  %79 = icmp sgt i32 %78, %spec.select73
  %spec.select73.1 = tail call i32 @llvm.smax.i32(i32 %78, i32 %spec.select73)
  %80 = trunc nuw nsw i64 %indvars.iv.next106 to i32
  %spec.select74.1 = select i1 %79, i32 %80, i32 %spec.select74
  %indvars.iv.next106.1 = or disjoint i64 %indvars.iv105, 2
  %81 = getelementptr inbounds i32, ptr %23, i64 %indvars.iv.next106.1
  %82 = load i32, ptr %81, align 4, !tbaa !5
  %83 = icmp sgt i32 %82, %spec.select73.1
  %spec.select73.2 = tail call i32 @llvm.smax.i32(i32 %82, i32 %spec.select73.1)
  %84 = trunc nuw nsw i64 %indvars.iv.next106.1 to i32
  %spec.select74.2 = select i1 %83, i32 %84, i32 %spec.select74.1
  %indvars.iv.next106.2 = or disjoint i64 %indvars.iv105, 3
  %85 = getelementptr inbounds i32, ptr %23, i64 %indvars.iv.next106.2
  %86 = load i32, ptr %85, align 4, !tbaa !5
  %87 = icmp sgt i32 %86, %spec.select73.2
  %spec.select73.3 = tail call i32 @llvm.smax.i32(i32 %86, i32 %spec.select73.2)
  %88 = trunc nuw nsw i64 %indvars.iv.next106.2 to i32
  %spec.select74.3 = select i1 %87, i32 %88, i32 %spec.select74.2
  %indvars.iv.next106.3 = add nuw nsw i64 %indvars.iv105, 4
  %niter147.next.3 = add i64 %niter147, 4
  %niter147.ncmp.3 = icmp eq i64 %niter147.next.3, %unroll_iter146
  br i1 %niter147.ncmp.3, label %._crit_edge92.unr-lcssa, label %.preheader.new, !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 nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #3

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <4 x i32> @llvm.smin.v4i32(<4 x i32>, <4 x i32>) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <4 x i32> @llvm.smax.v4i32(<4 x i32>, <4 x i32>) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.vector.reduce.smin.v4i32(<4 x i32>) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.vector.reduce.smax.v4i32(<4 x i32>) #3

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 = { 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 nounwind willreturn allockind("free") memory(argmem: readwrite, 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nounwind allocsize(0) }
attributes #6 = { 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 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10, !12, !11}
!14 = distinct !{!14, !10, !11, !12}
!15 = distinct !{!15, !10, !12, !11}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.unroll.disable"}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10}


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