; 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
@.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__.mSheetInfoWrite = external hidden unnamed_addr constant [16 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

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

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

15:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = icmp eq ptr %16, null
  br i1 %17, label %22, label %18

18:                                               ; preds = %15
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = ptrtoint ptr %19 to i64
  %21 = icmp eq i64 %20, -1
  br label %22

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

27:                                               ; preds = %22
  %28 = load i32, ptr %9, align 4, !tbaa !9
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %28, i32 noundef -1, ptr noundef @.str, i32 noundef 312, ptr noundef @__FUNCTION__.mSheetInfoWrite, ptr noundef @.str.4)
  br label %29

29:                                               ; preds = %27, %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %30

30:                                               ; preds = %29
  br label %31

31:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %32 = load i32, ptr %8, align 4, !tbaa !9
  %33 = icmp sle i32 %32, 0
  br i1 %33, label %34, label %43

34:                                               ; preds = %31
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = icmp eq ptr %35, null
  br i1 %36, label %41, label %37

37:                                               ; preds = %34
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = ptrtoint ptr %38 to i64
  %40 = icmp eq i64 %39, -1
  br label %41

41:                                               ; preds = %37, %34
  %42 = phi i1 [ true, %34 ], [ %40, %37 ]
  br label %43

43:                                               ; preds = %41, %31
  %44 = phi i1 [ false, %31 ], [ %42, %41 ]
  %45 = zext i1 %44 to i32
  store i32 %45, ptr %10, align 4, !tbaa !9
  %46 = load i32, ptr %10, align 4, !tbaa !9
  %47 = icmp ne i32 %46, 0
  br i1 %47, label %48, label %50

48:                                               ; preds = %43
  %49 = load i32, ptr %10, align 4, !tbaa !9
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %49, i32 noundef -1, ptr noundef @.str, i32 noundef 313, ptr noundef @__FUNCTION__.mSheetInfoWrite, ptr noundef @.str.7)
  br label %50

50:                                               ; preds = %48, %43
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %51

51:                                               ; preds = %50
  %52 = load i32, ptr %8, align 4, !tbaa !9
  %53 = icmp sle i32 %52, 0
  br i1 %53, label %54, label %59

54:                                               ; preds = %51
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  %56 = call i64 @strlen(ptr noundef %55) #5
  %57 = add i64 %56, 1
  %58 = trunc i64 %57 to i32
  store i32 %58, ptr %8, align 4, !tbaa !9
  br label %59

59:                                               ; preds = %54, %51
  br label %60

60:                                               ; preds = %59
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %61 = load i32, ptr %6, align 4, !tbaa !9
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.MSheet, ptr %62, i32 0, i32 0
  %64 = load i32, ptr %63, align 8, !tbaa !11
  %65 = icmp sgt i32 %61, %64
  %66 = zext i1 %65 to i32
  store i32 %66, ptr %11, align 4, !tbaa !9
  %67 = load i32, ptr %11, align 4, !tbaa !9
  %68 = icmp ne i32 %67, 0
  br i1 %68, label %69, label %71

69:                                               ; preds = %60
  %70 = load i32, ptr %11, 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 316, ptr noundef @__FUNCTION__.mSheetInfoWrite, ptr noundef @.str.8)
  br label %71

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

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

75:                                               ; preds = %72
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.MSheet, ptr %76, i32 0, i32 0
  %78 = load i32, ptr %77, align 8, !tbaa !11
  store i32 %78, ptr %6, align 4, !tbaa !9
  br label %79

79:                                               ; preds = %75, %72
  %80 = load i32, ptr %6, align 4, !tbaa !9
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.MSheet, ptr %81, i32 0, i32 0
  %83 = load i32, ptr %82, align 8, !tbaa !11
  %84 = icmp eq i32 %80, %83
  br i1 %84, label %85, label %87

85:                                               ; preds = %79
  %86 = load ptr, ptr %5, align 8, !tbaa !5
  call void @mSheetRowAppend(ptr noundef %86, i32 noundef -1)
  br label %87

87:                                               ; preds = %85, %79
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %88 = load ptr, ptr %5, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.HandleList, ptr %88, i64 -1
  %90 = getelementptr inbounds %struct.HandleList, ptr %89, i32 0, i32 0
  %91 = getelementptr inbounds %struct.MList, ptr %90, i32 0, i32 1
  %92 = load ptr, ptr %91, align 8, !tbaa !13
  %93 = getelementptr inbounds ptr, ptr %92, i64 0
  %94 = load ptr, ptr %93, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.MHandle, ptr %94, i32 0, i32 3
  %96 = load ptr, ptr %95, align 8, !tbaa !16
  store ptr %96, ptr %12, align 8, !tbaa !5
  %97 = load ptr, ptr %12, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.HandleSheetCreate, ptr %97, i32 0, i32 9
  %99 = load ptr, ptr %98, align 8, !tbaa !18
  %100 = icmp eq ptr %99, null
  br i1 %100, label %101, label %105

101:                                              ; preds = %87
  %102 = call ptr @mMemoryCreate(i32 noundef -1, i32 noundef -1, i32 noundef 0)
  %103 = load ptr, ptr %12, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.HandleSheetCreate, ptr %103, i32 0, i32 9
  store ptr %102, ptr %104, align 8, !tbaa !18
  br label %105

105:                                              ; preds = %101, %87
  %106 = load ptr, ptr %12, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.HandleSheetCreate, ptr %106, i32 0, i32 9
  %108 = load ptr, ptr %107, align 8, !tbaa !18
  %109 = load ptr, ptr %7, align 8, !tbaa !5
  %110 = load i32, ptr %8, align 4, !tbaa !9
  %111 = call ptr @mMemoryWrite(ptr noundef %108, ptr noundef %109, i32 noundef %110)
  %112 = load ptr, ptr %5, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.MSheet, ptr %112, i32 0, i32 1
  %114 = load ptr, ptr %113, align 8, !tbaa !20
  %115 = load i32, ptr %6, align 4, !tbaa !9
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds ptr, ptr %114, i64 %116
  store ptr %111, ptr %117, align 8, !tbaa !5
  %118 = load i32, ptr %6, align 4, !tbaa !9
  %119 = load ptr, ptr %5, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct.MSheet, ptr %119, i32 0, i32 0
  %121 = load i32, ptr %120, align 8, !tbaa !11
  %122 = sub nsw i32 %121, 1
  %123 = icmp ne i32 %118, %122
  br i1 %123, label %124, label %148

124:                                              ; preds = %105
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %125 = load ptr, ptr %5, align 8, !tbaa !5
  %126 = call ptr @GetHandle(ptr noundef %125, i32 noundef 4, i32 noundef -2124459017, ptr noundef @endSheetWrite)
  store ptr %126, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %127 = load ptr, ptr %13, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct.MHandle, ptr %127, i32 0, i32 3
  %129 = load ptr, ptr %128, align 8, !tbaa !16
  store ptr %129, ptr %14, align 8, !tbaa !5
  %130 = load i32, ptr %8, align 4, !tbaa !9
  %131 = load ptr, ptr %14, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct.HandleSheetWrite, ptr %131, i32 0, i32 0
  %133 = load i32, ptr %132, align 4, !tbaa !21
  %134 = add nsw i32 %133, %130
  store i32 %134, ptr %132, align 4, !tbaa !21
  %135 = load ptr, ptr %14, align 8, !tbaa !5
  %136 = getelementptr inbounds %struct.HandleSheetWrite, ptr %135, i32 0, i32 0
  %137 = load i32, ptr %136, align 4, !tbaa !21
  %138 = icmp sgt i32 %137, 16384
  br i1 %138, label %139, label %147

139:                                              ; preds = %124
  %140 = load ptr, ptr %5, align 8, !tbaa !5
  %141 = load ptr, ptr %12, align 8, !tbaa !5
  %142 = getelementptr inbounds %struct.HandleSheetCreate, ptr %141, i32 0, i32 9
  %143 = load ptr, ptr %142, align 8, !tbaa !18
  call void @mSheetOperate(ptr noundef %140, ptr noundef @MemoryCollect, ptr noundef %143)
  %144 = load ptr, ptr %12, align 8, !tbaa !5
  %145 = getelementptr inbounds %struct.HandleSheetCreate, ptr %144, i32 0, i32 9
  %146 = load ptr, ptr %145, align 8, !tbaa !18
  call void @MemoryDefrag(ptr noundef %146)
  br label %147

147:                                              ; preds = %139, %124
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  br label %148

148:                                              ; preds = %147, %105
  %149 = load ptr, ptr %5, align 8, !tbaa !5
  %150 = getelementptr inbounds %struct.MSheet, ptr %149, i32 0, i32 1
  %151 = load ptr, ptr %150, align 8, !tbaa !20
  %152 = load i32, ptr %6, align 4, !tbaa !9
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds ptr, ptr %151, i64 %153
  %155 = load ptr, ptr %154, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  ret ptr %155
}

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 = !{!19, !6, i64 120}
!19 = !{!"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}
!20 = !{!12, !6, i64 8}
!21 = !{!22, !10, i64 0}
!22 = !{!"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
@.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__.mSheetInfoWrite = external hidden unnamed_addr constant [16 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

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: 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

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

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

10:                                               ; preds = %4, %5
  %11 = icmp slt i32 %3, 1
  br i1 %11, label %12, label %22

12:                                               ; preds = %10
  %magicptr43 = ptrtoint ptr %2 to i64
  switch i64 %magicptr43, label %18 [
    i64 -1, label %13
    i64 0, label %13
  ]

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

18:                                               ; preds = %12, %13
  %19 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %2) #4
  %20 = trunc i64 %19 to i32
  %21 = add i32 %20, 1
  br label %22

22:                                               ; preds = %10, %18
  %.039 = phi i32 [ %21, %18 ], [ %3, %10 ]
  %23 = load i32, ptr %0, align 8, !tbaa !5
  %24 = icmp slt i32 %23, %1
  br i1 %24, label %25, label %26

25:                                               ; preds = %22
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 316, ptr noundef nonnull @__FUNCTION__.mSheetInfoWrite, ptr noundef nonnull @.str.8) #3
  %.pre.pre = load i32, ptr %0, align 8, !tbaa !5
  br label %26

26:                                               ; preds = %25, %22
  %.pre = phi i32 [ %.pre.pre, %25 ], [ %23, %22 ]
  %27 = icmp slt i32 %1, 0
  br i1 %27, label %.thread, label %28

28:                                               ; preds = %26
  %29 = icmp eq i32 %.pre, %1
  br i1 %29, label %.thread, label %30

.thread:                                          ; preds = %26, %28
  %.047 = phi i32 [ %1, %28 ], [ %.pre, %26 ]
  tail call void @mSheetRowAppend(ptr noundef nonnull %0, i32 noundef -1)
  br label %30

30:                                               ; preds = %.thread, %28
  %.046 = phi i32 [ %.047, %.thread ], [ %1, %28 ]
  %31 = getelementptr inbounds i8, ptr %0, i64 -24
  %32 = load ptr, ptr %31, align 8, !tbaa !11
  %33 = load ptr, ptr %32, align 8, !tbaa !14
  %34 = getelementptr inbounds i8, ptr %33, i64 16
  %35 = load ptr, ptr %34, align 8, !tbaa !15
  %36 = getelementptr inbounds i8, ptr %35, i64 120
  %37 = load ptr, ptr %36, align 8, !tbaa !17
  %38 = icmp eq ptr %37, null
  br i1 %38, label %39, label %41

39:                                               ; preds = %30
  %40 = tail call ptr @mMemoryCreate(i32 noundef -1, i32 noundef -1, i32 noundef 0) #3
  store ptr %40, ptr %36, align 8, !tbaa !17
  br label %41

41:                                               ; preds = %39, %30
  %42 = phi ptr [ %40, %39 ], [ %37, %30 ]
  %43 = tail call ptr @mMemoryWrite(ptr noundef %42, ptr noundef %2, i32 noundef %.039) #3
  %44 = getelementptr inbounds i8, ptr %0, i64 8
  %45 = load ptr, ptr %44, align 8, !tbaa !19
  %46 = sext i32 %.046 to i64
  %47 = getelementptr inbounds ptr, ptr %45, i64 %46
  store ptr %43, ptr %47, align 8, !tbaa !14
  %48 = load i32, ptr %0, align 8, !tbaa !5
  %49 = add nsw i32 %48, -1
  %.not = icmp eq i32 %.046, %49
  br i1 %.not, label %60, label %50

50:                                               ; preds = %41
  %51 = tail call ptr @GetHandle(ptr noundef nonnull %0, i32 noundef 4, i32 noundef -2124459017, ptr noundef nonnull @endSheetWrite) #3
  %52 = getelementptr inbounds i8, ptr %51, i64 16
  %53 = load ptr, ptr %52, align 8, !tbaa !15
  %54 = load i32, ptr %53, align 4, !tbaa !20
  %55 = add nsw i32 %54, %.039
  store i32 %55, ptr %53, align 4, !tbaa !20
  %56 = icmp sgt i32 %55, 16384
  br i1 %56, label %57, label %60

57:                                               ; preds = %50
  %58 = load ptr, ptr %36, align 8, !tbaa !17
  tail call void @mSheetOperate(ptr noundef nonnull %0, ptr noundef nonnull @MemoryCollect, ptr noundef %58)
  %59 = load ptr, ptr %36, align 8, !tbaa !17
  tail call void @MemoryDefrag(ptr noundef %59) #3
  br label %60

60:                                               ; preds = %50, %57, %41
  %61 = load ptr, ptr %44, align 8, !tbaa !19
  %62 = getelementptr inbounds ptr, ptr %61, i64 %46
  %63 = load ptr, ptr %62, align 8, !tbaa !14
  ret ptr %63
}

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 = !{!18, !10, i64 120}
!18 = !{!"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}
!19 = !{!6, !10, i64 8}
!20 = !{!21, !7, i64 0}
!21 = !{!"HandleSheetWrite", !7, i64 0}


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