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

; 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::VertexCustomHasher" = type { ptr, i64, ptr, ptr }

@.str = external hidden unnamed_addr constant [39 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [75 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [33 x i8], align 1
@__PRETTY_FUNCTION__.meshopt_generateVertexRemapCustom = external hidden unnamed_addr constant [171 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [64 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [45 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: mustprogress nounwind uwtable
declare dso_local void @_ZN17meshopt_AllocatorC2Ev(ptr noundef nonnull align 8 dereferenceable(200)) unnamed_addr #2 align 2

declare i32 @__gxx_personality_v0(...)

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

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

; Function Attrs: mustprogress uwtable
define dso_local i64 @meshopt_generateVertexRemapCustom(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3, i64 noundef %4, i64 noundef %5, ptr noundef %6, ptr noundef %7) #3 personality ptr @__gxx_personality_v0 {
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca %class.meshopt_Allocator, align 8
  %18 = alloca %"struct.meshopt::VertexCustomHasher", align 8
  %19 = alloca ptr, align 8
  %20 = alloca i32, align 4
  store ptr %0, ptr %9, align 8, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !5
  store i64 %2, ptr %11, align 8, !tbaa !9
  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 ptr %6, ptr %15, align 8, !tbaa !5
  store ptr %7, ptr %16, align 8, !tbaa !5
  %21 = load ptr, ptr %10, align 8, !tbaa !5
  %22 = icmp ne ptr %21, null
  br i1 %22, label %27, label %23

23:                                               ; preds = %8
  %24 = load i64, ptr %11, align 8, !tbaa !9
  %25 = load i64, ptr %13, align 8, !tbaa !9
  %26 = icmp eq i64 %24, %25
  br label %27

27:                                               ; preds = %23, %8
  %28 = phi i1 [ true, %8 ], [ %26, %23 ]
  br i1 %28, label %29, label %30

29:                                               ; preds = %27
  br label %32

30:                                               ; preds = %27
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 347, ptr noundef @__PRETTY_FUNCTION__.meshopt_generateVertexRemapCustom) #4
  unreachable

31:                                               ; No predecessors!
  br label %32

32:                                               ; preds = %31, %29
  %33 = load ptr, ptr %10, align 8, !tbaa !5
  %34 = icmp ne ptr %33, null
  br i1 %34, label %35, label %39

35:                                               ; preds = %32
  %36 = load i64, ptr %11, align 8, !tbaa !9
  %37 = urem i64 %36, 3
  %38 = icmp eq i64 %37, 0
  br label %39

39:                                               ; preds = %35, %32
  %40 = phi i1 [ true, %32 ], [ %38, %35 ]
  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 348, ptr noundef @__PRETTY_FUNCTION__.meshopt_generateVertexRemapCustom) #4
  unreachable

43:                                               ; No predecessors!
  br label %44

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

47:                                               ; preds = %44
  %48 = load i64, ptr %14, align 8, !tbaa !9
  %49 = icmp ule i64 %48, 256
  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.8, ptr noundef @.str.1, i32 noundef 349, ptr noundef @__PRETTY_FUNCTION__.meshopt_generateVertexRemapCustom) #4
  unreachable

54:                                               ; No predecessors!
  br label %55

55:                                               ; preds = %54, %52
  %56 = load i64, ptr %14, 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.9, ptr noundef @.str.1, i32 noundef 350, ptr noundef @__PRETTY_FUNCTION__.meshopt_generateVertexRemapCustom) #4
  unreachable

61:                                               ; No predecessors!
  br label %62

62:                                               ; preds = %61, %59
  call void @llvm.lifetime.start.p0(i64 200, ptr %17) #5
  call void @_ZN17meshopt_AllocatorC2Ev(ptr noundef nonnull align 8 dereferenceable(200) %17)
  call void @llvm.lifetime.start.p0(i64 32, ptr %18) #5
  %63 = getelementptr inbounds %"struct.meshopt::VertexCustomHasher", ptr %18, i32 0, i32 0
  %64 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %64, ptr %63, align 8, !tbaa !11
  %65 = getelementptr inbounds %"struct.meshopt::VertexCustomHasher", ptr %18, i32 0, i32 1
  %66 = load i64, ptr %14, align 8, !tbaa !9
  %67 = udiv i64 %66, 4
  store i64 %67, ptr %65, align 8, !tbaa !13
  %68 = getelementptr inbounds %"struct.meshopt::VertexCustomHasher", ptr %18, i32 0, i32 2
  %69 = load ptr, ptr %15, align 8, !tbaa !5
  store ptr %69, ptr %68, align 8, !tbaa !14
  %70 = getelementptr inbounds %"struct.meshopt::VertexCustomHasher", ptr %18, i32 0, i32 3
  %71 = load ptr, ptr %16, align 8, !tbaa !5
  store ptr %71, ptr %70, align 8, !tbaa !15
  %72 = load ptr, ptr %9, align 8, !tbaa !5
  %73 = load ptr, ptr %10, align 8, !tbaa !5
  %74 = load i64, ptr %11, align 8, !tbaa !9
  %75 = load i64, ptr %13, align 8, !tbaa !9
  %76 = invoke noundef i64 @_ZN7meshoptL19generateVertexRemapINS_18VertexCustomHasherEEEmPjPKjmmRKT_R17meshopt_Allocator(ptr noundef %72, ptr noundef %73, i64 noundef %74, i64 noundef %75, ptr noundef nonnull align 8 dereferenceable(32) %18, ptr noundef nonnull align 8 dereferenceable(200) %17)
          to label %77 unwind label %78

77:                                               ; preds = %62
  call void @llvm.lifetime.end.p0(i64 32, ptr %18) #5
  call void @_ZN17meshopt_AllocatorD2Ev(ptr noundef nonnull align 8 dereferenceable(200) %17) #5
  call void @llvm.lifetime.end.p0(i64 200, ptr %17) #5
  ret i64 %76

78:                                               ; preds = %62
  %79 = landingpad { ptr, i32 }
          cleanup
  %80 = extractvalue { ptr, i32 } %79, 0
  store ptr %80, ptr %19, align 8
  %81 = extractvalue { ptr, i32 } %79, 1
  store i32 %81, ptr %20, align 4
  call void @llvm.lifetime.end.p0(i64 32, ptr %18) #5
  call void @_ZN17meshopt_AllocatorD2Ev(ptr noundef nonnull align 8 dereferenceable(200) %17) #5
  call void @llvm.lifetime.end.p0(i64 200, ptr %17) #5
  br label %82

82:                                               ; preds = %78
  %83 = load ptr, ptr %19, align 8
  %84 = load i32, ptr %20, align 4
  %85 = insertvalue { ptr, i32 } poison, ptr %83, 0
  %86 = insertvalue { ptr, i32 } %85, i32 %84, 1
  resume { ptr, i32 } %86
}

; Function Attrs: mustprogress uwtable
declare hidden noundef i64 @_ZN7meshoptL19generateVertexRemapINS_18VertexCustomHasherEEEmPjPKjmmRKT_R17meshopt_Allocator(ptr noundef, ptr noundef, i64 noundef, i64 noundef, ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(200)) #3

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 = { 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 #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 = { 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 = !{!"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, !6, i64 0}
!12 = !{!"_ZTSN7meshopt18VertexCustomHasherE", !6, i64 0, !10, i64 8, !6, i64 16, !6, i64 24}
!13 = !{!12, !10, i64 8}
!14 = !{!12, !6, i64 16}
!15 = !{!12, !6, i64 24}


; 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::VertexCustomHasher" = type { ptr, i64, ptr, ptr }

@.str = external hidden unnamed_addr constant [39 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [75 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [33 x i8], align 1
@__PRETTY_FUNCTION__.meshopt_generateVertexRemapCustom = external hidden unnamed_addr constant [171 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [64 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [45 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 nounwind uwtable
declare dso_local void @_ZN17meshopt_AllocatorC2Ev(ptr noundef nonnull align 8 dereferenceable(200)) unnamed_addr #2 align 2

declare i32 @__gxx_personality_v0(...)

; 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 nounwind uwtable
declare dso_local void @_ZN17meshopt_AllocatorD2Ev(ptr noundef nonnull align 8 dereferenceable(200)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @meshopt_generateVertexRemapCustom(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3, i64 noundef %4, i64 noundef %5, ptr noundef %6, ptr noundef %7) local_unnamed_addr #3 personality ptr @__gxx_personality_v0 {
  %9 = alloca %class.meshopt_Allocator, align 8
  %10 = alloca %"struct.meshopt::VertexCustomHasher", align 8
  %11 = icmp ne ptr %1, null
  %12 = icmp eq i64 %2, %4
  %13 = or i1 %11, %12
  br i1 %13, label %15, label %14

14:                                               ; preds = %8
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 347, ptr noundef nonnull @__PRETTY_FUNCTION__.meshopt_generateVertexRemapCustom) #4
  unreachable

15:                                               ; preds = %8
  %16 = urem i64 %2, 3
  %17 = icmp ne i64 %16, 0
  %or.cond.not = and i1 %11, %17
  br i1 %or.cond.not, label %18, label %.critedge

18:                                               ; preds = %15
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 348, ptr noundef nonnull @__PRETTY_FUNCTION__.meshopt_generateVertexRemapCustom) #4
  unreachable

.critedge:                                        ; preds = %15
  %19 = add i64 %5, -12
  %20 = icmp ult i64 %19, 245
  br i1 %20, label %22, label %21

21:                                               ; preds = %.critedge
  tail call void @__assert_fail(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.1, i32 noundef 349, ptr noundef nonnull @__PRETTY_FUNCTION__.meshopt_generateVertexRemapCustom) #4
  unreachable

22:                                               ; preds = %.critedge
  %23 = and i64 %5, 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.9, ptr noundef nonnull @.str.1, i32 noundef 350, ptr noundef nonnull @__PRETTY_FUNCTION__.meshopt_generateVertexRemapCustom) #4
  unreachable

26:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 200, ptr nonnull %9) #5
  call void @_ZN17meshopt_AllocatorC2Ev(ptr noundef nonnull align 8 dereferenceable(200) %9)
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %10) #5
  store ptr %3, ptr %10, align 8, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %10, i64 8
  %28 = lshr exact i64 %5, 2
  store i64 %28, ptr %27, align 8, !tbaa !11
  %29 = getelementptr inbounds i8, ptr %10, i64 16
  store ptr %6, ptr %29, align 8, !tbaa !12
  %30 = getelementptr inbounds i8, ptr %10, i64 24
  store ptr %7, ptr %30, align 8, !tbaa !13
  %31 = invoke noundef i64 @_ZN7meshoptL19generateVertexRemapINS_18VertexCustomHasherEEEmPjPKjmmRKT_R17meshopt_Allocator(ptr noundef %0, ptr noundef %1, i64 noundef %2, i64 noundef %4, ptr noundef nonnull align 8 dereferenceable(32) %10, ptr noundef nonnull align 8 dereferenceable(200) %9)
          to label %32 unwind label %33

32:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %10) #5
  call void @_ZN17meshopt_AllocatorD2Ev(ptr noundef nonnull align 8 dereferenceable(200) %9) #5
  call void @llvm.lifetime.end.p0(i64 200, ptr nonnull %9) #5
  ret i64 %31

33:                                               ; preds = %26
  %34 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %10) #5
  call void @_ZN17meshopt_AllocatorD2Ev(ptr noundef nonnull align 8 dereferenceable(200) %9) #5
  call void @llvm.lifetime.end.p0(i64 200, ptr nonnull %9) #5
  resume { ptr, i32 } %34
}

; Function Attrs: mustprogress uwtable
declare hidden noundef i64 @_ZN7meshoptL19generateVertexRemapINS_18VertexCustomHasherEEEmPjPKjmmRKT_R17meshopt_Allocator(ptr noundef, ptr noundef, i64 noundef, i64 noundef, ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(200)) local_unnamed_addr #3

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 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 #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 = { 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, !7, i64 0}
!6 = !{!"_ZTSN7meshopt18VertexCustomHasherE", !7, i64 0, !10, i64 8, !7, i64 16, !7, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!6, !7, i64 16}
!13 = !{!6, !7, i64 24}


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