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

@.str = external hidden unnamed_addr constant [77 x i8], align 1
@__FUNCTION__.mSheetPlace = external hidden unnamed_addr constant [12 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [32 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 void @m_Free(ptr noundef) #1

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

declare ptr @m_Malloc(i32 noundef) #1

; 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 @mSheetRowAppend(ptr noundef, i32 noundef) #4

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

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

22:                                               ; preds = %5
  %23 = load i32, ptr %9, align 4, !tbaa !9
  %24 = icmp sle i32 %23, 0
  br i1 %24, label %25, label %26

25:                                               ; preds = %22, %5
  br label %165

26:                                               ; preds = %22
  br label %27

27:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %28 = load i32, ptr %10, align 4, !tbaa !9
  %29 = icmp sle i32 %28, 0
  %30 = zext i1 %29 to i32
  store i32 %30, ptr %11, align 4, !tbaa !9
  %31 = load i32, ptr %11, align 4, !tbaa !9
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %33, label %35

33:                                               ; preds = %27
  %34 = load i32, ptr %11, align 4, !tbaa !9
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %34, i32 noundef -1, ptr noundef @.str, i32 noundef 182, ptr noundef @__FUNCTION__.mSheetPlace, ptr noundef @.str.6)
  br label %35

35:                                               ; preds = %33, %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  br label %36

36:                                               ; preds = %35
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = load i32, ptr %8, align 4, !tbaa !9
  call void @mSheetRowAppend(ptr noundef %37, i32 noundef %38)
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %39

39:                                               ; preds = %48, %36
  %40 = load i32, ptr %12, align 4, !tbaa !9
  %41 = load i32, ptr %8, align 4, !tbaa !9
  %42 = icmp slt i32 %40, %41
  br i1 %42, label %44, label %43

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

44:                                               ; preds = %39
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = load i32, ptr %12, align 4, !tbaa !9
  %47 = load i32, ptr %9, align 4, !tbaa !9
  call void @mSheetColAppend(ptr noundef %45, i32 noundef %46, i32 noundef %47)
  br label %48

48:                                               ; preds = %44
  %49 = load i32, ptr %12, align 4, !tbaa !9
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %12, align 4, !tbaa !9
  br label %39, !llvm.loop !11

51:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %52 = load i32, ptr %8, align 4, !tbaa !9
  %53 = load i32, ptr %9, align 4, !tbaa !9
  %54 = mul nsw i32 %52, %53
  %55 = sext i32 %54 to i64
  %56 = mul i64 %55, 8
  %57 = trunc i64 %56 to i32
  %58 = call ptr @m_Malloc(i32 noundef %57)
  store ptr %58, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %59 = load ptr, ptr %6, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.HandleList, ptr %59, i64 -1
  %61 = getelementptr inbounds %struct.HandleList, ptr %60, i32 0, i32 0
  %62 = getelementptr inbounds %struct.MList, ptr %61, i32 0, i32 1
  %63 = load ptr, ptr %62, align 8, !tbaa !13
  %64 = getelementptr inbounds ptr, ptr %63, i64 0
  %65 = load ptr, ptr %64, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.MHandle, ptr %65, i32 0, i32 3
  %67 = load ptr, ptr %66, align 8, !tbaa !16
  store ptr %67, ptr %14, align 8, !tbaa !5
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.MSheet, ptr %68, i32 0, i32 1
  %70 = load ptr, ptr %69, align 8, !tbaa !18
  %71 = load i32, ptr %8, align 4, !tbaa !9
  %72 = sext i32 %71 to i64
  %73 = mul i64 %72, 8
  call void @llvm.memset.p0.i64(ptr align 8 %70, i8 0, i64 %73, i1 false)
  %74 = load ptr, ptr %14, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.HandleSheetCreate, ptr %74, i32 0, i32 9
  %76 = load ptr, ptr %75, align 8, !tbaa !20
  %77 = icmp eq ptr %76, null
  br i1 %77, label %78, label %87

78:                                               ; preds = %51
  %79 = load i32, ptr %8, align 4, !tbaa !9
  %80 = load i32, ptr %9, align 4, !tbaa !9
  %81 = mul nsw i32 %79, %80
  %82 = load i32, ptr %10, align 4, !tbaa !9
  %83 = mul nsw i32 %81, %82
  %84 = call ptr @mMemoryCreate(i32 noundef 1, i32 noundef %83, i32 noundef 0)
  %85 = load ptr, ptr %14, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.HandleSheetCreate, ptr %85, i32 0, i32 9
  store ptr %84, ptr %86, align 8, !tbaa !20
  br label %97

87:                                               ; preds = %51
  %88 = load ptr, ptr %14, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.HandleSheetCreate, ptr %88, i32 0, i32 9
  %90 = load ptr, ptr %89, align 8, !tbaa !20
  %91 = load i32, ptr %8, align 4, !tbaa !9
  %92 = load i32, ptr %9, align 4, !tbaa !9
  %93 = mul nsw i32 %91, %92
  %94 = load i32, ptr %10, align 4, !tbaa !9
  %95 = mul nsw i32 %93, %94
  %96 = call ptr @mMemoryAppend(ptr noundef %90, i32 noundef %95)
  br label %97

97:                                               ; preds = %87, %78
  %98 = load ptr, ptr %14, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.HandleSheetCreate, ptr %98, i32 0, i32 9
  %100 = load ptr, ptr %99, align 8, !tbaa !20
  %101 = load i32, ptr %8, align 4, !tbaa !9
  %102 = load i32, ptr %9, align 4, !tbaa !9
  %103 = mul nsw i32 %101, %102
  %104 = load i32, ptr %10, align 4, !tbaa !9
  call void @mMemoryIndex(ptr noundef %100, i32 noundef %103, i32 noundef %104, ptr noundef %13, i32 noundef 1)
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %105 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %105, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %106 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %106, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  store i32 0, ptr %17, align 4, !tbaa !9
  br label %107

107:                                              ; preds = %160, %97
  %108 = load i32, ptr %17, align 4, !tbaa !9
  %109 = load i32, ptr %8, align 4, !tbaa !9
  %110 = icmp slt i32 %108, %109
  br i1 %110, label %112, label %111

111:                                              ; preds = %107
  store i32 7, ptr %18, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  br label %163

112:                                              ; preds = %107
  %113 = load ptr, ptr %6, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.MSheet, ptr %113, i32 0, i32 3
  %115 = load ptr, ptr %114, align 8, !tbaa !22
  %116 = load i32, ptr %17, align 4, !tbaa !9
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds ptr, ptr %115, i64 %117
  %119 = load ptr, ptr %118, align 8, !tbaa !5
  %120 = load ptr, ptr %16, align 8, !tbaa !5
  %121 = load i32, ptr %9, align 4, !tbaa !9
  %122 = sext i32 %121 to i64
  %123 = mul i64 %122, 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %119, ptr align 8 %120, i64 %123, i1 false)
  %124 = load ptr, ptr %16, align 8, !tbaa !5
  %125 = load i32, ptr %9, align 4, !tbaa !9
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds ptr, ptr %124, i64 %126
  store ptr %127, ptr %16, align 8, !tbaa !5
  %128 = load ptr, ptr %7, align 8, !tbaa !5
  %129 = icmp ne ptr %128, null
  br i1 %129, label %130, label %159

130:                                              ; preds = %112
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #5
  store i32 0, ptr %19, align 4, !tbaa !9
  br label %131

131:                                              ; preds = %155, %130
  %132 = load i32, ptr %19, align 4, !tbaa !9
  %133 = load i32, ptr %9, align 4, !tbaa !9
  %134 = icmp slt i32 %132, %133
  br i1 %134, label %136, label %135

135:                                              ; preds = %131
  store i32 10, ptr %18, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #5
  br label %158

136:                                              ; preds = %131
  %137 = load ptr, ptr %6, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct.MSheet, ptr %137, i32 0, i32 3
  %139 = load ptr, ptr %138, align 8, !tbaa !22
  %140 = load i32, ptr %17, align 4, !tbaa !9
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds ptr, ptr %139, i64 %141
  %143 = load ptr, ptr %142, align 8, !tbaa !5
  %144 = load i32, ptr %19, align 4, !tbaa !9
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds ptr, ptr %143, i64 %145
  %147 = load ptr, ptr %146, align 8, !tbaa !5
  %148 = load ptr, ptr %15, align 8, !tbaa !5
  %149 = load i32, ptr %10, align 4, !tbaa !9
  %150 = sext i32 %149 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %147, ptr align 1 %148, i64 %150, i1 false)
  %151 = load i32, ptr %10, align 4, !tbaa !9
  %152 = load ptr, ptr %15, align 8, !tbaa !5
  %153 = sext i32 %151 to i64
  %154 = getelementptr inbounds i8, ptr %152, i64 %153
  store ptr %154, ptr %15, align 8, !tbaa !5
  br label %155

155:                                              ; preds = %136
  %156 = load i32, ptr %19, align 4, !tbaa !9
  %157 = add nsw i32 %156, 1
  store i32 %157, ptr %19, align 4, !tbaa !9
  br label %131, !llvm.loop !23

158:                                              ; preds = %135
  br label %159

159:                                              ; preds = %158, %112
  br label %160

160:                                              ; preds = %159
  %161 = load i32, ptr %17, align 4, !tbaa !9
  %162 = add nsw i32 %161, 1
  store i32 %162, ptr %17, align 4, !tbaa !9
  br label %107, !llvm.loop !24

163:                                              ; preds = %111
  %164 = load ptr, ptr %13, align 8, !tbaa !5
  call void @m_Free(ptr noundef %164)
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  br label %165

165:                                              ; preds = %163, %25
  ret void
}

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

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

declare void @mMemoryIndex(ptr noundef, i32 noundef, i32 noundef, ptr noundef, i32 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #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 = !{!"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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!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 8}
!19 = !{!"MSheet", !10, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!20 = !{!21, !6, i64 120}
!21 = !{!"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}
!22 = !{!19, !6, i64 24}
!23 = distinct !{!23, !12}
!24 = distinct !{!24, !12}


; 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__.mSheetPlace = external hidden unnamed_addr constant [12 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [32 x i8], align 1

; Function Attrs: mustprogress 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, ...) local_unnamed_addr #1

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

declare void @m_Free(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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @mSheetPlace(ptr noundef %0, ptr noundef readonly %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #4 {
  %6 = alloca ptr, align 8
  %7 = icmp slt i32 %2, 1
  %8 = icmp slt i32 %3, 1
  %or.cond = or i1 %7, %8
  br i1 %or.cond, label %88, label %9

9:                                                ; preds = %5
  %10 = icmp slt i32 %4, 1
  br i1 %10, label %11, label %.lr.ph.preheader

11:                                               ; preds = %9
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 182, ptr noundef nonnull @__FUNCTION__.mSheetPlace, ptr noundef nonnull @.str.6) #5
  br label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %9, %11
  tail call void @mSheetRowAppend(ptr noundef %0, i32 noundef %2)
  br label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #5
  %12 = mul nuw nsw i32 %3, %2
  %13 = shl i32 %12, 3
  %14 = tail call ptr @m_Malloc(i32 noundef %13) #5
  store ptr %14, ptr %6, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %0, i64 -24
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  %17 = load ptr, ptr %16, align 8, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %17, i64 16
  %19 = load ptr, ptr %18, align 8, !tbaa !13
  %20 = getelementptr inbounds i8, ptr %0, i64 8
  %21 = load ptr, ptr %20, align 8, !tbaa !15
  %22 = zext nneg i32 %2 to i64
  %23 = shl nuw nsw i64 %22, 3
  tail call void @llvm.memset.p0.i64(ptr align 8 %21, i8 0, i64 %23, i1 false)
  %24 = getelementptr inbounds i8, ptr %19, i64 120
  %25 = load ptr, ptr %24, align 8, !tbaa !17
  %26 = icmp eq ptr %25, null
  %27 = mul nsw i32 %12, %4
  br i1 %26, label %29, label %31

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.05559 = phi i32 [ %28, %.lr.ph ], [ 0, %.lr.ph.preheader ]
  tail call void @mSheetColAppend(ptr noundef %0, i32 noundef %.05559, i32 noundef %3)
  %28 = add nuw nsw i32 %.05559, 1
  %exitcond.not = icmp eq i32 %28, %2
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !19

29:                                               ; preds = %._crit_edge
  %30 = tail call ptr @mMemoryCreate(i32 noundef 1, i32 noundef %27, i32 noundef 0) #5
  store ptr %30, ptr %24, align 8, !tbaa !17
  br label %.lr.ph67

31:                                               ; preds = %._crit_edge
  %32 = tail call ptr @mMemoryAppend(ptr noundef nonnull %25, i32 noundef %27) #5
  %.pre = load ptr, ptr %24, align 8, !tbaa !17
  br label %.lr.ph67

.lr.ph67:                                         ; preds = %29, %31
  %33 = phi ptr [ %.pre, %31 ], [ %30, %29 ]
  call void @mMemoryIndex(ptr noundef %33, i32 noundef %12, i32 noundef %4, ptr noundef nonnull %6, i32 noundef 1) #5
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %0, i64 24
  %36 = zext nneg i32 %3 to i64
  %37 = shl nuw nsw i64 %36, 3
  %.not = icmp eq ptr %1, null
  %38 = sext i32 %4 to i64
  br i1 %.not, label %.lr.ph67.split.us.preheader, label %.lr.ph67.split

.lr.ph67.split.us.preheader:                      ; preds = %.lr.ph67
  %xtraiter102 = and i64 %22, 1
  %39 = icmp eq i32 %2, 1
  br i1 %39, label %._crit_edge68.loopexit.unr-lcssa, label %.lr.ph67.split.us.preheader.new

.lr.ph67.split.us.preheader.new:                  ; preds = %.lr.ph67.split.us.preheader
  %unroll_iter104 = and i64 %22, 2147483646
  br label %.lr.ph67.split.us

.lr.ph67.split.us:                                ; preds = %.lr.ph67.split.us, %.lr.ph67.split.us.preheader.new
  %indvars.iv86 = phi i64 [ 0, %.lr.ph67.split.us.preheader.new ], [ %indvars.iv.next87.1, %.lr.ph67.split.us ]
  %.05364.us = phi ptr [ %34, %.lr.ph67.split.us.preheader.new ], [ %47, %.lr.ph67.split.us ]
  %niter105 = phi i64 [ 0, %.lr.ph67.split.us.preheader.new ], [ %niter105.next.1, %.lr.ph67.split.us ]
  %40 = load ptr, ptr %35, align 8, !tbaa !21
  %41 = getelementptr inbounds ptr, ptr %40, i64 %indvars.iv86
  %42 = load ptr, ptr %41, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %42, ptr align 8 %.05364.us, i64 %37, i1 false)
  %43 = getelementptr inbounds ptr, ptr %.05364.us, i64 %36
  %indvars.iv.next87 = or disjoint i64 %indvars.iv86, 1
  %44 = load ptr, ptr %35, align 8, !tbaa !21
  %45 = getelementptr inbounds ptr, ptr %44, i64 %indvars.iv.next87
  %46 = load ptr, ptr %45, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %46, ptr align 8 %43, i64 %37, i1 false)
  %47 = getelementptr inbounds ptr, ptr %43, i64 %36
  %indvars.iv.next87.1 = add nuw nsw i64 %indvars.iv86, 2
  %niter105.next.1 = add i64 %niter105, 2
  %niter105.ncmp.1 = icmp eq i64 %niter105.next.1, %unroll_iter104
  br i1 %niter105.ncmp.1, label %._crit_edge68.loopexit.unr-lcssa, label %.lr.ph67.split.us, !llvm.loop !22

.lr.ph67.split:                                   ; preds = %.lr.ph67
  %48 = icmp sgt i32 %3, 0
  br i1 %48, label %.preheader.us.preheader, label %.preheader.preheader

.preheader.preheader:                             ; preds = %.lr.ph67.split
  %xtraiter = and i64 %22, 1
  %49 = icmp eq i32 %2, 1
  br i1 %49, label %._crit_edge68.loopexit96.unr-lcssa, label %.preheader.preheader.new

.preheader.preheader.new:                         ; preds = %.preheader.preheader
  %unroll_iter = and i64 %22, 2147483646
  br label %.preheader

.preheader.us.preheader:                          ; preds = %.lr.ph67.split
  %xtraiter97 = and i64 %36, 1
  %50 = icmp eq i32 %3, 1
  %unroll_iter100 = and i64 %36, 2147483646
  %lcmp.mod98.not = icmp eq i64 %xtraiter97, 0
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %..loopexit_crit_edge.us
  %indvars.iv81 = phi i64 [ %indvars.iv.next82, %..loopexit_crit_edge.us ], [ 0, %.preheader.us.preheader ]
  %.05364.us70 = phi ptr [ %72, %..loopexit_crit_edge.us ], [ %34, %.preheader.us.preheader ]
  %.05463.us71 = phi ptr [ %.lcssa, %..loopexit_crit_edge.us ], [ %1, %.preheader.us.preheader ]
  %51 = load ptr, ptr %35, align 8, !tbaa !21
  %52 = getelementptr inbounds ptr, ptr %51, i64 %indvars.iv81
  %53 = load ptr, ptr %52, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %53, ptr align 8 %.05364.us70, i64 %37, i1 false)
  br i1 %50, label %..loopexit_crit_edge.us.unr-lcssa, label %.preheader.us.new

.preheader.us.new:                                ; preds = %.preheader.us, %.preheader.us.new
  %indvars.iv76 = phi i64 [ %indvars.iv.next77.1, %.preheader.us.new ], [ 0, %.preheader.us ]
  %.160.us = phi ptr [ %65, %.preheader.us.new ], [ %.05463.us71, %.preheader.us ]
  %niter101 = phi i64 [ %niter101.next.1, %.preheader.us.new ], [ 0, %.preheader.us ]
  %54 = load ptr, ptr %35, align 8, !tbaa !21
  %55 = getelementptr inbounds ptr, ptr %54, i64 %indvars.iv81
  %56 = load ptr, ptr %55, align 8, !tbaa !5
  %57 = getelementptr inbounds ptr, ptr %56, i64 %indvars.iv76
  %58 = load ptr, ptr %57, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %58, ptr align 1 %.160.us, i64 %38, i1 false)
  %59 = getelementptr inbounds i8, ptr %.160.us, i64 %38
  %indvars.iv.next77 = or disjoint i64 %indvars.iv76, 1
  %60 = load ptr, ptr %35, align 8, !tbaa !21
  %61 = getelementptr inbounds ptr, ptr %60, i64 %indvars.iv81
  %62 = load ptr, ptr %61, align 8, !tbaa !5
  %63 = getelementptr inbounds ptr, ptr %62, i64 %indvars.iv.next77
  %64 = load ptr, ptr %63, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %64, ptr align 1 %59, i64 %38, i1 false)
  %65 = getelementptr inbounds i8, ptr %59, i64 %38
  %indvars.iv.next77.1 = add nuw nsw i64 %indvars.iv76, 2
  %niter101.next.1 = add i64 %niter101, 2
  %niter101.ncmp.1 = icmp eq i64 %niter101.next.1, %unroll_iter100
  br i1 %niter101.ncmp.1, label %..loopexit_crit_edge.us.unr-lcssa, label %.preheader.us.new, !llvm.loop !23

..loopexit_crit_edge.us.unr-lcssa:                ; preds = %.preheader.us.new, %.preheader.us
  %.lcssa.ph = phi ptr [ poison, %.preheader.us ], [ %65, %.preheader.us.new ]
  %indvars.iv76.unr = phi i64 [ 0, %.preheader.us ], [ %indvars.iv.next77.1, %.preheader.us.new ]
  %.160.us.unr = phi ptr [ %.05463.us71, %.preheader.us ], [ %65, %.preheader.us.new ]
  br i1 %lcmp.mod98.not, label %..loopexit_crit_edge.us, label %..loopexit_crit_edge.us.epilog-lcssa

..loopexit_crit_edge.us.epilog-lcssa:             ; preds = %..loopexit_crit_edge.us.unr-lcssa
  %66 = load ptr, ptr %35, align 8, !tbaa !21
  %67 = getelementptr inbounds ptr, ptr %66, i64 %indvars.iv81
  %68 = load ptr, ptr %67, align 8, !tbaa !5
  %69 = getelementptr inbounds ptr, ptr %68, i64 %indvars.iv76.unr
  %70 = load ptr, ptr %69, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %70, ptr align 1 %.160.us.unr, i64 %38, i1 false)
  %71 = getelementptr inbounds i8, ptr %.160.us.unr, i64 %38
  br label %..loopexit_crit_edge.us

..loopexit_crit_edge.us:                          ; preds = %..loopexit_crit_edge.us.unr-lcssa, %..loopexit_crit_edge.us.epilog-lcssa
  %.lcssa = phi ptr [ %.lcssa.ph, %..loopexit_crit_edge.us.unr-lcssa ], [ %71, %..loopexit_crit_edge.us.epilog-lcssa ]
  %72 = getelementptr inbounds ptr, ptr %.05364.us70, i64 %36
  %indvars.iv.next82 = add nuw nsw i64 %indvars.iv81, 1
  %exitcond85.not = icmp eq i64 %indvars.iv.next82, %22
  br i1 %exitcond85.not, label %._crit_edge68, label %.preheader.us, !llvm.loop !22

._crit_edge68.loopexit.unr-lcssa:                 ; preds = %.lr.ph67.split.us, %.lr.ph67.split.us.preheader
  %indvars.iv86.unr = phi i64 [ 0, %.lr.ph67.split.us.preheader ], [ %indvars.iv.next87.1, %.lr.ph67.split.us ]
  %.05364.us.unr = phi ptr [ %34, %.lr.ph67.split.us.preheader ], [ %47, %.lr.ph67.split.us ]
  %lcmp.mod103.not = icmp eq i64 %xtraiter102, 0
  br i1 %lcmp.mod103.not, label %._crit_edge68, label %.lr.ph67.split.us.epil

.lr.ph67.split.us.epil:                           ; preds = %._crit_edge68.loopexit.unr-lcssa
  %73 = load ptr, ptr %35, align 8, !tbaa !21
  %74 = getelementptr inbounds ptr, ptr %73, i64 %indvars.iv86.unr
  %75 = load ptr, ptr %74, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %75, ptr align 8 %.05364.us.unr, i64 %37, i1 false)
  br label %._crit_edge68

._crit_edge68.loopexit96.unr-lcssa:               ; preds = %.preheader, %.preheader.preheader
  %indvars.iv.unr = phi i64 [ 0, %.preheader.preheader ], [ %indvars.iv.next.1, %.preheader ]
  %.05364.unr = phi ptr [ %34, %.preheader.preheader ], [ %87, %.preheader ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge68, label %.preheader.epil

.preheader.epil:                                  ; preds = %._crit_edge68.loopexit96.unr-lcssa
  %76 = load ptr, ptr %35, align 8, !tbaa !21
  %77 = getelementptr inbounds ptr, ptr %76, i64 %indvars.iv.unr
  %78 = load ptr, ptr %77, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %78, ptr align 8 %.05364.unr, i64 %37, i1 false)
  br label %._crit_edge68

._crit_edge68:                                    ; preds = %.preheader.epil, %._crit_edge68.loopexit96.unr-lcssa, %..loopexit_crit_edge.us, %.lr.ph67.split.us.epil, %._crit_edge68.loopexit.unr-lcssa
  %79 = load ptr, ptr %6, align 8, !tbaa !5
  call void @m_Free(ptr noundef %79) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #5
  br label %88

.preheader:                                       ; preds = %.preheader, %.preheader.preheader.new
  %indvars.iv = phi i64 [ 0, %.preheader.preheader.new ], [ %indvars.iv.next.1, %.preheader ]
  %.05364 = phi ptr [ %34, %.preheader.preheader.new ], [ %87, %.preheader ]
  %niter = phi i64 [ 0, %.preheader.preheader.new ], [ %niter.next.1, %.preheader ]
  %80 = load ptr, ptr %35, align 8, !tbaa !21
  %81 = getelementptr inbounds ptr, ptr %80, i64 %indvars.iv
  %82 = load ptr, ptr %81, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %82, ptr align 8 %.05364, i64 %37, i1 false)
  %83 = getelementptr inbounds ptr, ptr %.05364, i64 %36
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %84 = load ptr, ptr %35, align 8, !tbaa !21
  %85 = getelementptr inbounds ptr, ptr %84, i64 %indvars.iv.next
  %86 = load ptr, ptr %85, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %86, ptr align 8 %83, i64 %37, i1 false)
  %87 = getelementptr inbounds ptr, ptr %83, i64 %36
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge68.loopexit96.unr-lcssa, label %.preheader, !llvm.loop !22

88:                                               ; preds = %5, %._crit_edge68
  ret void
}

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

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

declare void @mMemoryIndex(ptr noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 8}
!10 = !{!"HandleList", !11, i64 0, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28}
!11 = !{!"MList", !12, i64 0, !6, i64 8}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !6, i64 16}
!14 = !{!"MHandle", !12, i64 0, !12, i64 4, !6, i64 8, !6, i64 16}
!15 = !{!16, !6, i64 8}
!16 = !{!"MSheet", !12, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!17 = !{!18, !6, i64 120}
!18 = !{!"HandleSheetCreate", !6, i64 0, !6, i64 8, !7, i64 16, !12, i64 80, !12, i64 84, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!16, !6, i64 24}
!22 = distinct !{!22, !20}
!23 = distinct !{!23, !20}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass