; 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.MSheet = type { i32, ptr, ptr, ptr }
%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.HandleSheetWrite = type { i32 }

@.str = external hidden unnamed_addr constant [77 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [27 x i8], align 1
@__FUNCTION__.mSheetWrite = external hidden unnamed_addr constant [12 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [23 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

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

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

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

declare ptr @mMemoryCreate(i32 noundef, i32 noundef, i32 noundef) #1

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

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

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

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

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

25:                                               ; preds = %21, %18
  %26 = phi i1 [ true, %18 ], [ %24, %21 ]
  %27 = zext i1 %26 to i32
  store i32 %27, ptr %11, align 4, !tbaa !9
  %28 = load i32, ptr %11, align 4, !tbaa !9
  %29 = icmp ne i32 %28, 0
  br i1 %29, label %30, label %32

30:                                               ; preds = %25
  %31 = load i32, ptr %11, align 4, !tbaa !9
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %31, i32 noundef -1, ptr noundef @.str, i32 noundef 277, ptr noundef @__FUNCTION__.mSheetWrite, ptr noundef @.str.4)
  br label %32

32:                                               ; preds = %30, %25
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %33

33:                                               ; preds = %32
  br label %34

34:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %35 = load i32, ptr %10, align 4, !tbaa !9
  %36 = icmp sle i32 %35, 0
  br i1 %36, label %37, label %46

37:                                               ; preds = %34
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = icmp eq ptr %38, null
  br i1 %39, label %44, label %40

40:                                               ; preds = %37
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  %42 = ptrtoint ptr %41 to i64
  %43 = icmp eq i64 %42, -1
  br label %44

44:                                               ; preds = %40, %37
  %45 = phi i1 [ true, %37 ], [ %43, %40 ]
  br label %46

46:                                               ; preds = %44, %34
  %47 = phi i1 [ false, %34 ], [ %45, %44 ]
  %48 = zext i1 %47 to i32
  store i32 %48, ptr %12, align 4, !tbaa !9
  %49 = load i32, ptr %12, align 4, !tbaa !9
  %50 = icmp ne i32 %49, 0
  br i1 %50, label %51, label %53

51:                                               ; preds = %46
  %52 = load i32, ptr %12, align 4, !tbaa !9
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %52, i32 noundef -1, ptr noundef @.str, i32 noundef 278, ptr noundef @__FUNCTION__.mSheetWrite, ptr noundef @.str.7)
  br label %53

53:                                               ; preds = %51, %46
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %54

54:                                               ; preds = %53
  br label %55

55:                                               ; preds = %54
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %56 = load i32, ptr %7, align 4, !tbaa !9
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.MSheet, ptr %57, i32 0, i32 0
  %59 = load i32, ptr %58, align 8, !tbaa !11
  %60 = icmp sgt i32 %56, %59
  br i1 %60, label %64, label %61

61:                                               ; preds = %55
  %62 = load i32, ptr %7, align 4, !tbaa !9
  %63 = icmp slt i32 %62, 0
  br label %64

64:                                               ; preds = %61, %55
  %65 = phi i1 [ true, %55 ], [ %63, %61 ]
  %66 = zext i1 %65 to i32
  store i32 %66, ptr %13, align 4, !tbaa !9
  %67 = load i32, ptr %13, align 4, !tbaa !9
  %68 = icmp ne i32 %67, 0
  br i1 %68, label %69, label %71

69:                                               ; preds = %64
  %70 = load i32, ptr %13, align 4, !tbaa !9
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %70, i32 noundef -1, ptr noundef @.str, i32 noundef 279, ptr noundef @__FUNCTION__.mSheetWrite, ptr noundef @.str.8)
  br label %71

71:                                               ; preds = %69, %64
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  br label %72

72:                                               ; preds = %71
  %73 = load i32, ptr %10, align 4, !tbaa !9
  %74 = icmp sle i32 %73, 0
  br i1 %74, label %75, label %80

75:                                               ; preds = %72
  %76 = load ptr, ptr %9, align 8, !tbaa !5
  %77 = call i64 @strlen(ptr noundef %76) #5
  %78 = add i64 %77, 1
  %79 = trunc i64 %78 to i32
  store i32 %79, ptr %10, align 4, !tbaa !9
  br label %80

80:                                               ; preds = %75, %72
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %81 = load ptr, ptr %6, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.HandleList, ptr %81, i64 -1
  %83 = getelementptr inbounds %struct.HandleList, ptr %82, i32 0, i32 0
  %84 = getelementptr inbounds %struct.MList, ptr %83, i32 0, i32 1
  %85 = load ptr, ptr %84, align 8, !tbaa !13
  %86 = getelementptr inbounds ptr, ptr %85, i64 0
  %87 = load ptr, ptr %86, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.MHandle, ptr %87, i32 0, i32 3
  %89 = load ptr, ptr %88, align 8, !tbaa !16
  store ptr %89, ptr %14, align 8, !tbaa !5
  %90 = load i32, ptr %7, align 4, !tbaa !9
  %91 = load ptr, ptr %6, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.MSheet, ptr %91, i32 0, i32 0
  %93 = load i32, ptr %92, align 8, !tbaa !11
  %94 = icmp eq i32 %90, %93
  br i1 %94, label %95, label %97

95:                                               ; preds = %80
  %96 = load ptr, ptr %6, align 8, !tbaa !5
  call void @mSheetRowAppend(ptr noundef %96, i32 noundef -1)
  br label %97

97:                                               ; preds = %95, %80
  br label %98

98:                                               ; preds = %97
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %99 = load i32, ptr %8, align 4, !tbaa !9
  %100 = load ptr, ptr %6, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.MSheet, ptr %100, i32 0, i32 2
  %102 = load ptr, ptr %101, align 8, !tbaa !18
  %103 = load i32, ptr %7, align 4, !tbaa !9
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds i32, ptr %102, i64 %104
  %106 = load i32, ptr %105, align 4, !tbaa !9
  %107 = icmp sgt i32 %99, %106
  %108 = zext i1 %107 to i32
  store i32 %108, ptr %15, align 4, !tbaa !9
  %109 = load i32, ptr %15, align 4, !tbaa !9
  %110 = icmp ne i32 %109, 0
  br i1 %110, label %111, label %113

111:                                              ; preds = %98
  %112 = load i32, ptr %15, align 4, !tbaa !9
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %112, i32 noundef -1, ptr noundef @.str, i32 noundef 286, ptr noundef @__FUNCTION__.mSheetWrite, ptr noundef @.str.8)
  br label %113

113:                                              ; preds = %111, %98
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  br label %114

114:                                              ; preds = %113
  br label %115

115:                                              ; preds = %114
  %116 = load i32, ptr %8, align 4, !tbaa !9
  %117 = icmp slt i32 %116, 0
  br i1 %117, label %118, label %126

118:                                              ; preds = %115
  %119 = load ptr, ptr %6, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct.MSheet, ptr %119, i32 0, i32 2
  %121 = load ptr, ptr %120, align 8, !tbaa !18
  %122 = load i32, ptr %7, align 4, !tbaa !9
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds i32, ptr %121, i64 %123
  %125 = load i32, ptr %124, align 4, !tbaa !9
  store i32 %125, ptr %8, align 4, !tbaa !9
  br label %126

126:                                              ; preds = %118, %115
  %127 = load i32, ptr %8, align 4, !tbaa !9
  %128 = load ptr, ptr %6, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct.MSheet, ptr %128, i32 0, i32 2
  %130 = load ptr, ptr %129, align 8, !tbaa !18
  %131 = load i32, ptr %7, align 4, !tbaa !9
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds i32, ptr %130, i64 %132
  %134 = load i32, ptr %133, align 4, !tbaa !9
  %135 = icmp eq i32 %127, %134
  br i1 %135, label %136, label %139

136:                                              ; preds = %126
  %137 = load ptr, ptr %6, align 8, !tbaa !5
  %138 = load i32, ptr %7, align 4, !tbaa !9
  call void @mSheetColAppend(ptr noundef %137, i32 noundef %138, i32 noundef -1)
  br label %139

139:                                              ; preds = %136, %126
  %140 = load ptr, ptr %14, align 8, !tbaa !5
  %141 = getelementptr inbounds %struct.HandleSheetCreate, ptr %140, i32 0, i32 9
  %142 = load ptr, ptr %141, align 8, !tbaa !19
  %143 = icmp eq ptr %142, null
  br i1 %143, label %144, label %148

144:                                              ; preds = %139
  %145 = call ptr @mMemoryCreate(i32 noundef -1, i32 noundef -1, i32 noundef 0)
  %146 = load ptr, ptr %14, align 8, !tbaa !5
  %147 = getelementptr inbounds %struct.HandleSheetCreate, ptr %146, i32 0, i32 9
  store ptr %145, ptr %147, align 8, !tbaa !19
  br label %148

148:                                              ; preds = %144, %139
  %149 = load ptr, ptr %14, align 8, !tbaa !5
  %150 = getelementptr inbounds %struct.HandleSheetCreate, ptr %149, i32 0, i32 9
  %151 = load ptr, ptr %150, align 8, !tbaa !19
  %152 = load ptr, ptr %9, align 8, !tbaa !5
  %153 = load i32, ptr %10, align 4, !tbaa !9
  %154 = call ptr @mMemoryWrite(ptr noundef %151, ptr noundef %152, i32 noundef %153)
  %155 = load ptr, ptr %6, align 8, !tbaa !5
  %156 = getelementptr inbounds %struct.MSheet, ptr %155, i32 0, i32 3
  %157 = load ptr, ptr %156, align 8, !tbaa !21
  %158 = load i32, ptr %7, align 4, !tbaa !9
  %159 = sext i32 %158 to i64
  %160 = getelementptr inbounds ptr, ptr %157, i64 %159
  %161 = load ptr, ptr %160, align 8, !tbaa !5
  %162 = load i32, ptr %8, align 4, !tbaa !9
  %163 = sext i32 %162 to i64
  %164 = getelementptr inbounds ptr, ptr %161, i64 %163
  store ptr %154, ptr %164, align 8, !tbaa !5
  %165 = load i32, ptr %7, align 4, !tbaa !9
  %166 = load ptr, ptr %6, align 8, !tbaa !5
  %167 = getelementptr inbounds %struct.MSheet, ptr %166, i32 0, i32 0
  %168 = load i32, ptr %167, align 8, !tbaa !11
  %169 = sub nsw i32 %168, 1
  %170 = icmp ne i32 %165, %169
  br i1 %170, label %171, label %206

171:                                              ; preds = %148
  %172 = load i32, ptr %8, align 4, !tbaa !9
  %173 = load ptr, ptr %6, align 8, !tbaa !5
  %174 = getelementptr inbounds %struct.MSheet, ptr %173, i32 0, i32 2
  %175 = load ptr, ptr %174, align 8, !tbaa !18
  %176 = load i32, ptr %7, align 4, !tbaa !9
  %177 = sext i32 %176 to i64
  %178 = getelementptr inbounds i32, ptr %175, i64 %177
  %179 = load i32, ptr %178, align 4, !tbaa !9
  %180 = sub nsw i32 %179, 1
  %181 = icmp ne i32 %172, %180
  br i1 %181, label %182, label %206

182:                                              ; preds = %171
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %183 = load ptr, ptr %6, align 8, !tbaa !5
  %184 = call ptr @GetHandle(ptr noundef %183, i32 noundef 4, i32 noundef -2124459017, ptr noundef @endSheetWrite)
  store ptr %184, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  %185 = load ptr, ptr %16, align 8, !tbaa !5
  %186 = getelementptr inbounds %struct.MHandle, ptr %185, i32 0, i32 3
  %187 = load ptr, ptr %186, align 8, !tbaa !16
  store ptr %187, ptr %17, align 8, !tbaa !5
  %188 = load i32, ptr %10, align 4, !tbaa !9
  %189 = load ptr, ptr %17, align 8, !tbaa !5
  %190 = getelementptr inbounds %struct.HandleSheetWrite, ptr %189, i32 0, i32 0
  %191 = load i32, ptr %190, align 4, !tbaa !22
  %192 = add nsw i32 %191, %188
  store i32 %192, ptr %190, align 4, !tbaa !22
  %193 = load ptr, ptr %17, align 8, !tbaa !5
  %194 = getelementptr inbounds %struct.HandleSheetWrite, ptr %193, i32 0, i32 0
  %195 = load i32, ptr %194, align 4, !tbaa !22
  %196 = icmp sgt i32 %195, 16384
  br i1 %196, label %197, label %205

197:                                              ; preds = %182
  %198 = load ptr, ptr %6, align 8, !tbaa !5
  %199 = load ptr, ptr %14, align 8, !tbaa !5
  %200 = getelementptr inbounds %struct.HandleSheetCreate, ptr %199, i32 0, i32 9
  %201 = load ptr, ptr %200, align 8, !tbaa !19
  call void @mSheetOperate(ptr noundef %198, ptr noundef @MemoryCollect, ptr noundef %201)
  %202 = load ptr, ptr %14, align 8, !tbaa !5
  %203 = getelementptr inbounds %struct.HandleSheetCreate, ptr %202, i32 0, i32 9
  %204 = load ptr, ptr %203, align 8, !tbaa !19
  call void @MemoryDefrag(ptr noundef %204)
  br label %205

205:                                              ; preds = %197, %182
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  br label %206

206:                                              ; preds = %205, %171, %148
  %207 = load ptr, ptr %6, align 8, !tbaa !5
  %208 = getelementptr inbounds %struct.MSheet, ptr %207, i32 0, i32 3
  %209 = load ptr, ptr %208, align 8, !tbaa !21
  %210 = load i32, ptr %7, align 4, !tbaa !9
  %211 = sext i32 %210 to i64
  %212 = getelementptr inbounds ptr, ptr %209, i64 %211
  %213 = load ptr, ptr %212, align 8, !tbaa !5
  %214 = load i32, ptr %8, align 4, !tbaa !9
  %215 = sext i32 %214 to i64
  %216 = getelementptr inbounds ptr, ptr %213, i64 %215
  %217 = load ptr, ptr %216, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  ret ptr %217
}

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

declare ptr @mMemoryWrite(ptr noundef, ptr noundef, i32 noundef) #1

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

declare void @MemoryDefrag(ptr noundef) #1

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 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 #4 = { nounwind }
attributes #5 = { 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, !10, i64 0}
!12 = !{!"MSheet", !10, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!13 = !{!14, !6, i64 8}
!14 = !{!"HandleList", !15, i64 0, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28}
!15 = !{!"MList", !10, i64 0, !6, i64 8}
!16 = !{!17, !6, i64 16}
!17 = !{!"MHandle", !10, i64 0, !10, i64 4, !6, i64 8, !6, i64 16}
!18 = !{!12, !6, i64 16}
!19 = !{!20, !6, i64 120}
!20 = !{!"HandleSheetCreate", !6, i64 0, !6, i64 8, !7, i64 16, !10, i64 80, !10, i64 84, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120}
!21 = !{!12, !6, i64 24}
!22 = !{!23, !10, i64 0}
!23 = !{!"HandleSheetWrite", !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 [77 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [27 x i8], align 1
@__FUNCTION__.mSheetWrite = external hidden unnamed_addr constant [12 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [23 x i8], align 1

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

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

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

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

declare ptr @mMemoryCreate(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

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

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

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

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

11:                                               ; preds = %5, %6
  %12 = icmp slt i32 %4, 1
  br i1 %12, label %13, label %.thread

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

14:                                               ; preds = %13, %13
  %15 = icmp eq ptr %3, null
  %16 = icmp eq ptr %3, inttoptr (i64 -1 to ptr)
  %17 = or i1 %15, %16
  %18 = zext i1 %17 to i32
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %18, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 278, ptr noundef nonnull @__FUNCTION__.mSheetWrite, ptr noundef nonnull @.str.7) #3
  br label %.thread

.thread:                                          ; preds = %13, %11, %14
  %19 = load i32, ptr %0, align 8, !tbaa !5
  %20 = icmp slt i32 %19, %1
  %21 = icmp slt i32 %1, 0
  %22 = or i1 %21, %20
  br i1 %22, label %23, label %24

23:                                               ; preds = %.thread
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 279, ptr noundef nonnull @__FUNCTION__.mSheetWrite, ptr noundef nonnull @.str.8) #3
  br label %24

24:                                               ; preds = %23, %.thread
  br i1 %12, label %25, label %29

25:                                               ; preds = %24
  %26 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %3) #4
  %27 = trunc i64 %26 to i32
  %28 = add i32 %27, 1
  br label %29

29:                                               ; preds = %25, %24
  %.056 = phi i32 [ %28, %25 ], [ %4, %24 ]
  %30 = getelementptr inbounds i8, ptr %0, i64 -24
  %31 = load ptr, ptr %30, align 8, !tbaa !11
  %32 = load ptr, ptr %31, align 8, !tbaa !14
  %33 = getelementptr inbounds i8, ptr %32, i64 16
  %34 = load ptr, ptr %33, align 8, !tbaa !15
  %35 = load i32, ptr %0, align 8, !tbaa !5
  %36 = icmp eq i32 %35, %1
  br i1 %36, label %37, label %38

37:                                               ; preds = %29
  tail call void @mSheetRowAppend(ptr noundef nonnull %0, i32 noundef -1)
  br label %38

38:                                               ; preds = %29, %37
  %39 = getelementptr inbounds i8, ptr %0, i64 16
  %40 = load ptr, ptr %39, align 8, !tbaa !17
  %41 = sext i32 %1 to i64
  %42 = getelementptr inbounds i32, ptr %40, i64 %41
  %43 = load i32, ptr %42, align 4, !tbaa !18
  %44 = icmp slt i32 %43, %2
  br i1 %44, label %45, label %46

45:                                               ; preds = %38
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 286, ptr noundef nonnull @__FUNCTION__.mSheetWrite, ptr noundef nonnull @.str.8) #3
  %.pre.pre = load ptr, ptr %39, align 8, !tbaa !17
  br label %46

46:                                               ; preds = %45, %38
  %.pre = phi ptr [ %.pre.pre, %45 ], [ %40, %38 ]
  %47 = icmp slt i32 %2, 0
  %48 = getelementptr inbounds i32, ptr %.pre, i64 %41
  %49 = load i32, ptr %48, align 4, !tbaa !18
  br i1 %47, label %.thread63, label %50

50:                                               ; preds = %46
  %51 = icmp eq i32 %49, %2
  br i1 %51, label %.thread63, label %52

.thread63:                                        ; preds = %46, %50
  %.066 = phi i32 [ %2, %50 ], [ %49, %46 ]
  tail call void @mSheetColAppend(ptr noundef nonnull %0, i32 noundef %1, i32 noundef -1)
  br label %52

52:                                               ; preds = %.thread63, %50
  %.065 = phi i32 [ %.066, %.thread63 ], [ %2, %50 ]
  %53 = getelementptr inbounds i8, ptr %34, i64 120
  %54 = load ptr, ptr %53, align 8, !tbaa !19
  %55 = icmp eq ptr %54, null
  br i1 %55, label %56, label %58

56:                                               ; preds = %52
  %57 = tail call ptr @mMemoryCreate(i32 noundef -1, i32 noundef -1, i32 noundef 0) #3
  store ptr %57, ptr %53, align 8, !tbaa !19
  br label %58

58:                                               ; preds = %56, %52
  %59 = phi ptr [ %57, %56 ], [ %54, %52 ]
  %60 = tail call ptr @mMemoryWrite(ptr noundef %59, ptr noundef %3, i32 noundef %.056) #3
  %61 = getelementptr inbounds i8, ptr %0, i64 24
  %62 = load ptr, ptr %61, align 8, !tbaa !21
  %63 = getelementptr inbounds ptr, ptr %62, i64 %41
  %64 = load ptr, ptr %63, align 8, !tbaa !14
  %65 = sext i32 %.065 to i64
  %66 = getelementptr inbounds ptr, ptr %64, i64 %65
  store ptr %60, ptr %66, align 8, !tbaa !14
  %67 = load i32, ptr %0, align 8, !tbaa !5
  %68 = add nsw i32 %67, -1
  %.not = icmp eq i32 %68, %1
  br i1 %.not, label %84, label %69

69:                                               ; preds = %58
  %70 = load ptr, ptr %39, align 8, !tbaa !17
  %71 = getelementptr inbounds i32, ptr %70, i64 %41
  %72 = load i32, ptr %71, align 4, !tbaa !18
  %73 = add nsw i32 %72, -1
  %.not59 = icmp eq i32 %.065, %73
  br i1 %.not59, label %84, label %74

74:                                               ; preds = %69
  %75 = tail call ptr @GetHandle(ptr noundef nonnull %0, i32 noundef 4, i32 noundef -2124459017, ptr noundef nonnull @endSheetWrite) #3
  %76 = getelementptr inbounds i8, ptr %75, i64 16
  %77 = load ptr, ptr %76, align 8, !tbaa !15
  %78 = load i32, ptr %77, align 4, !tbaa !22
  %79 = add nsw i32 %78, %.056
  store i32 %79, ptr %77, align 4, !tbaa !22
  %80 = icmp sgt i32 %79, 16384
  br i1 %80, label %81, label %84

81:                                               ; preds = %74
  %82 = load ptr, ptr %53, align 8, !tbaa !19
  tail call void @mSheetOperate(ptr noundef nonnull %0, ptr noundef nonnull @MemoryCollect, ptr noundef %82)
  %83 = load ptr, ptr %53, align 8, !tbaa !19
  tail call void @MemoryDefrag(ptr noundef %83) #3
  br label %84

84:                                               ; preds = %74, %81, %69, %58
  %85 = load ptr, ptr %61, align 8, !tbaa !21
  %86 = getelementptr inbounds ptr, ptr %85, i64 %41
  %87 = load ptr, ptr %86, align 8, !tbaa !14
  %88 = getelementptr inbounds ptr, ptr %87, i64 %65
  %89 = load ptr, ptr %88, align 8, !tbaa !14
  ret ptr %89
}

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

declare ptr @mMemoryWrite(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

declare void @MemoryCollect(ptr noundef, ptr noundef) #0

declare void @MemoryDefrag(ptr noundef) local_unnamed_addr #0

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 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 #3 = { nounwind }
attributes #4 = { 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, !7, i64 0}
!6 = !{!"MSheet", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"HandleList", !13, i64 0, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28}
!13 = !{!"MList", !7, i64 0, !10, i64 8}
!14 = !{!10, !10, i64 0}
!15 = !{!16, !10, i64 16}
!16 = !{!"MHandle", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16}
!17 = !{!6, !10, i64 16}
!18 = !{!7, !7, i64 0}
!19 = !{!20, !10, i64 120}
!20 = !{!"HandleSheetCreate", !10, i64 0, !10, i64 8, !8, i64 16, !7, i64 80, !7, i64 84, !10, i64 88, !10, i64 96, !10, i64 104, !10, i64 112, !10, i64 120}
!21 = !{!6, !10, i64 24}
!22 = !{!23, !7, i64 0}
!23 = !{!"HandleSheetWrite", !7, i64 0}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass