; LLVM IR from Slingshot-Physics/slingshot-community :: common/geometry/src (quickhull)

; 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.geometry::types::triangleMesh_t" = type { i32, i32, [1000 x %"struct.geometry::types::meshTriangle_t"], [500 x %class.Vector3] }
%"struct.geometry::types::meshTriangle_t" = type { [3 x i32], %class.Vector3 }
%class.Vector3 = type { [3 x float] }
%"struct.geometry::types::minkowskiDiffVertex_t" = type { i32, i32, %class.Vector3, %class.Vector3, %class.Vector3 }

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZN7Vector3aSERKS_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) #1 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN8geometry4mesh12generateHullEjPKNS_5types21minkowskiDiffVertex_tERNS1_14triangleMesh_tE(i32 noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(30008)) #1

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #2

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) #3

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN8geometry4mesh12generateHullEjPK7Vector3RNS_5types14triangleMesh_tE(i32 noundef %0, ptr noundef %1, ptr noundef nonnull align 4 dereferenceable(30008) %2) #1 personality ptr @__gxx_personality_v0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !9
  %12 = load ptr, ptr %6, align 8, !tbaa !9
  %13 = getelementptr inbounds %"struct.geometry::types::triangleMesh_t", ptr %12, i32 0, i32 1
  store i32 0, ptr %13, align 4, !tbaa !11
  %14 = load ptr, ptr %6, align 8, !tbaa !9
  %15 = getelementptr inbounds %"struct.geometry::types::triangleMesh_t", ptr %14, i32 0, i32 0
  store i32 0, ptr %15, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %16 = load i32, ptr %4, align 4, !tbaa !5
  %17 = zext i32 %16 to i64
  %18 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %17, i64 44)
  %19 = extractvalue { i64, i1 } %18, 1
  %20 = extractvalue { i64, i1 } %18, 0
  %21 = select i1 %19, i64 -1, i64 %20
  %22 = call noalias noundef nonnull ptr @_Znam(i64 noundef %21) #7
  %23 = icmp eq i64 %17, 0
  br i1 %23, label %31, label %24

24:                                               ; preds = %3
  %25 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffVertex_t", ptr %22, i64 %17
  br label %26

26:                                               ; preds = %28, %24
  %27 = phi ptr [ %22, %24 ], [ %29, %28 ]
  invoke void @_ZN8geometry5types21minkowskiDiffVertex_tC2Ev(ptr noundef nonnull align 4 dereferenceable(44) %27)
          to label %28 unwind label %37

28:                                               ; preds = %26
  %29 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffVertex_t", ptr %27, i64 1
  %30 = icmp eq ptr %29, %25
  br i1 %30, label %31, label %26

31:                                               ; preds = %28, %3
  store ptr %22, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %32

32:                                               ; preds = %62, %31
  %33 = load i32, ptr %10, align 4, !tbaa !5
  %34 = load i32, ptr %4, align 4, !tbaa !5
  %35 = icmp ult i32 %33, %34
  br i1 %35, label %41, label %36

36:                                               ; preds = %32
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %65

37:                                               ; preds = %26
  %38 = landingpad { ptr, i32 }
          cleanup
  %39 = extractvalue { ptr, i32 } %38, 0
  store ptr %39, ptr %8, align 8
  %40 = extractvalue { ptr, i32 } %38, 1
  store i32 %40, ptr %9, align 4
  call void @_ZdaPvm(ptr noundef %22, i64 noundef %21) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  br label %75

41:                                               ; preds = %32
  %42 = load ptr, ptr %7, align 8, !tbaa !9
  %43 = load i32, ptr %10, align 4, !tbaa !5
  %44 = zext i32 %43 to i64
  %45 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffVertex_t", ptr %42, i64 %44
  %46 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffVertex_t", ptr %45, i32 0, i32 0
  store i32 -1, ptr %46, align 4, !tbaa !14
  %47 = load ptr, ptr %7, align 8, !tbaa !9
  %48 = load i32, ptr %10, align 4, !tbaa !5
  %49 = zext i32 %48 to i64
  %50 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffVertex_t", ptr %47, i64 %49
  %51 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffVertex_t", ptr %50, i32 0, i32 1
  store i32 -1, ptr %51, align 4, !tbaa !17
  %52 = load ptr, ptr %5, align 8, !tbaa !9
  %53 = load i32, ptr %10, align 4, !tbaa !5
  %54 = zext i32 %53 to i64
  %55 = getelementptr inbounds %class.Vector3, ptr %52, i64 %54
  %56 = load ptr, ptr %7, align 8, !tbaa !9
  %57 = load i32, ptr %10, align 4, !tbaa !5
  %58 = zext i32 %57 to i64
  %59 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffVertex_t", ptr %56, i64 %58
  %60 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffVertex_t", ptr %59, i32 0, i32 2
  %61 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZN7Vector3aSERKS_(ptr noundef nonnull align 4 dereferenceable(12) %60, ptr noundef nonnull align 4 dereferenceable(12) %55)
  br label %62

62:                                               ; preds = %41
  %63 = load i32, ptr %10, align 4, !tbaa !5
  %64 = add i32 %63, 1
  store i32 %64, ptr %10, align 4, !tbaa !5
  br label %32, !llvm.loop !18

65:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %66 = load i32, ptr %4, align 4, !tbaa !5
  %67 = load ptr, ptr %7, align 8, !tbaa !9
  %68 = load ptr, ptr %6, align 8, !tbaa !9
  %69 = call noundef i32 @_ZN8geometry4mesh12generateHullEjPKNS_5types21minkowskiDiffVertex_tERNS1_14triangleMesh_tE(i32 noundef %66, ptr noundef %67, ptr noundef nonnull align 4 dereferenceable(30008) %68)
  store i32 %69, ptr %11, align 4, !tbaa !5
  %70 = load ptr, ptr %7, align 8, !tbaa !9
  %71 = icmp eq ptr %70, null
  br i1 %71, label %73, label %72

72:                                               ; preds = %65
  call void @_ZdaPv(ptr noundef %70) #8
  br label %73

73:                                               ; preds = %72, %65
  %74 = load i32, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  ret i32 %74

75:                                               ; preds = %37
  %76 = load ptr, ptr %8, align 8
  %77 = load i32, ptr %9, align 4
  %78 = insertvalue { ptr, i32 } poison, ptr %76, 0
  %79 = insertvalue { ptr, i32 } %78, i32 %77, 1
  resume { ptr, i32 } %79
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN8geometry5types21minkowskiDiffVertex_tC2Ev(ptr noundef nonnull align 4 dereferenceable(44)) unnamed_addr #5 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPvm(ptr noundef, i64 noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nobuiltin allocsize(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 = { nobuiltin 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { inlinehint 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 #6 = { nounwind }
attributes #7 = { builtin allocsize(0) }
attributes #8 = { builtin 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 = !{!"int", !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, !6, i64 4}
!12 = !{!"_ZTSN8geometry5types14triangleMesh_tE", !6, i64 0, !6, i64 4, !7, i64 8, !7, i64 24008}
!13 = !{!12, !6, i64 0}
!14 = !{!15, !6, i64 0}
!15 = !{!"_ZTSN8geometry5types21minkowskiDiffVertex_tE", !6, i64 0, !6, i64 4, !16, i64 8, !16, i64 20, !16, i64 32}
!16 = !{!"_ZTS7Vector3", !7, i64 0}
!17 = !{!15, !6, i64 4}
!18 = distinct !{!18, !19}
!19 = !{!"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"

%"struct.geometry::types::minkowskiDiffVertex_t" = type { i32, i32, %class.Vector3, %class.Vector3, %class.Vector3 }
%class.Vector3 = type { [3 x float] }

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZN7Vector3aSERKS_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN8geometry4mesh12generateHullEjPKNS_5types21minkowskiDiffVertex_tERNS1_14triangleMesh_tE(i32 noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(30008)) local_unnamed_addr #0

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #1

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN8geometry4mesh12generateHullEjPK7Vector3RNS_5types14triangleMesh_tE(i32 noundef %0, ptr noundef %1, ptr noundef nonnull align 4 dereferenceable(30008) %2) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %4 = getelementptr inbounds i8, ptr %2, i64 4
  store i32 0, ptr %4, align 4, !tbaa !5
  store i32 0, ptr %2, align 4, !tbaa !10
  %5 = zext i32 %0 to i64
  %6 = mul nuw nsw i64 %5, 44
  %7 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %6) #4
  %8 = icmp eq i32 %0, 0
  br i1 %8, label %._crit_edge, label %9

9:                                                ; preds = %3
  %10 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffVertex_t", ptr %7, i64 %5
  br label %11

11:                                               ; preds = %13, %9
  %12 = phi ptr [ %7, %9 ], [ %14, %13 ]
  invoke void @_ZN8geometry5types21minkowskiDiffVertex_tC2Ev(ptr noundef nonnull align 4 dereferenceable(44) %12)
          to label %13 unwind label %17

13:                                               ; preds = %11
  %14 = getelementptr inbounds i8, ptr %12, i64 44
  %15 = icmp eq ptr %14, %10
  br i1 %15, label %.loopexit, label %11

.loopexit:                                        ; preds = %13
  br i1 %8, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %3, %.loopexit
  %16 = tail call noundef i32 @_ZN8geometry4mesh12generateHullEjPKNS_5types21minkowskiDiffVertex_tERNS1_14triangleMesh_tE(i32 noundef %0, ptr noundef nonnull %7, ptr noundef nonnull align 4 dereferenceable(30008) %2)
  tail call void @_ZdaPv(ptr noundef nonnull %7) #5
  ret i32 %16

17:                                               ; preds = %11
  %18 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdaPvm(ptr noundef nonnull %7, i64 noundef %6) #5
  resume { ptr, i32 } %18

.lr.ph:                                           ; preds = %.loopexit, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.loopexit ]
  %19 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffVertex_t", ptr %7, i64 %indvars.iv
  store i32 -1, ptr %19, align 4, !tbaa !11
  %20 = getelementptr inbounds i8, ptr %19, i64 4
  store i32 -1, ptr %20, align 4, !tbaa !14
  %21 = getelementptr inbounds %class.Vector3, ptr %1, i64 %indvars.iv
  %22 = getelementptr inbounds i8, ptr %19, i64 8
  %23 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZN7Vector3aSERKS_(ptr noundef nonnull align 4 dereferenceable(12) %22, ptr noundef nonnull align 4 dereferenceable(12) %21)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %5
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !15
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN8geometry5types21minkowskiDiffVertex_tC2Ev(ptr noundef nonnull align 4 dereferenceable(44)) unnamed_addr #3 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPvm(ptr noundef, i64 noundef) local_unnamed_addr #2

attributes #0 = { 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 #1 = { nobuiltin allocsize(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 = { nobuiltin 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 #3 = { inlinehint 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 = { builtin allocsize(0) }
attributes #5 = { builtin 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 4}
!6 = !{!"_ZTSN8geometry5types14triangleMesh_tE", !7, i64 0, !7, i64 4, !8, i64 8, !8, i64 24008}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 0}
!11 = !{!12, !7, i64 0}
!12 = !{!"_ZTSN8geometry5types21minkowskiDiffVertex_tE", !7, i64 0, !7, i64 4, !13, i64 8, !13, i64 20, !13, i64 32}
!13 = !{!"_ZTS7Vector3", !8, i64 0}
!14 = !{!12, !7, i64 4}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


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