; LLVM IR from UtkarshPathrabe/Competitive-Coding :: Model Algorithms/Dynamic Programming/Box Stacking Problem.ll (Z14maxStackHeightP3Boxi)

; 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"

%struct.Box = type { i32, i32, i32 }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z7comparePKvS0_(ptr noundef, ptr noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z14maxStackHeightP3Boxi(ptr noundef %0, i32 noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %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
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %16 = load i32, ptr %4, align 4, !tbaa !9
  %17 = mul nsw i32 3, %16
  %18 = zext i32 %17 to i64
  %19 = call ptr @llvm.stacksave.p0()
  store ptr %19, ptr %5, align 8
  %20 = alloca %struct.Box, i64 %18, align 16
  store i64 %18, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  store i32 0, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %21

21:                                               ; preds = %121, %2
  %22 = load i32, ptr %8, align 4, !tbaa !9
  %23 = load i32, ptr %4, align 4, !tbaa !9
  %24 = icmp slt i32 %22, %23
  br i1 %24, label %26, label %25

25:                                               ; preds = %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  br label %124

26:                                               ; preds = %21
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = load i32, ptr %8, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds %struct.Box, ptr %27, i64 %29
  %31 = load i32, ptr %7, align 4, !tbaa !9
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %7, align 4, !tbaa !9
  %33 = sext i32 %31 to i64
  %34 = getelementptr inbounds %struct.Box, ptr %20, i64 %33
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %34, ptr align 4 %30, i64 12, i1 false), !tbaa.struct !11
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = load i32, ptr %8, align 4, !tbaa !9
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds %struct.Box, ptr %35, i64 %37
  %39 = getelementptr inbounds %struct.Box, ptr %38, i32 0, i32 1
  %40 = load i32, ptr %39, align 4, !tbaa !12
  %41 = load i32, ptr %7, align 4, !tbaa !9
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds %struct.Box, ptr %20, i64 %42
  %44 = getelementptr inbounds %struct.Box, ptr %43, i32 0, i32 0
  store i32 %40, ptr %44, align 4, !tbaa !14
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = load i32, ptr %8, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds %struct.Box, ptr %45, i64 %47
  %49 = getelementptr inbounds %struct.Box, ptr %48, i32 0, i32 0
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = load i32, ptr %8, align 4, !tbaa !9
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds %struct.Box, ptr %50, i64 %52
  %54 = getelementptr inbounds %struct.Box, ptr %53, i32 0, i32 2
  %55 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %49, ptr noundef nonnull align 4 dereferenceable(4) %54)
  %56 = load i32, ptr %55, align 4, !tbaa !9
  %57 = load i32, ptr %7, align 4, !tbaa !9
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds %struct.Box, ptr %20, i64 %58
  %60 = getelementptr inbounds %struct.Box, ptr %59, i32 0, i32 2
  store i32 %56, ptr %60, align 4, !tbaa !15
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = load i32, ptr %8, align 4, !tbaa !9
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds %struct.Box, ptr %61, i64 %63
  %65 = getelementptr inbounds %struct.Box, ptr %64, i32 0, i32 0
  %66 = load ptr, ptr %3, align 8, !tbaa !5
  %67 = load i32, ptr %8, align 4, !tbaa !9
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds %struct.Box, ptr %66, i64 %68
  %70 = getelementptr inbounds %struct.Box, ptr %69, i32 0, i32 2
  %71 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %65, ptr noundef nonnull align 4 dereferenceable(4) %70)
  %72 = load i32, ptr %71, align 4, !tbaa !9
  %73 = load i32, ptr %7, align 4, !tbaa !9
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr %7, align 4, !tbaa !9
  %75 = sext i32 %73 to i64
  %76 = getelementptr inbounds %struct.Box, ptr %20, i64 %75
  %77 = getelementptr inbounds %struct.Box, ptr %76, i32 0, i32 1
  store i32 %72, ptr %77, align 4, !tbaa !12
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  %79 = load i32, ptr %8, align 4, !tbaa !9
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds %struct.Box, ptr %78, i64 %80
  %82 = getelementptr inbounds %struct.Box, ptr %81, i32 0, i32 2
  %83 = load i32, ptr %82, align 4, !tbaa !15
  %84 = load i32, ptr %7, align 4, !tbaa !9
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds %struct.Box, ptr %20, i64 %85
  %87 = getelementptr inbounds %struct.Box, ptr %86, i32 0, i32 0
  store i32 %83, ptr %87, align 4, !tbaa !14
  %88 = load ptr, ptr %3, align 8, !tbaa !5
  %89 = load i32, ptr %8, align 4, !tbaa !9
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds %struct.Box, ptr %88, i64 %90
  %92 = getelementptr inbounds %struct.Box, ptr %91, i32 0, i32 0
  %93 = load ptr, ptr %3, align 8, !tbaa !5
  %94 = load i32, ptr %8, align 4, !tbaa !9
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds %struct.Box, ptr %93, i64 %95
  %97 = getelementptr inbounds %struct.Box, ptr %96, i32 0, i32 1
  %98 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %92, ptr noundef nonnull align 4 dereferenceable(4) %97)
  %99 = load i32, ptr %98, align 4, !tbaa !9
  %100 = load i32, ptr %7, align 4, !tbaa !9
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds %struct.Box, ptr %20, i64 %101
  %103 = getelementptr inbounds %struct.Box, ptr %102, i32 0, i32 2
  store i32 %99, ptr %103, align 4, !tbaa !15
  %104 = load ptr, ptr %3, align 8, !tbaa !5
  %105 = load i32, ptr %8, align 4, !tbaa !9
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds %struct.Box, ptr %104, i64 %106
  %108 = getelementptr inbounds %struct.Box, ptr %107, i32 0, i32 0
  %109 = load ptr, ptr %3, align 8, !tbaa !5
  %110 = load i32, ptr %8, align 4, !tbaa !9
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds %struct.Box, ptr %109, i64 %111
  %113 = getelementptr inbounds %struct.Box, ptr %112, i32 0, i32 1
  %114 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %108, ptr noundef nonnull align 4 dereferenceable(4) %113)
  %115 = load i32, ptr %114, align 4, !tbaa !9
  %116 = load i32, ptr %7, align 4, !tbaa !9
  %117 = add nsw i32 %116, 1
  store i32 %117, ptr %7, align 4, !tbaa !9
  %118 = sext i32 %116 to i64
  %119 = getelementptr inbounds %struct.Box, ptr %20, i64 %118
  %120 = getelementptr inbounds %struct.Box, ptr %119, i32 0, i32 1
  store i32 %115, ptr %120, align 4, !tbaa !12
  br label %121

121:                                              ; preds = %26
  %122 = load i32, ptr %8, align 4, !tbaa !9
  %123 = add nsw i32 %122, 1
  store i32 %123, ptr %8, align 4, !tbaa !9
  br label %21, !llvm.loop !16

124:                                              ; preds = %25
  %125 = load i32, ptr %4, align 4, !tbaa !9
  %126 = mul nsw i32 3, %125
  store i32 %126, ptr %4, align 4, !tbaa !9
  %127 = load i32, ptr %4, align 4, !tbaa !9
  %128 = sext i32 %127 to i64
  call void @qsort(ptr noundef %20, i64 noundef %128, i64 noundef 12, ptr noundef @_Z7comparePKvS0_)
  %129 = load i32, ptr %4, align 4, !tbaa !9
  %130 = zext i32 %129 to i64
  %131 = alloca i32, i64 %130, align 16
  store i64 %130, ptr %9, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %132

132:                                              ; preds = %146, %124
  %133 = load i32, ptr %10, align 4, !tbaa !9
  %134 = load i32, ptr %4, align 4, !tbaa !9
  %135 = icmp slt i32 %133, %134
  br i1 %135, label %137, label %136

136:                                              ; preds = %132
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  br label %149

137:                                              ; preds = %132
  %138 = load i32, ptr %10, align 4, !tbaa !9
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds %struct.Box, ptr %20, i64 %139
  %141 = getelementptr inbounds %struct.Box, ptr %140, i32 0, i32 0
  %142 = load i32, ptr %141, align 4, !tbaa !14
  %143 = load i32, ptr %10, align 4, !tbaa !9
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds i32, ptr %131, i64 %144
  store i32 %142, ptr %145, align 4, !tbaa !9
  br label %146

146:                                              ; preds = %137
  %147 = load i32, ptr %10, align 4, !tbaa !9
  %148 = add nsw i32 %147, 1
  store i32 %148, ptr %10, align 4, !tbaa !9
  br label %132, !llvm.loop !18

149:                                              ; preds = %136
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  store i32 1, ptr %11, align 4, !tbaa !9
  br label %150

150:                                              ; preds = %220, %149
  %151 = load i32, ptr %11, align 4, !tbaa !9
  %152 = load i32, ptr %4, align 4, !tbaa !9
  %153 = icmp slt i32 %151, %152
  br i1 %153, label %155, label %154

154:                                              ; preds = %150
  store i32 8, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  br label %223

155:                                              ; preds = %150
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %156

156:                                              ; preds = %216, %155
  %157 = load i32, ptr %13, align 4, !tbaa !9
  %158 = load i32, ptr %11, align 4, !tbaa !9
  %159 = icmp slt i32 %157, %158
  br i1 %159, label %161, label %160

160:                                              ; preds = %156
  store i32 11, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  br label %219

161:                                              ; preds = %156
  %162 = load i32, ptr %11, align 4, !tbaa !9
  %163 = sext i32 %162 to i64
  %164 = getelementptr inbounds %struct.Box, ptr %20, i64 %163
  %165 = getelementptr inbounds %struct.Box, ptr %164, i32 0, i32 1
  %166 = load i32, ptr %165, align 4, !tbaa !12
  %167 = load i32, ptr %13, align 4, !tbaa !9
  %168 = sext i32 %167 to i64
  %169 = getelementptr inbounds %struct.Box, ptr %20, i64 %168
  %170 = getelementptr inbounds %struct.Box, ptr %169, i32 0, i32 1
  %171 = load i32, ptr %170, align 4, !tbaa !12
  %172 = icmp slt i32 %166, %171
  br i1 %172, label %173, label %215

173:                                              ; preds = %161
  %174 = load i32, ptr %11, align 4, !tbaa !9
  %175 = sext i32 %174 to i64
  %176 = getelementptr inbounds %struct.Box, ptr %20, i64 %175
  %177 = getelementptr inbounds %struct.Box, ptr %176, i32 0, i32 2
  %178 = load i32, ptr %177, align 4, !tbaa !15
  %179 = load i32, ptr %13, align 4, !tbaa !9
  %180 = sext i32 %179 to i64
  %181 = getelementptr inbounds %struct.Box, ptr %20, i64 %180
  %182 = getelementptr inbounds %struct.Box, ptr %181, i32 0, i32 2
  %183 = load i32, ptr %182, align 4, !tbaa !15
  %184 = icmp slt i32 %178, %183
  br i1 %184, label %185, label %215

185:                                              ; preds = %173
  %186 = load i32, ptr %11, align 4, !tbaa !9
  %187 = sext i32 %186 to i64
  %188 = getelementptr inbounds i32, ptr %131, i64 %187
  %189 = load i32, ptr %188, align 4, !tbaa !9
  %190 = load i32, ptr %13, align 4, !tbaa !9
  %191 = sext i32 %190 to i64
  %192 = getelementptr inbounds i32, ptr %131, i64 %191
  %193 = load i32, ptr %192, align 4, !tbaa !9
  %194 = load i32, ptr %11, align 4, !tbaa !9
  %195 = sext i32 %194 to i64
  %196 = getelementptr inbounds %struct.Box, ptr %20, i64 %195
  %197 = getelementptr inbounds %struct.Box, ptr %196, i32 0, i32 0
  %198 = load i32, ptr %197, align 4, !tbaa !14
  %199 = add nsw i32 %193, %198
  %200 = icmp slt i32 %189, %199
  br i1 %200, label %201, label %215

201:                                              ; preds = %185
  %202 = load i32, ptr %13, align 4, !tbaa !9
  %203 = sext i32 %202 to i64
  %204 = getelementptr inbounds i32, ptr %131, i64 %203
  %205 = load i32, ptr %204, align 4, !tbaa !9
  %206 = load i32, ptr %11, align 4, !tbaa !9
  %207 = sext i32 %206 to i64
  %208 = getelementptr inbounds %struct.Box, ptr %20, i64 %207
  %209 = getelementptr inbounds %struct.Box, ptr %208, i32 0, i32 0
  %210 = load i32, ptr %209, align 4, !tbaa !14
  %211 = add nsw i32 %205, %210
  %212 = load i32, ptr %11, align 4, !tbaa !9
  %213 = sext i32 %212 to i64
  %214 = getelementptr inbounds i32, ptr %131, i64 %213
  store i32 %211, ptr %214, align 4, !tbaa !9
  br label %215

215:                                              ; preds = %201, %185, %173, %161
  br label %216

216:                                              ; preds = %215
  %217 = load i32, ptr %13, align 4, !tbaa !9
  %218 = add nsw i32 %217, 1
  store i32 %218, ptr %13, align 4, !tbaa !9
  br label %156, !llvm.loop !19

219:                                              ; preds = %160
  br label %220

220:                                              ; preds = %219
  %221 = load i32, ptr %11, align 4, !tbaa !9
  %222 = add nsw i32 %221, 1
  store i32 %222, ptr %11, align 4, !tbaa !9
  br label %150, !llvm.loop !20

223:                                              ; preds = %154
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #7
  %224 = getelementptr inbounds i32, ptr %131, i64 0
  %225 = load i32, ptr %224, align 16, !tbaa !9
  store i32 %225, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  store i32 1, ptr %15, align 4, !tbaa !9
  br label %226

226:                                              ; preds = %244, %223
  %227 = load i32, ptr %15, align 4, !tbaa !9
  %228 = load i32, ptr %4, align 4, !tbaa !9
  %229 = icmp slt i32 %227, %228
  br i1 %229, label %231, label %230

230:                                              ; preds = %226
  store i32 14, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  br label %247

231:                                              ; preds = %226
  %232 = load i32, ptr %14, align 4, !tbaa !9
  %233 = load i32, ptr %15, align 4, !tbaa !9
  %234 = sext i32 %233 to i64
  %235 = getelementptr inbounds i32, ptr %131, i64 %234
  %236 = load i32, ptr %235, align 4, !tbaa !9
  %237 = icmp slt i32 %232, %236
  br i1 %237, label %238, label %243

238:                                              ; preds = %231
  %239 = load i32, ptr %15, align 4, !tbaa !9
  %240 = sext i32 %239 to i64
  %241 = getelementptr inbounds i32, ptr %131, i64 %240
  %242 = load i32, ptr %241, align 4, !tbaa !9
  store i32 %242, ptr %14, align 4, !tbaa !9
  br label %243

243:                                              ; preds = %238, %231
  br label %244

244:                                              ; preds = %243
  %245 = load i32, ptr %15, align 4, !tbaa !9
  %246 = add nsw i32 %245, 1
  store i32 %246, ptr %15, align 4, !tbaa !9
  br label %226, !llvm.loop !21

247:                                              ; preds = %230
  %248 = load i32, ptr %14, align 4, !tbaa !9
  store i32 1, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  %249 = load ptr, ptr %5, align 8
  call void @llvm.stackrestore.p0(ptr %249)
  ret i32 %248
}

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #2

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

; 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)) #5

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

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

declare void @qsort(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #6

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #2

attributes #0 = { 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 #1 = { 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 #2 = { nocallback nofree nosync nounwind willreturn }
attributes #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 #6 = { "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 #7 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{i64 0, i64 4, !9, i64 4, i64 4, !9, i64 8, i64 4, !9}
!12 = !{!13, !10, i64 4}
!13 = !{!"_ZTS3Box", !10, i64 0, !10, i64 4, !10, i64 8}
!14 = !{!13, !10, i64 0}
!15 = !{!13, !10, i64 8}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}
!19 = distinct !{!19, !17}
!20 = distinct !{!20, !17}
!21 = distinct !{!21, !17}


; 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"

%struct.Box = type { i32, i32, i32 }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z7comparePKvS0_(ptr noundef, ptr noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z14maxStackHeightP3Boxi(ptr noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = mul i32 %1, 3
  %4 = zext i32 %3 to i64
  %5 = alloca %struct.Box, i64 %4, align 16
  %6 = icmp sgt i32 %1, 0
  br i1 %6, label %.lr.ph.preheader, label %._crit_edge.thread

._crit_edge.thread:                               ; preds = %2
  %7 = sext i32 %3 to i64
  call void @qsort(ptr noundef nonnull %5, i64 noundef %7, i64 noundef 12, ptr noundef nonnull @_Z7comparePKvS0_)
  %8 = alloca i32, i64 %4, align 16
  br label %._crit_edge81.thread

.lr.ph.preheader:                                 ; preds = %2
  %wide.trip.count = zext nneg i32 %1 to i64
  br label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph
  %9 = sext i32 %3 to i64
  call void @qsort(ptr noundef nonnull %5, i64 noundef %9, i64 noundef 12, ptr noundef nonnull @_Z7comparePKvS0_)
  %10 = alloca i32, i64 %4, align 16
  br i1 %6, label %.lr.ph78.preheader, label %._crit_edge81.thread

.lr.ph78.preheader:                               ; preds = %._crit_edge
  %smax = call i32 @llvm.smax.i32(i32 %3, i32 1)
  %wide.trip.count95 = zext nneg i32 %smax to i64
  %min.iters.check = icmp slt i32 %3, 9
  br i1 %min.iters.check, label %.lr.ph78.preheader129, label %vector.ph

.lr.ph78.preheader129:                            ; preds = %vector.body, %.lr.ph78.preheader
  %indvars.iv92.ph = phi i64 [ 0, %.lr.ph78.preheader ], [ %n.vec, %vector.body ]
  br label %.lr.ph78

vector.ph:                                        ; preds = %.lr.ph78.preheader
  %n.mod.vf = and i64 %wide.trip.count95, 7
  %11 = icmp eq i64 %n.mod.vf, 0
  %12 = select i1 %11, i64 8, i64 %n.mod.vf
  %n.vec = sub nsw i64 %wide.trip.count95, %12
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %13 = or disjoint i64 %index, 1
  %14 = or disjoint i64 %index, 2
  %15 = or disjoint i64 %index, 3
  %16 = or disjoint i64 %index, 4
  %17 = or disjoint i64 %index, 5
  %18 = or disjoint i64 %index, 6
  %19 = or disjoint i64 %index, 7
  %20 = getelementptr inbounds %struct.Box, ptr %5, i64 %index
  %21 = getelementptr inbounds %struct.Box, ptr %5, i64 %13
  %22 = getelementptr inbounds %struct.Box, ptr %5, i64 %14
  %23 = getelementptr inbounds %struct.Box, ptr %5, i64 %15
  %24 = getelementptr inbounds %struct.Box, ptr %5, i64 %16
  %25 = getelementptr inbounds %struct.Box, ptr %5, i64 %17
  %26 = getelementptr inbounds %struct.Box, ptr %5, i64 %18
  %27 = getelementptr inbounds %struct.Box, ptr %5, i64 %19
  %28 = load i32, ptr %20, align 16, !tbaa !5
  %29 = load i32, ptr %21, align 4, !tbaa !5
  %30 = load i32, ptr %22, align 8, !tbaa !5
  %31 = load i32, ptr %23, align 4, !tbaa !5
  %32 = insertelement <4 x i32> poison, i32 %28, i64 0
  %33 = insertelement <4 x i32> %32, i32 %29, i64 1
  %34 = insertelement <4 x i32> %33, i32 %30, i64 2
  %35 = insertelement <4 x i32> %34, i32 %31, i64 3
  %36 = load i32, ptr %24, align 16, !tbaa !5
  %37 = load i32, ptr %25, align 4, !tbaa !5
  %38 = load i32, ptr %26, align 8, !tbaa !5
  %39 = load i32, ptr %27, align 4, !tbaa !5
  %40 = insertelement <4 x i32> poison, i32 %36, i64 0
  %41 = insertelement <4 x i32> %40, i32 %37, i64 1
  %42 = insertelement <4 x i32> %41, i32 %38, i64 2
  %43 = insertelement <4 x i32> %42, i32 %39, i64 3
  %44 = getelementptr inbounds i32, ptr %10, i64 %index
  %45 = getelementptr inbounds i8, ptr %44, i64 16
  store <4 x i32> %35, ptr %44, align 16, !tbaa !10
  store <4 x i32> %43, ptr %45, align 16, !tbaa !10
  %index.next = add nuw i64 %index, 8
  %46 = icmp eq i64 %index.next, %n.vec
  br i1 %46, label %.lr.ph78.preheader129, label %vector.body, !llvm.loop !11

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv87 = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next88, %.lr.ph ]
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %47 = getelementptr inbounds %struct.Box, ptr %0, i64 %indvars.iv
  %48 = getelementptr inbounds %struct.Box, ptr %5, i64 %indvars.iv87
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %48, ptr noundef nonnull align 4 dereferenceable(12) %47, i64 12, i1 false), !tbaa.struct !15
  %49 = getelementptr inbounds i8, ptr %47, i64 4
  %50 = load i32, ptr %49, align 4, !tbaa !16
  %51 = getelementptr i8, ptr %48, i64 12
  store i32 %50, ptr %51, align 4, !tbaa !5
  %52 = getelementptr inbounds i8, ptr %47, i64 8
  %53 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %47, ptr noundef nonnull align 4 dereferenceable(4) %52)
  %54 = load i32, ptr %53, align 4, !tbaa !10
  %55 = getelementptr i8, ptr %48, i64 20
  store i32 %54, ptr %55, align 4, !tbaa !17
  %56 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %47, ptr noundef nonnull align 4 dereferenceable(4) %52)
  %57 = load i32, ptr %56, align 4, !tbaa !10
  %58 = getelementptr i8, ptr %48, i64 16
  store i32 %57, ptr %58, align 4, !tbaa !16
  %59 = load i32, ptr %52, align 4, !tbaa !17
  %60 = getelementptr inbounds i8, ptr %48, i64 24
  store i32 %59, ptr %60, align 4, !tbaa !5
  %61 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %47, ptr noundef nonnull align 4 dereferenceable(4) %49)
  %62 = load i32, ptr %61, align 4, !tbaa !10
  %63 = getelementptr inbounds i8, ptr %48, i64 32
  store i32 %62, ptr %63, align 4, !tbaa !17
  %64 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %47, ptr noundef nonnull align 4 dereferenceable(4) %49)
  %65 = load i32, ptr %64, align 4, !tbaa !10
  %indvars.iv.next88 = add nuw nsw i64 %indvars.iv87, 3
  %66 = getelementptr inbounds i8, ptr %48, i64 28
  store i32 %65, ptr %66, align 4, !tbaa !16
  %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 !18

.preheader73:                                     ; preds = %.lr.ph78
  br i1 %6, label %.preheader.preheader, label %._crit_edge81.thread

.preheader.preheader:                             ; preds = %.preheader73
  %smax105 = call i32 @llvm.smax.i32(i32 %3, i32 2)
  %wide.trip.count106 = zext nneg i32 %smax105 to i64
  br label %.preheader

.lr.ph78:                                         ; preds = %.lr.ph78.preheader129, %.lr.ph78
  %indvars.iv92 = phi i64 [ %indvars.iv.next93, %.lr.ph78 ], [ %indvars.iv92.ph, %.lr.ph78.preheader129 ]
  %67 = getelementptr inbounds %struct.Box, ptr %5, i64 %indvars.iv92
  %68 = load i32, ptr %67, align 4, !tbaa !5
  %69 = getelementptr inbounds i32, ptr %10, i64 %indvars.iv92
  store i32 %68, ptr %69, align 4, !tbaa !10
  %indvars.iv.next93 = add nuw nsw i64 %indvars.iv92, 1
  %exitcond96.not = icmp eq i64 %indvars.iv.next93, %wide.trip.count95
  br i1 %exitcond96.not, label %.preheader73, label %.lr.ph78, !llvm.loop !19

.preheader:                                       ; preds = %.preheader.preheader, %84
  %indvars.iv102 = phi i64 [ 1, %.preheader.preheader ], [ %indvars.iv.next103, %84 ]
  %70 = getelementptr inbounds %struct.Box, ptr %5, i64 %indvars.iv102
  %71 = getelementptr inbounds i8, ptr %70, i64 4
  %72 = load i32, ptr %71, align 4, !tbaa !16
  %73 = getelementptr inbounds i8, ptr %70, i64 8
  %74 = getelementptr inbounds i32, ptr %10, i64 %indvars.iv102
  br label %85

._crit_edge81.thread:                             ; preds = %.preheader73, %._crit_edge.thread, %._crit_edge
  %.ph114 = phi ptr [ %10, %.preheader73 ], [ %10, %._crit_edge ], [ %8, %._crit_edge.thread ]
  %75 = load i32, ptr %.ph114, align 16, !tbaa !10
  br label %._crit_edge86

._crit_edge81:                                    ; preds = %84
  %76 = load i32, ptr %10, align 16, !tbaa !10
  br i1 %6, label %.lr.ph85.preheader, label %._crit_edge86

.lr.ph85.preheader:                               ; preds = %._crit_edge81
  %smax111 = call i32 @llvm.smax.i32(i32 %3, i32 2)
  %wide.trip.count112 = zext nneg i32 %smax111 to i64
  %77 = add nsw i64 %wide.trip.count106, -1
  %min.iters.check117 = icmp slt i32 %3, 9
  br i1 %min.iters.check117, label %.lr.ph85.preheader127, label %vector.ph118

.lr.ph85.preheader127:                            ; preds = %middle.block115, %.lr.ph85.preheader
  %indvars.iv108.ph = phi i64 [ 1, %.lr.ph85.preheader ], [ %ind.end, %middle.block115 ]
  %.06482.ph = phi i32 [ %76, %.lr.ph85.preheader ], [ %83, %middle.block115 ]
  br label %.lr.ph85

vector.ph118:                                     ; preds = %.lr.ph85.preheader
  %n.vec120 = and i64 %77, -8
  %ind.end = or disjoint i64 %n.vec120, 1
  %minmax.ident.splatinsert = insertelement <4 x i32> poison, i32 %76, i64 0
  %minmax.ident.splat = shufflevector <4 x i32> %minmax.ident.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
  br label %vector.body122

vector.body122:                                   ; preds = %vector.body122, %vector.ph118
  %index123 = phi i64 [ 0, %vector.ph118 ], [ %index.next126, %vector.body122 ]
  %vec.phi = phi <4 x i32> [ %minmax.ident.splat, %vector.ph118 ], [ %80, %vector.body122 ]
  %vec.phi124 = phi <4 x i32> [ %minmax.ident.splat, %vector.ph118 ], [ %81, %vector.body122 ]
  %offset.idx = or disjoint i64 %index123, 1
  %78 = getelementptr inbounds i32, ptr %10, i64 %offset.idx
  %79 = getelementptr inbounds i8, ptr %78, i64 16
  %wide.load = load <4 x i32>, ptr %78, align 4, !tbaa !10
  %wide.load125 = load <4 x i32>, ptr %79, align 4, !tbaa !10
  %80 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %vec.phi, <4 x i32> %wide.load)
  %81 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %vec.phi124, <4 x i32> %wide.load125)
  %index.next126 = add nuw i64 %index123, 8
  %82 = icmp eq i64 %index.next126, %n.vec120
  br i1 %82, label %middle.block115, label %vector.body122, !llvm.loop !20

middle.block115:                                  ; preds = %vector.body122
  %rdx.minmax = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %80, <4 x i32> %81)
  %83 = call i32 @llvm.vector.reduce.smax.v4i32(<4 x i32> %rdx.minmax)
  %cmp.n = icmp eq i64 %77, %n.vec120
  br i1 %cmp.n, label %._crit_edge86, label %.lr.ph85.preheader127

84:                                               ; preds = %101
  %indvars.iv.next103 = add nuw nsw i64 %indvars.iv102, 1
  %exitcond107.not = icmp eq i64 %indvars.iv.next103, %wide.trip.count106
  br i1 %exitcond107.not, label %._crit_edge81, label %.preheader, !llvm.loop !21

85:                                               ; preds = %.preheader, %101
  %indvars.iv97 = phi i64 [ 0, %.preheader ], [ %indvars.iv.next98, %101 ]
  %86 = getelementptr inbounds %struct.Box, ptr %5, i64 %indvars.iv97
  %87 = getelementptr inbounds i8, ptr %86, i64 4
  %88 = load i32, ptr %87, align 4, !tbaa !16
  %89 = icmp slt i32 %72, %88
  br i1 %89, label %90, label %101

90:                                               ; preds = %85
  %91 = load i32, ptr %73, align 4, !tbaa !17
  %92 = getelementptr inbounds i8, ptr %86, i64 8
  %93 = load i32, ptr %92, align 4, !tbaa !17
  %94 = icmp slt i32 %91, %93
  br i1 %94, label %95, label %101

95:                                               ; preds = %90
  %96 = load i32, ptr %74, align 4, !tbaa !10
  %97 = getelementptr inbounds i32, ptr %10, i64 %indvars.iv97
  %98 = load i32, ptr %97, align 4, !tbaa !10
  %99 = load i32, ptr %70, align 4, !tbaa !5
  %100 = add nsw i32 %99, %98
  %spec.store.select = call i32 @llvm.smax.i32(i32 %96, i32 %100)
  store i32 %spec.store.select, ptr %74, align 4
  br label %101

101:                                              ; preds = %95, %85, %90
  %indvars.iv.next98 = add nuw nsw i64 %indvars.iv97, 1
  %exitcond101.not = icmp eq i64 %indvars.iv.next98, %indvars.iv102
  br i1 %exitcond101.not, label %84, label %85, !llvm.loop !22

._crit_edge86:                                    ; preds = %.lr.ph85, %middle.block115, %._crit_edge81.thread, %._crit_edge81
  %.064.lcssa = phi i32 [ %76, %._crit_edge81 ], [ %75, %._crit_edge81.thread ], [ %83, %middle.block115 ], [ %spec.select, %.lr.ph85 ]
  ret i32 %.064.lcssa

.lr.ph85:                                         ; preds = %.lr.ph85.preheader127, %.lr.ph85
  %indvars.iv108 = phi i64 [ %indvars.iv.next109, %.lr.ph85 ], [ %indvars.iv108.ph, %.lr.ph85.preheader127 ]
  %.06482 = phi i32 [ %spec.select, %.lr.ph85 ], [ %.06482.ph, %.lr.ph85.preheader127 ]
  %102 = getelementptr inbounds i32, ptr %10, i64 %indvars.iv108
  %103 = load i32, ptr %102, align 4, !tbaa !10
  %spec.select = call i32 @llvm.smax.i32(i32 %.06482, i32 %103)
  %indvars.iv.next109 = add nuw nsw i64 %indvars.iv108, 1
  %exitcond113.not = icmp eq i64 %indvars.iv.next109, %wide.trip.count112
  br i1 %exitcond113.not, label %._crit_edge86, label %.lr.ph85, !llvm.loop !23
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3

; Function Attrs: nofree
declare void @qsort(ptr noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #4

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

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

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

attributes #0 = { 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 #1 = { 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 #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { nofree "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 = { 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, !7, i64 0}
!6 = !{!"_ZTS3Box", !7, i64 0, !7, i64 4, !7, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!7, !7, i64 0}
!11 = distinct !{!11, !12, !13, !14}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!"llvm.loop.isvectorized", i32 1}
!14 = !{!"llvm.loop.unroll.runtime.disable"}
!15 = !{i64 0, i64 4, !10, i64 4, i64 4, !10, i64 8, i64 4, !10}
!16 = !{!6, !7, i64 4}
!17 = !{!6, !7, i64 8}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !12, !14, !13}
!20 = distinct !{!20, !12, !13, !14}
!21 = distinct !{!21, !12}
!22 = distinct !{!22, !12}
!23 = distinct !{!23, !12, !14, !13}


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