; LLVM IR from Seeed-Studio/Seeed_Arduino_edgeimpulse :: src/edge-impulse-sdk/CMSIS/NN/Source/SoftmaxFunctions (arm_softmax_s8)

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

27:                                               ; preds = %179, %7
  %28 = load i32, ptr %17, align 4, !tbaa !9
  %29 = load i32, ptr %9, align 4, !tbaa !9
  %30 = icmp slt i32 %28, %29
  br i1 %30, label %31, label %182

31:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 1, ptr %18) #3
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = load i8, ptr %32, align 1, !tbaa !11
  store i8 %33, ptr %18, align 1, !tbaa !11
  store i32 1, ptr %16, align 4, !tbaa !9
  br label %34

34:                                               ; preds = %61, %31
  %35 = load i32, ptr %16, align 4, !tbaa !9
  %36 = load i32, ptr %10, align 4, !tbaa !9
  %37 = icmp slt i32 %35, %36
  br i1 %37, label %38, label %64

38:                                               ; preds = %34
  %39 = load i8, ptr %18, align 1, !tbaa !11
  %40 = sext i8 %39 to i32
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = load i32, ptr %16, align 4, !tbaa !9
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds i8, ptr %41, i64 %43
  %45 = load i8, ptr %44, align 1, !tbaa !11
  %46 = sext i8 %45 to i32
  %47 = icmp sgt i32 %40, %46
  br i1 %47, label %48, label %51

48:                                               ; preds = %38
  %49 = load i8, ptr %18, align 1, !tbaa !11
  %50 = sext i8 %49 to i32
  br label %58

51:                                               ; preds = %38
  %52 = load ptr, ptr %8, align 8, !tbaa !5
  %53 = load i32, ptr %16, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds i8, ptr %52, i64 %54
  %56 = load i8, ptr %55, align 1, !tbaa !11
  %57 = sext i8 %56 to i32
  br label %58

58:                                               ; preds = %51, %48
  %59 = phi i32 [ %50, %48 ], [ %57, %51 ]
  %60 = trunc i32 %59 to i8
  store i8 %60, ptr %18, align 1, !tbaa !11
  br label %61

61:                                               ; preds = %58
  %62 = load i32, ptr %16, align 4, !tbaa !9
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %16, align 4, !tbaa !9
  br label %34, !llvm.loop !12

64:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  store i32 0, ptr %19, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #3
  store i32 0, ptr %20, align 4, !tbaa !9
  store i32 0, ptr %16, align 4, !tbaa !9
  br label %65

65:                                               ; preds = %93, %64
  %66 = load i32, ptr %16, align 4, !tbaa !9
  %67 = load i32, ptr %10, align 4, !tbaa !9
  %68 = icmp slt i32 %66, %67
  br i1 %68, label %69, label %96

69:                                               ; preds = %65
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  %71 = load i32, ptr %16, align 4, !tbaa !9
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds i8, ptr %70, i64 %72
  %74 = load i8, ptr %73, align 1, !tbaa !11
  %75 = sext i8 %74 to i32
  %76 = load i8, ptr %18, align 1, !tbaa !11
  %77 = sext i8 %76 to i32
  %78 = sub nsw i32 %75, %77
  store i32 %78, ptr %19, align 4, !tbaa !9
  %79 = load i32, ptr %19, align 4, !tbaa !9
  %80 = load i32, ptr %13, align 4, !tbaa !9
  %81 = icmp sge i32 %79, %80
  br i1 %81, label %82, label %92

82:                                               ; preds = %69
  %83 = load i32, ptr %19, align 4, !tbaa !9
  %84 = load i32, ptr %15, align 4, !tbaa !9
  %85 = mul nsw i32 %83, %84
  %86 = load i32, ptr %11, align 4, !tbaa !9
  %87 = call i32 @arm_nn_sat_doubling_high_mult(i32 noundef %85, i32 noundef %86)
  %88 = call i32 @arm_nn_exp_on_negative_values(i32 noundef %87)
  %89 = call i32 @arm_nn_divide_by_power_of_two(i32 noundef %88, i32 noundef 12)
  %90 = load i32, ptr %20, align 4, !tbaa !9
  %91 = add nsw i32 %90, %89
  store i32 %91, ptr %20, align 4, !tbaa !9
  br label %92

92:                                               ; preds = %82, %69
  br label %93

93:                                               ; preds = %92
  %94 = load i32, ptr %16, align 4, !tbaa !9
  %95 = add nsw i32 %94, 1
  store i32 %95, ptr %16, align 4, !tbaa !9
  br label %65, !llvm.loop !14

96:                                               ; preds = %65
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #3
  %97 = load i32, ptr %20, align 4, !tbaa !9
  %98 = call zeroext i8 @__CLZ(i32 noundef %97)
  %99 = zext i8 %98 to i32
  store i32 %99, ptr %21, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #3
  %100 = load i32, ptr %21, align 4, !tbaa !9
  %101 = sub nsw i32 12, %100
  %102 = add nsw i32 %101, 23
  store i32 %102, ptr %22, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #3
  %103 = load i32, ptr %20, align 4, !tbaa !9
  %104 = load i32, ptr %21, align 4, !tbaa !9
  %105 = shl i32 %103, %104
  %106 = sub nsw i32 %105, -2147483648
  %107 = call i32 @arm_nn_one_over_one_plus_x_for_x_in_0_1(i32 noundef %106)
  store i32 %107, ptr %23, align 4, !tbaa !9
  store i32 0, ptr %16, align 4, !tbaa !9
  br label %108

108:                                              ; preds = %167, %96
  %109 = load i32, ptr %16, align 4, !tbaa !9
  %110 = load i32, ptr %10, align 4, !tbaa !9
  %111 = icmp slt i32 %109, %110
  br i1 %111, label %112, label %170

112:                                              ; preds = %108
  %113 = load ptr, ptr %8, align 8, !tbaa !5
  %114 = load i32, ptr %16, align 4, !tbaa !9
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds i8, ptr %113, i64 %115
  %117 = load i8, ptr %116, align 1, !tbaa !11
  %118 = sext i8 %117 to i32
  %119 = load i8, ptr %18, align 1, !tbaa !11
  %120 = sext i8 %119 to i32
  %121 = sub nsw i32 %118, %120
  store i32 %121, ptr %19, align 4, !tbaa !9
  %122 = load i32, ptr %19, align 4, !tbaa !9
  %123 = load i32, ptr %13, align 4, !tbaa !9
  %124 = icmp sge i32 %122, %123
  br i1 %124, label %125, label %161

125:                                              ; preds = %112
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #3
  %126 = load i32, ptr %23, align 4, !tbaa !9
  %127 = load i32, ptr %19, align 4, !tbaa !9
  %128 = load i32, ptr %15, align 4, !tbaa !9
  %129 = mul nsw i32 %127, %128
  %130 = load i32, ptr %11, align 4, !tbaa !9
  %131 = call i32 @arm_nn_sat_doubling_high_mult(i32 noundef %129, i32 noundef %130)
  %132 = call i32 @arm_nn_exp_on_negative_values(i32 noundef %131)
  %133 = call i32 @arm_nn_sat_doubling_high_mult(i32 noundef %126, i32 noundef %132)
  %134 = load i32, ptr %22, align 4, !tbaa !9
  %135 = call i32 @arm_nn_divide_by_power_of_two(i32 noundef %133, i32 noundef %134)
  %136 = sub nsw i32 %135, 128
  store i32 %136, ptr %24, align 4, !tbaa !9
  %137 = load i32, ptr %24, align 4, !tbaa !9
  %138 = icmp slt i32 %137, 127
  br i1 %138, label %139, label %141

139:                                              ; preds = %125
  %140 = load i32, ptr %24, align 4, !tbaa !9
  br label %142

141:                                              ; preds = %125
  br label %142

142:                                              ; preds = %141, %139
  %143 = phi i32 [ %140, %139 ], [ 127, %141 ]
  %144 = icmp sgt i32 %143, -128
  br i1 %144, label %145, label %153

145:                                              ; preds = %142
  %146 = load i32, ptr %24, align 4, !tbaa !9
  %147 = icmp slt i32 %146, 127
  br i1 %147, label %148, label %150

148:                                              ; preds = %145
  %149 = load i32, ptr %24, align 4, !tbaa !9
  br label %151

150:                                              ; preds = %145
  br label %151

151:                                              ; preds = %150, %148
  %152 = phi i32 [ %149, %148 ], [ 127, %150 ]
  br label %154

153:                                              ; preds = %142
  br label %154

154:                                              ; preds = %153, %151
  %155 = phi i32 [ %152, %151 ], [ -128, %153 ]
  %156 = trunc i32 %155 to i8
  %157 = load ptr, ptr %14, align 8, !tbaa !5
  %158 = load i32, ptr %16, align 4, !tbaa !9
  %159 = sext i32 %158 to i64
  %160 = getelementptr inbounds i8, ptr %157, i64 %159
  store i8 %156, ptr %160, align 1, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #3
  br label %166

161:                                              ; preds = %112
  %162 = load ptr, ptr %14, align 8, !tbaa !5
  %163 = load i32, ptr %16, align 4, !tbaa !9
  %164 = sext i32 %163 to i64
  %165 = getelementptr inbounds i8, ptr %162, i64 %164
  store i8 -128, ptr %165, align 1, !tbaa !11
  br label %166

166:                                              ; preds = %161, %154
  br label %167

167:                                              ; preds = %166
  %168 = load i32, ptr %16, align 4, !tbaa !9
  %169 = add nsw i32 %168, 1
  store i32 %169, ptr %16, align 4, !tbaa !9
  br label %108, !llvm.loop !15

170:                                              ; preds = %108
  %171 = load i32, ptr %10, align 4, !tbaa !9
  %172 = load ptr, ptr %8, align 8, !tbaa !5
  %173 = sext i32 %171 to i64
  %174 = getelementptr inbounds i8, ptr %172, i64 %173
  store ptr %174, ptr %8, align 8, !tbaa !5
  %175 = load i32, ptr %10, align 4, !tbaa !9
  %176 = load ptr, ptr %14, align 8, !tbaa !5
  %177 = sext i32 %175 to i64
  %178 = getelementptr inbounds i8, ptr %176, i64 %177
  store ptr %178, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %18) #3
  br label %179

179:                                              ; preds = %170
  %180 = load i32, ptr %17, align 4, !tbaa !9
  %181 = add nsw i32 %180, 1
  store i32 %181, ptr %17, align 4, !tbaa !9
  br label %27, !llvm.loop !16

182:                                              ; preds = %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  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: alwaysinline nounwind uwtable
declare hidden i32 @arm_nn_divide_by_power_of_two(i32 noundef, i32 noundef) #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @arm_nn_exp_on_negative_values(i32 noundef) #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @arm_nn_sat_doubling_high_mult(i32 noundef, i32 noundef) #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden zeroext i8 @__CLZ(i32 noundef) #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @arm_nn_one_over_one_plus_x_for_x_in_0_1(i32 noundef) #2

; 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 = { alwaysinline 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 }

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


; 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 void @arm_softmax_s8(ptr nocapture noundef readonly %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, ptr nocapture noundef writeonly %6) local_unnamed_addr #0 {
  %8 = icmp sgt i32 %1, 0
  br i1 %8, label %.lr.ph80, label %._crit_edge81

.lr.ph80:                                         ; preds = %7
  %9 = icmp sgt i32 %2, 1
  %10 = icmp sgt i32 %2, 0
  %11 = sext i32 %2 to i64
  br i1 %10, label %.lr.ph80.split.us.preheader, label %.preheader

.lr.ph80.split.us.preheader:                      ; preds = %.lr.ph80
  %wide.trip.count = zext nneg i32 %2 to i64
  %wide.trip.count115 = zext nneg i32 %2 to i64
  %12 = add nsw i64 %wide.trip.count, -1
  %min.iters.check = icmp ult i32 %2, 9
  %min.iters.check126 = icmp ult i32 %2, 33
  %n.vec = and i64 %12, -32
  %cmp.n = icmp eq i64 %12, %n.vec
  %ind.end131 = or disjoint i64 %n.vec, 1
  %n.vec.remaining = and i64 %12, 24
  %min.epilog.iters.check = icmp eq i64 %n.vec.remaining, 0
  %n.vec130 = and i64 %12, -8
  %ind.end = or disjoint i64 %n.vec130, 1
  %cmp.n139 = icmp eq i64 %12, %n.vec130
  br label %.lr.ph80.split.us

.lr.ph80.split.us:                                ; preds = %.lr.ph80.split.us.preheader, %._crit_edge75.us
  %.078.us = phi ptr [ %62, %._crit_edge75.us ], [ %0, %.lr.ph80.split.us.preheader ]
  %.05477.us = phi ptr [ %63, %._crit_edge75.us ], [ %6, %.lr.ph80.split.us.preheader ]
  %.05676.us = phi i32 [ %64, %._crit_edge75.us ], [ 0, %.lr.ph80.split.us.preheader ]
  %13 = load i8, ptr %.078.us, align 1, !tbaa !5
  br i1 %9, label %iter.check, label %.lr.ph70.us

iter.check:                                       ; preds = %.lr.ph80.split.us
  br i1 %min.iters.check, label %.lr.ph.us.preheader, label %vector.main.loop.iter.check

vector.main.loop.iter.check:                      ; preds = %iter.check
  br i1 %min.iters.check126, label %vec.epilog.ph, label %vector.ph

vector.ph:                                        ; preds = %vector.main.loop.iter.check
  %minmax.ident.splatinsert = insertelement <16 x i8> poison, i8 %13, i64 0
  %minmax.ident.splat = shufflevector <16 x i8> %minmax.ident.splatinsert, <16 x i8> poison, <16 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <16 x i8> [ %minmax.ident.splat, %vector.ph ], [ %16, %vector.body ]
  %vec.phi127 = phi <16 x i8> [ %minmax.ident.splat, %vector.ph ], [ %17, %vector.body ]
  %offset.idx = or disjoint i64 %index, 1
  %14 = getelementptr inbounds i8, ptr %.078.us, i64 %offset.idx
  %15 = getelementptr inbounds i8, ptr %14, i64 16
  %wide.load = load <16 x i8>, ptr %14, align 1, !tbaa !5
  %wide.load128 = load <16 x i8>, ptr %15, align 1, !tbaa !5
  %16 = tail call <16 x i8> @llvm.smax.v16i8(<16 x i8> %vec.phi, <16 x i8> %wide.load)
  %17 = tail call <16 x i8> @llvm.smax.v16i8(<16 x i8> %vec.phi127, <16 x i8> %wide.load128)
  %index.next = add nuw i64 %index, 32
  %18 = icmp eq i64 %index.next, %n.vec
  br i1 %18, label %middle.block, label %vector.body, !llvm.loop !8

middle.block:                                     ; preds = %vector.body
  %rdx.minmax = tail call <16 x i8> @llvm.smax.v16i8(<16 x i8> %16, <16 x i8> %17)
  %19 = tail call i8 @llvm.vector.reduce.smax.v16i8(<16 x i8> %rdx.minmax)
  br i1 %cmp.n, label %.lr.ph70.us, label %vec.epilog.iter.check

vec.epilog.iter.check:                            ; preds = %middle.block
  br i1 %min.epilog.iters.check, label %.lr.ph.us.preheader, label %vec.epilog.ph

.lr.ph.us.preheader:                              ; preds = %vec.epilog.middle.block, %iter.check, %vec.epilog.iter.check
  %indvars.iv.ph = phi i64 [ 1, %iter.check ], [ %ind.end131, %vec.epilog.iter.check ], [ %ind.end, %vec.epilog.middle.block ]
  %.05966.us.ph = phi i8 [ %13, %iter.check ], [ %19, %vec.epilog.iter.check ], [ %23, %vec.epilog.middle.block ]
  br label %.lr.ph.us

vec.epilog.ph:                                    ; preds = %vector.main.loop.iter.check, %vec.epilog.iter.check
  %bc.merge.rdx = phi i8 [ %19, %vec.epilog.iter.check ], [ %13, %vector.main.loop.iter.check ]
  %vec.epilog.resume.val = phi i64 [ %n.vec, %vec.epilog.iter.check ], [ 0, %vector.main.loop.iter.check ]
  %minmax.ident.splatinsert134 = insertelement <8 x i8> poison, i8 %bc.merge.rdx, i64 0
  %minmax.ident.splat135 = shufflevector <8 x i8> %minmax.ident.splatinsert134, <8 x i8> poison, <8 x i32> zeroinitializer
  br label %vec.epilog.vector.body

vec.epilog.vector.body:                           ; preds = %vec.epilog.vector.body, %vec.epilog.ph
  %index132 = phi i64 [ %vec.epilog.resume.val, %vec.epilog.ph ], [ %index.next138, %vec.epilog.vector.body ]
  %vec.phi133 = phi <8 x i8> [ %minmax.ident.splat135, %vec.epilog.ph ], [ %21, %vec.epilog.vector.body ]
  %offset.idx136 = or disjoint i64 %index132, 1
  %20 = getelementptr inbounds i8, ptr %.078.us, i64 %offset.idx136
  %wide.load137 = load <8 x i8>, ptr %20, align 1, !tbaa !5
  %21 = tail call <8 x i8> @llvm.smax.v8i8(<8 x i8> %vec.phi133, <8 x i8> %wide.load137)
  %index.next138 = add nuw i64 %index132, 8
  %22 = icmp eq i64 %index.next138, %n.vec130
  br i1 %22, label %vec.epilog.middle.block, label %vec.epilog.vector.body, !llvm.loop !12

vec.epilog.middle.block:                          ; preds = %vec.epilog.vector.body
  %23 = tail call i8 @llvm.vector.reduce.smax.v8i8(<8 x i8> %21)
  br i1 %cmp.n139, label %.lr.ph70.us, label %.lr.ph.us.preheader

.lr.ph74.us:                                      ; preds = %58
  %24 = tail call zeroext i8 @__CLZ(i32 noundef %.158.us)
  %25 = zext i8 %24 to i32
  %26 = sub nsw i32 35, %25
  %27 = shl i32 %.158.us, %25
  %28 = xor i32 %27, -2147483648
  %29 = tail call i32 @arm_nn_one_over_one_plus_x_for_x_in_0_1(i32 noundef %28)
  br label %30

30:                                               ; preds = %.lr.ph74.us, %45
  %indvars.iv117 = phi i64 [ 0, %.lr.ph74.us ], [ %indvars.iv.next118, %45 ]
  %31 = getelementptr inbounds i8, ptr %.078.us, i64 %indvars.iv117
  %32 = load i8, ptr %31, align 1, !tbaa !5
  %33 = sext i8 %32 to i32
  %34 = sub nsw i32 %33, %61
  %.not.us = icmp slt i32 %34, %5
  br i1 %.not.us, label %45, label %35

35:                                               ; preds = %30
  %36 = shl i32 %34, %4
  %37 = tail call i32 @arm_nn_sat_doubling_high_mult(i32 noundef %36, i32 noundef %3)
  %38 = tail call i32 @arm_nn_exp_on_negative_values(i32 noundef %37)
  %39 = tail call i32 @arm_nn_sat_doubling_high_mult(i32 noundef %29, i32 noundef %38)
  %40 = tail call i32 @arm_nn_divide_by_power_of_two(i32 noundef %39, i32 noundef %26)
  %41 = tail call i32 @llvm.smin.i32(i32 %40, i32 255)
  %42 = tail call i32 @llvm.smax.i32(i32 %41, i32 0)
  %43 = trunc nuw i32 %42 to i8
  %44 = xor i8 %43, -128
  br label %45

45:                                               ; preds = %30, %35
  %.sink = phi i8 [ %44, %35 ], [ -128, %30 ]
  %46 = getelementptr inbounds i8, ptr %.05477.us, i64 %indvars.iv117
  store i8 %.sink, ptr %46, align 1
  %indvars.iv.next118 = add nuw nsw i64 %indvars.iv117, 1
  %exitcond121.not = icmp eq i64 %indvars.iv.next118, %wide.trip.count115
  br i1 %exitcond121.not, label %._crit_edge75.us, label %30, !llvm.loop !13

47:                                               ; preds = %.lr.ph70.us, %58
  %indvars.iv112 = phi i64 [ 0, %.lr.ph70.us ], [ %indvars.iv.next113, %58 ]
  %.05768.us = phi i32 [ 0, %.lr.ph70.us ], [ %.158.us, %58 ]
  %48 = getelementptr inbounds i8, ptr %.078.us, i64 %indvars.iv112
  %49 = load i8, ptr %48, align 1, !tbaa !5
  %50 = sext i8 %49 to i32
  %51 = sub nsw i32 %50, %61
  %.not65.us = icmp slt i32 %51, %5
  br i1 %.not65.us, label %58, label %52

52:                                               ; preds = %47
  %53 = shl i32 %51, %4
  %54 = tail call i32 @arm_nn_sat_doubling_high_mult(i32 noundef %53, i32 noundef %3)
  %55 = tail call i32 @arm_nn_exp_on_negative_values(i32 noundef %54)
  %56 = tail call i32 @arm_nn_divide_by_power_of_two(i32 noundef %55, i32 noundef 12)
  %57 = add nsw i32 %56, %.05768.us
  br label %58

58:                                               ; preds = %52, %47
  %.158.us = phi i32 [ %57, %52 ], [ %.05768.us, %47 ]
  %indvars.iv.next113 = add nuw nsw i64 %indvars.iv112, 1
  %exitcond116.not = icmp eq i64 %indvars.iv.next113, %wide.trip.count115
  br i1 %exitcond116.not, label %.lr.ph74.us, label %47, !llvm.loop !14

.lr.ph.us:                                        ; preds = %.lr.ph.us.preheader, %.lr.ph.us
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph.us ], [ %indvars.iv.ph, %.lr.ph.us.preheader ]
  %.05966.us = phi i8 [ %.059..us, %.lr.ph.us ], [ %.05966.us.ph, %.lr.ph.us.preheader ]
  %59 = getelementptr inbounds i8, ptr %.078.us, i64 %indvars.iv
  %60 = load i8, ptr %59, align 1, !tbaa !5
  %.059..us = tail call i8 @llvm.smax.i8(i8 %.05966.us, i8 %60)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond111.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond111.not, label %.lr.ph70.us, label %.lr.ph.us, !llvm.loop !15

.lr.ph70.us:                                      ; preds = %.lr.ph.us, %middle.block, %vec.epilog.middle.block, %.lr.ph80.split.us
  %.059.lcssa.us = phi i8 [ %13, %.lr.ph80.split.us ], [ %19, %middle.block ], [ %23, %vec.epilog.middle.block ], [ %.059..us, %.lr.ph.us ]
  %61 = sext i8 %.059.lcssa.us to i32
  br label %47

._crit_edge75.us:                                 ; preds = %45
  %62 = getelementptr inbounds i8, ptr %.078.us, i64 %11
  %63 = getelementptr inbounds i8, ptr %.05477.us, i64 %11
  %64 = add nuw nsw i32 %.05676.us, 1
  %exitcond122.not = icmp eq i32 %64, %1
  br i1 %exitcond122.not, label %._crit_edge81, label %.lr.ph80.split.us, !llvm.loop !16

.preheader:                                       ; preds = %.lr.ph80, %.preheader
  %.05676 = phi i32 [ %67, %.preheader ], [ 0, %.lr.ph80 ]
  %65 = tail call zeroext i8 @__CLZ(i32 noundef 0)
  %66 = tail call i32 @arm_nn_one_over_one_plus_x_for_x_in_0_1(i32 noundef -2147483648)
  %67 = add nuw nsw i32 %.05676, 1
  %exitcond.not = icmp eq i32 %67, %1
  br i1 %exitcond.not, label %._crit_edge81, label %.preheader, !llvm.loop !16

._crit_edge81:                                    ; preds = %.preheader, %._crit_edge75.us, %7
  ret void
}

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @arm_nn_divide_by_power_of_two(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @arm_nn_exp_on_negative_values(i32 noundef) local_unnamed_addr #1

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @arm_nn_sat_doubling_high_mult(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: alwaysinline nounwind uwtable
declare hidden zeroext i8 @__CLZ(i32 noundef) local_unnamed_addr #1

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @arm_nn_one_over_one_plus_x_for_x_in_0_1(i32 noundef) local_unnamed_addr #1

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

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <16 x i8> @llvm.smax.v16i8(<16 x i8>, <16 x i8>) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i8 @llvm.vector.reduce.smax.v16i8(<16 x i8>) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <8 x i8> @llvm.smax.v8i8(<8 x i8>, <8 x i8>) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i8 @llvm.vector.reduce.smax.v8i8(<8 x i8>) #2

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 = { alwaysinline 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

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


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