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

%struct.meshopt_Bounds = type { [3 x float], float, [3 x float], [3 x float], float, [3 x i8], i8 }

@.str.1 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [50 x i8], align 1
@__PRETTY_FUNCTION__.meshopt_computeSphereBounds = external hidden unnamed_addr constant [97 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [34 x i8], align 1

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZN7meshoptL21computeBoundingSphereEPfPKfmmS2_mm(ptr noundef, ptr noundef, i64 noundef, i64 noundef, ptr noundef, i64 noundef, i64 noundef) #3

; Function Attrs: mustprogress uwtable
define dso_local void @meshopt_computeSphereBounds(ptr dead_on_unwind noalias writable sret(%struct.meshopt_Bounds) align 4 %0, ptr noundef %1, i64 noundef %2, i64 noundef %3, ptr noundef %4, i64 noundef %5) #4 {
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca float, align 4
  %13 = alloca [4 x float], align 16
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i64 %2, ptr %8, align 8, !tbaa !9
  store i64 %3, ptr %9, align 8, !tbaa !9
  store ptr %4, ptr %10, align 8, !tbaa !5
  store i64 %5, ptr %11, align 8, !tbaa !9
  %14 = load i64, ptr %9, align 8, !tbaa !9
  %15 = icmp uge i64 %14, 12
  br i1 %15, label %16, label %19

16:                                               ; preds = %6
  %17 = load i64, ptr %9, align 8, !tbaa !9
  %18 = icmp ule i64 %17, 256
  br label %19

19:                                               ; preds = %16, %6
  %20 = phi i1 [ false, %6 ], [ %18, %16 ]
  br i1 %20, label %21, label %22

21:                                               ; preds = %19
  br label %24

22:                                               ; preds = %19
  call void @__assert_fail(ptr noundef @.str.23, ptr noundef @.str.1, i32 noundef 1584, ptr noundef @__PRETTY_FUNCTION__.meshopt_computeSphereBounds) #5
  unreachable

23:                                               ; No predecessors!
  br label %24

24:                                               ; preds = %23, %21
  %25 = load i64, ptr %9, align 8, !tbaa !9
  %26 = urem i64 %25, 4
  %27 = icmp eq i64 %26, 0
  br i1 %27, label %28, label %29

28:                                               ; preds = %24
  br label %31

29:                                               ; preds = %24
  call void @__assert_fail(ptr noundef @.str.24, ptr noundef @.str.1, i32 noundef 1585, ptr noundef @__PRETTY_FUNCTION__.meshopt_computeSphereBounds) #5
  unreachable

30:                                               ; No predecessors!
  br label %31

31:                                               ; preds = %30, %28
  %32 = load i64, ptr %11, align 8, !tbaa !9
  %33 = icmp uge i64 %32, 4
  br i1 %33, label %34, label %37

34:                                               ; preds = %31
  %35 = load i64, ptr %11, align 8, !tbaa !9
  %36 = icmp ule i64 %35, 256
  br i1 %36, label %40, label %37

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

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

42:                                               ; preds = %40
  br label %45

43:                                               ; preds = %40
  call void @__assert_fail(ptr noundef @.str.25, ptr noundef @.str.1, i32 noundef 1586, ptr noundef @__PRETTY_FUNCTION__.meshopt_computeSphereBounds) #5
  unreachable

44:                                               ; No predecessors!
  br label %45

45:                                               ; preds = %44, %42
  %46 = load i64, ptr %11, align 8, !tbaa !9
  %47 = urem i64 %46, 4
  %48 = icmp eq i64 %47, 0
  br i1 %48, label %49, label %50

49:                                               ; preds = %45
  br label %52

50:                                               ; preds = %45
  call void @__assert_fail(ptr noundef @.str.26, ptr noundef @.str.1, i32 noundef 1587, ptr noundef @__PRETTY_FUNCTION__.meshopt_computeSphereBounds) #5
  unreachable

51:                                               ; No predecessors!
  br label %52

52:                                               ; preds = %51, %49
  call void @llvm.memset.p0.i64(ptr align 4 %0, i8 0, i64 48, i1 false)
  %53 = load i64, ptr %8, align 8, !tbaa !9
  %54 = icmp eq i64 %53, 0
  br i1 %54, label %55, label %56

55:                                               ; preds = %52
  br label %90

56:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  store float 0.000000e+00, ptr %12, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #6
  call void @llvm.memset.p0.i64(ptr align 16 %13, i8 0, i64 16, i1 false)
  %57 = getelementptr inbounds [4 x float], ptr %13, i64 0, i64 0
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = load i64, ptr %8, align 8, !tbaa !9
  %60 = load i64, ptr %9, align 8, !tbaa !9
  %61 = load ptr, ptr %10, align 8, !tbaa !5
  %62 = icmp ne ptr %61, null
  br i1 %62, label %63, label %65

63:                                               ; preds = %56
  %64 = load ptr, ptr %10, align 8, !tbaa !5
  br label %66

65:                                               ; preds = %56
  br label %66

66:                                               ; preds = %65, %63
  %67 = phi ptr [ %64, %63 ], [ %12, %65 ]
  %68 = load ptr, ptr %10, align 8, !tbaa !5
  %69 = icmp ne ptr %68, null
  br i1 %69, label %70, label %72

70:                                               ; preds = %66
  %71 = load i64, ptr %11, align 8, !tbaa !9
  br label %73

72:                                               ; preds = %66
  br label %73

73:                                               ; preds = %72, %70
  %74 = phi i64 [ %71, %70 ], [ 0, %72 ]
  call void @_ZN7meshoptL21computeBoundingSphereEPfPKfmmS2_mm(ptr noundef %57, ptr noundef %58, i64 noundef %59, i64 noundef %60, ptr noundef %67, i64 noundef %74, i64 noundef 7)
  %75 = getelementptr inbounds [4 x float], ptr %13, i64 0, i64 0
  %76 = load float, ptr %75, align 16, !tbaa !11
  %77 = getelementptr inbounds %struct.meshopt_Bounds, ptr %0, i32 0, i32 0
  %78 = getelementptr inbounds [3 x float], ptr %77, i64 0, i64 0
  store float %76, ptr %78, align 4, !tbaa !11
  %79 = getelementptr inbounds [4 x float], ptr %13, i64 0, i64 1
  %80 = load float, ptr %79, align 4, !tbaa !11
  %81 = getelementptr inbounds %struct.meshopt_Bounds, ptr %0, i32 0, i32 0
  %82 = getelementptr inbounds [3 x float], ptr %81, i64 0, i64 1
  store float %80, ptr %82, align 4, !tbaa !11
  %83 = getelementptr inbounds [4 x float], ptr %13, i64 0, i64 2
  %84 = load float, ptr %83, align 8, !tbaa !11
  %85 = getelementptr inbounds %struct.meshopt_Bounds, ptr %0, i32 0, i32 0
  %86 = getelementptr inbounds [3 x float], ptr %85, i64 0, i64 2
  store float %84, ptr %86, align 4, !tbaa !11
  %87 = getelementptr inbounds [4 x float], ptr %13, i64 0, i64 3
  %88 = load float, ptr %87, align 4, !tbaa !11
  %89 = getelementptr inbounds %struct.meshopt_Bounds, ptr %0, i32 0, i32 1
  store float %88, ptr %89, align 4, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %90

90:                                               ; preds = %73, %55
  ret void
}

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 #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 = { noreturn nounwind }
attributes #6 = { 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 = !{!"float", !7, i64 0}
!13 = !{!14, !12, i64 12}
!14 = !{!"_ZTS14meshopt_Bounds", !7, i64 0, !12, i64 12, !7, i64 16, !7, i64 28, !12, i64 40, !7, i64 44, !7, i64 47}


; 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.meshopt_Bounds = type { [3 x float], float, [3 x float], [3 x float], float, [3 x i8], i8 }

@.str.1 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [50 x i8], align 1
@__PRETTY_FUNCTION__.meshopt_computeSphereBounds = external hidden unnamed_addr constant [97 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [34 x i8], align 1

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

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZN7meshoptL21computeBoundingSphereEPfPKfmmS2_mm(ptr noundef, ptr noundef, i64 noundef, i64 noundef, ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @meshopt_computeSphereBounds(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct.meshopt_Bounds) align 4 %0, ptr noundef %1, i64 noundef %2, i64 noundef %3, ptr noundef %4, i64 noundef %5) local_unnamed_addr #3 {
  %7 = alloca float, align 4
  %8 = alloca [4 x float], align 16
  %9 = add i64 %3, -12
  %10 = icmp ult i64 %9, 245
  br i1 %10, label %12, label %11

11:                                               ; preds = %6
  tail call void @__assert_fail(ptr noundef nonnull @.str.23, ptr noundef nonnull @.str.1, i32 noundef 1584, ptr noundef nonnull @__PRETTY_FUNCTION__.meshopt_computeSphereBounds) #4
  unreachable

12:                                               ; preds = %6
  %13 = and i64 %3, 3
  %14 = icmp eq i64 %13, 0
  br i1 %14, label %16, label %15

15:                                               ; preds = %12
  tail call void @__assert_fail(ptr noundef nonnull @.str.24, ptr noundef nonnull @.str.1, i32 noundef 1585, ptr noundef nonnull @__PRETTY_FUNCTION__.meshopt_computeSphereBounds) #4
  unreachable

16:                                               ; preds = %12
  %17 = add i64 %5, -4
  %or.cond = icmp ult i64 %17, 253
  %18 = icmp eq ptr %4, null
  %or.cond3 = or i1 %18, %or.cond
  br i1 %or.cond3, label %.critedge, label %19

19:                                               ; preds = %16
  tail call void @__assert_fail(ptr noundef nonnull @.str.25, ptr noundef nonnull @.str.1, i32 noundef 1586, ptr noundef nonnull @__PRETTY_FUNCTION__.meshopt_computeSphereBounds) #4
  unreachable

.critedge:                                        ; preds = %16
  %20 = and i64 %5, 3
  %21 = icmp eq i64 %20, 0
  br i1 %21, label %23, label %22

22:                                               ; preds = %.critedge
  tail call void @__assert_fail(ptr noundef nonnull @.str.26, ptr noundef nonnull @.str.1, i32 noundef 1587, ptr noundef nonnull @__PRETTY_FUNCTION__.meshopt_computeSphereBounds) #4
  unreachable

23:                                               ; preds = %.critedge
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(48) %0, i8 0, i64 48, i1 false)
  %24 = icmp eq i64 %2, 0
  br i1 %24, label %29, label %25

25:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #5
  store float 0.000000e+00, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %8) #5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %8, i8 0, i64 16, i1 false)
  %26 = select i1 %18, ptr %7, ptr %4
  %27 = select i1 %18, i64 0, i64 %5
  call void @_ZN7meshoptL21computeBoundingSphereEPfPKfmmS2_mm(ptr noundef nonnull %8, ptr noundef %1, i64 noundef %2, i64 noundef %3, ptr noundef nonnull %26, i64 noundef %27, i64 noundef 7)
  %28 = load <4 x float>, ptr %8, align 16, !tbaa !5
  store <4 x float> %28, ptr %0, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #5
  br label %29

29:                                               ; preds = %23, %25
  ret void
}

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 #4 = { noreturn nounwind }
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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass