; LLVM IR from zeux/meshoptimizer :: demo/main.ll (Z8packMeshRSt6vectorI12PackedVertexSaIS0_EERKS_I6VertexSaIS4_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"

%struct.Vertex = type { float, float, float, float, float, float, float, float }
%struct.PackedVertex = type { i16, i16, i16, i16, i8, i8, i8, i8, i16, i16 }

; 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 i64 @_ZNKSt6vectorI6VertexSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(32) ptr @_ZNKSt6vectorI6VertexSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z8packMeshRSt6vectorI12PackedVertexSaIS0_EERKS_I6VertexSaIS4_EE(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(24) %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  store i64 0, ptr %5, align 8, !tbaa !9
  br label %8

8:                                                ; preds = %76, %2
  %9 = load i64, ptr %5, align 8, !tbaa !9
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = call noundef i64 @_ZNKSt6vectorI6VertexSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %10) #5
  %12 = icmp ult i64 %9, %11
  br i1 %12, label %14, label %13

13:                                               ; preds = %8
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  br label %79

14:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = load i64, ptr %5, align 8, !tbaa !9
  %17 = call noundef nonnull align 4 dereferenceable(32) ptr @_ZNKSt6vectorI6VertexSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %15, i64 noundef %16) #5
  store ptr %17, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = load i64, ptr %5, align 8, !tbaa !9
  %20 = call noundef nonnull align 2 dereferenceable(16) ptr @_ZNSt6vectorI12PackedVertexSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %18, i64 noundef %19) #5
  store ptr %20, ptr %7, align 8, !tbaa !5
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.Vertex, ptr %21, i32 0, i32 0
  %23 = load float, ptr %22, align 4, !tbaa !11
  %24 = call zeroext i16 @meshopt_quantizeHalf(float noundef %23)
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.PackedVertex, ptr %25, i32 0, i32 0
  store i16 %24, ptr %26, align 2, !tbaa !14
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.Vertex, ptr %27, i32 0, i32 1
  %29 = load float, ptr %28, align 4, !tbaa !17
  %30 = call zeroext i16 @meshopt_quantizeHalf(float noundef %29)
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.PackedVertex, ptr %31, i32 0, i32 1
  store i16 %30, ptr %32, align 2, !tbaa !18
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.Vertex, ptr %33, i32 0, i32 2
  %35 = load float, ptr %34, align 4, !tbaa !19
  %36 = call zeroext i16 @meshopt_quantizeHalf(float noundef %35)
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.PackedVertex, ptr %37, i32 0, i32 2
  store i16 %36, ptr %38, align 2, !tbaa !20
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.PackedVertex, ptr %39, i32 0, i32 3
  store i16 0, ptr %40, align 2, !tbaa !21
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.Vertex, ptr %41, i32 0, i32 3
  %43 = load float, ptr %42, align 4, !tbaa !22
  %44 = call noundef i32 @_Z21meshopt_quantizeSnormfi(float noundef %43, i32 noundef 8)
  %45 = trunc i32 %44 to i8
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.PackedVertex, ptr %46, i32 0, i32 4
  store i8 %45, ptr %47, align 2, !tbaa !23
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.Vertex, ptr %48, i32 0, i32 4
  %50 = load float, ptr %49, align 4, !tbaa !24
  %51 = call noundef i32 @_Z21meshopt_quantizeSnormfi(float noundef %50, i32 noundef 8)
  %52 = trunc i32 %51 to i8
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.PackedVertex, ptr %53, i32 0, i32 5
  store i8 %52, ptr %54, align 1, !tbaa !25
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.Vertex, ptr %55, i32 0, i32 5
  %57 = load float, ptr %56, align 4, !tbaa !26
  %58 = call noundef i32 @_Z21meshopt_quantizeSnormfi(float noundef %57, i32 noundef 8)
  %59 = trunc i32 %58 to i8
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.PackedVertex, ptr %60, i32 0, i32 6
  store i8 %59, ptr %61, align 2, !tbaa !27
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.PackedVertex, ptr %62, i32 0, i32 7
  store i8 0, ptr %63, align 1, !tbaa !28
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.Vertex, ptr %64, i32 0, i32 6
  %66 = load float, ptr %65, align 4, !tbaa !29
  %67 = call zeroext i16 @meshopt_quantizeHalf(float noundef %66)
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.PackedVertex, ptr %68, i32 0, i32 8
  store i16 %67, ptr %69, align 2, !tbaa !30
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.Vertex, ptr %70, i32 0, i32 7
  %72 = load float, ptr %71, align 4, !tbaa !31
  %73 = call zeroext i16 @meshopt_quantizeHalf(float noundef %72)
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.PackedVertex, ptr %74, i32 0, i32 9
  store i16 %73, ptr %75, align 2, !tbaa !32
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br label %76

76:                                               ; preds = %14
  %77 = load i64, ptr %5, align 8, !tbaa !9
  %78 = add i64 %77, 1
  store i64 %78, ptr %5, align 8, !tbaa !9
  br label %8, !llvm.loop !33

79:                                               ; preds = %13
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 2 dereferenceable(16) ptr @_ZNSt6vectorI12PackedVertexSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

declare zeroext i16 @meshopt_quantizeHalf(float noundef) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z21meshopt_quantizeSnormfi(float noundef, i32 noundef) #4

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 = { 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 #3 = { "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 = { inlinehint 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 #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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"_ZTS6Vertex", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !13, i64 24, !13, i64 28}
!13 = !{!"float", !7, i64 0}
!14 = !{!15, !16, i64 0}
!15 = !{!"_ZTS12PackedVertex", !16, i64 0, !16, i64 2, !16, i64 4, !16, i64 6, !7, i64 8, !7, i64 9, !7, i64 10, !7, i64 11, !16, i64 12, !16, i64 14}
!16 = !{!"short", !7, i64 0}
!17 = !{!12, !13, i64 4}
!18 = !{!15, !16, i64 2}
!19 = !{!12, !13, i64 8}
!20 = !{!15, !16, i64 4}
!21 = !{!15, !16, i64 6}
!22 = !{!12, !13, i64 12}
!23 = !{!15, !7, i64 8}
!24 = !{!12, !13, i64 16}
!25 = !{!15, !7, i64 9}
!26 = !{!12, !13, i64 20}
!27 = !{!15, !7, i64 10}
!28 = !{!15, !7, i64 11}
!29 = !{!12, !13, i64 24}
!30 = !{!15, !16, i64 12}
!31 = !{!12, !13, i64 28}
!32 = !{!15, !16, i64 14}
!33 = distinct !{!33, !34}
!34 = !{!"llvm.loop.mustprogress"}


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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorI6VertexSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(32) ptr @_ZNKSt6vectorI6VertexSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z8packMeshRSt6vectorI12PackedVertexSaIS0_EERKS_I6VertexSaIS4_EE(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(24) %1) local_unnamed_addr #1 {
  %3 = tail call noundef i64 @_ZNKSt6vectorI6VertexSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %1) #4
  %.not = icmp eq i64 %3, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %2
  ret void

.lr.ph:                                           ; preds = %2, %.lr.ph
  %.024 = phi i64 [ %41, %.lr.ph ], [ 0, %2 ]
  %4 = tail call noundef nonnull align 4 dereferenceable(32) ptr @_ZNKSt6vectorI6VertexSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %.024) #4
  %5 = tail call noundef nonnull align 2 dereferenceable(16) ptr @_ZNSt6vectorI12PackedVertexSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %.024) #4
  %6 = load float, ptr %4, align 4, !tbaa !5
  %7 = tail call zeroext i16 @meshopt_quantizeHalf(float noundef %6)
  store i16 %7, ptr %5, align 2, !tbaa !10
  %8 = getelementptr inbounds i8, ptr %4, i64 4
  %9 = load float, ptr %8, align 4, !tbaa !13
  %10 = tail call zeroext i16 @meshopt_quantizeHalf(float noundef %9)
  %11 = getelementptr inbounds i8, ptr %5, i64 2
  store i16 %10, ptr %11, align 2, !tbaa !14
  %12 = getelementptr inbounds i8, ptr %4, i64 8
  %13 = load float, ptr %12, align 4, !tbaa !15
  %14 = tail call zeroext i16 @meshopt_quantizeHalf(float noundef %13)
  %15 = getelementptr inbounds i8, ptr %5, i64 4
  store i16 %14, ptr %15, align 2, !tbaa !16
  %16 = getelementptr inbounds i8, ptr %5, i64 6
  store i16 0, ptr %16, align 2, !tbaa !17
  %17 = getelementptr inbounds i8, ptr %4, i64 12
  %18 = load float, ptr %17, align 4, !tbaa !18
  %19 = tail call noundef i32 @_Z21meshopt_quantizeSnormfi(float noundef %18, i32 noundef 8)
  %20 = trunc i32 %19 to i8
  %21 = getelementptr inbounds i8, ptr %5, i64 8
  store i8 %20, ptr %21, align 2, !tbaa !19
  %22 = getelementptr inbounds i8, ptr %4, i64 16
  %23 = load float, ptr %22, align 4, !tbaa !20
  %24 = tail call noundef i32 @_Z21meshopt_quantizeSnormfi(float noundef %23, i32 noundef 8)
  %25 = trunc i32 %24 to i8
  %26 = getelementptr inbounds i8, ptr %5, i64 9
  store i8 %25, ptr %26, align 1, !tbaa !21
  %27 = getelementptr inbounds i8, ptr %4, i64 20
  %28 = load float, ptr %27, align 4, !tbaa !22
  %29 = tail call noundef i32 @_Z21meshopt_quantizeSnormfi(float noundef %28, i32 noundef 8)
  %30 = trunc i32 %29 to i8
  %31 = getelementptr inbounds i8, ptr %5, i64 10
  store i8 %30, ptr %31, align 2, !tbaa !23
  %32 = getelementptr inbounds i8, ptr %5, i64 11
  store i8 0, ptr %32, align 1, !tbaa !24
  %33 = getelementptr inbounds i8, ptr %4, i64 24
  %34 = load float, ptr %33, align 4, !tbaa !25
  %35 = tail call zeroext i16 @meshopt_quantizeHalf(float noundef %34)
  %36 = getelementptr inbounds i8, ptr %5, i64 12
  store i16 %35, ptr %36, align 2, !tbaa !26
  %37 = getelementptr inbounds i8, ptr %4, i64 28
  %38 = load float, ptr %37, align 4, !tbaa !27
  %39 = tail call zeroext i16 @meshopt_quantizeHalf(float noundef %38)
  %40 = getelementptr inbounds i8, ptr %5, i64 14
  store i16 %39, ptr %40, align 2, !tbaa !28
  %41 = add nuw i64 %.024, 1
  %42 = tail call noundef i64 @_ZNKSt6vectorI6VertexSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %1) #4
  %43 = icmp ult i64 %41, %42
  br i1 %43, label %.lr.ph, label %._crit_edge, !llvm.loop !29
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 2 dereferenceable(16) ptr @_ZNSt6vectorI12PackedVertexSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

declare zeroext i16 @meshopt_quantizeHalf(float noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z21meshopt_quantizeSnormfi(float noundef, i32 noundef) local_unnamed_addr #3

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 = { 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 #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 = { inlinehint 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 = { 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 0}
!6 = !{!"_ZTS6Vertex", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !12, i64 0}
!11 = !{!"_ZTS12PackedVertex", !12, i64 0, !12, i64 2, !12, i64 4, !12, i64 6, !8, i64 8, !8, i64 9, !8, i64 10, !8, i64 11, !12, i64 12, !12, i64 14}
!12 = !{!"short", !8, i64 0}
!13 = !{!6, !7, i64 4}
!14 = !{!11, !12, i64 2}
!15 = !{!6, !7, i64 8}
!16 = !{!11, !12, i64 4}
!17 = !{!11, !12, i64 6}
!18 = !{!6, !7, i64 12}
!19 = !{!11, !8, i64 8}
!20 = !{!6, !7, i64 16}
!21 = !{!11, !8, i64 9}
!22 = !{!6, !7, i64 20}
!23 = !{!11, !8, i64 10}
!24 = !{!11, !8, i64 11}
!25 = !{!6, !7, i64 24}
!26 = !{!11, !12, i64 12}
!27 = !{!6, !7, i64 28}
!28 = !{!11, !12, i64 14}
!29 = distinct !{!29, !30}
!30 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass