; LLVM IR from zeux/meshoptimizer :: tools/vcachetuner.ll (Z4gen0mRKSt6vectorI4MeshSaIS0_EE)

; 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.std::vector.15" = type { %"struct.std::_Vector_base.16" }
%"struct.std::_Vector_base.16" = type { %"struct.std::_Vector_base<State, std::allocator<State>>::_Vector_impl" }
%"struct.std::_Vector_base<State, std::allocator<State>>::_Vector_impl" = type { %"struct.std::_Vector_base<State, std::allocator<State>>::_Vector_impl_data" }
%"struct.std::_Vector_base<State, std::allocator<State>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.State = type { [16 x float], [8 x float], float }

; 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: mustprogress nounwind uwtable
declare dso_local noundef float @_Z6rand01v() #1

declare i32 @__gxx_personality_v0(...)

; 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 uwtable
declare dso_local noundef float @_Z13fitness_scoreRK5StateRKSt6vectorI4MeshSaIS3_EE(ptr noundef nonnull align 4 dereferenceable(100), ptr noundef nonnull align 8 dereferenceable(24)) #3

; Function Attrs: mustprogress uwtable
define dso_local void @_Z4gen0mRKSt6vectorI4MeshSaIS0_EE(ptr dead_on_unwind noalias writable sret(%"class.std::vector.15") align 8 %0, i64 noundef %1, ptr noundef nonnull align 8 dereferenceable(24) %2) #3 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i1, align 1
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca %struct.State, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %4, align 8
  store i64 %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !9
  store i1 false, ptr %7, align 1
  call void @_ZNSt6vectorI5StateSaIS0_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store i64 0, ptr %8, align 8, !tbaa !5
  br label %15

15:                                               ; preds = %54, %3
  %16 = load i64, ptr %8, align 8, !tbaa !5
  %17 = load i64, ptr %5, align 8, !tbaa !5
  %18 = icmp ult i64 %16, %17
  br i1 %18, label %20, label %19

19:                                               ; preds = %15
  store i32 2, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %61

20:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 100, ptr %10) #4
  call void @llvm.memset.p0.i64(ptr align 4 %10, i8 0, i64 100, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !11
  br label %21

21:                                               ; preds = %31, %20
  %22 = load i32, ptr %11, align 4, !tbaa !11
  %23 = icmp slt i32 %22, 16
  br i1 %23, label %25, label %24

24:                                               ; preds = %21
  store i32 5, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %34

25:                                               ; preds = %21
  %26 = call noundef float @_Z6rand01v()
  %27 = getelementptr inbounds %struct.State, ptr %10, i32 0, i32 0
  %28 = load i32, ptr %11, align 4, !tbaa !11
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [16 x float], ptr %27, i64 0, i64 %29
  store float %26, ptr %30, align 4, !tbaa !13
  br label %31

31:                                               ; preds = %25
  %32 = load i32, ptr %11, align 4, !tbaa !11
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %11, align 4, !tbaa !11
  br label %21, !llvm.loop !15

34:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  store i32 0, ptr %12, align 4, !tbaa !11
  br label %35

35:                                               ; preds = %45, %34
  %36 = load i32, ptr %12, align 4, !tbaa !11
  %37 = icmp slt i32 %36, 8
  br i1 %37, label %39, label %38

38:                                               ; preds = %35
  store i32 8, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %48

39:                                               ; preds = %35
  %40 = call noundef float @_Z6rand01v()
  %41 = getelementptr inbounds %struct.State, ptr %10, i32 0, i32 1
  %42 = load i32, ptr %12, align 4, !tbaa !11
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [8 x float], ptr %41, i64 0, i64 %43
  store float %40, ptr %44, align 4, !tbaa !13
  br label %45

45:                                               ; preds = %39
  %46 = load i32, ptr %12, align 4, !tbaa !11
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %12, align 4, !tbaa !11
  br label %35, !llvm.loop !17

48:                                               ; preds = %38
  %49 = load ptr, ptr %6, align 8, !tbaa !9
  %50 = invoke noundef float @_Z13fitness_scoreRK5StateRKSt6vectorI4MeshSaIS3_EE(ptr noundef nonnull align 4 dereferenceable(100) %10, ptr noundef nonnull align 8 dereferenceable(24) %49)
          to label %51 unwind label %57

51:                                               ; preds = %48
  %52 = getelementptr inbounds %struct.State, ptr %10, i32 0, i32 2
  store float %50, ptr %52, align 4, !tbaa !18
  invoke void @_ZNSt6vectorI5StateSaIS0_EE9push_backERKS0_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 4 dereferenceable(100) %10)
          to label %53 unwind label %57

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

54:                                               ; preds = %53
  %55 = load i64, ptr %8, align 8, !tbaa !5
  %56 = add i64 %55, 1
  store i64 %56, ptr %8, align 8, !tbaa !5
  br label %15, !llvm.loop !20

57:                                               ; preds = %51, %48
  %58 = landingpad { ptr, i32 }
          cleanup
  %59 = extractvalue { ptr, i32 } %58, 0
  store ptr %59, ptr %13, align 8
  %60 = extractvalue { ptr, i32 } %58, 1
  store i32 %60, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 100, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @_ZNSt6vectorI5StateSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  br label %65

61:                                               ; preds = %19
  store i1 true, ptr %7, align 1
  store i32 1, ptr %9, align 4
  %62 = load i1, ptr %7, align 1
  br i1 %62, label %64, label %63

63:                                               ; preds = %61
  call void @_ZNSt6vectorI5StateSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  br label %64

64:                                               ; preds = %63, %61
  ret void

65:                                               ; preds = %57
  %66 = load ptr, ptr %13, align 8
  %67 = load i32, ptr %14, align 4
  %68 = insertvalue { ptr, i32 } poison, ptr %66, 0
  %69 = insertvalue { ptr, i32 } %68, i32 %67, 1
  resume { ptr, i32 } %69
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorI5StateSaIS0_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorI5StateSaIS0_EE9push_backERKS0_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(100)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorI5StateSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 #4 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = !{!19, !14, i64 96}
!19 = !{!"_ZTS5State", !7, i64 0, !7, i64 64, !14, i64 96}
!20 = distinct !{!20, !16}


; 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.std::vector.15" = type { %"struct.std::_Vector_base.16" }
%"struct.std::_Vector_base.16" = type { %"struct.std::_Vector_base<State, std::allocator<State>>::_Vector_impl" }
%"struct.std::_Vector_base<State, std::allocator<State>>::_Vector_impl" = type { %"struct.std::_Vector_base<State, std::allocator<State>>::_Vector_impl_data" }
%"struct.std::_Vector_base<State, std::allocator<State>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.State = type { [16 x float], [8 x float], float }

; 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: mustprogress nounwind uwtable
declare dso_local noundef float @_Z6rand01v() local_unnamed_addr #1

declare i32 @__gxx_personality_v0(...)

; 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 uwtable
declare dso_local noundef float @_Z13fitness_scoreRK5StateRKSt6vectorI4MeshSaIS3_EE(ptr noundef nonnull align 4 dereferenceable(100), ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local void @_Z4gen0mRKSt6vectorI4MeshSaIS0_EE(ptr dead_on_unwind noalias nonnull writable sret(%"class.std::vector.15") align 8 %0, i64 noundef %1, ptr noundef nonnull align 8 dereferenceable(24) %2) local_unnamed_addr #3 personality ptr @__gxx_personality_v0 {
  %4 = alloca %struct.State, align 4
  tail call void @_ZNSt6vectorI5StateSaIS0_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  %.not = icmp eq i64 %1, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %5 = getelementptr inbounds i8, ptr %4, i64 64
  %6 = getelementptr inbounds i8, ptr %4, i64 96
  %7 = getelementptr inbounds i8, ptr %4, i64 4
  %8 = getelementptr inbounds i8, ptr %4, i64 8
  %9 = getelementptr inbounds i8, ptr %4, i64 12
  %10 = getelementptr inbounds i8, ptr %4, i64 16
  %11 = getelementptr inbounds i8, ptr %4, i64 20
  %12 = getelementptr inbounds i8, ptr %4, i64 24
  %13 = getelementptr inbounds i8, ptr %4, i64 28
  %14 = getelementptr inbounds i8, ptr %4, i64 32
  %15 = getelementptr inbounds i8, ptr %4, i64 36
  %16 = getelementptr inbounds i8, ptr %4, i64 40
  %17 = getelementptr inbounds i8, ptr %4, i64 44
  %18 = getelementptr inbounds i8, ptr %4, i64 48
  %19 = getelementptr inbounds i8, ptr %4, i64 52
  %20 = getelementptr inbounds i8, ptr %4, i64 56
  %21 = getelementptr inbounds i8, ptr %4, i64 60
  %22 = getelementptr inbounds i8, ptr %4, i64 68
  %23 = getelementptr inbounds i8, ptr %4, i64 72
  %24 = getelementptr inbounds i8, ptr %4, i64 76
  %25 = getelementptr inbounds i8, ptr %4, i64 80
  %26 = getelementptr inbounds i8, ptr %4, i64 84
  %27 = getelementptr inbounds i8, ptr %4, i64 88
  %28 = getelementptr inbounds i8, ptr %4, i64 92
  br label %.preheader.preheader

.preheader.preheader:                             ; preds = %.lr.ph, %55
  %.016 = phi i64 [ 0, %.lr.ph ], [ %56, %55 ]
  call void @llvm.lifetime.start.p0(i64 100, ptr nonnull %4) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(100) %4, i8 0, i64 100, i1 false)
  %29 = call noundef float @_Z6rand01v()
  store float %29, ptr %4, align 4, !tbaa !5
  %30 = call noundef float @_Z6rand01v()
  store float %30, ptr %7, align 4, !tbaa !5
  %31 = call noundef float @_Z6rand01v()
  store float %31, ptr %8, align 4, !tbaa !5
  %32 = call noundef float @_Z6rand01v()
  store float %32, ptr %9, align 4, !tbaa !5
  %33 = call noundef float @_Z6rand01v()
  store float %33, ptr %10, align 4, !tbaa !5
  %34 = call noundef float @_Z6rand01v()
  store float %34, ptr %11, align 4, !tbaa !5
  %35 = call noundef float @_Z6rand01v()
  store float %35, ptr %12, align 4, !tbaa !5
  %36 = call noundef float @_Z6rand01v()
  store float %36, ptr %13, align 4, !tbaa !5
  %37 = call noundef float @_Z6rand01v()
  store float %37, ptr %14, align 4, !tbaa !5
  %38 = call noundef float @_Z6rand01v()
  store float %38, ptr %15, align 4, !tbaa !5
  %39 = call noundef float @_Z6rand01v()
  store float %39, ptr %16, align 4, !tbaa !5
  %40 = call noundef float @_Z6rand01v()
  store float %40, ptr %17, align 4, !tbaa !5
  %41 = call noundef float @_Z6rand01v()
  store float %41, ptr %18, align 4, !tbaa !5
  %42 = call noundef float @_Z6rand01v()
  store float %42, ptr %19, align 4, !tbaa !5
  %43 = call noundef float @_Z6rand01v()
  store float %43, ptr %20, align 4, !tbaa !5
  %44 = call noundef float @_Z6rand01v()
  store float %44, ptr %21, align 4, !tbaa !5
  %45 = call noundef float @_Z6rand01v()
  store float %45, ptr %5, align 4, !tbaa !5
  %46 = call noundef float @_Z6rand01v()
  store float %46, ptr %22, align 4, !tbaa !5
  %47 = call noundef float @_Z6rand01v()
  store float %47, ptr %23, align 4, !tbaa !5
  %48 = call noundef float @_Z6rand01v()
  store float %48, ptr %24, align 4, !tbaa !5
  %49 = call noundef float @_Z6rand01v()
  store float %49, ptr %25, align 4, !tbaa !5
  %50 = call noundef float @_Z6rand01v()
  store float %50, ptr %26, align 4, !tbaa !5
  %51 = call noundef float @_Z6rand01v()
  store float %51, ptr %27, align 4, !tbaa !5
  %52 = call noundef float @_Z6rand01v()
  store float %52, ptr %28, align 4, !tbaa !5
  %53 = invoke noundef float @_Z13fitness_scoreRK5StateRKSt6vectorI4MeshSaIS3_EE(ptr noundef nonnull align 4 dereferenceable(100) %4, ptr noundef nonnull align 8 dereferenceable(24) %2)
          to label %54 unwind label %57

54:                                               ; preds = %.preheader.preheader
  store float %53, ptr %6, align 4, !tbaa !9
  invoke void @_ZNSt6vectorI5StateSaIS0_EE9push_backERKS0_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 4 dereferenceable(100) %4)
          to label %55 unwind label %57

55:                                               ; preds = %54
  call void @llvm.lifetime.end.p0(i64 100, ptr nonnull %4) #4
  %56 = add nuw i64 %.016, 1
  %exitcond.not = icmp eq i64 %56, %1
  br i1 %exitcond.not, label %._crit_edge, label %.preheader.preheader, !llvm.loop !11

57:                                               ; preds = %54, %.preheader.preheader
  %58 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 100, ptr nonnull %4) #4
  call void @_ZNSt6vectorI5StateSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  resume { ptr, i32 } %58

._crit_edge:                                      ; preds = %55, %3
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorI5StateSaIS0_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorI5StateSaIS0_EE9push_backERKS0_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(100)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorI5StateSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #1 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 #4 = { 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"}
!9 = !{!10, !6, i64 96}
!10 = !{!"_ZTS5State", !7, i64 0, !7, i64 64, !6, i64 96}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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