; LLVM IR from zeux/meshoptimizer :: src (clusterizer)

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

%class.meshopt_Allocator = type { [24 x ptr], i64 }
%struct.meshopt_Meshlet = type { i32, i32, i32, i32 }

@.str = external hidden unnamed_addr constant [21 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [57 x i8], align 1
@__PRETTY_FUNCTION__.meshopt_buildMeshletsScan = external hidden unnamed_addr constant [139 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [87 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local i64 @meshopt_buildMeshletsBound(i64 noundef, i64 noundef, i64 noundef) #0

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN17meshopt_AllocatorC2Ev(ptr noundef nonnull align 8 dereferenceable(200)) unnamed_addr #0 align 2

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN17meshopt_Allocator8allocateIsEEPT_m(ptr noundef nonnull align 8 dereferenceable(200), i64 noundef) #4 align 2

; Function Attrs: mustprogress uwtable
declare hidden noundef zeroext i1 @_ZN7meshoptL13appendMeshletER15meshopt_MeshletjjjPsPS0_PjPhmmmb(ptr noundef nonnull align 4 dereferenceable(16), i32 noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef, i64 noundef, i64 noundef, i1 noundef zeroext) #4

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZN7meshoptL13finishMeshletER15meshopt_MeshletPh(ptr noundef nonnull align 4 dereferenceable(16), ptr noundef) #0

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN17meshopt_AllocatorD2Ev(ptr noundef nonnull align 8 dereferenceable(200)) unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local i64 @meshopt_buildMeshletsScan(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i64 noundef %4, i64 noundef %5, i64 noundef %6, i64 noundef %7) #4 personality ptr @__gxx_personality_v0 {
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  %17 = alloca %class.meshopt_Allocator, align 8
  %18 = alloca ptr, align 8
  %19 = alloca ptr, align 8
  %20 = alloca i32, align 4
  %21 = alloca %struct.meshopt_Meshlet, align 4
  %22 = alloca i64, align 8
  %23 = alloca i64, align 8
  %24 = alloca i32, align 4
  %25 = alloca i32, align 4
  %26 = alloca i32, align 4
  store ptr %0, ptr %9, align 8, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !5
  store ptr %2, ptr %11, align 8, !tbaa !5
  store ptr %3, ptr %12, align 8, !tbaa !5
  store i64 %4, ptr %13, align 8, !tbaa !9
  store i64 %5, ptr %14, align 8, !tbaa !9
  store i64 %6, ptr %15, align 8, !tbaa !9
  store i64 %7, ptr %16, align 8, !tbaa !9
  %27 = load i64, ptr %13, align 8, !tbaa !9
  %28 = urem i64 %27, 3
  %29 = icmp eq i64 %28, 0
  br i1 %29, label %30, label %31

30:                                               ; preds = %8
  br label %33

31:                                               ; preds = %8
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 1267, ptr noundef @__PRETTY_FUNCTION__.meshopt_buildMeshletsScan) #6
  unreachable

32:                                               ; No predecessors!
  br label %33

33:                                               ; preds = %32, %30
  %34 = load i64, ptr %15, align 8, !tbaa !9
  %35 = icmp uge i64 %34, 3
  br i1 %35, label %36, label %39

36:                                               ; preds = %33
  %37 = load i64, ptr %15, align 8, !tbaa !9
  %38 = icmp ule i64 %37, 256
  br label %39

39:                                               ; preds = %36, %33
  %40 = phi i1 [ false, %33 ], [ %38, %36 ]
  br i1 %40, label %41, label %42

41:                                               ; preds = %39
  br label %44

42:                                               ; preds = %39
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 1269, ptr noundef @__PRETTY_FUNCTION__.meshopt_buildMeshletsScan) #6
  unreachable

43:                                               ; No predecessors!
  br label %44

44:                                               ; preds = %43, %41
  %45 = load i64, ptr %16, align 8, !tbaa !9
  %46 = icmp uge i64 %45, 1
  br i1 %46, label %47, label %50

47:                                               ; preds = %44
  %48 = load i64, ptr %16, align 8, !tbaa !9
  %49 = icmp ule i64 %48, 512
  br label %50

50:                                               ; preds = %47, %44
  %51 = phi i1 [ false, %44 ], [ %49, %47 ]
  br i1 %51, label %52, label %53

52:                                               ; preds = %50
  br label %55

53:                                               ; preds = %50
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 1270, ptr noundef @__PRETTY_FUNCTION__.meshopt_buildMeshletsScan) #6
  unreachable

54:                                               ; No predecessors!
  br label %55

55:                                               ; preds = %54, %52
  %56 = load i64, ptr %16, align 8, !tbaa !9
  %57 = urem i64 %56, 4
  %58 = icmp eq i64 %57, 0
  br i1 %58, label %59, label %60

59:                                               ; preds = %55
  br label %62

60:                                               ; preds = %55
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 1271, ptr noundef @__PRETTY_FUNCTION__.meshopt_buildMeshletsScan) #6
  unreachable

61:                                               ; No predecessors!
  br label %62

62:                                               ; preds = %61, %59
  call void @llvm.lifetime.start.p0(i64 200, ptr %17) #7
  call void @_ZN17meshopt_AllocatorC2Ev(ptr noundef nonnull align 8 dereferenceable(200) %17)
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #7
  %63 = load i64, ptr %14, align 8, !tbaa !9
  %64 = invoke noundef ptr @_ZN17meshopt_Allocator8allocateIsEEPT_m(ptr noundef nonnull align 8 dereferenceable(200) %17, i64 noundef %63)
          to label %65 unwind label %74

65:                                               ; preds = %62
  store ptr %64, ptr %18, align 8, !tbaa !5
  %66 = load ptr, ptr %18, align 8, !tbaa !5
  %67 = load i64, ptr %14, align 8, !tbaa !9
  %68 = mul i64 %67, 2
  call void @llvm.memset.p0.i64(ptr align 2 %66, i8 -1, i64 %68, i1 false)
  call void @llvm.lifetime.start.p0(i64 16, ptr %21) #7
  call void @llvm.memset.p0.i64(ptr align 4 %21, i8 0, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #7
  store i64 0, ptr %22, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #7
  store i64 0, ptr %23, align 8, !tbaa !9
  br label %69

69:                                               ; preds = %129, %65
  %70 = load i64, ptr %23, align 8, !tbaa !9
  %71 = load i64, ptr %13, align 8, !tbaa !9
  %72 = icmp ult i64 %70, %71
  br i1 %72, label %78, label %73

73:                                               ; preds = %69
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #7
  br label %136

74:                                               ; preds = %62
  %75 = landingpad { ptr, i32 }
          cleanup
  %76 = extractvalue { ptr, i32 } %75, 0
  store ptr %76, ptr %19, align 8
  %77 = extractvalue { ptr, i32 } %75, 1
  store i32 %77, ptr %20, align 4
  br label %164

78:                                               ; preds = %69
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #7
  %79 = load ptr, ptr %12, align 8, !tbaa !5
  %80 = load i64, ptr %23, align 8, !tbaa !9
  %81 = add i64 %80, 0
  %82 = getelementptr inbounds i32, ptr %79, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !11
  store i32 %83, ptr %24, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #7
  %84 = load ptr, ptr %12, align 8, !tbaa !5
  %85 = load i64, ptr %23, align 8, !tbaa !9
  %86 = add i64 %85, 1
  %87 = getelementptr inbounds i32, ptr %84, i64 %86
  %88 = load i32, ptr %87, align 4, !tbaa !11
  store i32 %88, ptr %25, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #7
  %89 = load ptr, ptr %12, align 8, !tbaa !5
  %90 = load i64, ptr %23, align 8, !tbaa !9
  %91 = add i64 %90, 2
  %92 = getelementptr inbounds i32, ptr %89, i64 %91
  %93 = load i32, ptr %92, align 4, !tbaa !11
  store i32 %93, ptr %26, align 4, !tbaa !11
  %94 = load i32, ptr %24, align 4, !tbaa !11
  %95 = zext i32 %94 to i64
  %96 = load i64, ptr %14, align 8, !tbaa !9
  %97 = icmp ult i64 %95, %96
  br i1 %97, label %98, label %108

98:                                               ; preds = %78
  %99 = load i32, ptr %25, align 4, !tbaa !11
  %100 = zext i32 %99 to i64
  %101 = load i64, ptr %14, align 8, !tbaa !9
  %102 = icmp ult i64 %100, %101
  br i1 %102, label %103, label %108

103:                                              ; preds = %98
  %104 = load i32, ptr %26, align 4, !tbaa !11
  %105 = zext i32 %104 to i64
  %106 = load i64, ptr %14, align 8, !tbaa !9
  %107 = icmp ult i64 %105, %106
  br label %108

108:                                              ; preds = %103, %98, %78
  %109 = phi i1 [ false, %98 ], [ false, %78 ], [ %107, %103 ]
  br i1 %109, label %110, label %111

110:                                              ; preds = %108
  br label %113

111:                                              ; preds = %108
  call void @__assert_fail(ptr noundef @.str.11, ptr noundef @.str.1, i32 noundef 1285, ptr noundef @__PRETTY_FUNCTION__.meshopt_buildMeshletsScan) #6
  unreachable

112:                                              ; No predecessors!
  br label %113

113:                                              ; preds = %112, %110
  %114 = load i32, ptr %24, align 4, !tbaa !11
  %115 = load i32, ptr %25, align 4, !tbaa !11
  %116 = load i32, ptr %26, align 4, !tbaa !11
  %117 = load ptr, ptr %18, align 8, !tbaa !5
  %118 = load ptr, ptr %9, align 8, !tbaa !5
  %119 = load ptr, ptr %10, align 8, !tbaa !5
  %120 = load ptr, ptr %11, align 8, !tbaa !5
  %121 = load i64, ptr %22, align 8, !tbaa !9
  %122 = load i64, ptr %15, align 8, !tbaa !9
  %123 = load i64, ptr %16, align 8, !tbaa !9
  %124 = invoke noundef zeroext i1 @_ZN7meshoptL13appendMeshletER15meshopt_MeshletjjjPsPS0_PjPhmmmb(ptr noundef nonnull align 4 dereferenceable(16) %21, i32 noundef %114, i32 noundef %115, i32 noundef %116, ptr noundef %117, ptr noundef %118, ptr noundef %119, ptr noundef %120, i64 noundef %121, i64 noundef %122, i64 noundef %123, i1 noundef zeroext false)
          to label %125 unwind label %132

125:                                              ; preds = %113
  %126 = zext i1 %124 to i64
  %127 = load i64, ptr %22, align 8, !tbaa !9
  %128 = add i64 %127, %126
  store i64 %128, ptr %22, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #7
  br label %129

129:                                              ; preds = %125
  %130 = load i64, ptr %23, align 8, !tbaa !9
  %131 = add i64 %130, 3
  store i64 %131, ptr %23, align 8, !tbaa !9
  br label %69, !llvm.loop !13

132:                                              ; preds = %113
  %133 = landingpad { ptr, i32 }
          cleanup
  %134 = extractvalue { ptr, i32 } %133, 0
  store ptr %134, ptr %19, align 8
  %135 = extractvalue { ptr, i32 } %133, 1
  store i32 %135, ptr %20, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #7
  br label %163

136:                                              ; preds = %73
  %137 = getelementptr inbounds %struct.meshopt_Meshlet, ptr %21, i32 0, i32 3
  %138 = load i32, ptr %137, align 4, !tbaa !15
  %139 = icmp ne i32 %138, 0
  br i1 %139, label %140, label %151

140:                                              ; preds = %136
  %141 = load ptr, ptr %11, align 8, !tbaa !5
  invoke void @_ZN7meshoptL13finishMeshletER15meshopt_MeshletPh(ptr noundef nonnull align 4 dereferenceable(16) %21, ptr noundef %141)
          to label %142 unwind label %147

142:                                              ; preds = %140
  %143 = load ptr, ptr %9, align 8, !tbaa !5
  %144 = load i64, ptr %22, align 8, !tbaa !9
  %145 = add i64 %144, 1
  store i64 %145, ptr %22, align 8, !tbaa !9
  %146 = getelementptr inbounds %struct.meshopt_Meshlet, ptr %143, i64 %144
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %146, ptr align 4 %21, i64 16, i1 false), !tbaa.struct !17
  br label %151

147:                                              ; preds = %140
  %148 = landingpad { ptr, i32 }
          cleanup
  %149 = extractvalue { ptr, i32 } %148, 0
  store ptr %149, ptr %19, align 8
  %150 = extractvalue { ptr, i32 } %148, 1
  store i32 %150, ptr %20, align 4
  br label %163

151:                                              ; preds = %142, %136
  %152 = load i64, ptr %22, align 8, !tbaa !9
  %153 = load i64, ptr %13, align 8, !tbaa !9
  %154 = load i64, ptr %15, align 8, !tbaa !9
  %155 = load i64, ptr %16, align 8, !tbaa !9
  %156 = call i64 @meshopt_buildMeshletsBound(i64 noundef %153, i64 noundef %154, i64 noundef %155)
  %157 = icmp ule i64 %152, %156
  br i1 %157, label %158, label %159

158:                                              ; preds = %151
  br label %161

159:                                              ; preds = %151
  call void @__assert_fail(ptr noundef @.str.15, ptr noundef @.str.1, i32 noundef 1298, ptr noundef @__PRETTY_FUNCTION__.meshopt_buildMeshletsScan) #6
  unreachable

160:                                              ; No predecessors!
  br label %161

161:                                              ; preds = %160, %158
  %162 = load i64, ptr %22, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %21) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #7
  call void @_ZN17meshopt_AllocatorD2Ev(ptr noundef nonnull align 8 dereferenceable(200) %17) #7
  call void @llvm.lifetime.end.p0(i64 200, ptr %17) #7
  ret i64 %162

163:                                              ; preds = %147, %132
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %21) #7
  br label %164

164:                                              ; preds = %163, %74
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #7
  call void @_ZN17meshopt_AllocatorD2Ev(ptr noundef nonnull align 8 dereferenceable(200) %17) #7
  call void @llvm.lifetime.end.p0(i64 200, ptr %17) #7
  br label %165

165:                                              ; preds = %164
  %166 = load ptr, ptr %19, align 8
  %167 = load i32, ptr %20, align 4
  %168 = insertvalue { ptr, i32 } poison, ptr %166, 0
  %169 = insertvalue { ptr, i32 } %168, i32 %167, 1
  resume { ptr, i32 } %169
}

attributes #0 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { noreturn nounwind "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 nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { mustprogress 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { noreturn nounwind }
attributes #7 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !12, i64 12}
!16 = !{!"_ZTS15meshopt_Meshlet", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12}
!17 = !{i64 0, i64 4, !11, i64 4, i64 4, !11, i64 8, i64 4, !11, i64 12, i64 4, !11}


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

%class.meshopt_Allocator = type { [24 x ptr], i64 }
%struct.meshopt_Meshlet = type { i32, i32, i32, i32 }

@.str = external hidden unnamed_addr constant [21 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [57 x i8], align 1
@__PRETTY_FUNCTION__.meshopt_buildMeshletsScan = external hidden unnamed_addr constant [139 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [87 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local i64 @meshopt_buildMeshletsBound(i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN17meshopt_AllocatorC2Ev(ptr noundef nonnull align 8 dereferenceable(200)) unnamed_addr #0 align 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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN17meshopt_Allocator8allocateIsEEPT_m(ptr noundef nonnull align 8 dereferenceable(200), i64 noundef) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare hidden noundef zeroext i1 @_ZN7meshoptL13appendMeshletER15meshopt_MeshletjjjPsPS0_PjPhmmmb(ptr noundef nonnull align 4 dereferenceable(16), i32 noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef, i64 noundef, i64 noundef, i1 noundef zeroext) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZN7meshoptL13finishMeshletER15meshopt_MeshletPh(ptr noundef nonnull align 4 dereferenceable(16), ptr noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN17meshopt_AllocatorD2Ev(ptr noundef nonnull align 8 dereferenceable(200)) unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local i64 @meshopt_buildMeshletsScan(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr nocapture noundef readonly %3, i64 noundef %4, i64 noundef %5, i64 noundef %6, i64 noundef %7) local_unnamed_addr #4 personality ptr @__gxx_personality_v0 {
  %9 = alloca %class.meshopt_Allocator, align 8
  %10 = alloca %struct.meshopt_Meshlet, align 4
  %11 = urem i64 %4, 3
  %12 = icmp eq i64 %11, 0
  br i1 %12, label %14, label %13

13:                                               ; preds = %8
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 1267, ptr noundef nonnull @__PRETTY_FUNCTION__.meshopt_buildMeshletsScan) #6
  unreachable

14:                                               ; preds = %8
  %15 = add i64 %6, -3
  %16 = icmp ult i64 %15, 254
  br i1 %16, label %18, label %17

17:                                               ; preds = %14
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 1269, ptr noundef nonnull @__PRETTY_FUNCTION__.meshopt_buildMeshletsScan) #6
  unreachable

18:                                               ; preds = %14
  %19 = add i64 %7, -1
  %20 = icmp ult i64 %19, 512
  br i1 %20, label %22, label %21

21:                                               ; preds = %18
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 1270, ptr noundef nonnull @__PRETTY_FUNCTION__.meshopt_buildMeshletsScan) #6
  unreachable

22:                                               ; preds = %18
  %23 = and i64 %7, 3
  %24 = icmp eq i64 %23, 0
  br i1 %24, label %26, label %25

25:                                               ; preds = %22
  tail call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 1271, ptr noundef nonnull @__PRETTY_FUNCTION__.meshopt_buildMeshletsScan) #6
  unreachable

26:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 200, ptr nonnull %9) #7
  call void @_ZN17meshopt_AllocatorC2Ev(ptr noundef nonnull align 8 dereferenceable(200) %9)
  %27 = invoke noundef ptr @_ZN17meshopt_Allocator8allocateIsEEPT_m(ptr noundef nonnull align 8 dereferenceable(200) %9, i64 noundef %5)
          to label %28 unwind label %32

28:                                               ; preds = %26
  %29 = shl i64 %5, 1
  call void @llvm.memset.p0.i64(ptr align 2 %27, i8 -1, i64 %29, i1 false)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %10) #7
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(16) %10, i8 0, i64 16, i1 false)
  %.not60 = icmp eq i64 %4, 0
  br i1 %.not60, label %.thread, label %.lr.ph

.thread:                                          ; preds = %28
  %30 = call i64 @meshopt_buildMeshletsBound(i64 noundef %4, i64 noundef %6, i64 noundef %7)
  br label %61

._crit_edge:                                      ; preds = %48
  %.phi.trans.insert = getelementptr inbounds i8, ptr %10, i64 12
  %.pre = load i32, ptr %.phi.trans.insert, align 4, !tbaa !5
  %31 = icmp eq i32 %.pre, 0
  br i1 %31, label %58, label %55

32:                                               ; preds = %26
  %33 = landingpad { ptr, i32 }
          cleanup
  br label %62

.lr.ph:                                           ; preds = %28, %48
  %.04559 = phi i64 [ %50, %48 ], [ 0, %28 ]
  %.04658 = phi i64 [ %51, %48 ], [ 0, %28 ]
  %34 = getelementptr inbounds i32, ptr %3, i64 %.04658
  %35 = load i32, ptr %34, align 4, !tbaa !10
  %36 = getelementptr i8, ptr %34, i64 4
  %37 = load i32, ptr %36, align 4, !tbaa !10
  %38 = getelementptr i8, ptr %34, i64 8
  %39 = load i32, ptr %38, align 4, !tbaa !10
  %40 = zext i32 %35 to i64
  %41 = icmp ult i64 %40, %5
  %42 = zext i32 %37 to i64
  %43 = icmp ult i64 %42, %5
  %or.cond = select i1 %41, i1 %43, i1 false
  %44 = zext i32 %39 to i64
  %45 = icmp ult i64 %44, %5
  %or.cond55 = select i1 %or.cond, i1 %45, i1 false
  br i1 %or.cond55, label %46, label %.critedge

.critedge:                                        ; preds = %.lr.ph
  call void @__assert_fail(ptr noundef nonnull @.str.11, ptr noundef nonnull @.str.1, i32 noundef 1285, ptr noundef nonnull @__PRETTY_FUNCTION__.meshopt_buildMeshletsScan) #6
  unreachable

46:                                               ; preds = %.lr.ph
  %47 = invoke noundef zeroext i1 @_ZN7meshoptL13appendMeshletER15meshopt_MeshletjjjPsPS0_PjPhmmmb(ptr noundef nonnull align 4 dereferenceable(16) %10, i32 noundef %35, i32 noundef %37, i32 noundef %39, ptr noundef %27, ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %.04559, i64 noundef %6, i64 noundef %7, i1 noundef zeroext false)
          to label %48 unwind label %53

48:                                               ; preds = %46
  %49 = zext i1 %47 to i64
  %50 = add i64 %.04559, %49
  %51 = add i64 %.04658, 3
  %52 = icmp ult i64 %51, %4
  br i1 %52, label %.lr.ph, label %._crit_edge, !llvm.loop !11

53:                                               ; preds = %46
  %54 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %10) #7
  br label %62

55:                                               ; preds = %._crit_edge
  call void @_ZN7meshoptL13finishMeshletER15meshopt_MeshletPh(ptr noundef nonnull align 4 dereferenceable(16) %10, ptr noundef %2)
  %56 = add i64 %50, 1
  %57 = getelementptr inbounds %struct.meshopt_Meshlet, ptr %0, i64 %50
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(16) %57, ptr noundef nonnull align 4 dereferenceable(16) %10, i64 16, i1 false), !tbaa.struct !13
  br label %58

58:                                               ; preds = %55, %._crit_edge
  %.1 = phi i64 [ %56, %55 ], [ %50, %._crit_edge ]
  %59 = call i64 @meshopt_buildMeshletsBound(i64 noundef %4, i64 noundef %6, i64 noundef %7)
  %.not51 = icmp ugt i64 %.1, %59
  br i1 %.not51, label %60, label %61

60:                                               ; preds = %58
  call void @__assert_fail(ptr noundef nonnull @.str.15, ptr noundef nonnull @.str.1, i32 noundef 1298, ptr noundef nonnull @__PRETTY_FUNCTION__.meshopt_buildMeshletsScan) #6
  unreachable

61:                                               ; preds = %.thread, %58
  %.165 = phi i64 [ 0, %.thread ], [ %.1, %58 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %10) #7
  call void @_ZN17meshopt_AllocatorD2Ev(ptr noundef nonnull align 8 dereferenceable(200) %9) #7
  call void @llvm.lifetime.end.p0(i64 200, ptr nonnull %9) #7
  ret i64 %.165

62:                                               ; preds = %53, %32
  %.pn = phi { ptr, i32 } [ %54, %53 ], [ %33, %32 ]
  call void @_ZN17meshopt_AllocatorD2Ev(ptr noundef nonnull align 8 dereferenceable(200) %9) #7
  call void @llvm.lifetime.end.p0(i64 200, ptr nonnull %9) #7
  resume { ptr, i32 } %.pn
}

attributes #0 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { noreturn nounwind "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 nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { mustprogress 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { noreturn nounwind }
attributes #7 = { 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 12}
!6 = !{!"_ZTS15meshopt_Meshlet", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!7, !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{i64 0, i64 4, !10, i64 4, i64 4, !10, i64 8, i64 4, !10, i64 12, i64 4, !10}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass