; 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.HandleMemory = type { i32, i32, i32, i32, ptr, i32, i32, ptr, i32 }
%struct.MMemoryBlock = type { i32, i32, ptr, ptr, 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
@.str.5 = external hidden unnamed_addr constant [15 x i8], align 1
@__FUNCTION__.mMemoryWrite = external hidden unnamed_addr constant [13 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [55 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 uwtable
declare dso_local void @mMemoryRedefine(ptr noundef, i32 noundef, i32 noundef, i32 noundef) #2

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @mMemoryWrite(ptr noundef %0, ptr noundef %1, i32 noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  br label %19

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

22:                                               ; preds = %19
  %23 = load ptr, ptr %4, 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 %7, align 4, !tbaa !9
  %29 = load i32, ptr %7, align 4, !tbaa !9
  %30 = icmp ne i32 %29, 0
  br i1 %30, label %31, label %33

31:                                               ; preds = %26
  %32 = load i32, ptr %7, 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 762, ptr noundef @__FUNCTION__.mMemoryWrite, ptr noundef @.str.4)
  br label %33

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

34:                                               ; preds = %33
  %35 = load i32, ptr %6, align 4, !tbaa !9
  %36 = icmp slt i32 %35, 0
  br i1 %36, label %37, label %52

37:                                               ; preds = %34
  br label %38

38:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = icmp eq ptr %39, null
  %41 = zext i1 %40 to i32
  store i32 %41, ptr %8, align 4, !tbaa !9
  %42 = load i32, ptr %8, align 4, !tbaa !9
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %44, label %46

44:                                               ; preds = %38
  %45 = load i32, ptr %8, align 4, !tbaa !9
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %45, i32 noundef -1, ptr noundef @.str, i32 noundef 763, ptr noundef @__FUNCTION__.mMemoryWrite, ptr noundef @.str.10)
  br label %46

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

47:                                               ; preds = %46
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = call i64 @strlen(ptr noundef %48) #6
  %50 = add i64 %49, 1
  %51 = trunc i64 %50 to i32
  store i32 %51, ptr %6, align 4, !tbaa !9
  br label %52

52:                                               ; preds = %47, %34
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.HandleList, ptr %53, i64 -1
  %55 = getelementptr inbounds %struct.HandleList, ptr %54, i32 0, i32 0
  %56 = getelementptr inbounds %struct.MList, ptr %55, i32 0, i32 1
  %57 = load ptr, ptr %56, align 8, !tbaa !11
  %58 = getelementptr inbounds ptr, ptr %57, i64 0
  %59 = load ptr, ptr %58, align 8, !tbaa !5
  store ptr %59, ptr %9, align 8, !tbaa !5
  br label %60

60:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %61 = load ptr, ptr %9, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.MHandle, ptr %61, i32 0, i32 0
  %63 = load volatile i32, ptr %62, align 8, !tbaa !14
  %64 = icmp ne i32 %63, 628699680
  %65 = zext i1 %64 to i32
  store i32 %65, ptr %10, align 4, !tbaa !9
  %66 = load i32, ptr %10, align 4, !tbaa !9
  %67 = icmp ne i32 %66, 0
  br i1 %67, label %68, label %70

68:                                               ; preds = %60
  %69 = load i32, ptr %10, align 4, !tbaa !9
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %69, i32 noundef -1, ptr noundef @.str, i32 noundef 766, ptr noundef @__FUNCTION__.mMemoryWrite, ptr noundef @.str.5)
  br label %70

70:                                               ; preds = %68, %60
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %71

71:                                               ; preds = %70
  br label %72

72:                                               ; preds = %71
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %73 = load ptr, ptr %9, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.MHandle, ptr %73, i32 0, i32 3
  %75 = load ptr, ptr %74, align 8, !tbaa !16
  store ptr %75, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %76 = load ptr, ptr %11, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.HandleMemory, ptr %76, i32 0, i32 1
  %78 = load i32, ptr %77, align 4, !tbaa !17
  store i32 %78, ptr %12, align 4, !tbaa !9
  %79 = load i32, ptr %12, align 4, !tbaa !9
  %80 = icmp ne i32 %79, 0
  br i1 %80, label %81, label %83

81:                                               ; preds = %72
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  call void @mMemoryDevice(ptr noundef %82, i32 noundef 0)
  br label %83

83:                                               ; preds = %81, %72
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.MList, ptr %84, i32 0, i32 0
  %86 = load i32, ptr %85, align 8, !tbaa !19
  %87 = icmp eq i32 %86, 0
  br i1 %87, label %88, label %100

88:                                               ; preds = %83
  %89 = load ptr, ptr %4, align 8, !tbaa !5
  %90 = load i32, ptr %6, align 4, !tbaa !9
  %91 = shl i32 %90, 6
  %92 = icmp sgt i32 8192, %91
  br i1 %92, label %93, label %94

93:                                               ; preds = %88
  br label %97

94:                                               ; preds = %88
  %95 = load i32, ptr %6, align 4, !tbaa !9
  %96 = shl i32 %95, 6
  br label %97

97:                                               ; preds = %94, %93
  %98 = phi i32 [ 8192, %93 ], [ %96, %94 ]
  %99 = load i32, ptr %12, align 4, !tbaa !9
  call void @mMemoryRedefine(ptr noundef %89, i32 noundef 1, i32 noundef %98, i32 noundef %99)
  br label %100

100:                                              ; preds = %97, %83
  %101 = load ptr, ptr %11, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.HandleMemory, ptr %101, i32 0, i32 4
  %103 = load ptr, ptr %102, align 8, !tbaa !20
  %104 = icmp eq ptr %103, null
  br i1 %104, label %105, label %123

105:                                              ; preds = %100
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %106 = load ptr, ptr %4, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.MList, ptr %106, i32 0, i32 1
  %108 = load ptr, ptr %107, align 8, !tbaa !21
  %109 = getelementptr inbounds ptr, ptr %108, i64 0
  %110 = load ptr, ptr %109, align 8, !tbaa !5
  store ptr %110, ptr %13, align 8, !tbaa !5
  %111 = load ptr, ptr %11, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.HandleMemory, ptr %111, i32 0, i32 3
  store i32 0, ptr %112, align 4, !tbaa !22
  %113 = load ptr, ptr %13, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.MMemoryBlock, ptr %113, i32 0, i32 2
  %115 = load ptr, ptr %114, align 8, !tbaa !23
  %116 = load ptr, ptr %11, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.HandleMemory, ptr %116, i32 0, i32 4
  store ptr %115, ptr %117, align 8, !tbaa !20
  %118 = load ptr, ptr %13, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.MMemoryBlock, ptr %118, i32 0, i32 1
  %120 = load i32, ptr %119, align 4, !tbaa !25
  %121 = load ptr, ptr %11, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.HandleMemory, ptr %121, i32 0, i32 5
  store i32 %120, ptr %122, align 8, !tbaa !26
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  br label %123

123:                                              ; preds = %105, %100
  br label %124

124:                                              ; preds = %123
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  %125 = load ptr, ptr %11, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.HandleMemory, ptr %125, i32 0, i32 3
  %127 = load i32, ptr %126, align 4, !tbaa !22
  %128 = load ptr, ptr %4, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct.MList, ptr %128, i32 0, i32 0
  %130 = load i32, ptr %129, align 8, !tbaa !19
  %131 = icmp sge i32 %127, %130
  %132 = zext i1 %131 to i32
  store i32 %132, ptr %14, align 4, !tbaa !9
  %133 = load i32, ptr %14, align 4, !tbaa !9
  %134 = icmp ne i32 %133, 0
  br i1 %134, label %135, label %143

135:                                              ; preds = %124
  %136 = load i32, ptr %14, align 4, !tbaa !9
  %137 = load ptr, ptr %11, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct.HandleMemory, ptr %137, i32 0, i32 3
  %139 = load i32, ptr %138, align 4, !tbaa !22
  %140 = load ptr, ptr %4, align 8, !tbaa !5
  %141 = getelementptr inbounds %struct.MList, ptr %140, i32 0, i32 0
  %142 = load i32, ptr %141, align 8, !tbaa !19
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %136, i32 noundef -1, ptr noundef @.str, i32 noundef 780, ptr noundef @__FUNCTION__.mMemoryWrite, ptr noundef @.str.11, i32 noundef %139, i32 noundef %142)
  br label %143

143:                                              ; preds = %135, %124
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  br label %144

144:                                              ; preds = %143
  br label %145

145:                                              ; preds = %144
  br label %146

146:                                              ; preds = %223, %145
  %147 = load ptr, ptr %11, align 8, !tbaa !5
  %148 = getelementptr inbounds %struct.HandleMemory, ptr %147, i32 0, i32 5
  %149 = load i32, ptr %148, align 8, !tbaa !26
  %150 = load i32, ptr %6, align 4, !tbaa !9
  %151 = icmp slt i32 %149, %150
  br i1 %151, label %152, label %241

152:                                              ; preds = %146
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  %153 = load ptr, ptr %11, align 8, !tbaa !5
  %154 = getelementptr inbounds %struct.HandleMemory, ptr %153, i32 0, i32 3
  %155 = load i32, ptr %154, align 4, !tbaa !22
  %156 = add nsw i32 %155, 1
  store i32 %156, ptr %15, align 4, !tbaa !9
  %157 = load i32, ptr %15, align 4, !tbaa !9
  %158 = load ptr, ptr %11, align 8, !tbaa !5
  %159 = getelementptr inbounds %struct.HandleMemory, ptr %158, i32 0, i32 3
  store i32 %157, ptr %159, align 4, !tbaa !22
  %160 = load i32, ptr %15, align 4, !tbaa !9
  %161 = load ptr, ptr %4, align 8, !tbaa !5
  %162 = getelementptr inbounds %struct.MList, ptr %161, i32 0, i32 0
  %163 = load i32, ptr %162, align 8, !tbaa !19
  %164 = icmp sge i32 %160, %163
  br i1 %164, label %165, label %223

165:                                              ; preds = %152
  %166 = load ptr, ptr %4, align 8, !tbaa !5
  %167 = load i32, ptr %15, align 4, !tbaa !9
  %168 = add nsw i32 %167, 1
  call void @mMemoryRedefine(ptr noundef %166, i32 noundef %168, i32 noundef -1, i32 noundef -1)
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  %169 = load i32, ptr %6, align 4, !tbaa !9
  %170 = shl i32 %169, 6
  %171 = icmp sgt i32 8192, %170
  br i1 %171, label %172, label %173

172:                                              ; preds = %165
  br label %176

173:                                              ; preds = %165
  %174 = load i32, ptr %6, align 4, !tbaa !9
  %175 = shl i32 %174, 6
  br label %176

176:                                              ; preds = %173, %172
  %177 = phi i32 [ 8192, %172 ], [ %175, %173 ]
  %178 = load ptr, ptr %4, align 8, !tbaa !5
  %179 = getelementptr inbounds %struct.MList, ptr %178, i32 0, i32 1
  %180 = load ptr, ptr %179, align 8, !tbaa !21
  %181 = load i32, ptr %15, align 4, !tbaa !9
  %182 = sub nsw i32 %181, 1
  %183 = sext i32 %182 to i64
  %184 = getelementptr inbounds ptr, ptr %180, i64 %183
  %185 = load ptr, ptr %184, align 8, !tbaa !5
  %186 = getelementptr inbounds %struct.MMemoryBlock, ptr %185, i32 0, i32 1
  %187 = load i32, ptr %186, align 4, !tbaa !25
  %188 = mul nsw i32 %187, 2
  %189 = icmp sgt i32 %177, %188
  br i1 %189, label %190, label %200

190:                                              ; preds = %176
  %191 = load i32, ptr %6, align 4, !tbaa !9
  %192 = shl i32 %191, 6
  %193 = icmp sgt i32 8192, %192
  br i1 %193, label %194, label %195

194:                                              ; preds = %190
  br label %198

195:                                              ; preds = %190
  %196 = load i32, ptr %6, align 4, !tbaa !9
  %197 = shl i32 %196, 6
  br label %198

198:                                              ; preds = %195, %194
  %199 = phi i32 [ 8192, %194 ], [ %197, %195 ]
  br label %212

200:                                              ; preds = %176
  %201 = load ptr, ptr %4, align 8, !tbaa !5
  %202 = getelementptr inbounds %struct.MList, ptr %201, i32 0, i32 1
  %203 = load ptr, ptr %202, align 8, !tbaa !21
  %204 = load i32, ptr %15, align 4, !tbaa !9
  %205 = sub nsw i32 %204, 1
  %206 = sext i32 %205 to i64
  %207 = getelementptr inbounds ptr, ptr %203, i64 %206
  %208 = load ptr, ptr %207, align 8, !tbaa !5
  %209 = getelementptr inbounds %struct.MMemoryBlock, ptr %208, i32 0, i32 1
  %210 = load i32, ptr %209, align 4, !tbaa !25
  %211 = mul nsw i32 %210, 2
  br label %212

212:                                              ; preds = %200, %198
  %213 = phi i32 [ %199, %198 ], [ %211, %200 ]
  store i32 %213, ptr %16, align 4, !tbaa !9
  %214 = load i32, ptr %16, align 4, !tbaa !9
  %215 = load i32, ptr %12, align 4, !tbaa !9
  %216 = call ptr @mMemoryBlockCreate(i32 noundef %214, i32 noundef %215)
  %217 = load ptr, ptr %4, align 8, !tbaa !5
  %218 = getelementptr inbounds %struct.MList, ptr %217, i32 0, i32 1
  %219 = load ptr, ptr %218, align 8, !tbaa !21
  %220 = load i32, ptr %15, align 4, !tbaa !9
  %221 = sext i32 %220 to i64
  %222 = getelementptr inbounds ptr, ptr %219, i64 %221
  store ptr %216, ptr %222, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  br label %223

223:                                              ; preds = %212, %152
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  %224 = load ptr, ptr %4, align 8, !tbaa !5
  %225 = getelementptr inbounds %struct.MList, ptr %224, i32 0, i32 1
  %226 = load ptr, ptr %225, align 8, !tbaa !21
  %227 = load i32, ptr %15, align 4, !tbaa !9
  %228 = sext i32 %227 to i64
  %229 = getelementptr inbounds ptr, ptr %226, i64 %228
  %230 = load ptr, ptr %229, align 8, !tbaa !5
  store ptr %230, ptr %17, align 8, !tbaa !5
  %231 = load ptr, ptr %17, align 8, !tbaa !5
  %232 = getelementptr inbounds %struct.MMemoryBlock, ptr %231, i32 0, i32 2
  %233 = load ptr, ptr %232, align 8, !tbaa !23
  %234 = load ptr, ptr %11, align 8, !tbaa !5
  %235 = getelementptr inbounds %struct.HandleMemory, ptr %234, i32 0, i32 4
  store ptr %233, ptr %235, align 8, !tbaa !20
  %236 = load ptr, ptr %17, align 8, !tbaa !5
  %237 = getelementptr inbounds %struct.MMemoryBlock, ptr %236, i32 0, i32 1
  %238 = load i32, ptr %237, align 4, !tbaa !25
  %239 = load ptr, ptr %11, align 8, !tbaa !5
  %240 = getelementptr inbounds %struct.HandleMemory, ptr %239, i32 0, i32 5
  store i32 %238, ptr %240, align 8, !tbaa !26
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  br label %146

241:                                              ; preds = %146
  %242 = load ptr, ptr %5, align 8, !tbaa !5
  %243 = icmp ne ptr %242, null
  br i1 %243, label %244, label %251

244:                                              ; preds = %241
  %245 = load ptr, ptr %11, align 8, !tbaa !5
  %246 = getelementptr inbounds %struct.HandleMemory, ptr %245, i32 0, i32 4
  %247 = load ptr, ptr %246, align 8, !tbaa !20
  %248 = load ptr, ptr %5, align 8, !tbaa !5
  %249 = load i32, ptr %6, align 4, !tbaa !9
  %250 = sext i32 %249 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %247, ptr align 1 %248, i64 %250, i1 false)
  br label %251

251:                                              ; preds = %244, %241
  %252 = load ptr, ptr %11, align 8, !tbaa !5
  %253 = getelementptr inbounds %struct.HandleMemory, ptr %252, i32 0, i32 4
  %254 = load ptr, ptr %253, align 8, !tbaa !20
  store ptr %254, ptr %18, align 8, !tbaa !5
  %255 = load ptr, ptr %11, align 8, !tbaa !5
  %256 = getelementptr inbounds %struct.HandleMemory, ptr %255, i32 0, i32 4
  %257 = load ptr, ptr %256, align 8, !tbaa !20
  %258 = load i32, ptr %6, align 4, !tbaa !9
  %259 = sext i32 %258 to i64
  %260 = getelementptr inbounds i8, ptr %257, i64 %259
  %261 = load ptr, ptr %11, align 8, !tbaa !5
  %262 = getelementptr inbounds %struct.HandleMemory, ptr %261, i32 0, i32 4
  store ptr %260, ptr %262, align 8, !tbaa !20
  %263 = load ptr, ptr %11, align 8, !tbaa !5
  %264 = getelementptr inbounds %struct.HandleMemory, ptr %263, i32 0, i32 5
  %265 = load i32, ptr %264, align 8, !tbaa !26
  %266 = load i32, ptr %6, align 4, !tbaa !9
  %267 = sub nsw i32 %265, %266
  %268 = load ptr, ptr %11, align 8, !tbaa !5
  %269 = getelementptr inbounds %struct.HandleMemory, ptr %268, i32 0, i32 5
  store i32 %267, ptr %269, align 8, !tbaa !26
  %270 = load ptr, ptr %18, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  ret ptr %270
}

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #4

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nounwind willreturn memory(read) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind }
attributes #6 = { nounwind willreturn memory(read) }

!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 = !{!18, !10, i64 4}
!18 = !{!"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}
!19 = !{!13, !10, i64 0}
!20 = !{!18, !6, i64 16}
!21 = !{!13, !6, i64 8}
!22 = !{!18, !10, i64 12}
!23 = !{!24, !6, i64 8}
!24 = !{!"MMemoryBlock", !10, i64 0, !10, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !10, i64 32}
!25 = !{!24, !10, i64 4}
!26 = !{!18, !10, i64 24}


; 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
@.str.5 = external hidden unnamed_addr constant [15 x i8], align 1
@__FUNCTION__.mMemoryWrite = external hidden unnamed_addr constant [13 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [55 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: nounwind uwtable
declare dso_local void @mMemoryRedefine(ptr noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; 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: nounwind uwtable
declare dso_local void @mMemoryDevice(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local ptr @mMemoryWrite(ptr noundef %0, ptr noundef readonly %1, i32 noundef %2) local_unnamed_addr #1 {
  %magicptr = ptrtoint ptr %0 to i64
  switch i64 %magicptr, label %9 [
    i64 -1, label %4
    i64 0, label %4
  ]

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

9:                                                ; preds = %3, %4
  %10 = icmp slt i32 %2, 0
  br i1 %10, label %11, label %18

11:                                               ; preds = %9
  %12 = icmp eq ptr %1, null
  br i1 %12, label %13, label %14

13:                                               ; preds = %11
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 763, ptr noundef nonnull @__FUNCTION__.mMemoryWrite, ptr noundef nonnull @.str.10) #5
  br label %14

14:                                               ; preds = %13, %11
  %15 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %1) #6
  %16 = trunc i64 %15 to i32
  %17 = add i32 %16, 1
  br label %18

18:                                               ; preds = %14, %9
  %.0 = phi i32 [ %17, %14 ], [ %2, %9 ]
  %19 = getelementptr inbounds i8, ptr %0, i64 -24
  %20 = load ptr, ptr %19, align 8, !tbaa !5
  %21 = load ptr, ptr %20, align 8, !tbaa !12
  %22 = load volatile i32, ptr %21, align 8, !tbaa !13
  %.not82 = icmp eq i32 %22, 628699680
  br i1 %.not82, label %24, label %23

23:                                               ; preds = %18
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 766, ptr noundef nonnull @__FUNCTION__.mMemoryWrite, ptr noundef nonnull @.str.5) #5
  br label %24

24:                                               ; preds = %23, %18
  %25 = getelementptr inbounds i8, ptr %21, i64 16
  %26 = load ptr, ptr %25, align 8, !tbaa !15
  %27 = getelementptr inbounds i8, ptr %26, i64 4
  %28 = load i32, ptr %27, align 4, !tbaa !16
  %.not = icmp eq i32 %28, 0
  br i1 %.not, label %30, label %29

29:                                               ; preds = %24
  tail call void @mMemoryDevice(ptr noundef nonnull %0, i32 noundef 0)
  br label %30

30:                                               ; preds = %29, %24
  %31 = load i32, ptr %0, align 8, !tbaa !18
  %32 = icmp eq i32 %31, 0
  br i1 %32, label %33, label %36

33:                                               ; preds = %30
  %34 = shl i32 %.0, 6
  %35 = tail call i32 @llvm.smax.i32(i32 %34, i32 8192)
  tail call void @mMemoryRedefine(ptr noundef nonnull %0, i32 noundef 1, i32 noundef %35, i32 noundef %28)
  br label %36

36:                                               ; preds = %33, %30
  %37 = getelementptr inbounds i8, ptr %26, i64 16
  %38 = load ptr, ptr %37, align 8, !tbaa !19
  %39 = icmp eq ptr %38, null
  br i1 %39, label %40, label %._crit_edge84

._crit_edge84:                                    ; preds = %36
  %.phi.trans.insert = getelementptr inbounds i8, ptr %26, i64 12
  %.pre = load i32, ptr %.phi.trans.insert, align 4, !tbaa !20
  br label %50

40:                                               ; preds = %36
  %41 = getelementptr inbounds i8, ptr %0, i64 8
  %42 = load ptr, ptr %41, align 8, !tbaa !21
  %43 = load ptr, ptr %42, align 8, !tbaa !12
  %44 = getelementptr inbounds i8, ptr %26, i64 12
  store i32 0, ptr %44, align 4, !tbaa !20
  %45 = getelementptr inbounds i8, ptr %43, i64 8
  %46 = load ptr, ptr %45, align 8, !tbaa !22
  store ptr %46, ptr %37, align 8, !tbaa !19
  %47 = getelementptr inbounds i8, ptr %43, i64 4
  %48 = load i32, ptr %47, align 4, !tbaa !24
  %49 = getelementptr inbounds i8, ptr %26, i64 24
  store i32 %48, ptr %49, align 8, !tbaa !25
  br label %50

50:                                               ; preds = %._crit_edge84, %40
  %51 = phi i32 [ %.pre, %._crit_edge84 ], [ 0, %40 ]
  %52 = getelementptr inbounds i8, ptr %26, i64 12
  %53 = load i32, ptr %0, align 8, !tbaa !18
  %.not83 = icmp slt i32 %51, %53
  br i1 %.not83, label %55, label %54

54:                                               ; preds = %50
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 780, ptr noundef nonnull @__FUNCTION__.mMemoryWrite, ptr noundef nonnull @.str.11, i32 noundef %51, i32 noundef %53) #5
  br label %55

55:                                               ; preds = %54, %50
  %56 = getelementptr inbounds i8, ptr %26, i64 24
  %57 = load i32, ptr %56, align 8, !tbaa !25
  %58 = icmp slt i32 %57, %.0
  br i1 %58, label %.lr.ph, label %.._crit_edge_crit_edge

.._crit_edge_crit_edge:                           ; preds = %55
  %.pre86.pre = load ptr, ptr %37, align 8, !tbaa !19
  br label %._crit_edge

.lr.ph:                                           ; preds = %55
  %59 = shl i32 %.0, 6
  %60 = getelementptr inbounds i8, ptr %0, i64 8
  br label %61

61:                                               ; preds = %.lr.ph, %79
  %62 = load i32, ptr %52, align 4, !tbaa !20
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %52, align 4, !tbaa !20
  %64 = load i32, ptr %0, align 8, !tbaa !18
  %.not81 = icmp slt i32 %63, %64
  br i1 %.not81, label %._crit_edge89, label %65

._crit_edge89:                                    ; preds = %61
  %.pre90 = sext i32 %63 to i64
  br label %79

65:                                               ; preds = %61
  %66 = add nsw i32 %62, 2
  tail call void @mMemoryRedefine(ptr noundef nonnull %0, i32 noundef %66, i32 noundef -1, i32 noundef -1)
  %67 = load ptr, ptr %60, align 8, !tbaa !21
  %68 = sext i32 %62 to i64
  %69 = getelementptr inbounds ptr, ptr %67, i64 %68
  %70 = load ptr, ptr %69, align 8, !tbaa !12
  %71 = getelementptr inbounds i8, ptr %70, i64 4
  %72 = load i32, ptr %71, align 4, !tbaa !24
  %73 = shl nsw i32 %72, 1
  %74 = tail call i32 @llvm.smax.i32(i32 %59, i32 %73)
  %. = tail call i32 @llvm.smax.i32(i32 %74, i32 8192)
  %75 = tail call ptr @mMemoryBlockCreate(i32 noundef %., i32 noundef %28)
  %76 = load ptr, ptr %60, align 8, !tbaa !21
  %77 = sext i32 %63 to i64
  %78 = getelementptr inbounds ptr, ptr %76, i64 %77
  store ptr %75, ptr %78, align 8, !tbaa !12
  br label %79

79:                                               ; preds = %._crit_edge89, %65
  %.pre-phi = phi i64 [ %.pre90, %._crit_edge89 ], [ %77, %65 ]
  %80 = load ptr, ptr %60, align 8, !tbaa !21
  %81 = getelementptr inbounds ptr, ptr %80, i64 %.pre-phi
  %82 = load ptr, ptr %81, align 8, !tbaa !12
  %83 = getelementptr inbounds i8, ptr %82, i64 8
  %84 = load ptr, ptr %83, align 8, !tbaa !22
  store ptr %84, ptr %37, align 8, !tbaa !19
  %85 = getelementptr inbounds i8, ptr %82, i64 4
  %86 = load i32, ptr %85, align 4, !tbaa !24
  store i32 %86, ptr %56, align 8, !tbaa !25
  %87 = icmp slt i32 %86, %.0
  br i1 %87, label %61, label %._crit_edge

._crit_edge:                                      ; preds = %79, %.._crit_edge_crit_edge
  %.pre86 = phi ptr [ %.pre86.pre, %.._crit_edge_crit_edge ], [ %84, %79 ]
  %88 = phi i32 [ %57, %.._crit_edge_crit_edge ], [ %86, %79 ]
  %.not80 = icmp eq ptr %1, null
  %.pre91 = sext i32 %.0 to i64
  br i1 %.not80, label %._crit_edge._crit_edge, label %89

89:                                               ; preds = %._crit_edge
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %.pre86, ptr nonnull align 1 %1, i64 %.pre91, i1 false)
  %.pre85 = load ptr, ptr %37, align 8, !tbaa !19
  %.pre87 = load i32, ptr %56, align 8, !tbaa !25
  br label %._crit_edge._crit_edge

._crit_edge._crit_edge:                           ; preds = %._crit_edge, %89
  %90 = phi i32 [ %.pre87, %89 ], [ %88, %._crit_edge ]
  %91 = phi ptr [ %.pre85, %89 ], [ %.pre86, %._crit_edge ]
  %92 = getelementptr inbounds i8, ptr %91, i64 %.pre91
  store ptr %92, ptr %37, align 8, !tbaa !19
  %93 = sub nsw i32 %90, %.0
  store i32 %93, ptr %56, align 8, !tbaa !25
  ret ptr %91
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #3

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

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 nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nofree nounwind willreturn memory(argmem: read) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nounwind }
attributes #6 = { nounwind willreturn memory(read) }

!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 = !{!17, !8, i64 4}
!17 = !{!"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}
!18 = !{!7, !8, i64 0}
!19 = !{!17, !11, i64 16}
!20 = !{!17, !8, i64 12}
!21 = !{!7, !11, i64 8}
!22 = !{!23, !11, i64 8}
!23 = !{!"MMemoryBlock", !8, i64 0, !8, i64 4, !11, i64 8, !11, i64 16, !11, i64 24, !8, i64 32}
!24 = !{!23, !8, i64 4}
!25 = !{!17, !8, i64 24}


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