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

; 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.HandleSheetCreate = type { ptr, ptr, [8 x i64], i32, i32, ptr, ptr, ptr, ptr, ptr }
%struct.MSheet = type { i32, ptr, ptr, ptr }

@.str = external hidden unnamed_addr constant [77 x i8], align 1
@__FUNCTION__.SheetCreate = external hidden unnamed_addr constant [12 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @endSheetCreate(ptr noundef) #0

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

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

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

; Function Attrs: 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 ptr @SheetCreate(i32 noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  store i32 %0, ptr %6, align 4, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %17 = call ptr @ObjectAlloc(i32 noundef 32)
  store ptr %17, ptr %10, align 8, !tbaa !9
  %18 = load ptr, ptr %10, align 8, !tbaa !9
  %19 = getelementptr inbounds %struct.HandleList, ptr %18, i64 -1
  %20 = getelementptr inbounds %struct.HandleList, ptr %19, i32 0, i32 4
  store i32 1018193866, ptr %20, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %21 = load ptr, ptr %10, align 8, !tbaa !9
  %22 = call ptr @GetHandle(ptr noundef %21, i32 noundef 128, i32 noundef 1018193866, ptr noundef @endSheetCreate)
  store ptr %22, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %23 = load ptr, ptr %11, align 8, !tbaa !9
  %24 = getelementptr inbounds %struct.MHandle, ptr %23, i32 0, i32 3
  %25 = load ptr, ptr %24, align 8, !tbaa !14
  store ptr %25, ptr %12, align 8, !tbaa !9
  %26 = load ptr, ptr %10, align 8, !tbaa !9
  %27 = load ptr, ptr %12, align 8, !tbaa !9
  %28 = getelementptr inbounds %struct.HandleSheetCreate, ptr %27, i32 0, i32 0
  store ptr %26, ptr %28, align 8, !tbaa !16
  %29 = load i32, ptr %6, align 4, !tbaa !5
  %30 = icmp slt i32 %29, 0
  br i1 %30, label %31, label %32

31:                                               ; preds = %4
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %32

32:                                               ; preds = %31, %4
  %33 = load i32, ptr %6, align 4, !tbaa !5
  %34 = load ptr, ptr %12, align 8, !tbaa !9
  %35 = getelementptr inbounds %struct.HandleSheetCreate, ptr %34, i32 0, i32 4
  store i32 %33, ptr %35, align 4, !tbaa !18
  %36 = load i32, ptr %6, align 4, !tbaa !5
  %37 = load ptr, ptr %10, align 8, !tbaa !9
  %38 = getelementptr inbounds %struct.MSheet, ptr %37, i32 0, i32 0
  store i32 %36, ptr %38, align 8, !tbaa !19
  %39 = load i32, ptr %6, align 4, !tbaa !5
  %40 = icmp eq i32 %39, 0
  br i1 %40, label %41, label %74

41:                                               ; preds = %32
  br label %42

42:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %43 = load ptr, ptr %7, align 8, !tbaa !9
  %44 = icmp eq ptr %43, null
  br i1 %44, label %49, label %45

45:                                               ; preds = %42
  %46 = load ptr, ptr %7, align 8, !tbaa !9
  %47 = ptrtoint ptr %46 to i64
  %48 = icmp eq i64 %47, -1
  br i1 %48, label %49, label %59

49:                                               ; preds = %45, %42
  %50 = load ptr, ptr %9, align 8, !tbaa !9
  %51 = icmp eq ptr %50, null
  br i1 %51, label %56, label %52

52:                                               ; preds = %49
  %53 = load ptr, ptr %9, align 8, !tbaa !9
  %54 = ptrtoint ptr %53 to i64
  %55 = icmp eq i64 %54, -1
  br label %56

56:                                               ; preds = %52, %49
  %57 = phi i1 [ true, %49 ], [ %55, %52 ]
  %58 = xor i1 %57, true
  br label %59

59:                                               ; preds = %56, %45
  %60 = phi i1 [ true, %45 ], [ %58, %56 ]
  %61 = zext i1 %60 to i32
  store i32 %61, ptr %13, align 4, !tbaa !5
  %62 = load i32, ptr %13, align 4, !tbaa !5
  %63 = icmp ne i32 %62, 0
  br i1 %63, label %64, label %66

64:                                               ; preds = %59
  %65 = load i32, ptr %13, align 4, !tbaa !5
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %65, i32 noundef -1, ptr noundef @.str, i32 noundef 59, ptr noundef @__FUNCTION__.SheetCreate, ptr noundef @.str.2)
  br label %66

66:                                               ; preds = %64, %59
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  br label %67

67:                                               ; preds = %66
  br label %68

68:                                               ; preds = %67
  %69 = load ptr, ptr %10, align 8, !tbaa !9
  %70 = getelementptr inbounds %struct.MSheet, ptr %69, i32 0, i32 2
  store ptr null, ptr %70, align 8, !tbaa !21
  %71 = load ptr, ptr %10, align 8, !tbaa !9
  %72 = getelementptr inbounds %struct.MSheet, ptr %71, i32 0, i32 3
  store ptr null, ptr %72, align 8, !tbaa !22
  %73 = load ptr, ptr %10, align 8, !tbaa !9
  store ptr %73, ptr %5, align 8
  store i32 1, ptr %14, align 4
  br label %293

74:                                               ; preds = %32
  %75 = load i32, ptr %6, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = mul i64 %76, 8
  %78 = trunc i64 %77 to i32
  %79 = call ptr @m_Malloc(i32 noundef %78)
  %80 = load ptr, ptr %12, align 8, !tbaa !9
  %81 = getelementptr inbounds %struct.HandleSheetCreate, ptr %80, i32 0, i32 7
  store ptr %79, ptr %81, align 8, !tbaa !23
  %82 = load i32, ptr %6, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = mul i64 %83, 4
  %85 = trunc i64 %84 to i32
  %86 = call ptr @m_Malloc(i32 noundef %85)
  %87 = load ptr, ptr %12, align 8, !tbaa !9
  %88 = getelementptr inbounds %struct.HandleSheetCreate, ptr %87, i32 0, i32 8
  store ptr %86, ptr %88, align 8, !tbaa !24
  %89 = load i32, ptr %6, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = mul i64 %90, 4
  %92 = trunc i64 %91 to i32
  %93 = call ptr @m_Malloc(i32 noundef %92)
  %94 = load ptr, ptr %12, align 8, !tbaa !9
  %95 = getelementptr inbounds %struct.HandleSheetCreate, ptr %94, i32 0, i32 6
  store ptr %93, ptr %95, align 8, !tbaa !25
  %96 = load i32, ptr %6, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = mul i64 %97, 8
  %99 = trunc i64 %98 to i32
  %100 = call ptr @m_Malloc(i32 noundef %99)
  %101 = load ptr, ptr %12, align 8, !tbaa !9
  %102 = getelementptr inbounds %struct.HandleSheetCreate, ptr %101, i32 0, i32 5
  store ptr %100, ptr %102, align 8, !tbaa !26
  %103 = load ptr, ptr %8, align 8, !tbaa !9
  %104 = icmp eq ptr %103, null
  br i1 %104, label %117, label %105

105:                                              ; preds = %74
  %106 = load ptr, ptr %8, align 8, !tbaa !9
  %107 = ptrtoint ptr %106 to i64
  %108 = icmp eq i64 %107, -1
  br i1 %108, label %117, label %109

109:                                              ; preds = %105
  %110 = load ptr, ptr %12, align 8, !tbaa !9
  %111 = getelementptr inbounds %struct.HandleSheetCreate, ptr %110, i32 0, i32 5
  %112 = load ptr, ptr %111, align 8, !tbaa !26
  %113 = load ptr, ptr %8, align 8, !tbaa !9
  %114 = load i32, ptr %6, align 4, !tbaa !5
  %115 = sext i32 %114 to i64
  %116 = mul i64 %115, 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %112, ptr align 8 %113, i64 %116, i1 false)
  br label %117

117:                                              ; preds = %109, %105, %74
  %118 = load ptr, ptr %7, align 8, !tbaa !9
  %119 = icmp eq ptr %118, null
  br i1 %119, label %240, label %120

120:                                              ; preds = %117
  %121 = load ptr, ptr %7, align 8, !tbaa !9
  %122 = ptrtoint ptr %121 to i64
  %123 = icmp eq i64 %122, -1
  br i1 %123, label %240, label %124

124:                                              ; preds = %120
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  store i32 0, ptr %15, align 4, !tbaa !5
  br label %125

125:                                              ; preds = %236, %124
  %126 = load i32, ptr %15, align 4, !tbaa !5
  %127 = load i32, ptr %6, align 4, !tbaa !5
  %128 = icmp slt i32 %126, %127
  br i1 %128, label %130, label %129

129:                                              ; preds = %125
  store i32 4, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  br label %239

130:                                              ; preds = %125
  %131 = load ptr, ptr %7, align 8, !tbaa !9
  %132 = load i32, ptr %15, align 4, !tbaa !5
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds i32, ptr %131, i64 %133
  %135 = load i32, ptr %134, align 4, !tbaa !5
  %136 = icmp sle i32 %135, 0
  br i1 %136, label %137, label %156

137:                                              ; preds = %130
  %138 = load ptr, ptr %12, align 8, !tbaa !9
  %139 = getelementptr inbounds %struct.HandleSheetCreate, ptr %138, i32 0, i32 7
  %140 = load ptr, ptr %139, align 8, !tbaa !23
  %141 = load i32, ptr %15, align 4, !tbaa !5
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds ptr, ptr %140, i64 %142
  store ptr null, ptr %143, align 8, !tbaa !9
  %144 = load ptr, ptr %12, align 8, !tbaa !9
  %145 = getelementptr inbounds %struct.HandleSheetCreate, ptr %144, i32 0, i32 8
  %146 = load ptr, ptr %145, align 8, !tbaa !24
  %147 = load i32, ptr %15, align 4, !tbaa !5
  %148 = sext i32 %147 to i64
  %149 = getelementptr inbounds i32, ptr %146, i64 %148
  store i32 0, ptr %149, align 4, !tbaa !5
  %150 = load ptr, ptr %12, align 8, !tbaa !9
  %151 = getelementptr inbounds %struct.HandleSheetCreate, ptr %150, i32 0, i32 6
  %152 = load ptr, ptr %151, align 8, !tbaa !25
  %153 = load i32, ptr %15, align 4, !tbaa !5
  %154 = sext i32 %153 to i64
  %155 = getelementptr inbounds i32, ptr %152, i64 %154
  store i32 0, ptr %155, align 4, !tbaa !5
  br label %236

156:                                              ; preds = %130
  %157 = load ptr, ptr %7, align 8, !tbaa !9
  %158 = load i32, ptr %15, align 4, !tbaa !5
  %159 = sext i32 %158 to i64
  %160 = getelementptr inbounds i32, ptr %157, i64 %159
  %161 = load i32, ptr %160, align 4, !tbaa !5
  %162 = sext i32 %161 to i64
  %163 = mul i64 %162, 8
  %164 = trunc i64 %163 to i32
  %165 = call ptr @m_Malloc(i32 noundef %164)
  %166 = load ptr, ptr %12, align 8, !tbaa !9
  %167 = getelementptr inbounds %struct.HandleSheetCreate, ptr %166, i32 0, i32 7
  %168 = load ptr, ptr %167, align 8, !tbaa !23
  %169 = load i32, ptr %15, align 4, !tbaa !5
  %170 = sext i32 %169 to i64
  %171 = getelementptr inbounds ptr, ptr %168, i64 %170
  store ptr %165, ptr %171, align 8, !tbaa !9
  %172 = load ptr, ptr %7, align 8, !tbaa !9
  %173 = load i32, ptr %15, align 4, !tbaa !5
  %174 = sext i32 %173 to i64
  %175 = getelementptr inbounds i32, ptr %172, i64 %174
  %176 = load i32, ptr %175, align 4, !tbaa !5
  %177 = load ptr, ptr %12, align 8, !tbaa !9
  %178 = getelementptr inbounds %struct.HandleSheetCreate, ptr %177, i32 0, i32 6
  %179 = load ptr, ptr %178, align 8, !tbaa !25
  %180 = load i32, ptr %15, align 4, !tbaa !5
  %181 = sext i32 %180 to i64
  %182 = getelementptr inbounds i32, ptr %179, i64 %181
  store i32 %176, ptr %182, align 4, !tbaa !5
  %183 = load ptr, ptr %7, align 8, !tbaa !9
  %184 = load i32, ptr %15, align 4, !tbaa !5
  %185 = sext i32 %184 to i64
  %186 = getelementptr inbounds i32, ptr %183, i64 %185
  %187 = load i32, ptr %186, align 4, !tbaa !5
  %188 = load ptr, ptr %12, align 8, !tbaa !9
  %189 = getelementptr inbounds %struct.HandleSheetCreate, ptr %188, i32 0, i32 8
  %190 = load ptr, ptr %189, align 8, !tbaa !24
  %191 = load i32, ptr %15, align 4, !tbaa !5
  %192 = sext i32 %191 to i64
  %193 = getelementptr inbounds i32, ptr %190, i64 %192
  store i32 %187, ptr %193, align 4, !tbaa !5
  %194 = load ptr, ptr %9, align 8, !tbaa !9
  %195 = icmp eq ptr %194, null
  br i1 %195, label %220, label %196

196:                                              ; preds = %156
  %197 = load ptr, ptr %9, align 8, !tbaa !9
  %198 = ptrtoint ptr %197 to i64
  %199 = icmp eq i64 %198, -1
  br i1 %199, label %220, label %200

200:                                              ; preds = %196
  %201 = load ptr, ptr %12, align 8, !tbaa !9
  %202 = getelementptr inbounds %struct.HandleSheetCreate, ptr %201, i32 0, i32 7
  %203 = load ptr, ptr %202, align 8, !tbaa !23
  %204 = load i32, ptr %15, align 4, !tbaa !5
  %205 = sext i32 %204 to i64
  %206 = getelementptr inbounds ptr, ptr %203, i64 %205
  %207 = load ptr, ptr %206, align 8, !tbaa !9
  %208 = load ptr, ptr %9, align 8, !tbaa !9
  %209 = load i32, ptr %15, align 4, !tbaa !5
  %210 = sext i32 %209 to i64
  %211 = getelementptr inbounds ptr, ptr %208, i64 %210
  %212 = load ptr, ptr %211, align 8, !tbaa !9
  %213 = load ptr, ptr %7, align 8, !tbaa !9
  %214 = load i32, ptr %15, align 4, !tbaa !5
  %215 = sext i32 %214 to i64
  %216 = getelementptr inbounds i32, ptr %213, i64 %215
  %217 = load i32, ptr %216, align 4, !tbaa !5
  %218 = sext i32 %217 to i64
  %219 = mul i64 %218, 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %207, ptr align 8 %212, i64 %219, i1 false)
  br label %235

220:                                              ; preds = %196, %156
  %221 = load ptr, ptr %12, align 8, !tbaa !9
  %222 = getelementptr inbounds %struct.HandleSheetCreate, ptr %221, i32 0, i32 7
  %223 = load ptr, ptr %222, align 8, !tbaa !23
  %224 = load i32, ptr %15, align 4, !tbaa !5
  %225 = sext i32 %224 to i64
  %226 = getelementptr inbounds ptr, ptr %223, i64 %225
  %227 = load ptr, ptr %226, align 8, !tbaa !9
  %228 = load ptr, ptr %7, align 8, !tbaa !9
  %229 = load i32, ptr %15, align 4, !tbaa !5
  %230 = sext i32 %229 to i64
  %231 = getelementptr inbounds i32, ptr %228, i64 %230
  %232 = load i32, ptr %231, align 4, !tbaa !5
  %233 = sext i32 %232 to i64
  %234 = mul i64 %233, 8
  call void @llvm.memset.p0.i64(ptr align 8 %227, i8 0, i64 %234, i1 false)
  br label %235

235:                                              ; preds = %220, %200
  br label %236

236:                                              ; preds = %235, %137
  %237 = load i32, ptr %15, align 4, !tbaa !5
  %238 = add nsw i32 %237, 1
  store i32 %238, ptr %15, align 4, !tbaa !5
  br label %125, !llvm.loop !27

239:                                              ; preds = %129
  br label %277

240:                                              ; preds = %120, %117
  br label %241

241:                                              ; preds = %240
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  %242 = load ptr, ptr %9, align 8, !tbaa !9
  %243 = icmp eq ptr %242, null
  br i1 %243, label %248, label %244

244:                                              ; preds = %241
  %245 = load ptr, ptr %9, align 8, !tbaa !9
  %246 = ptrtoint ptr %245 to i64
  %247 = icmp eq i64 %246, -1
  br label %248

248:                                              ; preds = %244, %241
  %249 = phi i1 [ true, %241 ], [ %247, %244 ]
  %250 = xor i1 %249, true
  %251 = zext i1 %250 to i32
  store i32 %251, ptr %16, align 4, !tbaa !5
  %252 = load i32, ptr %16, align 4, !tbaa !5
  %253 = icmp ne i32 %252, 0
  br i1 %253, label %254, label %256

254:                                              ; preds = %248
  %255 = load i32, ptr %16, align 4, !tbaa !5
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %255, i32 noundef -1, ptr noundef @.str, i32 noundef 95, ptr noundef @__FUNCTION__.SheetCreate, ptr noundef @.str.2)
  br label %256

256:                                              ; preds = %254, %248
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  br label %257

257:                                              ; preds = %256
  br label %258

258:                                              ; preds = %257
  %259 = load ptr, ptr %12, align 8, !tbaa !9
  %260 = getelementptr inbounds %struct.HandleSheetCreate, ptr %259, i32 0, i32 7
  %261 = load ptr, ptr %260, align 8, !tbaa !23
  %262 = load i32, ptr %6, align 4, !tbaa !5
  %263 = sext i32 %262 to i64
  %264 = mul i64 %263, 8
  call void @llvm.memset.p0.i64(ptr align 8 %261, i8 0, i64 %264, i1 false)
  %265 = load ptr, ptr %12, align 8, !tbaa !9
  %266 = getelementptr inbounds %struct.HandleSheetCreate, ptr %265, i32 0, i32 8
  %267 = load ptr, ptr %266, align 8, !tbaa !24
  %268 = load i32, ptr %6, align 4, !tbaa !5
  %269 = sext i32 %268 to i64
  %270 = mul i64 %269, 4
  call void @llvm.memset.p0.i64(ptr align 4 %267, i8 0, i64 %270, i1 false)
  %271 = load ptr, ptr %12, align 8, !tbaa !9
  %272 = getelementptr inbounds %struct.HandleSheetCreate, ptr %271, i32 0, i32 6
  %273 = load ptr, ptr %272, align 8, !tbaa !25
  %274 = load i32, ptr %6, align 4, !tbaa !5
  %275 = sext i32 %274 to i64
  %276 = mul i64 %275, 4
  call void @llvm.memset.p0.i64(ptr align 4 %273, i8 0, i64 %276, i1 false)
  br label %277

277:                                              ; preds = %258, %239
  %278 = load ptr, ptr %12, align 8, !tbaa !9
  %279 = getelementptr inbounds %struct.HandleSheetCreate, ptr %278, i32 0, i32 6
  %280 = load ptr, ptr %279, align 8, !tbaa !25
  %281 = load ptr, ptr %10, align 8, !tbaa !9
  %282 = getelementptr inbounds %struct.MSheet, ptr %281, i32 0, i32 2
  store ptr %280, ptr %282, align 8, !tbaa !21
  %283 = load ptr, ptr %12, align 8, !tbaa !9
  %284 = getelementptr inbounds %struct.HandleSheetCreate, ptr %283, i32 0, i32 7
  %285 = load ptr, ptr %284, align 8, !tbaa !23
  %286 = load ptr, ptr %10, align 8, !tbaa !9
  %287 = getelementptr inbounds %struct.MSheet, ptr %286, i32 0, i32 3
  store ptr %285, ptr %287, align 8, !tbaa !22
  br label %288

288:                                              ; preds = %277
  %289 = load ptr, ptr %10, align 8, !tbaa !9
  call void @m_PropertyFunction(ptr noundef %289, ptr noundef @.str.3, ptr noundef @mornMemoryDevice, ptr noundef null)
  br label %290

290:                                              ; preds = %288
  br label %291

291:                                              ; preds = %290
  %292 = load ptr, ptr %10, align 8, !tbaa !9
  store ptr %292, ptr %5, align 8
  store i32 1, ptr %14, align 4
  br label %293

293:                                              ; preds = %291, %68
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  %294 = load ptr, ptr %5, align 8
  ret ptr %294
}

declare ptr @ObjectAlloc(i32 noundef) #2

declare ptr @GetHandle(ptr noundef, i32 noundef, i32 noundef, ptr noundef) #2

declare ptr @m_Malloc(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) #4

declare void @m_PropertyFunction(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

declare void @mornMemoryDevice(ptr noundef, ptr noundef) #2

attributes #0 = { 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 = { "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: write) }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nounwind }

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

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


; 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 [77 x i8], align 1
@__FUNCTION__.SheetCreate = external hidden unnamed_addr constant [12 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @endSheetCreate(ptr noundef) #0

declare void @m_Exception(i32 noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, 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) #2

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @SheetCreate(i32 noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = tail call ptr @ObjectAlloc(i32 noundef 32) #5
  %6 = getelementptr inbounds i8, ptr %5, i64 -4
  store i32 1018193866, ptr %6, align 4, !tbaa !5
  %7 = tail call ptr @GetHandle(ptr noundef %5, i32 noundef 128, i32 noundef 1018193866, ptr noundef nonnull @endSheetCreate) #5
  %8 = getelementptr inbounds i8, ptr %7, i64 16
  %9 = load ptr, ptr %8, align 8, !tbaa !12
  store ptr %5, ptr %9, align 8, !tbaa !14
  %spec.store.select = tail call i32 @llvm.smax.i32(i32 %0, i32 0)
  %10 = getelementptr inbounds i8, ptr %9, i64 84
  store i32 %spec.store.select, ptr %10, align 4, !tbaa !16
  store i32 %spec.store.select, ptr %5, align 8, !tbaa !17
  %11 = icmp slt i32 %0, 1
  br i1 %11, label %12, label %16

12:                                               ; preds = %4
  %magicptr = ptrtoint ptr %1 to i64
  switch i64 %magicptr, label %.thread [
    i64 -1, label %13
    i64 0, label %13
  ]

13:                                               ; preds = %12, %12
  %magicptr109 = ptrtoint ptr %3 to i64
  switch i64 %magicptr109, label %.thread [
    i64 -1, label %14
    i64 0, label %14
  ]

.thread:                                          ; preds = %13, %12
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 59, ptr noundef nonnull @__FUNCTION__.SheetCreate, ptr noundef nonnull @.str.2) #5
  br label %14

14:                                               ; preds = %13, %13, %.thread
  %15 = getelementptr inbounds i8, ptr %5, i64 16
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %15, i8 0, i64 16, i1 false)
  br label %100

16:                                               ; preds = %4
  %17 = zext nneg i32 %spec.store.select to i64
  %18 = shl nuw nsw i64 %17, 3
  %19 = trunc i64 %18 to i32
  %20 = tail call ptr @m_Malloc(i32 noundef %19) #5
  %21 = getelementptr inbounds i8, ptr %9, i64 104
  store ptr %20, ptr %21, align 8, !tbaa !19
  %22 = shl nuw nsw i64 %17, 2
  %23 = trunc i64 %22 to i32
  %24 = tail call ptr @m_Malloc(i32 noundef %23) #5
  %25 = getelementptr inbounds i8, ptr %9, i64 112
  store ptr %24, ptr %25, align 8, !tbaa !20
  %26 = tail call ptr @m_Malloc(i32 noundef %23) #5
  %27 = getelementptr inbounds i8, ptr %9, i64 96
  store ptr %26, ptr %27, align 8, !tbaa !21
  %28 = tail call ptr @m_Malloc(i32 noundef %19) #5
  %29 = getelementptr inbounds i8, ptr %9, i64 88
  store ptr %28, ptr %29, align 8, !tbaa !22
  %magicptr105 = ptrtoint ptr %2 to i64
  switch i64 %magicptr105, label %30 [
    i64 -1, label %31
    i64 0, label %31
  ]

30:                                               ; preds = %16
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 8 %28, ptr align 8 %2, i64 %18, i1 false)
  br label %31

31:                                               ; preds = %16, %16, %30
  %magicptr106 = ptrtoint ptr %1 to i64
  switch i64 %magicptr106, label %.lr.ph [
    i64 -1, label %89
    i64 0, label %89
  ]

.lr.ph:                                           ; preds = %31
  %magicptr107 = ptrtoint ptr %3 to i64
  switch i64 %magicptr107, label %.lr.ph.split.preheader [
    i64 -1, label %.lr.ph.split.us
    i64 0, label %.lr.ph.split.us
  ]

.lr.ph.split.preheader:                           ; preds = %.lr.ph
  %wide.trip.count117 = zext nneg i32 %0 to i64
  br label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %.lr.ph
  %wide.trip.count = zext nneg i32 %0 to i64
  br label %32

32:                                               ; preds = %59, %.lr.ph.split.us
  %indvars.iv = phi i64 [ %indvars.iv.next, %59 ], [ 0, %.lr.ph.split.us ]
  %33 = getelementptr inbounds i32, ptr %1, i64 %indvars.iv
  %34 = load i32, ptr %33, align 4, !tbaa !23
  %35 = icmp slt i32 %34, 1
  br i1 %35, label %52, label %36

36:                                               ; preds = %32
  %37 = shl i32 %34, 3
  %38 = tail call ptr @m_Malloc(i32 noundef %37) #5
  %39 = load ptr, ptr %21, align 8, !tbaa !19
  %40 = getelementptr inbounds ptr, ptr %39, i64 %indvars.iv
  store ptr %38, ptr %40, align 8, !tbaa !24
  %41 = load i32, ptr %33, align 4, !tbaa !23
  %42 = load ptr, ptr %27, align 8, !tbaa !21
  %43 = getelementptr inbounds i32, ptr %42, i64 %indvars.iv
  store i32 %41, ptr %43, align 4, !tbaa !23
  %44 = load ptr, ptr %25, align 8, !tbaa !20
  %45 = getelementptr inbounds i32, ptr %44, i64 %indvars.iv
  store i32 %41, ptr %45, align 4, !tbaa !23
  %46 = load ptr, ptr %21, align 8, !tbaa !19
  %47 = getelementptr inbounds ptr, ptr %46, i64 %indvars.iv
  %48 = load ptr, ptr %47, align 8, !tbaa !24
  %49 = load i32, ptr %33, align 4, !tbaa !23
  %50 = sext i32 %49 to i64
  %51 = shl nsw i64 %50, 3
  tail call void @llvm.memset.p0.i64(ptr align 8 %48, i8 0, i64 %51, i1 false)
  br label %59

52:                                               ; preds = %32
  %53 = load ptr, ptr %21, align 8, !tbaa !19
  %54 = getelementptr inbounds ptr, ptr %53, i64 %indvars.iv
  store ptr null, ptr %54, align 8, !tbaa !24
  %55 = load ptr, ptr %25, align 8, !tbaa !20
  %56 = getelementptr inbounds i32, ptr %55, i64 %indvars.iv
  store i32 0, ptr %56, align 4, !tbaa !23
  %57 = load ptr, ptr %27, align 8, !tbaa !21
  %58 = getelementptr inbounds i32, ptr %57, i64 %indvars.iv
  store i32 0, ptr %58, align 4, !tbaa !23
  br label %59

59:                                               ; preds = %52, %36
  %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 %.loopexit, label %32, !llvm.loop !25

.lr.ph.split:                                     ; preds = %.lr.ph.split.preheader, %88
  %indvars.iv113 = phi i64 [ 0, %.lr.ph.split.preheader ], [ %indvars.iv.next114, %88 ]
  %60 = getelementptr inbounds i32, ptr %1, i64 %indvars.iv113
  %61 = load i32, ptr %60, align 4, !tbaa !23
  %62 = icmp slt i32 %61, 1
  br i1 %62, label %63, label %70

63:                                               ; preds = %.lr.ph.split
  %64 = load ptr, ptr %21, align 8, !tbaa !19
  %65 = getelementptr inbounds ptr, ptr %64, i64 %indvars.iv113
  store ptr null, ptr %65, align 8, !tbaa !24
  %66 = load ptr, ptr %25, align 8, !tbaa !20
  %67 = getelementptr inbounds i32, ptr %66, i64 %indvars.iv113
  store i32 0, ptr %67, align 4, !tbaa !23
  %68 = load ptr, ptr %27, align 8, !tbaa !21
  %69 = getelementptr inbounds i32, ptr %68, i64 %indvars.iv113
  store i32 0, ptr %69, align 4, !tbaa !23
  br label %88

70:                                               ; preds = %.lr.ph.split
  %71 = shl i32 %61, 3
  %72 = tail call ptr @m_Malloc(i32 noundef %71) #5
  %73 = load ptr, ptr %21, align 8, !tbaa !19
  %74 = getelementptr inbounds ptr, ptr %73, i64 %indvars.iv113
  store ptr %72, ptr %74, align 8, !tbaa !24
  %75 = load i32, ptr %60, align 4, !tbaa !23
  %76 = load ptr, ptr %27, align 8, !tbaa !21
  %77 = getelementptr inbounds i32, ptr %76, i64 %indvars.iv113
  store i32 %75, ptr %77, align 4, !tbaa !23
  %78 = load ptr, ptr %25, align 8, !tbaa !20
  %79 = getelementptr inbounds i32, ptr %78, i64 %indvars.iv113
  store i32 %75, ptr %79, align 4, !tbaa !23
  %80 = load ptr, ptr %21, align 8, !tbaa !19
  %81 = getelementptr inbounds ptr, ptr %80, i64 %indvars.iv113
  %82 = load ptr, ptr %81, align 8, !tbaa !24
  %83 = getelementptr inbounds ptr, ptr %3, i64 %indvars.iv113
  %84 = load ptr, ptr %83, align 8, !tbaa !24
  %85 = load i32, ptr %60, align 4, !tbaa !23
  %86 = sext i32 %85 to i64
  %87 = shl nsw i64 %86, 3
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 8 %82, ptr align 8 %84, i64 %87, i1 false)
  br label %88

88:                                               ; preds = %70, %63
  %indvars.iv.next114 = add nuw nsw i64 %indvars.iv113, 1
  %exitcond118.not = icmp eq i64 %indvars.iv.next114, %wide.trip.count117
  br i1 %exitcond118.not, label %.loopexit, label %.lr.ph.split, !llvm.loop !25

89:                                               ; preds = %31, %31
  %magicptr108 = ptrtoint ptr %3 to i64
  switch i64 %magicptr108, label %90 [
    i64 -1, label %94
    i64 0, label %94
  ]

90:                                               ; preds = %89
  %91 = icmp ne ptr %3, null
  %92 = icmp ne ptr %3, inttoptr (i64 -1 to ptr)
  %.not102 = and i1 %91, %92
  %93 = zext i1 %.not102 to i32
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %93, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 95, ptr noundef nonnull @__FUNCTION__.SheetCreate, ptr noundef nonnull @.str.2) #5
  br label %94

94:                                               ; preds = %89, %89, %90
  %95 = load ptr, ptr %21, align 8, !tbaa !19
  tail call void @llvm.memset.p0.i64(ptr align 8 %95, i8 0, i64 %18, i1 false)
  %96 = load ptr, ptr %25, align 8, !tbaa !20
  tail call void @llvm.memset.p0.i64(ptr align 4 %96, i8 0, i64 %22, i1 false)
  %97 = load ptr, ptr %27, align 8, !tbaa !21
  tail call void @llvm.memset.p0.i64(ptr align 4 %97, i8 0, i64 %22, i1 false)
  br label %.loopexit

.loopexit:                                        ; preds = %59, %88, %94
  %98 = getelementptr inbounds i8, ptr %5, i64 16
  %99 = load <2 x ptr>, ptr %27, align 8, !tbaa !24
  store <2 x ptr> %99, ptr %98, align 8, !tbaa !24
  tail call void @m_PropertyFunction(ptr noundef nonnull %5, ptr noundef nonnull @.str.3, ptr noundef nonnull @mornMemoryDevice, ptr noundef null) #5
  br label %100

100:                                              ; preds = %.loopexit, %14
  ret ptr %5
}

declare ptr @ObjectAlloc(i32 noundef) local_unnamed_addr #1

declare ptr @GetHandle(ptr noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

declare ptr @m_Malloc(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) #3

declare void @m_PropertyFunction(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @mornMemoryDevice(ptr noundef, ptr noundef) #1

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

attributes #0 = { 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 = { "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: write) }
attributes #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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, !8, i64 28}
!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 = !{!13, !11, i64 16}
!13 = !{!"MHandle", !8, i64 0, !8, i64 4, !11, i64 8, !11, i64 16}
!14 = !{!15, !11, i64 0}
!15 = !{!"HandleSheetCreate", !11, i64 0, !11, i64 8, !9, i64 16, !8, i64 80, !8, i64 84, !11, i64 88, !11, i64 96, !11, i64 104, !11, i64 112, !11, i64 120}
!16 = !{!15, !8, i64 84}
!17 = !{!18, !8, i64 0}
!18 = !{!"MSheet", !8, i64 0, !11, i64 8, !11, i64 16, !11, i64 24}
!19 = !{!15, !11, i64 104}
!20 = !{!15, !11, i64 112}
!21 = !{!15, !11, i64 96}
!22 = !{!15, !11, i64 88}
!23 = !{!8, !8, i64 0}
!24 = !{!11, !11, i64 0}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}


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