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

; 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.Vector3 = type { [3 x float] }
%"struct.geometry::types::epa::epaMesh_t" = type { %"class.geometry::mesh::TriangleGraphMesh", [384 x %"struct.geometry::types::minkowskiDiffVertex_t"], i32 }
%"class.geometry::mesh::TriangleGraphMesh" = type { i32, [128 x %"struct.geometry::types::leanNeighborTriangle_t"] }
%"struct.geometry::types::leanNeighborTriangle_t" = type { [3 x i32], [3 x i32] }
%"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: 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 void @_ZNK7Vector3miERKS_(ptr dead_on_unwind noalias writable sret(%class.Vector3) align 4, ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN8geometry5types3epa9epaMesh_t10vertExistsERKNS0_21minkowskiDiffVertex_tE(ptr noundef nonnull align 4 dereferenceable(19976) %0, ptr noundef nonnull align 4 dereferenceable(44) %1) #1 align 2 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca %class.Vector3, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %10

10:                                               ; preds = %63, %2
  %11 = load i32, ptr %6, align 4, !tbaa !9
  %12 = getelementptr inbounds %"struct.geometry::types::epa::epaMesh_t", ptr %9, i32 0, i32 2
  %13 = load i32, ptr %12, align 4, !tbaa !11
  %14 = icmp ult i32 %11, %13
  br i1 %14, label %16, label %15

15:                                               ; preds = %10
  store i32 2, ptr %7, align 4
  br label %66

16:                                               ; preds = %10
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffVertex_t", ptr %17, i32 0, i32 0
  %19 = load i32, ptr %18, align 4, !tbaa !14
  %20 = icmp ne i32 %19, -1
  br i1 %20, label %21, label %50

21:                                               ; preds = %16
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffVertex_t", ptr %22, i32 0, i32 1
  %24 = load i32, ptr %23, align 4, !tbaa !17
  %25 = icmp ne i32 %24, -1
  br i1 %25, label %26, label %50

26:                                               ; preds = %21
  %27 = getelementptr inbounds %"struct.geometry::types::epa::epaMesh_t", ptr %9, i32 0, i32 1
  %28 = load i32, ptr %6, align 4, !tbaa !9
  %29 = zext i32 %28 to i64
  %30 = getelementptr inbounds [384 x %"struct.geometry::types::minkowskiDiffVertex_t"], ptr %27, i64 0, i64 %29
  %31 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffVertex_t", ptr %30, i32 0, i32 0
  %32 = load i32, ptr %31, align 4, !tbaa !14
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffVertex_t", ptr %33, i32 0, i32 0
  %35 = load i32, ptr %34, align 4, !tbaa !14
  %36 = icmp eq i32 %32, %35
  br i1 %36, label %37, label %49

37:                                               ; preds = %26
  %38 = getelementptr inbounds %"struct.geometry::types::epa::epaMesh_t", ptr %9, i32 0, i32 1
  %39 = load i32, ptr %6, align 4, !tbaa !9
  %40 = zext i32 %39 to i64
  %41 = getelementptr inbounds [384 x %"struct.geometry::types::minkowskiDiffVertex_t"], ptr %38, i64 0, i64 %40
  %42 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffVertex_t", ptr %41, i32 0, i32 1
  %43 = load i32, ptr %42, align 4, !tbaa !17
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffVertex_t", ptr %44, i32 0, i32 1
  %46 = load i32, ptr %45, align 4, !tbaa !17
  %47 = icmp eq i32 %43, %46
  br i1 %47, label %48, label %49

48:                                               ; preds = %37
  store i1 true, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %66

49:                                               ; preds = %37, %26
  br label %62

50:                                               ; preds = %21, %16
  call void @llvm.lifetime.start.p0(i64 12, ptr %8) #3
  %51 = getelementptr inbounds %"struct.geometry::types::epa::epaMesh_t", ptr %9, i32 0, i32 1
  %52 = load i32, ptr %6, align 4, !tbaa !9
  %53 = zext i32 %52 to i64
  %54 = getelementptr inbounds [384 x %"struct.geometry::types::minkowskiDiffVertex_t"], ptr %51, i64 0, i64 %53
  %55 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffVertex_t", ptr %54, i32 0, i32 2
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffVertex_t", ptr %56, i32 0, i32 2
  call void @_ZNK7Vector3miERKS_(ptr dead_on_unwind writable sret(%class.Vector3) align 4 %8, ptr noundef nonnull align 4 dereferenceable(12) %55, ptr noundef nonnull align 4 dereferenceable(12) %57)
  %58 = call noundef float @_ZNK7Vector316magnitudeSquaredEv(ptr noundef nonnull align 4 dereferenceable(12) %8)
  %59 = fcmp olt float %58, 0x3D06849B80000000
  call void @llvm.lifetime.end.p0(i64 12, ptr %8) #3
  br i1 %59, label %60, label %61

60:                                               ; preds = %50
  store i1 true, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %66

61:                                               ; preds = %50
  br label %62

62:                                               ; preds = %61, %49
  br label %63

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

66:                                               ; preds = %60, %48, %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %67 = load i32, ptr %7, align 4
  switch i32 %67, label %71 [
    i32 2, label %68
    i32 1, label %69
  ]

68:                                               ; preds = %66
  store i1 false, ptr %3, align 1
  br label %69

69:                                               ; preds = %68, %66
  %70 = load i1, ptr %3, align 1
  ret i1 %70

71:                                               ; preds = %66
  unreachable
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK7Vector316magnitudeSquaredEv(ptr noundef nonnull align 4 dereferenceable(12)) #2 align 2

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 = { 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 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 19972}
!12 = !{!"_ZTSN8geometry5types3epa9epaMesh_tE", !13, i64 0, !7, i64 3076, !10, i64 19972}
!13 = !{!"_ZTSN8geometry4mesh17TriangleGraphMeshILj128EEE", !10, i64 0, !7, i64 4}
!14 = !{!15, !10, i64 0}
!15 = !{!"_ZTSN8geometry5types21minkowskiDiffVertex_tE", !10, i64 0, !10, i64 4, !16, i64 8, !16, i64 20, !16, i64 32}
!16 = !{!"_ZTS7Vector3", !7, i64 0}
!17 = !{!15, !10, 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"

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

; 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 uwtable
declare dso_local void @_ZNK7Vector3miERKS_(ptr dead_on_unwind noalias writable sret(%class.Vector3) align 4, ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN8geometry5types3epa9epaMesh_t10vertExistsERKNS0_21minkowskiDiffVertex_tE(ptr noundef nonnull align 4 dereferenceable(19976) %0, ptr noundef nonnull align 4 dereferenceable(44) %1) local_unnamed_addr #1 align 2 {
  %3 = alloca %class.Vector3, align 4
  %4 = getelementptr inbounds i8, ptr %0, i64 3076
  %5 = getelementptr inbounds i8, ptr %0, i64 19972
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %.not1718.not = icmp eq i32 %6, 0
  br i1 %.not1718.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %7 = getelementptr inbounds i8, ptr %1, i64 4
  %8 = getelementptr inbounds i8, ptr %1, i64 8
  br label %9

9:                                                ; preds = %.lr.ph, %26
  %10 = phi i32 [ %6, %.lr.ph ], [ %27, %26 ]
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %26 ]
  %11 = load i32, ptr %1, align 4, !tbaa !11
  %.not = icmp eq i32 %11, -1
  br i1 %.not, label %22, label %12

12:                                               ; preds = %9
  %13 = load i32, ptr %7, align 4, !tbaa !14
  %.not16 = icmp eq i32 %13, -1
  br i1 %.not16, label %22, label %14

14:                                               ; preds = %12
  %15 = getelementptr inbounds [384 x %"struct.geometry::types::minkowskiDiffVertex_t"], ptr %4, i64 0, i64 %indvars.iv
  %16 = load i32, ptr %15, align 4, !tbaa !11
  %17 = icmp eq i32 %16, %11
  br i1 %17, label %18, label %26

18:                                               ; preds = %14
  %19 = getelementptr inbounds i8, ptr %15, i64 4
  %20 = load i32, ptr %19, align 4, !tbaa !14
  %21 = icmp eq i32 %20, %13
  br i1 %21, label %._crit_edge, label %26

22:                                               ; preds = %12, %9
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %3) #3
  %23 = getelementptr inbounds [384 x %"struct.geometry::types::minkowskiDiffVertex_t"], ptr %4, i64 0, i64 %indvars.iv, i32 2
  call void @_ZNK7Vector3miERKS_(ptr dead_on_unwind nonnull writable sret(%class.Vector3) align 4 %3, ptr noundef nonnull align 4 dereferenceable(12) %23, ptr noundef nonnull align 4 dereferenceable(12) %8)
  %24 = call noundef float @_ZNK7Vector316magnitudeSquaredEv(ptr noundef nonnull align 4 dereferenceable(12) %3)
  %25 = fcmp olt float %24, 0x3D06849B80000000
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %3) #3
  br i1 %25, label %._crit_edge, label %._crit_edge26

._crit_edge26:                                    ; preds = %22
  %.pre = load i32, ptr %5, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %._crit_edge26, %18, %14
  %27 = phi i32 [ %.pre, %._crit_edge26 ], [ %10, %18 ], [ %10, %14 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %28 = zext i32 %27 to i64
  %.not17 = icmp ult i64 %indvars.iv.next, %28
  br i1 %.not17, label %9, label %._crit_edge, !llvm.loop !15

._crit_edge:                                      ; preds = %26, %18, %22, %2
  %.not17.lcssa = phi i1 [ false, %2 ], [ true, %22 ], [ true, %18 ], [ false, %26 ]
  ret i1 %.not17.lcssa
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK7Vector316magnitudeSquaredEv(ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #2 align 2

attributes #0 = { mustprogress 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 = { 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 = { 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, !8, i64 19972}
!6 = !{!"_ZTSN8geometry5types3epa9epaMesh_tE", !7, i64 0, !9, i64 3076, !8, i64 19972}
!7 = !{!"_ZTSN8geometry4mesh17TriangleGraphMeshILj128EEE", !8, i64 0, !9, i64 4}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!12, !8, i64 0}
!12 = !{!"_ZTSN8geometry5types21minkowskiDiffVertex_tE", !8, i64 0, !8, i64 4, !13, i64 8, !13, i64 20, !13, i64 32}
!13 = !{!"_ZTS7Vector3", !9, i64 0}
!14 = !{!12, !8, i64 4}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


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