; LLVM IR from jingweizhanghuai/Morn :: src/util (morn_memory_block)

; 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.HandleList = type { %struct.MList, i32, i32, i32, i32 }
%struct.MList = type { i32, ptr }
%struct.MHandle = type { i32, i32, ptr, ptr }
%struct.MMemoryBlock = type { i32, i32, ptr, ptr, ptr, i32 }
%struct.HandleMemory = type { i32, i32, i32, i32, ptr, i32, i32, ptr, i32 }

@.str = external hidden unnamed_addr constant [84 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [14 x i8], align 1
@__FUNCTION__.mMemoryRedefine = external hidden unnamed_addr constant [16 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [15 x i8], align 1

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

declare void @m_Exception(i32 noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ...) #1

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @mMemoryBlockCreate(i32 noundef, i32 noundef) #2

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

; Function Attrs: nounwind uwtable
declare dso_local void @mMemoryBlockRelease(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @mMemoryBlockRead(ptr noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local void @mMemoryRedefine(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %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 ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = icmp eq ptr %20, null
  br i1 %21, label %26, label %22

22:                                               ; preds = %19
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = ptrtoint ptr %23 to i64
  %25 = icmp eq i64 %24, -1
  br label %26

26:                                               ; preds = %22, %19
  %27 = phi i1 [ true, %19 ], [ %25, %22 ]
  %28 = zext i1 %27 to i32
  store i32 %28, ptr %9, align 4, !tbaa !9
  %29 = load i32, ptr %9, align 4, !tbaa !9
  %30 = icmp ne i32 %29, 0
  br i1 %30, label %31, label %33

31:                                               ; preds = %26
  %32 = load i32, ptr %9, align 4, !tbaa !9
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %32, i32 noundef -1, ptr noundef @.str, i32 noundef 459, ptr noundef @__FUNCTION__.mMemoryRedefine, ptr noundef @.str.4)
  br label %33

33:                                               ; preds = %31, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %34

34:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.HandleList, ptr %35, i64 -1
  %37 = getelementptr inbounds %struct.HandleList, ptr %36, i32 0, i32 0
  %38 = getelementptr inbounds %struct.MList, ptr %37, i32 0, i32 1
  %39 = load ptr, ptr %38, align 8, !tbaa !11
  %40 = getelementptr inbounds ptr, ptr %39, i64 0
  %41 = load ptr, ptr %40, align 8, !tbaa !5
  store ptr %41, ptr %10, align 8, !tbaa !5
  br label %42

42:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %43 = load ptr, ptr %10, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.MHandle, ptr %43, i32 0, i32 0
  %45 = load volatile i32, ptr %44, align 8, !tbaa !14
  %46 = icmp ne i32 %45, 628699680
  %47 = zext i1 %46 to i32
  store i32 %47, ptr %11, align 4, !tbaa !9
  %48 = load i32, ptr %11, align 4, !tbaa !9
  %49 = icmp ne i32 %48, 0
  br i1 %49, label %50, label %52

50:                                               ; preds = %42
  %51 = load i32, ptr %11, align 4, !tbaa !9
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %51, i32 noundef -1, ptr noundef @.str, i32 noundef 461, ptr noundef @__FUNCTION__.mMemoryRedefine, ptr noundef @.str.5)
  br label %52

52:                                               ; preds = %50, %42
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %53

53:                                               ; preds = %52
  br label %54

54:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %55 = load ptr, ptr %10, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.MHandle, ptr %55, i32 0, i32 3
  %57 = load ptr, ptr %56, align 8, !tbaa !16
  store ptr %57, ptr %12, align 8, !tbaa !5
  %58 = load i32, ptr %6, align 4, !tbaa !9
  %59 = icmp sle i32 %58, 0
  br i1 %59, label %60, label %64

60:                                               ; preds = %54
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.MList, ptr %61, i32 0, i32 0
  %63 = load i32, ptr %62, align 8, !tbaa !17
  store i32 %63, ptr %6, align 4, !tbaa !9
  br label %64

64:                                               ; preds = %60, %54
  %65 = load i32, ptr %6, align 4, !tbaa !9
  %66 = icmp sle i32 %65, 0
  br i1 %66, label %67, label %68

67:                                               ; preds = %64
  store i32 1, ptr %13, align 4
  br label %232

68:                                               ; preds = %64
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %69 = load i32, ptr %8, align 4, !tbaa !9
  %70 = icmp slt i32 %69, 0
  br i1 %70, label %71, label %80

71:                                               ; preds = %68
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.MList, ptr %72, i32 0, i32 1
  %74 = load ptr, ptr %73, align 8, !tbaa !18
  %75 = getelementptr inbounds ptr, ptr %74, i64 0
  %76 = load ptr, ptr %75, align 8, !tbaa !5
  store ptr %76, ptr %14, align 8, !tbaa !5
  %77 = load ptr, ptr %14, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.MMemoryBlock, ptr %77, i32 0, i32 0
  %79 = load i32, ptr %78, align 8, !tbaa !19
  store i32 %79, ptr %8, align 4, !tbaa !9
  br label %80

80:                                               ; preds = %71, %68
  %81 = load i32, ptr %6, align 4, !tbaa !9
  %82 = load ptr, ptr %12, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.HandleMemory, ptr %82, i32 0, i32 2
  %84 = load i32, ptr %83, align 8, !tbaa !21
  %85 = icmp sgt i32 %81, %84
  br i1 %85, label %86, label %140

86:                                               ; preds = %80
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  %87 = load ptr, ptr %12, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.HandleMemory, ptr %87, i32 0, i32 2
  %89 = load i32, ptr %88, align 8, !tbaa !21
  %90 = add nsw i32 %89, 8
  %91 = load i32, ptr %6, align 4, !tbaa !9
  %92 = icmp sgt i32 %90, %91
  br i1 %92, label %93, label %98

93:                                               ; preds = %86
  %94 = load ptr, ptr %12, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.HandleMemory, ptr %94, i32 0, i32 2
  %96 = load i32, ptr %95, align 8, !tbaa !21
  %97 = add nsw i32 %96, 8
  br label %100

98:                                               ; preds = %86
  %99 = load i32, ptr %6, align 4, !tbaa !9
  br label %100

100:                                              ; preds = %98, %93
  %101 = phi i32 [ %97, %93 ], [ %99, %98 ]
  store i32 %101, ptr %15, align 4, !tbaa !9
  %102 = load i32, ptr %15, align 4, !tbaa !9
  %103 = load ptr, ptr %12, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.HandleMemory, ptr %103, i32 0, i32 2
  store i32 %102, ptr %104, align 8, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  %105 = load i32, ptr %15, align 4, !tbaa !9
  %106 = sext i32 %105 to i64
  %107 = mul i64 %106, 8
  %108 = call noalias ptr @malloc(i64 noundef %107) #7
  store ptr %108, ptr %16, align 8, !tbaa !5
  %109 = load ptr, ptr %5, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.MList, ptr %109, i32 0, i32 0
  %111 = load i32, ptr %110, align 8, !tbaa !17
  %112 = icmp sgt i32 %111, 0
  br i1 %112, label %113, label %123

113:                                              ; preds = %100
  %114 = load ptr, ptr %16, align 8, !tbaa !5
  %115 = load ptr, ptr %5, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.MList, ptr %115, i32 0, i32 1
  %117 = load ptr, ptr %116, align 8, !tbaa !18
  %118 = load ptr, ptr %5, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.MList, ptr %118, i32 0, i32 0
  %120 = load i32, ptr %119, align 8, !tbaa !17
  %121 = sext i32 %120 to i64
  %122 = mul i64 %121, 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %114, ptr align 8 %117, i64 %122, i1 false)
  br label %123

123:                                              ; preds = %113, %100
  %124 = load ptr, ptr %16, align 8, !tbaa !5
  %125 = load ptr, ptr %5, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.MList, ptr %125, i32 0, i32 0
  %127 = load i32, ptr %126, align 8, !tbaa !17
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds ptr, ptr %124, i64 %128
  %130 = load i32, ptr %15, align 4, !tbaa !9
  %131 = load ptr, ptr %5, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct.MList, ptr %131, i32 0, i32 0
  %133 = load i32, ptr %132, align 8, !tbaa !17
  %134 = sub nsw i32 %130, %133
  %135 = sext i32 %134 to i64
  %136 = mul i64 %135, 8
  call void @llvm.memset.p0.i64(ptr align 8 %129, i8 0, i64 %136, i1 false)
  %137 = load ptr, ptr %16, align 8, !tbaa !5
  %138 = load ptr, ptr %5, align 8, !tbaa !5
  %139 = getelementptr inbounds %struct.MList, ptr %138, i32 0, i32 1
  store ptr %137, ptr %139, align 8, !tbaa !18
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  br label %140

140:                                              ; preds = %123, %80
  %141 = load i32, ptr %6, align 4, !tbaa !9
  %142 = load ptr, ptr %5, align 8, !tbaa !5
  %143 = getelementptr inbounds %struct.MList, ptr %142, i32 0, i32 0
  store i32 %141, ptr %143, align 8, !tbaa !17
  %144 = load i32, ptr %7, align 4, !tbaa !9
  %145 = icmp sle i32 %144, 0
  br i1 %145, label %146, label %153

146:                                              ; preds = %140
  %147 = load i32, ptr %8, align 4, !tbaa !9
  %148 = load ptr, ptr %12, align 8, !tbaa !5
  %149 = getelementptr inbounds %struct.HandleMemory, ptr %148, i32 0, i32 1
  %150 = load i32, ptr %149, align 4, !tbaa !23
  %151 = icmp eq i32 %147, %150
  br i1 %151, label %152, label %153

152:                                              ; preds = %146
  store i32 1, ptr %13, align 4
  br label %231

153:                                              ; preds = %146, %140
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  store i32 0, ptr %17, align 4, !tbaa !9
  br label %154

154:                                              ; preds = %218, %153
  %155 = load i32, ptr %17, align 4, !tbaa !9
  %156 = load i32, ptr %6, align 4, !tbaa !9
  %157 = icmp slt i32 %155, %156
  br i1 %157, label %159, label %158

158:                                              ; preds = %154
  store i32 6, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  br label %221

159:                                              ; preds = %154
  %160 = load ptr, ptr %5, align 8, !tbaa !5
  %161 = getelementptr inbounds %struct.MList, ptr %160, i32 0, i32 1
  %162 = load ptr, ptr %161, align 8, !tbaa !18
  %163 = load i32, ptr %17, align 4, !tbaa !9
  %164 = sext i32 %163 to i64
  %165 = getelementptr inbounds ptr, ptr %162, i64 %164
  %166 = load ptr, ptr %165, align 8, !tbaa !5
  store ptr %166, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #6
  %167 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %167, ptr %18, align 4, !tbaa !9
  %168 = load ptr, ptr %14, align 8, !tbaa !5
  %169 = icmp eq ptr %168, null
  br i1 %169, label %170, label %184

170:                                              ; preds = %159
  %171 = load i32, ptr %18, align 4, !tbaa !9
  %172 = icmp sgt i32 %171, 0
  br i1 %172, label %173, label %183

173:                                              ; preds = %170
  %174 = load i32, ptr %18, align 4, !tbaa !9
  %175 = load i32, ptr %8, align 4, !tbaa !9
  %176 = call ptr @mMemoryBlockCreate(i32 noundef %174, i32 noundef %175)
  %177 = load ptr, ptr %5, align 8, !tbaa !5
  %178 = getelementptr inbounds %struct.MList, ptr %177, i32 0, i32 1
  %179 = load ptr, ptr %178, align 8, !tbaa !18
  %180 = load i32, ptr %17, align 4, !tbaa !9
  %181 = sext i32 %180 to i64
  %182 = getelementptr inbounds ptr, ptr %179, i64 %181
  store ptr %176, ptr %182, align 8, !tbaa !5
  br label %183

183:                                              ; preds = %173, %170
  br label %217

184:                                              ; preds = %159
  %185 = load i32, ptr %18, align 4, !tbaa !9
  %186 = icmp sle i32 %185, 0
  br i1 %186, label %187, label %191

187:                                              ; preds = %184
  %188 = load ptr, ptr %14, align 8, !tbaa !5
  %189 = getelementptr inbounds %struct.MMemoryBlock, ptr %188, i32 0, i32 1
  %190 = load i32, ptr %189, align 4, !tbaa !24
  store i32 %190, ptr %18, align 4, !tbaa !9
  br label %191

191:                                              ; preds = %187, %184
  %192 = load i32, ptr %18, align 4, !tbaa !9
  %193 = load ptr, ptr %14, align 8, !tbaa !5
  %194 = getelementptr inbounds %struct.MMemoryBlock, ptr %193, i32 0, i32 1
  %195 = load i32, ptr %194, align 4, !tbaa !24
  %196 = icmp sgt i32 %192, %195
  br i1 %196, label %203, label %197

197:                                              ; preds = %191
  %198 = load ptr, ptr %14, align 8, !tbaa !5
  %199 = getelementptr inbounds %struct.MMemoryBlock, ptr %198, i32 0, i32 0
  %200 = load i32, ptr %199, align 8, !tbaa !19
  %201 = load i32, ptr %8, align 4, !tbaa !9
  %202 = icmp ne i32 %200, %201
  br i1 %202, label %203, label %214

203:                                              ; preds = %197, %191
  %204 = load ptr, ptr %14, align 8, !tbaa !5
  call void @mMemoryBlockRelease(ptr noundef %204)
  %205 = load i32, ptr %18, align 4, !tbaa !9
  %206 = load i32, ptr %8, align 4, !tbaa !9
  %207 = call ptr @mMemoryBlockCreate(i32 noundef %205, i32 noundef %206)
  %208 = load ptr, ptr %5, align 8, !tbaa !5
  %209 = getelementptr inbounds %struct.MList, ptr %208, i32 0, i32 1
  %210 = load ptr, ptr %209, align 8, !tbaa !18
  %211 = load i32, ptr %17, align 4, !tbaa !9
  %212 = sext i32 %211 to i64
  %213 = getelementptr inbounds ptr, ptr %210, i64 %212
  store ptr %207, ptr %213, align 8, !tbaa !5
  br label %216

214:                                              ; preds = %197
  %215 = load ptr, ptr %14, align 8, !tbaa !5
  call void @mMemoryBlockRead(ptr noundef %215)
  br label %216

216:                                              ; preds = %214, %203
  br label %217

217:                                              ; preds = %216, %183
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  br label %218

218:                                              ; preds = %217
  %219 = load i32, ptr %17, align 4, !tbaa !9
  %220 = add nsw i32 %219, 1
  store i32 %220, ptr %17, align 4, !tbaa !9
  br label %154, !llvm.loop !25

221:                                              ; preds = %158
  %222 = load i32, ptr %8, align 4, !tbaa !9
  %223 = icmp sgt i32 %222, 0
  br i1 %223, label %224, label %228

224:                                              ; preds = %221
  %225 = load i32, ptr %8, align 4, !tbaa !9
  %226 = load ptr, ptr %12, align 8, !tbaa !5
  %227 = getelementptr inbounds %struct.HandleMemory, ptr %226, i32 0, i32 1
  store i32 %225, ptr %227, align 4, !tbaa !23
  br label %228

228:                                              ; preds = %224, %221
  %229 = load ptr, ptr %12, align 8, !tbaa !5
  %230 = getelementptr inbounds %struct.HandleMemory, ptr %229, i32 0, i32 0
  store i32 0, ptr %230, align 8, !tbaa !27
  store i32 0, ptr %13, align 4
  br label %231

231:                                              ; preds = %228, %152
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  br label %232

232:                                              ; preds = %231, %67
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  %233 = load i32, ptr %13, align 4
  switch i32 %233, label %235 [
    i32 0, label %234
    i32 1, label %234
  ]

234:                                              ; preds = %232, %232
  ret void

235:                                              ; preds = %232
  unreachable
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"HandleList", !13, i64 0, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28}
!13 = !{!"MList", !10, i64 0, !6, i64 8}
!14 = !{!15, !10, i64 0}
!15 = !{!"MHandle", !10, i64 0, !10, i64 4, !6, i64 8, !6, i64 16}
!16 = !{!15, !6, i64 16}
!17 = !{!13, !10, i64 0}
!18 = !{!13, !6, i64 8}
!19 = !{!20, !10, i64 0}
!20 = !{!"MMemoryBlock", !10, i64 0, !10, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !10, i64 32}
!21 = !{!22, !10, i64 8}
!22 = !{!"HandleMemory", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !6, i64 16, !10, i64 24, !10, i64 28, !6, i64 32, !10, i64 40}
!23 = !{!22, !10, i64 4}
!24 = !{!20, !10, i64 4}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = !{!22, !10, i64 0}


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

@.str = external hidden unnamed_addr constant [84 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [14 x i8], align 1
@__FUNCTION__.mMemoryRedefine = external hidden unnamed_addr constant [16 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [15 x i8], align 1

declare void @m_Exception(i32 noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @mMemoryBlockCreate(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local void @mMemoryBlockRelease(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @mMemoryBlockRead(ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local void @mMemoryRedefine(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #1 {
  %magicptr = ptrtoint ptr %0 to i64
  switch i64 %magicptr, label %10 [
    i64 -1, label %5
    i64 0, label %5
  ]

5:                                                ; preds = %4, %4
  %6 = icmp eq ptr %0, null
  %7 = icmp eq ptr %0, inttoptr (i64 -1 to ptr)
  %8 = or i1 %6, %7
  %9 = zext i1 %8 to i32
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %9, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 459, ptr noundef nonnull @__FUNCTION__.mMemoryRedefine, ptr noundef nonnull @.str.4) #6
  br label %10

10:                                               ; preds = %4, %5
  %11 = getelementptr inbounds i8, ptr %0, i64 -24
  %12 = load ptr, ptr %11, align 8, !tbaa !5
  %13 = load ptr, ptr %12, align 8, !tbaa !12
  %14 = load volatile i32, ptr %13, align 8, !tbaa !13
  %.not78 = icmp eq i32 %14, 628699680
  br i1 %.not78, label %16, label %15

15:                                               ; preds = %10
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 461, ptr noundef nonnull @__FUNCTION__.mMemoryRedefine, ptr noundef nonnull @.str.5) #6
  br label %16

16:                                               ; preds = %15, %10
  %17 = getelementptr inbounds i8, ptr %13, i64 16
  %18 = load ptr, ptr %17, align 8, !tbaa !15
  %19 = icmp slt i32 %1, 1
  br i1 %19, label %20, label %.thread

20:                                               ; preds = %16
  %21 = load i32, ptr %0, align 8, !tbaa !16
  %22 = icmp slt i32 %21, 1
  br i1 %22, label %98, label %.thread

.thread:                                          ; preds = %16, %20
  %.06777 = phi i32 [ %21, %20 ], [ %1, %16 ]
  %23 = icmp slt i32 %3, 0
  br i1 %23, label %24, label %29

24:                                               ; preds = %.thread
  %25 = getelementptr inbounds i8, ptr %0, i64 8
  %26 = load ptr, ptr %25, align 8, !tbaa !17
  %27 = load ptr, ptr %26, align 8, !tbaa !12
  %28 = load i32, ptr %27, align 8, !tbaa !18
  br label %29

29:                                               ; preds = %24, %.thread
  %.068 = phi i32 [ %28, %24 ], [ %3, %.thread ]
  %30 = getelementptr inbounds i8, ptr %18, i64 8
  %31 = load i32, ptr %30, align 8, !tbaa !20
  %32 = icmp sgt i32 %.06777, %31
  br i1 %32, label %33, label %52

33:                                               ; preds = %29
  %34 = add nsw i32 %31, 8
  %..067 = tail call i32 @llvm.smax.i32(i32 %34, i32 %.06777)
  store i32 %..067, ptr %30, align 8, !tbaa !20
  %35 = zext nneg i32 %..067 to i64
  %36 = shl nuw nsw i64 %35, 3
  %37 = tail call noalias ptr @malloc(i64 noundef %36) #7
  %38 = load i32, ptr %0, align 8, !tbaa !16
  %39 = icmp sgt i32 %38, 0
  br i1 %39, label %40, label %45

40:                                               ; preds = %33
  %41 = getelementptr inbounds i8, ptr %0, i64 8
  %42 = load ptr, ptr %41, align 8, !tbaa !17
  %43 = zext nneg i32 %38 to i64
  %44 = shl nuw nsw i64 %43, 3
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 8 %37, ptr align 8 %42, i64 %44, i1 false)
  br label %45

45:                                               ; preds = %40, %33
  %46 = sext i32 %38 to i64
  %47 = getelementptr inbounds ptr, ptr %37, i64 %46
  %48 = sub nsw i32 %..067, %38
  %49 = sext i32 %48 to i64
  %50 = shl nsw i64 %49, 3
  tail call void @llvm.memset.p0.i64(ptr align 8 %47, i8 0, i64 %50, i1 false)
  %51 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %37, ptr %51, align 8, !tbaa !17
  br label %52

52:                                               ; preds = %45, %29
  store i32 %.06777, ptr %0, align 8, !tbaa !16
  %53 = icmp slt i32 %2, 1
  br i1 %53, label %54, label %.split.us.split.preheader

54:                                               ; preds = %52
  %55 = getelementptr inbounds i8, ptr %18, i64 4
  %56 = load i32, ptr %55, align 4, !tbaa !22
  %57 = icmp eq i32 %.068, %56
  br i1 %57, label %98, label %.split.split.us.preheader

.split.split.us.preheader:                        ; preds = %54
  %58 = getelementptr inbounds i8, ptr %0, i64 8
  %wide.trip.count = zext nneg i32 %.06777 to i64
  br label %.split.split.us

.split.us.split.preheader:                        ; preds = %52
  %59 = getelementptr inbounds i8, ptr %0, i64 8
  %wide.trip.count91 = zext nneg i32 %.06777 to i64
  br label %.split.us.split

.split.us.split:                                  ; preds = %.split.us.split.preheader, %79
  %indvars.iv87 = phi i64 [ 0, %.split.us.split.preheader ], [ %indvars.iv.next88, %79 ]
  %60 = load ptr, ptr %59, align 8, !tbaa !17
  %61 = getelementptr inbounds ptr, ptr %60, i64 %indvars.iv87
  %62 = load ptr, ptr %61, align 8, !tbaa !12
  %63 = icmp eq ptr %62, null
  br i1 %63, label %75, label %64

64:                                               ; preds = %.split.us.split
  %65 = getelementptr inbounds i8, ptr %62, i64 4
  %66 = load i32, ptr %65, align 4, !tbaa !23
  %67 = icmp slt i32 %66, %2
  br i1 %67, label %71, label %68

68:                                               ; preds = %64
  %69 = load i32, ptr %62, align 8, !tbaa !18
  %.not.us = icmp eq i32 %69, %.068
  br i1 %.not.us, label %70, label %71

70:                                               ; preds = %68
  tail call void @mMemoryBlockRead(ptr noundef nonnull %62)
  br label %79

71:                                               ; preds = %68, %64
  tail call void @mMemoryBlockRelease(ptr noundef nonnull %62)
  %72 = tail call ptr @mMemoryBlockCreate(i32 noundef %2, i32 noundef %.068)
  %73 = load ptr, ptr %59, align 8, !tbaa !17
  %74 = getelementptr inbounds ptr, ptr %73, i64 %indvars.iv87
  store ptr %72, ptr %74, align 8, !tbaa !12
  br label %79

75:                                               ; preds = %.split.us.split
  %76 = tail call ptr @mMemoryBlockCreate(i32 noundef %2, i32 noundef %.068)
  %77 = load ptr, ptr %59, align 8, !tbaa !17
  %78 = getelementptr inbounds ptr, ptr %77, i64 %indvars.iv87
  store ptr %76, ptr %78, align 8, !tbaa !12
  br label %79

79:                                               ; preds = %75, %71, %70
  %indvars.iv.next88 = add nuw nsw i64 %indvars.iv87, 1
  %exitcond92.not = icmp eq i64 %indvars.iv.next88, %wide.trip.count91
  br i1 %exitcond92.not, label %.split81.us, label %.split.us.split, !llvm.loop !24

.split.split.us:                                  ; preds = %.split.split.us.preheader, %93
  %indvars.iv = phi i64 [ 0, %.split.split.us.preheader ], [ %indvars.iv.next, %93 ]
  %80 = load ptr, ptr %58, align 8, !tbaa !17
  %81 = getelementptr inbounds ptr, ptr %80, i64 %indvars.iv
  %82 = load ptr, ptr %81, align 8, !tbaa !12
  %83 = icmp eq ptr %82, null
  br i1 %83, label %93, label %84

84:                                               ; preds = %.split.split.us
  %85 = load i32, ptr %82, align 8, !tbaa !18
  %.not.us84 = icmp eq i32 %85, %.068
  br i1 %.not.us84, label %86, label %87

86:                                               ; preds = %84
  tail call void @mMemoryBlockRead(ptr noundef nonnull %82)
  br label %93

87:                                               ; preds = %84
  %88 = getelementptr inbounds i8, ptr %82, i64 4
  %89 = load i32, ptr %88, align 4, !tbaa !23
  tail call void @mMemoryBlockRelease(ptr noundef nonnull %82)
  %90 = tail call ptr @mMemoryBlockCreate(i32 noundef %89, i32 noundef %.068)
  %91 = load ptr, ptr %58, align 8, !tbaa !17
  %92 = getelementptr inbounds ptr, ptr %91, i64 %indvars.iv
  store ptr %90, ptr %92, align 8, !tbaa !12
  br label %93

93:                                               ; preds = %.split.split.us, %87, %86
  %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 %.split81.us, label %.split.split.us, !llvm.loop !24

.split81.us:                                      ; preds = %79, %93
  %94 = icmp sgt i32 %.068, 0
  br i1 %94, label %95, label %97

95:                                               ; preds = %.split81.us
  %96 = getelementptr inbounds i8, ptr %18, i64 4
  store i32 %.068, ptr %96, align 4, !tbaa !22
  br label %97

97:                                               ; preds = %95, %.split81.us
  store i32 0, ptr %18, align 8, !tbaa !26
  br label %98

98:                                               ; preds = %97, %54, %20
  ret void
}

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

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

attributes #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 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !11, i64 8}
!6 = !{!"HandleList", !7, i64 0, !8, i64 16, !8, i64 20, !8, i64 24, !8, i64 28}
!7 = !{!"MList", !8, i64 0, !11, i64 8}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!14, !8, i64 0}
!14 = !{!"MHandle", !8, i64 0, !8, i64 4, !11, i64 8, !11, i64 16}
!15 = !{!14, !11, i64 16}
!16 = !{!7, !8, i64 0}
!17 = !{!7, !11, i64 8}
!18 = !{!19, !8, i64 0}
!19 = !{!"MMemoryBlock", !8, i64 0, !8, i64 4, !11, i64 8, !11, i64 16, !11, i64 24, !8, i64 32}
!20 = !{!21, !8, i64 8}
!21 = !{!"HandleMemory", !8, i64 0, !8, i64 4, !8, i64 8, !8, i64 12, !11, i64 16, !8, i64 24, !8, i64 28, !11, i64 32, !8, i64 40}
!22 = !{!21, !8, i64 4}
!23 = !{!19, !8, i64 4}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{!21, !8, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass