; LLVM IR from tanakamasayuki/Arduino_TensorFlowLite_ESP32 :: src/tensorflow/lite/micro/memory_planner (greedy_memory_planner)

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

%"class.tflite::GreedyMemoryPlanner" = type <{ %"class.tflite::MicroMemoryPlanner", i32, i32, ptr, ptr, ptr, ptr, i32, i32, ptr, i8, [7 x i8] }>
%"class.tflite::MicroMemoryPlanner" = type { ptr }
%"struct.tflite::GreedyMemoryPlanner::BufferRequirements" = type { i32, i32, i32, i32 }
%"struct.tflite::GreedyMemoryPlanner::ListEntry" = type { i32, i32, i32 }

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN6tflite19GreedyMemoryPlanner30NextSimultaneouslyActiveBufferEPKNS0_9ListEntryEii(ptr noundef nonnull align 8 dereferenceable(65), ptr noundef, i32 noundef, i32 noundef) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN6tflite19GreedyMemoryPlanner24CalculateOffsetsIfNeededEv(ptr noundef nonnull align 8 dereferenceable(65) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca ptr, align 8
  %21 = alloca i32, align 4
  %22 = alloca ptr, align 8
  %23 = alloca i32, align 4
  %24 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %25 = load ptr, ptr %2, align 8
  %26 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 10
  %27 = load i8, ptr %26, align 8, !tbaa !9, !range !14, !noundef !15
  %28 = trunc i8 %27 to i1
  br i1 %28, label %29, label %33

29:                                               ; preds = %1
  %30 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 2
  %31 = load i32, ptr %30, align 4, !tbaa !16
  %32 = icmp eq i32 %31, 0
  br i1 %32, label %33, label %34

33:                                               ; preds = %29, %1
  br label %341

34:                                               ; preds = %29
  %35 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 10
  store i8 0, ptr %35, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  %36 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 2
  %37 = load i32, ptr %36, align 4, !tbaa !16
  store i32 %37, ptr %3, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  store i32 0, ptr %4, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  store i32 0, ptr %5, align 4, !tbaa !17
  br label %38

38:                                               ; preds = %113, %34
  %39 = load i32, ptr %5, align 4, !tbaa !17
  %40 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 2
  %41 = load i32, ptr %40, align 4, !tbaa !16
  %42 = icmp slt i32 %39, %41
  br i1 %42, label %44, label %43

43:                                               ; preds = %38
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  br label %116

44:                                               ; preds = %38
  %45 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 3
  %46 = load ptr, ptr %45, align 8, !tbaa !18
  %47 = load i32, ptr %5, align 4, !tbaa !17
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::BufferRequirements", ptr %46, i64 %48
  %50 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::BufferRequirements", ptr %49, i32 0, i32 1
  %51 = load i32, ptr %50, align 4, !tbaa !19
  %52 = icmp eq i32 %51, -1
  br i1 %52, label %53, label %79

53:                                               ; preds = %44
  %54 = load i32, ptr %3, align 4, !tbaa !17
  %55 = add nsw i32 %54, -1
  store i32 %55, ptr %3, align 4, !tbaa !17
  %56 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 3
  %57 = load ptr, ptr %56, align 8, !tbaa !18
  %58 = load i32, ptr %5, align 4, !tbaa !17
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::BufferRequirements", ptr %57, i64 %59
  %61 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::BufferRequirements", ptr %60, i32 0, i32 0
  %62 = load i32, ptr %61, align 4, !tbaa !21
  %63 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 4
  %64 = load ptr, ptr %63, align 8, !tbaa !22
  %65 = load i32, ptr %3, align 4, !tbaa !17
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds i32, ptr %64, i64 %66
  store i32 %62, ptr %67, align 4, !tbaa !17
  %68 = load i32, ptr %5, align 4, !tbaa !17
  %69 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 5
  %70 = load ptr, ptr %69, align 8, !tbaa !23
  %71 = load i32, ptr %3, align 4, !tbaa !17
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds i32, ptr %70, i64 %72
  store i32 %68, ptr %73, align 4, !tbaa !17
  %74 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 9
  %75 = load ptr, ptr %74, align 8, !tbaa !24
  %76 = load i32, ptr %5, align 4, !tbaa !17
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds i32, ptr %75, i64 %77
  store i32 -1, ptr %78, align 4, !tbaa !17
  br label %112

79:                                               ; preds = %44
  %80 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 3
  %81 = load ptr, ptr %80, align 8, !tbaa !18
  %82 = load i32, ptr %5, align 4, !tbaa !17
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::BufferRequirements", ptr %81, i64 %83
  %85 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::BufferRequirements", ptr %84, i32 0, i32 0
  %86 = load i32, ptr %85, align 4, !tbaa !21
  %87 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 4
  %88 = load ptr, ptr %87, align 8, !tbaa !22
  %89 = load i32, ptr %4, align 4, !tbaa !17
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds i32, ptr %88, i64 %90
  store i32 %86, ptr %91, align 4, !tbaa !17
  %92 = load i32, ptr %5, align 4, !tbaa !17
  %93 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 5
  %94 = load ptr, ptr %93, align 8, !tbaa !23
  %95 = load i32, ptr %4, align 4, !tbaa !17
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds i32, ptr %94, i64 %96
  store i32 %92, ptr %97, align 4, !tbaa !17
  %98 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 3
  %99 = load ptr, ptr %98, align 8, !tbaa !18
  %100 = load i32, ptr %5, align 4, !tbaa !17
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::BufferRequirements", ptr %99, i64 %101
  %103 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::BufferRequirements", ptr %102, i32 0, i32 1
  %104 = load i32, ptr %103, align 4, !tbaa !19
  %105 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 9
  %106 = load ptr, ptr %105, align 8, !tbaa !24
  %107 = load i32, ptr %5, align 4, !tbaa !17
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds i32, ptr %106, i64 %108
  store i32 %104, ptr %109, align 4, !tbaa !17
  %110 = load i32, ptr %4, align 4, !tbaa !17
  %111 = add nsw i32 %110, 1
  store i32 %111, ptr %4, align 4, !tbaa !17
  br label %112

112:                                              ; preds = %79, %53
  br label %113

113:                                              ; preds = %112
  %114 = load i32, ptr %5, align 4, !tbaa !17
  %115 = add nsw i32 %114, 1
  store i32 %115, ptr %5, align 4, !tbaa !17
  br label %38, !llvm.loop !25

116:                                              ; preds = %43
  %117 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 4
  %118 = load ptr, ptr %117, align 8, !tbaa !22
  %119 = load i32, ptr %4, align 4, !tbaa !17
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds i32, ptr %118, i64 %120
  %122 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 5
  %123 = load ptr, ptr %122, align 8, !tbaa !23
  %124 = load i32, ptr %4, align 4, !tbaa !17
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds i32, ptr %123, i64 %125
  %127 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 2
  %128 = load i32, ptr %127, align 4, !tbaa !16
  %129 = load i32, ptr %4, align 4, !tbaa !17
  %130 = sub nsw i32 %128, %129
  call void @_ZN6tflite18ReverseSortInPlaceEPiS0_i(ptr noundef %121, ptr noundef %126, i32 noundef %130)
  %131 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 8
  store i32 0, ptr %131, align 4, !tbaa !27
  %132 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 7
  store i32 1, ptr %132, align 8, !tbaa !28
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %133 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 6
  %134 = load ptr, ptr %133, align 8, !tbaa !29
  %135 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 8
  %136 = load i32, ptr %135, align 4, !tbaa !27
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::ListEntry", ptr %134, i64 %137
  store ptr %138, ptr %6, align 8, !tbaa !5
  %139 = load ptr, ptr %6, align 8, !tbaa !5
  %140 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::ListEntry", ptr %139, i32 0, i32 2
  store i32 -1, ptr %140, align 4, !tbaa !30
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  %141 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 5
  %142 = load ptr, ptr %141, align 8, !tbaa !23
  %143 = getelementptr inbounds i32, ptr %142, i64 0
  %144 = load i32, ptr %143, align 4, !tbaa !17
  store i32 %144, ptr %7, align 4, !tbaa !17
  %145 = load i32, ptr %7, align 4, !tbaa !17
  %146 = load ptr, ptr %6, align 8, !tbaa !5
  %147 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::ListEntry", ptr %146, i32 0, i32 1
  store i32 %145, ptr %147, align 4, !tbaa !32
  %148 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 3
  %149 = load ptr, ptr %148, align 8, !tbaa !18
  %150 = load i32, ptr %7, align 4, !tbaa !17
  %151 = sext i32 %150 to i64
  %152 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::BufferRequirements", ptr %149, i64 %151
  %153 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::BufferRequirements", ptr %152, i32 0, i32 1
  %154 = load i32, ptr %153, align 4, !tbaa !19
  %155 = icmp eq i32 %154, -1
  br i1 %155, label %156, label %162

156:                                              ; preds = %116
  %157 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 9
  %158 = load ptr, ptr %157, align 8, !tbaa !24
  %159 = load i32, ptr %7, align 4, !tbaa !17
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds i32, ptr %158, i64 %160
  store i32 0, ptr %161, align 4, !tbaa !17
  br label %162

162:                                              ; preds = %156, %116
  %163 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 9
  %164 = load ptr, ptr %163, align 8, !tbaa !24
  %165 = load i32, ptr %7, align 4, !tbaa !17
  %166 = sext i32 %165 to i64
  %167 = getelementptr inbounds i32, ptr %164, i64 %166
  %168 = load i32, ptr %167, align 4, !tbaa !17
  %169 = load ptr, ptr %6, align 8, !tbaa !5
  %170 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::ListEntry", ptr %169, i32 0, i32 0
  store i32 %168, ptr %170, align 4, !tbaa !33
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  store i32 1, ptr %8, align 4, !tbaa !17
  br label %171

171:                                              ; preds = %337, %162
  %172 = load i32, ptr %8, align 4, !tbaa !17
  %173 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 2
  %174 = load i32, ptr %173, align 4, !tbaa !16
  %175 = icmp slt i32 %172, %174
  br i1 %175, label %177, label %176

176:                                              ; preds = %171
  store i32 5, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  br label %340

177:                                              ; preds = %171
  %178 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 5
  %179 = load ptr, ptr %178, align 8, !tbaa !23
  %180 = load i32, ptr %8, align 4, !tbaa !17
  %181 = sext i32 %180 to i64
  %182 = getelementptr inbounds i32, ptr %179, i64 %181
  %183 = load i32, ptr %182, align 4, !tbaa !17
  store i32 %183, ptr %7, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  %184 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 3
  %185 = load ptr, ptr %184, align 8, !tbaa !18
  %186 = load i32, ptr %7, align 4, !tbaa !17
  %187 = sext i32 %186 to i64
  %188 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::BufferRequirements", ptr %185, i64 %187
  store ptr %188, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  %189 = load ptr, ptr %10, align 8, !tbaa !5
  %190 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::BufferRequirements", ptr %189, i32 0, i32 0
  %191 = load i32, ptr %190, align 4, !tbaa !21
  store i32 %191, ptr %11, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  %192 = load ptr, ptr %10, align 8, !tbaa !5
  %193 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::BufferRequirements", ptr %192, i32 0, i32 2
  %194 = load i32, ptr %193, align 4, !tbaa !34
  store i32 %194, ptr %12, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #2
  %195 = load ptr, ptr %10, align 8, !tbaa !5
  %196 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::BufferRequirements", ptr %195, i32 0, i32 3
  %197 = load i32, ptr %196, align 4, !tbaa !35
  store i32 %197, ptr %13, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #2
  store i32 0, ptr %14, align 4, !tbaa !17
  %198 = load ptr, ptr %10, align 8, !tbaa !5
  %199 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::BufferRequirements", ptr %198, i32 0, i32 1
  %200 = load i32, ptr %199, align 4, !tbaa !19
  %201 = icmp eq i32 %200, -1
  br i1 %201, label %202, label %253

202:                                              ; preds = %177
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #2
  store ptr null, ptr %15, align 8, !tbaa !5
  br label %203

203:                                              ; preds = %251, %202
  br label %204

204:                                              ; preds = %203
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #2
  %205 = load ptr, ptr %15, align 8, !tbaa !5
  %206 = load i32, ptr %12, align 4, !tbaa !17
  %207 = load i32, ptr %13, align 4, !tbaa !17
  %208 = call noundef ptr @_ZN6tflite19GreedyMemoryPlanner30NextSimultaneouslyActiveBufferEPKNS0_9ListEntryEii(ptr noundef nonnull align 8 dereferenceable(65) %25, ptr noundef %205, i32 noundef %206, i32 noundef %207)
  store ptr %208, ptr %16, align 8, !tbaa !5
  %209 = load ptr, ptr %15, align 8, !tbaa !5
  %210 = icmp ne ptr %209, null
  br i1 %210, label %211, label %232

211:                                              ; preds = %204
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #2
  %212 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 3
  %213 = load ptr, ptr %212, align 8, !tbaa !18
  %214 = load ptr, ptr %15, align 8, !tbaa !5
  %215 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::ListEntry", ptr %214, i32 0, i32 1
  %216 = load i32, ptr %215, align 4, !tbaa !32
  %217 = sext i32 %216 to i64
  %218 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::BufferRequirements", ptr %213, i64 %217
  store ptr %218, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #2
  %219 = load ptr, ptr %15, align 8, !tbaa !5
  %220 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::ListEntry", ptr %219, i32 0, i32 0
  %221 = load i32, ptr %220, align 4, !tbaa !33
  %222 = load ptr, ptr %17, align 8, !tbaa !5
  %223 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::BufferRequirements", ptr %222, i32 0, i32 0
  %224 = load i32, ptr %223, align 4, !tbaa !21
  %225 = add nsw i32 %221, %224
  store i32 %225, ptr %18, align 4, !tbaa !17
  %226 = load i32, ptr %18, align 4, !tbaa !17
  %227 = load i32, ptr %14, align 4, !tbaa !17
  %228 = icmp sgt i32 %226, %227
  br i1 %228, label %229, label %231

229:                                              ; preds = %211
  %230 = load i32, ptr %18, align 4, !tbaa !17
  store i32 %230, ptr %14, align 4, !tbaa !17
  br label %231

231:                                              ; preds = %229, %211
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #2
  br label %232

232:                                              ; preds = %231, %204
  %233 = load ptr, ptr %16, align 8, !tbaa !5
  %234 = icmp eq ptr %233, null
  br i1 %234, label %235, label %236

235:                                              ; preds = %232
  store i32 9, ptr %9, align 4
  br label %249

236:                                              ; preds = %232
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #2
  %237 = load ptr, ptr %16, align 8, !tbaa !5
  %238 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::ListEntry", ptr %237, i32 0, i32 0
  %239 = load i32, ptr %238, align 4, !tbaa !33
  %240 = load i32, ptr %14, align 4, !tbaa !17
  %241 = sub nsw i32 %239, %240
  store i32 %241, ptr %19, align 4, !tbaa !17
  %242 = load i32, ptr %19, align 4, !tbaa !17
  %243 = load i32, ptr %11, align 4, !tbaa !17
  %244 = icmp sge i32 %242, %243
  br i1 %244, label %245, label %246

245:                                              ; preds = %236
  store i32 9, ptr %9, align 4
  br label %248

246:                                              ; preds = %236
  %247 = load ptr, ptr %16, align 8, !tbaa !5
  store ptr %247, ptr %15, align 8, !tbaa !5
  store i32 0, ptr %9, align 4
  br label %248

248:                                              ; preds = %246, %245
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #2
  br label %249

249:                                              ; preds = %248, %235
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #2
  %250 = load i32, ptr %9, align 4
  switch i32 %250, label %342 [
    i32 0, label %251
    i32 9, label %252
  ]

251:                                              ; preds = %249
  br label %203, !llvm.loop !36

252:                                              ; preds = %249
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #2
  br label %257

253:                                              ; preds = %177
  %254 = load ptr, ptr %10, align 8, !tbaa !5
  %255 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::BufferRequirements", ptr %254, i32 0, i32 1
  %256 = load i32, ptr %255, align 4, !tbaa !19
  store i32 %256, ptr %14, align 4, !tbaa !17
  br label %257

257:                                              ; preds = %253, %252
  %258 = load i32, ptr %14, align 4, !tbaa !17
  %259 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 9
  %260 = load ptr, ptr %259, align 8, !tbaa !24
  %261 = load i32, ptr %7, align 4, !tbaa !17
  %262 = sext i32 %261 to i64
  %263 = getelementptr inbounds i32, ptr %260, i64 %262
  store i32 %258, ptr %263, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #2
  %264 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 6
  %265 = load ptr, ptr %264, align 8, !tbaa !29
  %266 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 7
  %267 = load i32, ptr %266, align 8, !tbaa !28
  %268 = sext i32 %267 to i64
  %269 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::ListEntry", ptr %265, i64 %268
  store ptr %269, ptr %20, align 8, !tbaa !5
  %270 = load i32, ptr %14, align 4, !tbaa !17
  %271 = load ptr, ptr %20, align 8, !tbaa !5
  %272 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::ListEntry", ptr %271, i32 0, i32 0
  store i32 %270, ptr %272, align 4, !tbaa !33
  %273 = load i32, ptr %7, align 4, !tbaa !17
  %274 = load ptr, ptr %20, align 8, !tbaa !5
  %275 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::ListEntry", ptr %274, i32 0, i32 1
  store i32 %273, ptr %275, align 4, !tbaa !32
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #2
  %276 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 7
  %277 = load i32, ptr %276, align 8, !tbaa !28
  store i32 %277, ptr %21, align 4, !tbaa !17
  %278 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 7
  %279 = load i32, ptr %278, align 8, !tbaa !28
  %280 = add nsw i32 %279, 1
  store i32 %280, ptr %278, align 8, !tbaa !28
  %281 = load ptr, ptr %6, align 8, !tbaa !5
  %282 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::ListEntry", ptr %281, i32 0, i32 0
  %283 = load i32, ptr %282, align 4, !tbaa !33
  %284 = load i32, ptr %14, align 4, !tbaa !17
  %285 = icmp sgt i32 %283, %284
  br i1 %285, label %286, label %294

286:                                              ; preds = %257
  %287 = load ptr, ptr %20, align 8, !tbaa !5
  store ptr %287, ptr %6, align 8, !tbaa !5
  %288 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 8
  %289 = load i32, ptr %288, align 4, !tbaa !27
  %290 = load ptr, ptr %6, align 8, !tbaa !5
  %291 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::ListEntry", ptr %290, i32 0, i32 2
  store i32 %289, ptr %291, align 4, !tbaa !30
  %292 = load i32, ptr %21, align 4, !tbaa !17
  %293 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 8
  store i32 %292, ptr %293, align 4, !tbaa !27
  br label %336

294:                                              ; preds = %257
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #2
  %295 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %295, ptr %22, align 8, !tbaa !5
  br label %296

296:                                              ; preds = %334, %294
  br label %297

297:                                              ; preds = %296
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #2
  %298 = load ptr, ptr %22, align 8, !tbaa !5
  %299 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::ListEntry", ptr %298, i32 0, i32 2
  %300 = load i32, ptr %299, align 4, !tbaa !30
  store i32 %300, ptr %23, align 4, !tbaa !17
  %301 = load i32, ptr %23, align 4, !tbaa !17
  %302 = icmp eq i32 %301, -1
  br i1 %302, label %303, label %309

303:                                              ; preds = %297
  %304 = load i32, ptr %21, align 4, !tbaa !17
  %305 = load ptr, ptr %22, align 8, !tbaa !5
  %306 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::ListEntry", ptr %305, i32 0, i32 2
  store i32 %304, ptr %306, align 4, !tbaa !30
  %307 = load ptr, ptr %20, align 8, !tbaa !5
  %308 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::ListEntry", ptr %307, i32 0, i32 2
  store i32 -1, ptr %308, align 4, !tbaa !30
  store i32 11, ptr %9, align 4
  br label %332

309:                                              ; preds = %297
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #2
  %310 = getelementptr inbounds %"class.tflite::GreedyMemoryPlanner", ptr %25, i32 0, i32 6
  %311 = load ptr, ptr %310, align 8, !tbaa !29
  %312 = load i32, ptr %23, align 4, !tbaa !17
  %313 = sext i32 %312 to i64
  %314 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::ListEntry", ptr %311, i64 %313
  store ptr %314, ptr %24, align 8, !tbaa !5
  %315 = load ptr, ptr %24, align 8, !tbaa !5
  %316 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::ListEntry", ptr %315, i32 0, i32 0
  %317 = load i32, ptr %316, align 4, !tbaa !33
  %318 = load i32, ptr %14, align 4, !tbaa !17
  %319 = icmp sgt i32 %317, %318
  br i1 %319, label %320, label %329

320:                                              ; preds = %309
  %321 = load ptr, ptr %22, align 8, !tbaa !5
  %322 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::ListEntry", ptr %321, i32 0, i32 2
  %323 = load i32, ptr %322, align 4, !tbaa !30
  %324 = load ptr, ptr %20, align 8, !tbaa !5
  %325 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::ListEntry", ptr %324, i32 0, i32 2
  store i32 %323, ptr %325, align 4, !tbaa !30
  %326 = load i32, ptr %21, align 4, !tbaa !17
  %327 = load ptr, ptr %22, align 8, !tbaa !5
  %328 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::ListEntry", ptr %327, i32 0, i32 2
  store i32 %326, ptr %328, align 4, !tbaa !30
  store i32 11, ptr %9, align 4
  br label %331

329:                                              ; preds = %309
  %330 = load ptr, ptr %24, align 8, !tbaa !5
  store ptr %330, ptr %22, align 8, !tbaa !5
  store i32 0, ptr %9, align 4
  br label %331

331:                                              ; preds = %329, %320
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #2
  br label %332

332:                                              ; preds = %331, %303
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #2
  %333 = load i32, ptr %9, align 4
  switch i32 %333, label %342 [
    i32 0, label %334
    i32 11, label %335
  ]

334:                                              ; preds = %332
  br label %296, !llvm.loop !37

335:                                              ; preds = %332
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #2
  br label %336

336:                                              ; preds = %335, %286
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  br label %337

337:                                              ; preds = %336
  %338 = load i32, ptr %8, align 4, !tbaa !17
  %339 = add nsw i32 %338, 1
  store i32 %339, ptr %8, align 4, !tbaa !17
  br label %171, !llvm.loop !38

340:                                              ; preds = %176
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  br label %341

341:                                              ; preds = %340, %33
  ret void

342:                                              ; preds = %332, %249
  unreachable
}

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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, !13, i64 64}
!10 = !{!"_ZTSN6tflite19GreedyMemoryPlannerE", !11, i64 0, !12, i64 8, !12, i64 12, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !12, i64 48, !12, i64 52, !6, i64 56, !13, i64 64}
!11 = !{!"_ZTSN6tflite18MicroMemoryPlannerE"}
!12 = !{!"int", !7, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = !{!10, !12, i64 12}
!17 = !{!12, !12, i64 0}
!18 = !{!10, !6, i64 16}
!19 = !{!20, !12, i64 4}
!20 = !{!"_ZTSN6tflite19GreedyMemoryPlanner18BufferRequirementsE", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12}
!21 = !{!20, !12, i64 0}
!22 = !{!10, !6, i64 24}
!23 = !{!10, !6, i64 32}
!24 = !{!10, !6, i64 56}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = !{!10, !12, i64 52}
!28 = !{!10, !12, i64 48}
!29 = !{!10, !6, i64 40}
!30 = !{!31, !12, i64 8}
!31 = !{!"_ZTSN6tflite19GreedyMemoryPlanner9ListEntryE", !12, i64 0, !12, i64 4, !12, i64 8}
!32 = !{!31, !12, i64 4}
!33 = !{!31, !12, i64 0}
!34 = !{!20, !12, i64 8}
!35 = !{!20, !12, i64 12}
!36 = distinct !{!36, !26}
!37 = distinct !{!37, !26}
!38 = distinct !{!38, !26}


; 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.tflite::GreedyMemoryPlanner::BufferRequirements" = type { i32, i32, i32, i32 }
%"struct.tflite::GreedyMemoryPlanner::ListEntry" = type { i32, i32, i32 }

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN6tflite19GreedyMemoryPlanner30NextSimultaneouslyActiveBufferEPKNS0_9ListEntryEii(ptr noundef nonnull align 8 dereferenceable(65), ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN6tflite19GreedyMemoryPlanner24CalculateOffsetsIfNeededEv(ptr noundef nonnull align 8 dereferenceable(65) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 64
  %3 = load i8, ptr %2, align 8, !tbaa !5, !range !13, !noundef !14
  %4 = trunc nuw i8 %3 to i1
  br i1 %4, label %5, label %.loopexit

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 12
  %7 = load i32, ptr %6, align 4, !tbaa !15
  %8 = icmp eq i32 %7, 0
  br i1 %8, label %.loopexit, label %9

9:                                                ; preds = %5
  store i8 0, ptr %2, align 8, !tbaa !5
  %10 = icmp sgt i32 %7, 0
  br i1 %10, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %9
  %11 = getelementptr inbounds i8, ptr %0, i64 16
  %12 = load ptr, ptr %11, align 8, !tbaa !16
  %13 = getelementptr inbounds i8, ptr %0, i64 24
  %14 = load ptr, ptr %13, align 8
  %15 = getelementptr inbounds i8, ptr %0, i64 32
  %16 = load ptr, ptr %15, align 8
  %17 = getelementptr inbounds i8, ptr %0, i64 56
  %18 = load ptr, ptr %17, align 8
  br label %44

._crit_edge:                                      ; preds = %65, %9
  %.078.lcssa = phi i32 [ 0, %9 ], [ %.179, %65 ]
  %.lcssa = phi i32 [ %7, %9 ], [ %67, %65 ]
  %19 = getelementptr inbounds i8, ptr %0, i64 24
  %20 = load ptr, ptr %19, align 8, !tbaa !17
  %21 = sext i32 %.078.lcssa to i64
  %22 = getelementptr inbounds i32, ptr %20, i64 %21
  %23 = getelementptr inbounds i8, ptr %0, i64 32
  %24 = load ptr, ptr %23, align 8, !tbaa !18
  %25 = getelementptr inbounds i32, ptr %24, i64 %21
  %26 = sub nsw i32 %.lcssa, %.078.lcssa
  tail call void @_ZN6tflite18ReverseSortInPlaceEPiS0_i(ptr noundef %22, ptr noundef %25, i32 noundef %26)
  %27 = getelementptr inbounds i8, ptr %0, i64 52
  store i32 0, ptr %27, align 4, !tbaa !19
  %28 = getelementptr inbounds i8, ptr %0, i64 48
  store i32 1, ptr %28, align 8, !tbaa !20
  %29 = getelementptr inbounds i8, ptr %0, i64 40
  %30 = load ptr, ptr %29, align 8, !tbaa !21
  %31 = getelementptr inbounds i8, ptr %30, i64 8
  store i32 -1, ptr %31, align 4, !tbaa !22
  %32 = load ptr, ptr %23, align 8, !tbaa !18
  %33 = load i32, ptr %32, align 4, !tbaa !24
  %34 = getelementptr inbounds i8, ptr %30, i64 4
  store i32 %33, ptr %34, align 4, !tbaa !25
  %35 = getelementptr inbounds i8, ptr %0, i64 16
  %36 = load ptr, ptr %35, align 8, !tbaa !16
  %37 = sext i32 %33 to i64
  %38 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::BufferRequirements", ptr %36, i64 %37, i32 1
  %39 = load i32, ptr %38, align 4, !tbaa !26
  %40 = icmp eq i32 %39, -1
  %41 = getelementptr inbounds i8, ptr %0, i64 56
  %42 = load ptr, ptr %41, align 8, !tbaa !28
  %43 = getelementptr inbounds i32, ptr %42, i64 %37
  br i1 %40, label %70, label %._crit_edge._crit_edge

._crit_edge._crit_edge:                           ; preds = %._crit_edge
  %.pre134 = load i32, ptr %43, align 4, !tbaa !24
  br label %71

44:                                               ; preds = %.lr.ph, %65
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %65 ]
  %.0118 = phi i32 [ %7, %.lr.ph ], [ %.1, %65 ]
  %.078117 = phi i32 [ 0, %.lr.ph ], [ %.179, %65 ]
  %45 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::BufferRequirements", ptr %12, i64 %indvars.iv
  %46 = getelementptr inbounds i8, ptr %45, i64 4
  %47 = load i32, ptr %46, align 4, !tbaa !26
  %48 = icmp eq i32 %47, -1
  br i1 %48, label %49, label %56

49:                                               ; preds = %44
  %50 = add nsw i32 %.0118, -1
  %51 = load i32, ptr %45, align 4, !tbaa !29
  %52 = sext i32 %50 to i64
  %53 = getelementptr inbounds i32, ptr %14, i64 %52
  store i32 %51, ptr %53, align 4, !tbaa !24
  %54 = getelementptr inbounds i32, ptr %16, i64 %52
  %55 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %55, ptr %54, align 4, !tbaa !24
  br label %65

56:                                               ; preds = %44
  %57 = load i32, ptr %45, align 4, !tbaa !29
  %58 = sext i32 %.078117 to i64
  %59 = getelementptr inbounds i32, ptr %14, i64 %58
  store i32 %57, ptr %59, align 4, !tbaa !24
  %60 = getelementptr inbounds i32, ptr %16, i64 %58
  %61 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %61, ptr %60, align 4, !tbaa !24
  %62 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::BufferRequirements", ptr %12, i64 %indvars.iv, i32 1
  %63 = load i32, ptr %62, align 4, !tbaa !26
  %64 = add nsw i32 %.078117, 1
  br label %65

65:                                               ; preds = %49, %56
  %.sink = phi i32 [ -1, %49 ], [ %63, %56 ]
  %.179 = phi i32 [ %.078117, %49 ], [ %64, %56 ]
  %.1 = phi i32 [ %50, %49 ], [ %.0118, %56 ]
  %66 = getelementptr inbounds i32, ptr %18, i64 %indvars.iv
  store i32 %.sink, ptr %66, align 4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %67 = load i32, ptr %6, align 4, !tbaa !15
  %68 = sext i32 %67 to i64
  %69 = icmp slt i64 %indvars.iv.next, %68
  br i1 %69, label %44, label %._crit_edge, !llvm.loop !30

70:                                               ; preds = %._crit_edge
  store i32 0, ptr %43, align 4, !tbaa !24
  br label %71

71:                                               ; preds = %._crit_edge._crit_edge, %70
  %72 = phi i32 [ %.pre134, %._crit_edge._crit_edge ], [ 0, %70 ]
  %73 = getelementptr inbounds i8, ptr %0, i64 56
  store i32 %72, ptr %30, align 4, !tbaa !32
  %74 = load i32, ptr %6, align 4, !tbaa !15
  %75 = icmp sgt i32 %74, 1
  br i1 %75, label %.lr.ph124, label %.loopexit

.lr.ph124:                                        ; preds = %71, %.thread108
  %76 = phi ptr [ %107, %.thread108 ], [ %30, %71 ]
  %77 = phi ptr [ %108, %.thread108 ], [ %42, %71 ]
  %indvars.iv130 = phi i64 [ %indvars.iv.next131, %.thread108 ], [ 1, %71 ]
  %.083122 = phi ptr [ %.184, %.thread108 ], [ %30, %71 ]
  %78 = load ptr, ptr %23, align 8, !tbaa !18
  %79 = getelementptr inbounds i32, ptr %78, i64 %indvars.iv130
  %80 = load i32, ptr %79, align 4, !tbaa !24
  %81 = load ptr, ptr %35, align 8, !tbaa !16
  %82 = sext i32 %80 to i64
  %83 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::BufferRequirements", ptr %81, i64 %82
  %84 = load i32, ptr %83, align 4, !tbaa !29
  %85 = getelementptr inbounds i8, ptr %83, i64 8
  %86 = load i32, ptr %85, align 4, !tbaa !33
  %87 = getelementptr inbounds i8, ptr %83, i64 12
  %88 = load i32, ptr %87, align 4, !tbaa !34
  %89 = getelementptr inbounds i8, ptr %83, i64 4
  %90 = load i32, ptr %89, align 4, !tbaa !26
  %91 = icmp eq i32 %90, -1
  br i1 %91, label %.preheader112, label %.thread

.preheader112:                                    ; preds = %.lr.ph124, %104
  %.093 = phi ptr [ %92, %104 ], [ null, %.lr.ph124 ]
  %.089 = phi i32 [ %.291, %104 ], [ 0, %.lr.ph124 ]
  %92 = tail call noundef ptr @_ZN6tflite19GreedyMemoryPlanner30NextSimultaneouslyActiveBufferEPKNS0_9ListEntryEii(ptr noundef nonnull align 8 dereferenceable(65) %0, ptr noundef %.093, i32 noundef %86, i32 noundef %88)
  %.not = icmp eq ptr %.093, null
  br i1 %.not, label %102, label %93

93:                                               ; preds = %.preheader112
  %94 = load ptr, ptr %35, align 8, !tbaa !16
  %95 = getelementptr inbounds i8, ptr %.093, i64 4
  %96 = load i32, ptr %95, align 4, !tbaa !25
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::BufferRequirements", ptr %94, i64 %97
  %99 = load i32, ptr %.093, align 4, !tbaa !32
  %100 = load i32, ptr %98, align 4, !tbaa !29
  %101 = add nsw i32 %100, %99
  %spec.select = tail call i32 @llvm.smax.i32(i32 %101, i32 %.089)
  br label %102

102:                                              ; preds = %93, %.preheader112
  %.291 = phi i32 [ %spec.select, %93 ], [ %.089, %.preheader112 ]
  %103 = icmp eq ptr %92, null
  br i1 %103, label %.thread.loopexit, label %104

104:                                              ; preds = %102
  %105 = load i32, ptr %92, align 4, !tbaa !32
  %106 = sub nsw i32 %105, %.291
  %.not101 = icmp slt i32 %106, %84
  br i1 %.not101, label %.preheader112, label %.thread.loopexit

.thread.loopexit:                                 ; preds = %104, %102
  %.pre135 = load ptr, ptr %73, align 8, !tbaa !28
  %.pre136 = load ptr, ptr %29, align 8, !tbaa !21
  br label %.thread

.thread:                                          ; preds = %.thread.loopexit, %.lr.ph124
  %107 = phi ptr [ %76, %.lr.ph124 ], [ %.pre136, %.thread.loopexit ]
  %108 = phi ptr [ %77, %.lr.ph124 ], [ %.pre135, %.thread.loopexit ]
  %.392 = phi i32 [ %90, %.lr.ph124 ], [ %.291, %.thread.loopexit ]
  %109 = getelementptr inbounds i32, ptr %108, i64 %82
  store i32 %.392, ptr %109, align 4, !tbaa !24
  %110 = load i32, ptr %28, align 8, !tbaa !20
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::ListEntry", ptr %107, i64 %111
  store i32 %.392, ptr %112, align 4, !tbaa !32
  %113 = getelementptr inbounds i8, ptr %112, i64 4
  store i32 %80, ptr %113, align 4, !tbaa !25
  %114 = add nsw i32 %110, 1
  store i32 %114, ptr %28, align 8, !tbaa !20
  %115 = load i32, ptr %.083122, align 4, !tbaa !32
  %116 = icmp sgt i32 %115, %.392
  br i1 %116, label %117, label %.preheader

117:                                              ; preds = %.thread
  %118 = load i32, ptr %27, align 4, !tbaa !19
  %119 = getelementptr inbounds i8, ptr %112, i64 8
  store i32 %118, ptr %119, align 4, !tbaa !22
  store i32 %110, ptr %27, align 4, !tbaa !19
  br label %.thread108

.preheader:                                       ; preds = %.thread, %126
  %.080 = phi ptr [ %128, %126 ], [ %.083122, %.thread ]
  %120 = getelementptr inbounds i8, ptr %.080, i64 8
  %121 = load i32, ptr %120, align 4, !tbaa !22
  %122 = icmp eq i32 %121, -1
  br i1 %122, label %123, label %126

123:                                              ; preds = %.preheader
  %124 = getelementptr inbounds i8, ptr %.080, i64 8
  store i32 %110, ptr %124, align 4, !tbaa !22
  %125 = getelementptr inbounds i8, ptr %112, i64 8
  store i32 -1, ptr %125, align 4, !tbaa !22
  br label %.thread108

126:                                              ; preds = %.preheader
  %127 = sext i32 %121 to i64
  %128 = getelementptr inbounds %"struct.tflite::GreedyMemoryPlanner::ListEntry", ptr %107, i64 %127
  %129 = load i32, ptr %128, align 4, !tbaa !32
  %130 = icmp sgt i32 %129, %.392
  br i1 %130, label %131, label %.preheader

131:                                              ; preds = %126
  %132 = getelementptr inbounds i8, ptr %.080, i64 8
  %133 = getelementptr inbounds i8, ptr %112, i64 8
  store i32 %121, ptr %133, align 4, !tbaa !22
  store i32 %110, ptr %132, align 4, !tbaa !22
  br label %.thread108

.thread108:                                       ; preds = %131, %123, %117
  %.184 = phi ptr [ %112, %117 ], [ %.083122, %123 ], [ %.083122, %131 ]
  %indvars.iv.next131 = add nuw nsw i64 %indvars.iv130, 1
  %134 = load i32, ptr %6, align 4, !tbaa !15
  %135 = sext i32 %134 to i64
  %136 = icmp slt i64 %indvars.iv.next131, %135
  br i1 %136, label %.lr.ph124, label %.loopexit, !llvm.loop !35

.loopexit:                                        ; preds = %.thread108, %71, %1, %5
  ret void
}

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

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 = { 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, !12, i64 64}
!6 = !{!"_ZTSN6tflite19GreedyMemoryPlannerE", !7, i64 0, !8, i64 8, !8, i64 12, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !8, i64 48, !8, i64 52, !11, i64 56, !12, i64 64}
!7 = !{!"_ZTSN6tflite18MicroMemoryPlannerE"}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!"bool", !9, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!6, !8, i64 12}
!16 = !{!6, !11, i64 16}
!17 = !{!6, !11, i64 24}
!18 = !{!6, !11, i64 32}
!19 = !{!6, !8, i64 52}
!20 = !{!6, !8, i64 48}
!21 = !{!6, !11, i64 40}
!22 = !{!23, !8, i64 8}
!23 = !{!"_ZTSN6tflite19GreedyMemoryPlanner9ListEntryE", !8, i64 0, !8, i64 4, !8, i64 8}
!24 = !{!8, !8, i64 0}
!25 = !{!23, !8, i64 4}
!26 = !{!27, !8, i64 4}
!27 = !{!"_ZTSN6tflite19GreedyMemoryPlanner18BufferRequirementsE", !8, i64 0, !8, i64 4, !8, i64 8, !8, i64 12}
!28 = !{!6, !11, i64 56}
!29 = !{!27, !8, i64 0}
!30 = distinct !{!30, !31}
!31 = !{!"llvm.loop.mustprogress"}
!32 = !{!23, !8, i64 0}
!33 = !{!27, !8, i64 8}
!34 = !{!27, !8, i64 12}
!35 = distinct !{!35, !31}


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