; LLVM IR from ravireddy07/cpp-book :: src/Subsequences/LongestBitonicSubsequence(LBS)/LongestBiotonicSubsequence.ll (Z3lbsPii)

; 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: mustprogress uwtable
define dso_local noundef i32 @_Z3lbsPii(ptr noundef %0, i32 noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %19 = load i32, ptr %4, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %20, i64 4)
  %22 = extractvalue { i64, i1 } %21, 1
  %23 = extractvalue { i64, i1 } %21, 0
  %24 = select i1 %22, i64 -1, i64 %23
  %25 = call noalias noundef nonnull ptr @_Znam(i64 noundef %24) #6
  store ptr %25, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %26 = load i32, ptr %4, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %27, i64 4)
  %29 = extractvalue { i64, i1 } %28, 1
  %30 = extractvalue { i64, i1 } %28, 0
  %31 = select i1 %29, i64 -1, i64 %30
  %32 = call noalias noundef nonnull ptr @_Znam(i64 noundef %31) #6
  store ptr %32, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %33 = load i32, ptr %4, align 4, !tbaa !9
  %34 = sext i32 %33 to i64
  %35 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %34, i64 4)
  %36 = extractvalue { i64, i1 } %35, 1
  %37 = extractvalue { i64, i1 } %35, 0
  %38 = select i1 %36, i64 -1, i64 %37
  %39 = call noalias noundef nonnull ptr @_Znam(i64 noundef %38) #6
  store ptr %39, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %40

40:                                               ; preds = %54, %2
  %41 = load i32, ptr %8, align 4, !tbaa !9
  %42 = load i32, ptr %4, align 4, !tbaa !9
  %43 = icmp slt i32 %41, %42
  br i1 %43, label %45, label %44

44:                                               ; preds = %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %57

45:                                               ; preds = %40
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = load i32, ptr %8, align 4, !tbaa !9
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds i32, ptr %46, i64 %48
  store i32 1, ptr %49, align 4, !tbaa !9
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = load i32, ptr %8, align 4, !tbaa !9
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds i32, ptr %50, i64 %52
  store i32 1, ptr %53, align 4, !tbaa !9
  br label %54

54:                                               ; preds = %45
  %55 = load i32, ptr %8, align 4, !tbaa !9
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %8, align 4, !tbaa !9
  br label %40, !llvm.loop !11

57:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 1, ptr %9, align 4, !tbaa !9
  br label %58

58:                                               ; preds = %103, %57
  %59 = load i32, ptr %9, align 4, !tbaa !9
  %60 = load i32, ptr %4, align 4, !tbaa !9
  %61 = icmp slt i32 %59, %60
  br i1 %61, label %63, label %62

62:                                               ; preds = %58
  store i32 5, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %106

63:                                               ; preds = %58
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %64

64:                                               ; preds = %99, %63
  %65 = load i32, ptr %11, align 4, !tbaa !9
  %66 = load i32, ptr %9, align 4, !tbaa !9
  %67 = icmp slt i32 %65, %66
  br i1 %67, label %69, label %68

68:                                               ; preds = %64
  store i32 8, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  br label %102

69:                                               ; preds = %64
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = load i32, ptr %9, align 4, !tbaa !9
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds i32, ptr %70, i64 %72
  %74 = load i32, ptr %73, align 4, !tbaa !9
  %75 = load ptr, ptr %3, align 8, !tbaa !5
  %76 = load i32, ptr %11, align 4, !tbaa !9
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds i32, ptr %75, i64 %77
  %79 = load i32, ptr %78, align 4, !tbaa !9
  %80 = icmp sgt i32 %74, %79
  br i1 %80, label %81, label %98

81:                                               ; preds = %69
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  %83 = load i32, ptr %9, align 4, !tbaa !9
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds i32, ptr %82, i64 %84
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %86 = load ptr, ptr %5, align 8, !tbaa !5
  %87 = load i32, ptr %11, align 4, !tbaa !9
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds i32, ptr %86, i64 %88
  %90 = load i32, ptr %89, align 4, !tbaa !9
  %91 = add nsw i32 1, %90
  store i32 %91, ptr %12, align 4, !tbaa !9
  %92 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %85, ptr noundef nonnull align 4 dereferenceable(4) %12)
  %93 = load i32, ptr %92, align 4, !tbaa !9
  %94 = load ptr, ptr %5, align 8, !tbaa !5
  %95 = load i32, ptr %9, align 4, !tbaa !9
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds i32, ptr %94, i64 %96
  store i32 %93, ptr %97, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  br label %98

98:                                               ; preds = %81, %69
  br label %99

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

102:                                              ; preds = %68
  br label %103

103:                                              ; preds = %102
  %104 = load i32, ptr %9, align 4, !tbaa !9
  %105 = add nsw i32 %104, 1
  store i32 %105, ptr %9, align 4, !tbaa !9
  br label %58, !llvm.loop !14

106:                                              ; preds = %62
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %107 = load i32, ptr %4, align 4, !tbaa !9
  %108 = sub nsw i32 %107, 2
  store i32 %108, ptr %13, align 4, !tbaa !9
  br label %109

109:                                              ; preds = %155, %106
  %110 = load i32, ptr %13, align 4, !tbaa !9
  %111 = icmp sge i32 %110, 0
  br i1 %111, label %113, label %112

112:                                              ; preds = %109
  store i32 11, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  br label %158

113:                                              ; preds = %109
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  %114 = load i32, ptr %4, align 4, !tbaa !9
  %115 = sub nsw i32 %114, 1
  store i32 %115, ptr %14, align 4, !tbaa !9
  br label %116

116:                                              ; preds = %151, %113
  %117 = load i32, ptr %14, align 4, !tbaa !9
  %118 = load i32, ptr %13, align 4, !tbaa !9
  %119 = icmp sgt i32 %117, %118
  br i1 %119, label %121, label %120

120:                                              ; preds = %116
  store i32 14, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  br label %154

121:                                              ; preds = %116
  %122 = load ptr, ptr %3, align 8, !tbaa !5
  %123 = load i32, ptr %13, align 4, !tbaa !9
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds i32, ptr %122, i64 %124
  %126 = load i32, ptr %125, align 4, !tbaa !9
  %127 = load ptr, ptr %3, align 8, !tbaa !5
  %128 = load i32, ptr %14, align 4, !tbaa !9
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds i32, ptr %127, i64 %129
  %131 = load i32, ptr %130, align 4, !tbaa !9
  %132 = icmp sgt i32 %126, %131
  br i1 %132, label %133, label %150

133:                                              ; preds = %121
  %134 = load ptr, ptr %6, align 8, !tbaa !5
  %135 = load i32, ptr %13, align 4, !tbaa !9
  %136 = sext i32 %135 to i64
  %137 = getelementptr inbounds i32, ptr %134, i64 %136
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  %138 = load ptr, ptr %6, align 8, !tbaa !5
  %139 = load i32, ptr %14, align 4, !tbaa !9
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds i32, ptr %138, i64 %140
  %142 = load i32, ptr %141, align 4, !tbaa !9
  %143 = add nsw i32 %142, 1
  store i32 %143, ptr %15, align 4, !tbaa !9
  %144 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %137, ptr noundef nonnull align 4 dereferenceable(4) %15)
  %145 = load i32, ptr %144, align 4, !tbaa !9
  %146 = load ptr, ptr %6, align 8, !tbaa !5
  %147 = load i32, ptr %13, align 4, !tbaa !9
  %148 = sext i32 %147 to i64
  %149 = getelementptr inbounds i32, ptr %146, i64 %148
  store i32 %145, ptr %149, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  br label %150

150:                                              ; preds = %133, %121
  br label %151

151:                                              ; preds = %150
  %152 = load i32, ptr %14, align 4, !tbaa !9
  %153 = add nsw i32 %152, -1
  store i32 %153, ptr %14, align 4, !tbaa !9
  br label %116, !llvm.loop !15

154:                                              ; preds = %120
  br label %155

155:                                              ; preds = %154
  %156 = load i32, ptr %13, align 4, !tbaa !9
  %157 = add nsw i32 %156, -1
  store i32 %157, ptr %13, align 4, !tbaa !9
  br label %109, !llvm.loop !16

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

159:                                              ; preds = %181, %158
  %160 = load i32, ptr %16, align 4, !tbaa !9
  %161 = load i32, ptr %4, align 4, !tbaa !9
  %162 = icmp slt i32 %160, %161
  br i1 %162, label %164, label %163

163:                                              ; preds = %159
  store i32 17, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  br label %184

164:                                              ; preds = %159
  %165 = load ptr, ptr %5, align 8, !tbaa !5
  %166 = load i32, ptr %16, align 4, !tbaa !9
  %167 = sext i32 %166 to i64
  %168 = getelementptr inbounds i32, ptr %165, i64 %167
  %169 = load i32, ptr %168, align 4, !tbaa !9
  %170 = load ptr, ptr %6, align 8, !tbaa !5
  %171 = load i32, ptr %16, align 4, !tbaa !9
  %172 = sext i32 %171 to i64
  %173 = getelementptr inbounds i32, ptr %170, i64 %172
  %174 = load i32, ptr %173, align 4, !tbaa !9
  %175 = add nsw i32 %169, %174
  %176 = sub nsw i32 %175, 1
  %177 = load ptr, ptr %7, align 8, !tbaa !5
  %178 = load i32, ptr %16, align 4, !tbaa !9
  %179 = sext i32 %178 to i64
  %180 = getelementptr inbounds i32, ptr %177, i64 %179
  store i32 %176, ptr %180, align 4, !tbaa !9
  br label %181

181:                                              ; preds = %164
  %182 = load i32, ptr %16, align 4, !tbaa !9
  %183 = add nsw i32 %182, 1
  store i32 %183, ptr %16, align 4, !tbaa !9
  br label %159, !llvm.loop !17

184:                                              ; preds = %163
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  store i32 -1, ptr %17, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  store i32 0, ptr %18, align 4, !tbaa !9
  br label %185

185:                                              ; preds = %205, %184
  %186 = load i32, ptr %18, align 4, !tbaa !9
  %187 = load i32, ptr %4, align 4, !tbaa !9
  %188 = icmp slt i32 %186, %187
  br i1 %188, label %190, label %189

189:                                              ; preds = %185
  store i32 20, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  br label %208

190:                                              ; preds = %185
  %191 = load ptr, ptr %7, align 8, !tbaa !5
  %192 = load i32, ptr %18, align 4, !tbaa !9
  %193 = sext i32 %192 to i64
  %194 = getelementptr inbounds i32, ptr %191, i64 %193
  %195 = load i32, ptr %194, align 4, !tbaa !9
  %196 = load i32, ptr %17, align 4, !tbaa !9
  %197 = icmp sgt i32 %195, %196
  br i1 %197, label %198, label %204

198:                                              ; preds = %190
  %199 = load ptr, ptr %7, align 8, !tbaa !5
  %200 = load i32, ptr %18, align 4, !tbaa !9
  %201 = sext i32 %200 to i64
  %202 = getelementptr inbounds i32, ptr %199, i64 %201
  %203 = load i32, ptr %202, align 4, !tbaa !9
  store i32 %203, ptr %17, align 4, !tbaa !9
  br label %204

204:                                              ; preds = %198, %190
  br label %205

205:                                              ; preds = %204
  %206 = load i32, ptr %18, align 4, !tbaa !9
  %207 = add nsw i32 %206, 1
  store i32 %207, ptr %18, align 4, !tbaa !9
  br label %185, !llvm.loop !18

208:                                              ; preds = %189
  %209 = load i32, ptr %17, align 4, !tbaa !9
  store i32 1, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  ret i32 %209
}

; 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 speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #2

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #3

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #4

attributes #0 = { mustprogress 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nobuiltin 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 #4 = { inlinehint mustprogress 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 #5 = { nounwind }
attributes #6 = { builtin 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++ 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}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !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: mustprogress uwtable
define dso_local noundef range(i32 -1, -2147483648) i32 @_Z3lbsPii(ptr nocapture noundef readonly %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = zext i32 %1 to i64
  %6 = icmp slt i32 %1, 0
  %7 = shl nuw nsw i64 %5, 2
  %8 = select i1 %6, i64 -1, i64 %7
  %9 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %8) #5
  %10 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %8) #5
  %11 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %8) #5
  %12 = icmp sgt i32 %1, 0
  br i1 %12, label %.lr.ph.preheader, label %._crit_edge86

.lr.ph.preheader:                                 ; preds = %2
  %min.iters.check = icmp ult i32 %1, 8
  br i1 %min.iters.check, label %.lr.ph.preheader142, label %vector.ph

.lr.ph.preheader142:                              ; preds = %middle.block, %.lr.ph.preheader
  %indvars.iv.ph = phi i64 [ 0, %.lr.ph.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph

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

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %13 = getelementptr inbounds i32, ptr %9, i64 %index
  %14 = getelementptr inbounds i8, ptr %13, i64 16
  store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, ptr %13, align 4, !tbaa !5
  store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, ptr %14, align 4, !tbaa !5
  %15 = getelementptr inbounds i32, ptr %10, i64 %index
  %16 = getelementptr inbounds i8, ptr %15, i64 16
  store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, ptr %15, align 4, !tbaa !5
  store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, ptr %16, align 4, !tbaa !5
  %index.next = add nuw i64 %index, 8
  %17 = icmp eq i64 %index.next, %n.vec
  br i1 %17, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %5
  br i1 %cmp.n, label %.preheader72, label %.lr.ph.preheader142

.preheader72:                                     ; preds = %.lr.ph, %middle.block
  %.not = icmp eq i32 %1, 1
  br i1 %.not, label %.preheader69, label %.preheader71

.lr.ph:                                           ; preds = %.lr.ph.preheader142, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %indvars.iv.ph, %.lr.ph.preheader142 ]
  %18 = getelementptr inbounds i32, ptr %9, i64 %indvars.iv
  store i32 1, ptr %18, align 4, !tbaa !5
  %19 = getelementptr inbounds i32, ptr %10, i64 %indvars.iv
  store i32 1, ptr %19, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %5
  br i1 %exitcond.not, label %.preheader72, label %.lr.ph, !llvm.loop !13

.preheader71:                                     ; preds = %.preheader72, %25
  %indvars.iv93 = phi i64 [ %indvars.iv.next94, %25 ], [ 1, %.preheader72 ]
  %20 = getelementptr inbounds i32, ptr %0, i64 %indvars.iv93
  %21 = getelementptr inbounds i32, ptr %9, i64 %indvars.iv93
  br label %26

._crit_edge:                                      ; preds = %25
  br i1 %.not, label %.preheader69, label %.preheader70.lr.ph

.preheader70.lr.ph:                               ; preds = %._crit_edge
  %22 = add nsw i32 %1, -2
  %.06276 = add nsw i32 %1, -1
  %23 = zext i32 %22 to i64
  %24 = sext i32 %.06276 to i64
  br label %.preheader70

25:                                               ; preds = %37
  %indvars.iv.next94 = add nuw nsw i64 %indvars.iv93, 1
  %exitcond97.not = icmp eq i64 %indvars.iv.next94, %5
  br i1 %exitcond97.not, label %._crit_edge, label %.preheader71, !llvm.loop !14

26:                                               ; preds = %.preheader71, %37
  %indvars.iv88 = phi i64 [ 0, %.preheader71 ], [ %indvars.iv.next89, %37 ]
  %27 = load i32, ptr %20, align 4, !tbaa !5
  %28 = getelementptr inbounds i32, ptr %0, i64 %indvars.iv88
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = icmp sgt i32 %27, %29
  br i1 %30, label %31, label %37

31:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #6
  %32 = getelementptr inbounds i32, ptr %9, i64 %indvars.iv88
  %33 = load i32, ptr %32, align 4, !tbaa !5
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %3, align 4, !tbaa !5
  %35 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %21, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %36 = load i32, ptr %35, align 4, !tbaa !5
  store i32 %36, ptr %21, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #6
  br label %37

37:                                               ; preds = %26, %31
  %indvars.iv.next89 = add nuw nsw i64 %indvars.iv88, 1
  %exitcond92.not = icmp eq i64 %indvars.iv.next89, %indvars.iv93
  br i1 %exitcond92.not, label %25, label %26, !llvm.loop !15

.preheader70:                                     ; preds = %.preheader70.lr.ph, %._crit_edge79
  %indvars.iv98 = phi i64 [ %23, %.preheader70.lr.ph ], [ %indvars.iv.next99, %._crit_edge79 ]
  %38 = icmp slt i64 %indvars.iv98, %24
  br i1 %38, label %.lr.ph78, label %._crit_edge79

.lr.ph78:                                         ; preds = %.preheader70
  %39 = getelementptr inbounds i32, ptr %0, i64 %indvars.iv98
  %40 = getelementptr inbounds i32, ptr %10, i64 %indvars.iv98
  br label %53

.preheader69:                                     ; preds = %._crit_edge79, %.preheader72, %._crit_edge
  br i1 %12, label %.lr.ph82.preheader, label %._crit_edge86

.lr.ph82.preheader:                               ; preds = %.preheader69
  %min.iters.check113 = icmp ult i32 %1, 8
  br i1 %min.iters.check113, label %.lr.ph82.preheader141, label %vector.ph114

.lr.ph82.preheader141:                            ; preds = %middle.block111, %.lr.ph82.preheader
  %indvars.iv101.ph = phi i64 [ 0, %.lr.ph82.preheader ], [ %n.vec116, %middle.block111 ]
  br label %.lr.ph82

vector.ph114:                                     ; preds = %.lr.ph82.preheader
  %n.vec116 = and i64 %5, 2147483640
  br label %vector.body118

vector.body118:                                   ; preds = %vector.body118, %vector.ph114
  %index119 = phi i64 [ 0, %vector.ph114 ], [ %index.next123, %vector.body118 ]
  %41 = getelementptr inbounds i32, ptr %9, i64 %index119
  %42 = getelementptr inbounds i8, ptr %41, i64 16
  %wide.load = load <4 x i32>, ptr %41, align 4, !tbaa !5
  %wide.load120 = load <4 x i32>, ptr %42, align 4, !tbaa !5
  %43 = getelementptr inbounds i32, ptr %10, i64 %index119
  %44 = getelementptr inbounds i8, ptr %43, i64 16
  %wide.load121 = load <4 x i32>, ptr %43, align 4, !tbaa !5
  %wide.load122 = load <4 x i32>, ptr %44, align 4, !tbaa !5
  %45 = add <4 x i32> %wide.load, <i32 -1, i32 -1, i32 -1, i32 -1>
  %46 = add <4 x i32> %wide.load120, <i32 -1, i32 -1, i32 -1, i32 -1>
  %47 = add <4 x i32> %45, %wide.load121
  %48 = add <4 x i32> %46, %wide.load122
  %49 = getelementptr inbounds i32, ptr %11, i64 %index119
  %50 = getelementptr inbounds i8, ptr %49, i64 16
  store <4 x i32> %47, ptr %49, align 4, !tbaa !5
  store <4 x i32> %48, ptr %50, align 4, !tbaa !5
  %index.next123 = add nuw i64 %index119, 8
  %51 = icmp eq i64 %index.next123, %n.vec116
  br i1 %51, label %middle.block111, label %vector.body118, !llvm.loop !16

middle.block111:                                  ; preds = %vector.body118
  %cmp.n124 = icmp eq i64 %n.vec116, %5
  br i1 %cmp.n124, label %.preheader, label %.lr.ph82.preheader141

._crit_edge79:                                    ; preds = %65, %.preheader70
  %indvars.iv.next99 = add nsw i64 %indvars.iv98, -1
  %52 = icmp sgt i64 %indvars.iv98, 0
  br i1 %52, label %.preheader70, label %.preheader69, !llvm.loop !17

53:                                               ; preds = %.lr.ph78, %65
  %.06277 = phi i32 [ %.06276, %.lr.ph78 ], [ %.062, %65 ]
  %54 = load i32, ptr %39, align 4, !tbaa !5
  %55 = zext nneg i32 %.06277 to i64
  %56 = getelementptr inbounds i32, ptr %0, i64 %55
  %57 = load i32, ptr %56, align 4, !tbaa !5
  %58 = icmp sgt i32 %54, %57
  br i1 %58, label %59, label %65

59:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #6
  %60 = getelementptr inbounds i32, ptr %10, i64 %55
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %4, align 4, !tbaa !5
  %63 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %40, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %64 = load i32, ptr %63, align 4, !tbaa !5
  store i32 %64, ptr %40, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #6
  br label %65

65:                                               ; preds = %53, %59
  %.062 = add nsw i32 %.06277, -1
  %66 = sext i32 %.062 to i64
  %67 = icmp slt i64 %indvars.iv98, %66
  br i1 %67, label %53, label %._crit_edge79, !llvm.loop !18

.preheader:                                       ; preds = %.lr.ph82, %middle.block111
  br i1 %12, label %.lr.ph85.preheader, label %._crit_edge86

.lr.ph85.preheader:                               ; preds = %.preheader
  %min.iters.check127 = icmp ult i32 %1, 8
  br i1 %min.iters.check127, label %.lr.ph85.preheader139, label %vector.ph128

.lr.ph85.preheader139:                            ; preds = %middle.block125, %.lr.ph85.preheader
  %indvars.iv106.ph = phi i64 [ 0, %.lr.ph85.preheader ], [ %n.vec130, %middle.block125 ]
  %.06083.ph = phi i32 [ -1, %.lr.ph85.preheader ], [ %73, %middle.block125 ]
  br label %.lr.ph85

vector.ph128:                                     ; preds = %.lr.ph85.preheader
  %n.vec130 = and i64 %5, 2147483640
  br label %vector.body132

vector.body132:                                   ; preds = %vector.body132, %vector.ph128
  %index133 = phi i64 [ 0, %vector.ph128 ], [ %index.next137, %vector.body132 ]
  %vec.phi = phi <4 x i32> [ <i32 -1, i32 -1, i32 -1, i32 -1>, %vector.ph128 ], [ %70, %vector.body132 ]
  %vec.phi134 = phi <4 x i32> [ <i32 -1, i32 -1, i32 -1, i32 -1>, %vector.ph128 ], [ %71, %vector.body132 ]
  %68 = getelementptr inbounds i32, ptr %11, i64 %index133
  %69 = getelementptr inbounds i8, ptr %68, i64 16
  %wide.load135 = load <4 x i32>, ptr %68, align 4, !tbaa !5
  %wide.load136 = load <4 x i32>, ptr %69, align 4, !tbaa !5
  %70 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %wide.load135, <4 x i32> %vec.phi)
  %71 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %wide.load136, <4 x i32> %vec.phi134)
  %index.next137 = add nuw i64 %index133, 8
  %72 = icmp eq i64 %index.next137, %n.vec130
  br i1 %72, label %middle.block125, label %vector.body132, !llvm.loop !19

middle.block125:                                  ; preds = %vector.body132
  %rdx.minmax = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %70, <4 x i32> %71)
  %73 = call i32 @llvm.vector.reduce.smax.v4i32(<4 x i32> %rdx.minmax)
  %cmp.n138 = icmp eq i64 %n.vec130, %5
  br i1 %cmp.n138, label %._crit_edge86, label %.lr.ph85.preheader139

.lr.ph82:                                         ; preds = %.lr.ph82.preheader141, %.lr.ph82
  %indvars.iv101 = phi i64 [ %indvars.iv.next102, %.lr.ph82 ], [ %indvars.iv101.ph, %.lr.ph82.preheader141 ]
  %74 = getelementptr inbounds i32, ptr %9, i64 %indvars.iv101
  %75 = load i32, ptr %74, align 4, !tbaa !5
  %76 = getelementptr inbounds i32, ptr %10, i64 %indvars.iv101
  %77 = load i32, ptr %76, align 4, !tbaa !5
  %78 = add i32 %75, -1
  %79 = add i32 %78, %77
  %80 = getelementptr inbounds i32, ptr %11, i64 %indvars.iv101
  store i32 %79, ptr %80, align 4, !tbaa !5
  %indvars.iv.next102 = add nuw nsw i64 %indvars.iv101, 1
  %exitcond105.not = icmp eq i64 %indvars.iv.next102, %5
  br i1 %exitcond105.not, label %.preheader, label %.lr.ph82, !llvm.loop !20

._crit_edge86:                                    ; preds = %.lr.ph85, %middle.block125, %2, %.preheader69, %.preheader
  %.060.lcssa = phi i32 [ -1, %.preheader ], [ -1, %.preheader69 ], [ -1, %2 ], [ %73, %middle.block125 ], [ %spec.select, %.lr.ph85 ]
  ret i32 %.060.lcssa

.lr.ph85:                                         ; preds = %.lr.ph85.preheader139, %.lr.ph85
  %indvars.iv106 = phi i64 [ %indvars.iv.next107, %.lr.ph85 ], [ %indvars.iv106.ph, %.lr.ph85.preheader139 ]
  %.06083 = phi i32 [ %spec.select, %.lr.ph85 ], [ %.06083.ph, %.lr.ph85.preheader139 ]
  %81 = getelementptr inbounds i32, ptr %11, i64 %indvars.iv106
  %82 = load i32, ptr %81, align 4, !tbaa !5
  %spec.select = call i32 @llvm.smax.i32(i32 %82, i32 %.06083)
  %indvars.iv.next107 = add nuw nsw i64 %indvars.iv106, 1
  %exitcond110.not = icmp eq i64 %indvars.iv.next107, %5
  br i1 %exitcond110.not, label %._crit_edge86, label %.lr.ph85, !llvm.loop !21
}

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

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3

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

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

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

attributes #0 = { mustprogress 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nobuiltin 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 = { inlinehint mustprogress 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { builtin 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++ 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}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10, !11, !12}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10, !11, !12}
!20 = distinct !{!20, !10, !12, !11}
!21 = distinct !{!21, !10, !12, !11}


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