; LLVM IR from DanEngelbrecht/longtail :: cmd (main)

; 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.Longtail_Monitor = type { i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.Longtail_StoreIndex = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.MonitorBlockInfo = type { i32, i64, i32, ptr, i32 }
%struct.Longtail_VersionIndex = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, ptr, ptr }
%struct.Longtail_VersionDiff = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.AssetInfo = type { i64, i32, i64, i64, i32 }

@MonitorBlockInfosCount = external dso_local global i32, align 4
@MonitorBlockInfos = external dso_local global ptr, align 8
@MonitorAssetInfosCount = external dso_local global i32, align 4
@MonitorAssetInfos = external dso_local global ptr, align 8
@MonitorChunkInfosCount = external dso_local global i32, align 4
@MonitorChunkInfos = external dso_local global ptr, align 8
@FrameBufferAPI = external dso_local global ptr, align 8
@.str.31 = external hidden unnamed_addr constant [8 x i8], align 1
@__const.InitMonitor.monitor = external hidden unnamed_addr constant %struct.Longtail_Monitor, align 8
@MonitorWindowReady = external hidden global i32, align 4

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

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

; Function Attrs: nounwind uwtable
define dso_local void @InitMonitor(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i64, align 8
  %16 = alloca %struct.Longtail_Monitor, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.Longtail_StoreIndex, ptr %17, i32 0, i32 2
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  %20 = load i32, ptr %19, align 4, !tbaa !11
  store i32 %20, ptr @MonitorBlockInfosCount, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %21 = load i32, ptr @MonitorBlockInfosCount, align 4, !tbaa !11
  %22 = zext i32 %21 to i64
  %23 = mul i64 40, %22
  store i64 %23, ptr %7, align 8, !tbaa !13
  %24 = load i64, ptr %7, align 8, !tbaa !13
  %25 = call ptr @Longtail_Alloc(ptr noundef @.str.31, i64 noundef %24)
  store ptr %25, ptr @MonitorBlockInfos, align 8, !tbaa !5
  %26 = load ptr, ptr @MonitorBlockInfos, align 8, !tbaa !5
  %27 = load i64, ptr %7, align 8, !tbaa !13
  call void @llvm.memset.p0.i64(ptr align 8 %26, i8 0, i64 %27, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !11
  br label %28

28:                                               ; preds = %65, %3
  %29 = load i32, ptr %8, align 4, !tbaa !11
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.Longtail_StoreIndex, ptr %30, i32 0, i32 2
  %32 = load ptr, ptr %31, align 8, !tbaa !9
  %33 = load i32, ptr %32, align 4, !tbaa !11
  %34 = icmp ult i32 %29, %33
  br i1 %34, label %36, label %35

35:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %68

36:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.Longtail_StoreIndex, ptr %37, i32 0, i32 7
  %39 = load ptr, ptr %38, align 8, !tbaa !15
  %40 = load i32, ptr %8, align 4, !tbaa !11
  %41 = zext i32 %40 to i64
  %42 = getelementptr inbounds i32, ptr %39, i64 %41
  %43 = load i32, ptr %42, align 4, !tbaa !11
  store i32 %43, ptr %9, align 4, !tbaa !11
  %44 = load i32, ptr %9, align 4, !tbaa !11
  %45 = load ptr, ptr @MonitorBlockInfos, align 8, !tbaa !5
  %46 = load i32, ptr %8, align 4, !tbaa !11
  %47 = zext i32 %46 to i64
  %48 = getelementptr inbounds %struct.MonitorBlockInfo, ptr %45, i64 %47
  %49 = getelementptr inbounds %struct.MonitorBlockInfo, ptr %48, i32 0, i32 2
  store i32 %44, ptr %49, align 8, !tbaa !16
  %50 = load i32, ptr %9, align 4, !tbaa !11
  %51 = zext i32 %50 to i64
  %52 = mul i64 8, %51
  %53 = call ptr @Longtail_Alloc(ptr noundef @.str.31, i64 noundef %52)
  %54 = load ptr, ptr @MonitorBlockInfos, align 8, !tbaa !5
  %55 = load i32, ptr %8, align 4, !tbaa !11
  %56 = zext i32 %55 to i64
  %57 = getelementptr inbounds %struct.MonitorBlockInfo, ptr %54, i64 %56
  %58 = getelementptr inbounds %struct.MonitorBlockInfo, ptr %57, i32 0, i32 3
  store ptr %53, ptr %58, align 8, !tbaa !18
  %59 = load ptr, ptr @MonitorBlockInfos, align 8, !tbaa !5
  %60 = load i32, ptr %8, align 4, !tbaa !11
  %61 = zext i32 %60 to i64
  %62 = getelementptr inbounds %struct.MonitorBlockInfo, ptr %59, i64 %61
  %63 = getelementptr inbounds %struct.MonitorBlockInfo, ptr %62, i32 0, i32 3
  %64 = load ptr, ptr %63, align 8, !tbaa !18
  call void @llvm.memset.p0.i64(ptr align 1 %64, i8 0, i64 8, i1 false)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %65

65:                                               ; preds = %36
  %66 = load i32, ptr %8, align 4, !tbaa !11
  %67 = add i32 %66, 1
  store i32 %67, ptr %8, align 4, !tbaa !11
  br label %28, !llvm.loop !19

68:                                               ; preds = %35
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.Longtail_VersionIndex, ptr %69, i32 0, i32 3
  %71 = load ptr, ptr %70, align 8, !tbaa !21
  %72 = load i32, ptr %71, align 4, !tbaa !11
  store i32 %72, ptr @MonitorAssetInfosCount, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %73 = load i32, ptr @MonitorAssetInfosCount, align 4, !tbaa !11
  %74 = zext i32 %73 to i64
  %75 = mul i64 40, %74
  store i64 %75, ptr %10, align 8, !tbaa !13
  %76 = load i64, ptr %10, align 8, !tbaa !13
  %77 = call ptr @Longtail_Alloc(ptr noundef @.str.31, i64 noundef %76)
  store ptr %77, ptr @MonitorAssetInfos, align 8, !tbaa !5
  %78 = load ptr, ptr @MonitorAssetInfos, align 8, !tbaa !5
  %79 = load i64, ptr %10, align 8, !tbaa !13
  call void @llvm.memset.p0.i64(ptr align 8 %78, i8 0, i64 %79, i1 false)
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  %81 = icmp ne ptr %80, null
  br i1 %81, label %82, label %173

82:                                               ; preds = %68
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  store i32 0, ptr %11, align 4, !tbaa !11
  br label %83

83:                                               ; preds = %124, %82
  %84 = load i32, ptr %11, align 4, !tbaa !11
  %85 = load ptr, ptr %6, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.Longtail_VersionDiff, ptr %85, i32 0, i32 2
  %87 = load ptr, ptr %86, align 8, !tbaa !23
  %88 = load i32, ptr %87, align 4, !tbaa !11
  %89 = icmp ult i32 %84, %88
  br i1 %89, label %91, label %90

90:                                               ; preds = %83
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  br label %127

91:                                               ; preds = %83
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %92 = load ptr, ptr %6, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.Longtail_VersionDiff, ptr %92, i32 0, i32 7
  %94 = load ptr, ptr %93, align 8, !tbaa !25
  %95 = load i32, ptr %11, align 4, !tbaa !11
  %96 = zext i32 %95 to i64
  %97 = getelementptr inbounds i32, ptr %94, i64 %96
  %98 = load i32, ptr %97, align 4, !tbaa !11
  store i32 %98, ptr %12, align 4, !tbaa !11
  %99 = load ptr, ptr %5, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.Longtail_VersionIndex, ptr %99, i32 0, i32 9
  %101 = load ptr, ptr %100, align 8, !tbaa !26
  %102 = load i32, ptr %12, align 4, !tbaa !11
  %103 = zext i32 %102 to i64
  %104 = getelementptr inbounds i32, ptr %101, i64 %103
  %105 = load i32, ptr %104, align 4, !tbaa !11
  %106 = load ptr, ptr @MonitorAssetInfos, align 8, !tbaa !5
  %107 = load i32, ptr %12, align 4, !tbaa !11
  %108 = zext i32 %107 to i64
  %109 = getelementptr inbounds %struct.AssetInfo, ptr %106, i64 %108
  %110 = getelementptr inbounds %struct.AssetInfo, ptr %109, i32 0, i32 1
  store i32 %105, ptr %110, align 8, !tbaa !27
  %111 = load ptr, ptr %5, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.Longtail_VersionIndex, ptr %111, i32 0, i32 9
  %113 = load ptr, ptr %112, align 8, !tbaa !26
  %114 = load i32, ptr %12, align 4, !tbaa !11
  %115 = zext i32 %114 to i64
  %116 = getelementptr inbounds i32, ptr %113, i64 %115
  %117 = load i32, ptr %116, align 4, !tbaa !11
  %118 = zext i32 %117 to i64
  %119 = load ptr, ptr @MonitorAssetInfos, align 8, !tbaa !5
  %120 = load i32, ptr %12, align 4, !tbaa !11
  %121 = zext i32 %120 to i64
  %122 = getelementptr inbounds %struct.AssetInfo, ptr %119, i64 %121
  %123 = getelementptr inbounds %struct.AssetInfo, ptr %122, i32 0, i32 3
  store volatile i64 %118, ptr %123, align 8, !tbaa !29
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  br label %124

124:                                              ; preds = %91
  %125 = load i32, ptr %11, align 4, !tbaa !11
  %126 = add i32 %125, 1
  store i32 %126, ptr %11, align 4, !tbaa !11
  br label %83, !llvm.loop !30

127:                                              ; preds = %90
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  store i32 0, ptr %13, align 4, !tbaa !11
  br label %128

128:                                              ; preds = %169, %127
  %129 = load i32, ptr %13, align 4, !tbaa !11
  %130 = load ptr, ptr %6, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct.Longtail_VersionDiff, ptr %130, i32 0, i32 1
  %132 = load ptr, ptr %131, align 8, !tbaa !31
  %133 = load i32, ptr %132, align 4, !tbaa !11
  %134 = icmp ult i32 %129, %133
  br i1 %134, label %136, label %135

135:                                              ; preds = %128
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  br label %172

136:                                              ; preds = %128
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  %137 = load ptr, ptr %6, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct.Longtail_VersionDiff, ptr %137, i32 0, i32 5
  %139 = load ptr, ptr %138, align 8, !tbaa !32
  %140 = load i32, ptr %13, align 4, !tbaa !11
  %141 = zext i32 %140 to i64
  %142 = getelementptr inbounds i32, ptr %139, i64 %141
  %143 = load i32, ptr %142, align 4, !tbaa !11
  store i32 %143, ptr %14, align 4, !tbaa !11
  %144 = load ptr, ptr %5, align 8, !tbaa !5
  %145 = getelementptr inbounds %struct.Longtail_VersionIndex, ptr %144, i32 0, i32 9
  %146 = load ptr, ptr %145, align 8, !tbaa !26
  %147 = load i32, ptr %14, align 4, !tbaa !11
  %148 = zext i32 %147 to i64
  %149 = getelementptr inbounds i32, ptr %146, i64 %148
  %150 = load i32, ptr %149, align 4, !tbaa !11
  %151 = load ptr, ptr @MonitorAssetInfos, align 8, !tbaa !5
  %152 = load i32, ptr %14, align 4, !tbaa !11
  %153 = zext i32 %152 to i64
  %154 = getelementptr inbounds %struct.AssetInfo, ptr %151, i64 %153
  %155 = getelementptr inbounds %struct.AssetInfo, ptr %154, i32 0, i32 1
  store i32 %150, ptr %155, align 8, !tbaa !27
  %156 = load ptr, ptr %5, align 8, !tbaa !5
  %157 = getelementptr inbounds %struct.Longtail_VersionIndex, ptr %156, i32 0, i32 9
  %158 = load ptr, ptr %157, align 8, !tbaa !26
  %159 = load i32, ptr %14, align 4, !tbaa !11
  %160 = zext i32 %159 to i64
  %161 = getelementptr inbounds i32, ptr %158, i64 %160
  %162 = load i32, ptr %161, align 4, !tbaa !11
  %163 = zext i32 %162 to i64
  %164 = load ptr, ptr @MonitorAssetInfos, align 8, !tbaa !5
  %165 = load i32, ptr %14, align 4, !tbaa !11
  %166 = zext i32 %165 to i64
  %167 = getelementptr inbounds %struct.AssetInfo, ptr %164, i64 %166
  %168 = getelementptr inbounds %struct.AssetInfo, ptr %167, i32 0, i32 3
  store volatile i64 %163, ptr %168, align 8, !tbaa !29
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  br label %169

169:                                              ; preds = %136
  %170 = load i32, ptr %13, align 4, !tbaa !11
  %171 = add i32 %170, 1
  store i32 %171, ptr %13, align 4, !tbaa !11
  br label %128, !llvm.loop !33

172:                                              ; preds = %135
  br label %173

173:                                              ; preds = %172, %68
  %174 = load ptr, ptr %5, align 8, !tbaa !5
  %175 = getelementptr inbounds %struct.Longtail_VersionIndex, ptr %174, i32 0, i32 4
  %176 = load ptr, ptr %175, align 8, !tbaa !34
  %177 = load i32, ptr %176, align 4, !tbaa !11
  store i32 %177, ptr @MonitorChunkInfosCount, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %178 = load i32, ptr @MonitorChunkInfosCount, align 4, !tbaa !11
  %179 = zext i32 %178 to i64
  %180 = mul i64 8, %179
  store i64 %180, ptr %15, align 8, !tbaa !13
  %181 = load i64, ptr %15, align 8, !tbaa !13
  %182 = call ptr @Longtail_Alloc(ptr noundef @.str.31, i64 noundef %181)
  store ptr %182, ptr @MonitorChunkInfos, align 8, !tbaa !5
  %183 = load ptr, ptr @MonitorChunkInfos, align 8, !tbaa !5
  %184 = load i64, ptr %15, align 8, !tbaa !13
  call void @llvm.memset.p0.i64(ptr align 8 %183, i8 0, i64 %184, i1 false)
  call void @llvm.lifetime.start.p0(i64 112, ptr %16) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %16, ptr align 8 @__const.InitMonitor.monitor, i64 112, i1 false)
  call void @Longtail_SetMonitor(ptr noundef %16)
  %185 = load ptr, ptr @FrameBufferAPI, align 8, !tbaa !5
  %186 = icmp ne ptr %185, null
  br i1 %186, label %187, label %189

187:                                              ; preds = %173
  %188 = call i32 @Longtail_AtomicAdd32(ptr noundef @MonitorWindowReady, i32 noundef 1)
  br label %189

189:                                              ; preds = %187, %173
  call void @llvm.lifetime.end.p0(i64 112, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  ret void
}

declare ptr @Longtail_Alloc(ptr noundef, i64 noundef) #2

; 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: 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 @Longtail_SetMonitor(ptr noundef) #2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 16}
!10 = !{!"Longtail_StoreIndex", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!10, !6, i64 56}
!16 = !{!17, !12, i64 16}
!17 = !{!"MonitorBlockInfo", !12, i64 0, !14, i64 8, !12, i64 16, !6, i64 24, !12, i64 32}
!18 = !{!17, !6, i64 24}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!22, !6, i64 24}
!22 = !{!"Longtail_VersionIndex", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !12, i64 128, !6, i64 136, !6, i64 144}
!23 = !{!24, !6, i64 16}
!24 = !{!"Longtail_VersionDiff", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72}
!25 = !{!24, !6, i64 56}
!26 = !{!22, !6, i64 72}
!27 = !{!28, !12, i64 8}
!28 = !{!"AssetInfo", !14, i64 0, !12, i64 8, !14, i64 16, !14, i64 24, !12, i64 32}
!29 = !{!28, !14, i64 24}
!30 = distinct !{!30, !20}
!31 = !{!24, !6, i64 8}
!32 = !{!24, !6, i64 40}
!33 = distinct !{!33, !20}
!34 = !{!22, !6, i64 32}


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

%struct.Longtail_Monitor = type { i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.MonitorBlockInfo = type { i32, i64, i32, ptr, i32 }
%struct.AssetInfo = type { i64, i32, i64, i64, i32 }

@MonitorBlockInfosCount = external dso_local local_unnamed_addr global i32, align 4
@MonitorBlockInfos = external dso_local local_unnamed_addr global ptr, align 8
@MonitorAssetInfosCount = external dso_local local_unnamed_addr global i32, align 4
@MonitorAssetInfos = external dso_local local_unnamed_addr global ptr, align 8
@MonitorChunkInfosCount = external dso_local local_unnamed_addr global i32, align 4
@MonitorChunkInfos = external dso_local local_unnamed_addr global ptr, align 8
@FrameBufferAPI = external dso_local local_unnamed_addr global ptr, align 8
@.str.31 = external hidden unnamed_addr constant [8 x i8], align 1
@__const.InitMonitor.monitor = external hidden unnamed_addr constant %struct.Longtail_Monitor, align 8
@MonitorWindowReady = external hidden global i32, align 4

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

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

; Function Attrs: nounwind uwtable
define dso_local void @InitMonitor(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr noundef readonly %2) local_unnamed_addr #1 {
  %4 = alloca %struct.Longtail_Monitor, align 8
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = load i32, ptr %6, align 4, !tbaa !10
  store i32 %7, ptr @MonitorBlockInfosCount, align 4, !tbaa !10
  %8 = zext i32 %7 to i64
  %9 = mul nuw nsw i64 %8, 40
  %10 = tail call ptr @Longtail_Alloc(ptr noundef nonnull @.str.31, i64 noundef %9) #5
  store ptr %10, ptr @MonitorBlockInfos, align 8, !tbaa !12
  tail call void @llvm.memset.p0.i64(ptr align 8 %10, i8 0, i64 %9, i1 false)
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = load i32, ptr %11, align 4, !tbaa !10
  %.not51 = icmp eq i32 %12, 0
  br i1 %.not51, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %13 = getelementptr inbounds i8, ptr %0, i64 56
  br label %28

._crit_edge:                                      ; preds = %28, %3
  %14 = getelementptr inbounds i8, ptr %1, i64 24
  %15 = load ptr, ptr %14, align 8, !tbaa !13
  %16 = load i32, ptr %15, align 4, !tbaa !10
  store i32 %16, ptr @MonitorAssetInfosCount, align 4, !tbaa !10
  %17 = zext i32 %16 to i64
  %18 = mul nuw nsw i64 %17, 40
  %19 = tail call ptr @Longtail_Alloc(ptr noundef nonnull @.str.31, i64 noundef %18) #5
  store ptr %19, ptr @MonitorAssetInfos, align 8, !tbaa !12
  tail call void @llvm.memset.p0.i64(ptr align 8 %19, i8 0, i64 %18, i1 false)
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %.loopexit, label %.preheader45

.preheader45:                                     ; preds = %._crit_edge
  %20 = getelementptr inbounds i8, ptr %2, i64 16
  %21 = load ptr, ptr %20, align 8, !tbaa !15
  %22 = load i32, ptr %21, align 4, !tbaa !10
  %.not52 = icmp eq i32 %22, 0
  br i1 %.not52, label %.preheader, label %.lr.ph48

.lr.ph48:                                         ; preds = %.preheader45
  %23 = getelementptr inbounds i8, ptr %2, i64 56
  %24 = load ptr, ptr %23, align 8, !tbaa !17
  %25 = getelementptr inbounds i8, ptr %1, i64 72
  %26 = load ptr, ptr %25, align 8, !tbaa !18
  %27 = load ptr, ptr @MonitorAssetInfos, align 8, !tbaa !12
  br label %54

28:                                               ; preds = %.lr.ph, %28
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %28 ]
  %29 = load ptr, ptr %13, align 8, !tbaa !19
  %30 = getelementptr inbounds i32, ptr %29, i64 %indvars.iv
  %31 = load i32, ptr %30, align 4, !tbaa !10
  %32 = load ptr, ptr @MonitorBlockInfos, align 8, !tbaa !12
  %33 = getelementptr inbounds %struct.MonitorBlockInfo, ptr %32, i64 %indvars.iv, i32 2
  store i32 %31, ptr %33, align 8, !tbaa !20
  %34 = zext i32 %31 to i64
  %35 = shl nuw nsw i64 %34, 3
  %36 = tail call ptr @Longtail_Alloc(ptr noundef nonnull @.str.31, i64 noundef %35) #5
  %37 = load ptr, ptr @MonitorBlockInfos, align 8, !tbaa !12
  %38 = getelementptr inbounds %struct.MonitorBlockInfo, ptr %37, i64 %indvars.iv, i32 3
  store ptr %36, ptr %38, align 8, !tbaa !23
  %39 = load ptr, ptr @MonitorBlockInfos, align 8, !tbaa !12
  %40 = getelementptr inbounds %struct.MonitorBlockInfo, ptr %39, i64 %indvars.iv, i32 3
  %41 = load ptr, ptr %40, align 8, !tbaa !23
  store i64 0, ptr %41, align 1
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = load i32, ptr %42, align 4, !tbaa !10
  %44 = zext i32 %43 to i64
  %45 = icmp ult i64 %indvars.iv.next, %44
  br i1 %45, label %28, label %._crit_edge, !llvm.loop !24

.preheader:                                       ; preds = %54, %.preheader45
  %46 = getelementptr inbounds i8, ptr %2, i64 8
  %47 = load ptr, ptr %46, align 8, !tbaa !26
  %48 = load i32, ptr %47, align 4, !tbaa !10
  %.not53 = icmp eq i32 %48, 0
  br i1 %.not53, label %.loopexit, label %.lr.ph50

.lr.ph50:                                         ; preds = %.preheader
  %49 = getelementptr inbounds i8, ptr %2, i64 40
  %50 = load ptr, ptr %49, align 8, !tbaa !27
  %51 = getelementptr inbounds i8, ptr %1, i64 72
  %52 = load ptr, ptr %51, align 8, !tbaa !18
  %53 = load ptr, ptr @MonitorAssetInfos, align 8, !tbaa !12
  br label %66

54:                                               ; preds = %.lr.ph48, %54
  %indvars.iv55 = phi i64 [ 0, %.lr.ph48 ], [ %indvars.iv.next56, %54 ]
  %55 = getelementptr inbounds i32, ptr %24, i64 %indvars.iv55
  %56 = load i32, ptr %55, align 4, !tbaa !10
  %57 = zext i32 %56 to i64
  %58 = getelementptr inbounds i32, ptr %26, i64 %57
  %59 = load i32, ptr %58, align 4, !tbaa !10
  %60 = getelementptr inbounds %struct.AssetInfo, ptr %27, i64 %57, i32 1
  store i32 %59, ptr %60, align 8, !tbaa !28
  %61 = zext i32 %59 to i64
  %62 = getelementptr inbounds %struct.AssetInfo, ptr %27, i64 %57, i32 3
  store volatile i64 %61, ptr %62, align 8, !tbaa !30
  %indvars.iv.next56 = add nuw nsw i64 %indvars.iv55, 1
  %63 = load i32, ptr %21, align 4, !tbaa !10
  %64 = zext i32 %63 to i64
  %65 = icmp ult i64 %indvars.iv.next56, %64
  br i1 %65, label %54, label %.preheader, !llvm.loop !31

66:                                               ; preds = %.lr.ph50, %66
  %indvars.iv58 = phi i64 [ 0, %.lr.ph50 ], [ %indvars.iv.next59, %66 ]
  %67 = getelementptr inbounds i32, ptr %50, i64 %indvars.iv58
  %68 = load i32, ptr %67, align 4, !tbaa !10
  %69 = zext i32 %68 to i64
  %70 = getelementptr inbounds i32, ptr %52, i64 %69
  %71 = load i32, ptr %70, align 4, !tbaa !10
  %72 = getelementptr inbounds %struct.AssetInfo, ptr %53, i64 %69, i32 1
  store i32 %71, ptr %72, align 8, !tbaa !28
  %73 = zext i32 %71 to i64
  %74 = getelementptr inbounds %struct.AssetInfo, ptr %53, i64 %69, i32 3
  store volatile i64 %73, ptr %74, align 8, !tbaa !30
  %indvars.iv.next59 = add nuw nsw i64 %indvars.iv58, 1
  %75 = load i32, ptr %47, align 4, !tbaa !10
  %76 = zext i32 %75 to i64
  %77 = icmp ult i64 %indvars.iv.next59, %76
  br i1 %77, label %66, label %.loopexit, !llvm.loop !32

.loopexit:                                        ; preds = %66, %.preheader, %._crit_edge
  %78 = getelementptr inbounds i8, ptr %1, i64 32
  %79 = load ptr, ptr %78, align 8, !tbaa !33
  %80 = load i32, ptr %79, align 4, !tbaa !10
  store i32 %80, ptr @MonitorChunkInfosCount, align 4, !tbaa !10
  %81 = zext i32 %80 to i64
  %82 = shl nuw nsw i64 %81, 3
  %83 = tail call ptr @Longtail_Alloc(ptr noundef nonnull @.str.31, i64 noundef %82) #5
  store ptr %83, ptr @MonitorChunkInfos, align 8, !tbaa !12
  tail call void @llvm.memset.p0.i64(ptr align 8 %83, i8 0, i64 %82, i1 false)
  call void @llvm.lifetime.start.p0(i64 112, ptr nonnull %4) #5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(112) %4, ptr noundef nonnull align 8 dereferenceable(112) @__const.InitMonitor.monitor, i64 112, i1 false)
  call void @Longtail_SetMonitor(ptr noundef nonnull %4) #5
  %84 = load ptr, ptr @FrameBufferAPI, align 8, !tbaa !12
  %.not44 = icmp eq ptr %84, null
  br i1 %.not44, label %87, label %85

85:                                               ; preds = %.loopexit
  %86 = call i32 @Longtail_AtomicAdd32(ptr noundef nonnull @MonitorWindowReady, i32 noundef 1) #5
  br label %87

87:                                               ; preds = %85, %.loopexit
  call void @llvm.lifetime.end.p0(i64 112, ptr nonnull %4) #5
  ret void
}

declare ptr @Longtail_Alloc(ptr noundef, i64 noundef) local_unnamed_addr #2

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

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

declare void @Longtail_SetMonitor(ptr noundef) local_unnamed_addr #2

declare i32 @Longtail_AtomicAdd32(ptr noundef, i32 noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { mustprogress 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, !7, i64 16}
!6 = !{!"Longtail_StoreIndex", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!7, !7, i64 0}
!13 = !{!14, !7, i64 24}
!14 = !{!"Longtail_VersionIndex", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !7, i64 112, !7, i64 120, !11, i64 128, !7, i64 136, !7, i64 144}
!15 = !{!16, !7, i64 16}
!16 = !{!"Longtail_VersionDiff", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72}
!17 = !{!16, !7, i64 56}
!18 = !{!14, !7, i64 72}
!19 = !{!6, !7, i64 56}
!20 = !{!21, !11, i64 16}
!21 = !{!"MonitorBlockInfo", !11, i64 0, !22, i64 8, !11, i64 16, !7, i64 24, !11, i64 32}
!22 = !{!"long", !8, i64 0}
!23 = !{!21, !7, i64 24}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{!16, !7, i64 8}
!27 = !{!16, !7, i64 40}
!28 = !{!29, !11, i64 8}
!29 = !{!"AssetInfo", !22, i64 0, !11, i64 8, !22, i64 16, !22, i64 24, !11, i64 32}
!30 = !{!29, !22, i64 24}
!31 = distinct !{!31, !25}
!32 = distinct !{!32, !25}
!33 = !{!14, !7, i64 32}


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