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

%"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 }
%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)) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN8geometry5types3epa9epaMesh_t7addVertERKNS0_21minkowskiDiffVertex_tE(ptr noundef nonnull align 4 dereferenceable(19976) %0, ptr noundef nonnull align 4 dereferenceable(44) %1) #0 align 2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %6 = load ptr, ptr %4, align 8
  %7 = getelementptr inbounds %"struct.geometry::types::epa::epaMesh_t", ptr %6, i32 0, i32 2
  %8 = load i32, ptr %7, align 4, !tbaa !9
  %9 = icmp uge i32 %8, 384
  br i1 %9, label %10, label %11

10:                                               ; preds = %2
  store i32 -2, ptr %3, align 4
  br label %63

11:                                               ; preds = %2
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffVertex_t", ptr %12, i32 0, i32 2
  %14 = getelementptr inbounds %"struct.geometry::types::epa::epaMesh_t", ptr %6, i32 0, i32 1
  %15 = getelementptr inbounds %"struct.geometry::types::epa::epaMesh_t", ptr %6, i32 0, i32 2
  %16 = load i32, ptr %15, align 4, !tbaa !9
  %17 = zext i32 %16 to i64
  %18 = getelementptr inbounds [384 x %"struct.geometry::types::minkowskiDiffVertex_t"], ptr %14, i64 0, i64 %17
  %19 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffVertex_t", ptr %18, i32 0, i32 2
  %20 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZN7Vector3aSERKS_(ptr noundef nonnull align 4 dereferenceable(12) %19, ptr noundef nonnull align 4 dereferenceable(12) %13)
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffVertex_t", ptr %21, i32 0, i32 0
  %23 = load i32, ptr %22, align 4, !tbaa !13
  %24 = getelementptr inbounds %"struct.geometry::types::epa::epaMesh_t", ptr %6, i32 0, i32 1
  %25 = getelementptr inbounds %"struct.geometry::types::epa::epaMesh_t", ptr %6, i32 0, i32 2
  %26 = load i32, ptr %25, align 4, !tbaa !9
  %27 = zext i32 %26 to i64
  %28 = getelementptr inbounds [384 x %"struct.geometry::types::minkowskiDiffVertex_t"], ptr %24, i64 0, i64 %27
  %29 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffVertex_t", ptr %28, i32 0, i32 0
  store i32 %23, ptr %29, align 4, !tbaa !13
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffVertex_t", ptr %30, i32 0, i32 1
  %32 = load i32, ptr %31, align 4, !tbaa !16
  %33 = getelementptr inbounds %"struct.geometry::types::epa::epaMesh_t", ptr %6, i32 0, i32 1
  %34 = getelementptr inbounds %"struct.geometry::types::epa::epaMesh_t", ptr %6, i32 0, i32 2
  %35 = load i32, ptr %34, align 4, !tbaa !9
  %36 = zext i32 %35 to i64
  %37 = getelementptr inbounds [384 x %"struct.geometry::types::minkowskiDiffVertex_t"], ptr %33, i64 0, i64 %36
  %38 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffVertex_t", ptr %37, i32 0, i32 1
  store i32 %32, ptr %38, align 4, !tbaa !16
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffVertex_t", ptr %39, i32 0, i32 3
  %41 = getelementptr inbounds %"struct.geometry::types::epa::epaMesh_t", ptr %6, i32 0, i32 1
  %42 = getelementptr inbounds %"struct.geometry::types::epa::epaMesh_t", ptr %6, i32 0, i32 2
  %43 = load i32, ptr %42, align 4, !tbaa !9
  %44 = zext i32 %43 to i64
  %45 = getelementptr inbounds [384 x %"struct.geometry::types::minkowskiDiffVertex_t"], ptr %41, i64 0, i64 %44
  %46 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffVertex_t", ptr %45, i32 0, i32 3
  %47 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZN7Vector3aSERKS_(ptr noundef nonnull align 4 dereferenceable(12) %46, ptr noundef nonnull align 4 dereferenceable(12) %40)
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffVertex_t", ptr %48, i32 0, i32 4
  %50 = getelementptr inbounds %"struct.geometry::types::epa::epaMesh_t", ptr %6, i32 0, i32 1
  %51 = getelementptr inbounds %"struct.geometry::types::epa::epaMesh_t", ptr %6, i32 0, i32 2
  %52 = load i32, ptr %51, align 4, !tbaa !9
  %53 = zext i32 %52 to i64
  %54 = getelementptr inbounds [384 x %"struct.geometry::types::minkowskiDiffVertex_t"], ptr %50, i64 0, i64 %53
  %55 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffVertex_t", ptr %54, i32 0, i32 4
  %56 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZN7Vector3aSERKS_(ptr noundef nonnull align 4 dereferenceable(12) %55, ptr noundef nonnull align 4 dereferenceable(12) %49)
  %57 = getelementptr inbounds %"struct.geometry::types::epa::epaMesh_t", ptr %6, i32 0, i32 2
  %58 = load i32, ptr %57, align 4, !tbaa !9
  %59 = add i32 %58, 1
  store i32 %59, ptr %57, align 4, !tbaa !9
  %60 = getelementptr inbounds %"struct.geometry::types::epa::epaMesh_t", ptr %6, i32 0, i32 2
  %61 = load i32, ptr %60, align 4, !tbaa !9
  %62 = sub i32 %61, 1
  store i32 %62, ptr %3, align 4
  br label %63

63:                                               ; preds = %11, %10
  %64 = load i32, ptr %3, align 4
  ret i32 %64
}

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

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


; 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
define dso_local noundef i32 @_ZN8geometry5types3epa9epaMesh_t7addVertERKNS0_21minkowskiDiffVertex_tE(ptr noundef nonnull align 4 dereferenceable(19976) %0, ptr noundef nonnull align 4 dereferenceable(44) %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 19972
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %5 = icmp ugt i32 %4, 383
  br i1 %5, label %26, label %6

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %1, i64 8
  %8 = getelementptr inbounds i8, ptr %0, i64 3076
  %9 = zext nneg i32 %4 to i64
  %10 = getelementptr inbounds [384 x %"struct.geometry::types::minkowskiDiffVertex_t"], ptr %8, i64 0, i64 %9, i32 2
  %11 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZN7Vector3aSERKS_(ptr noundef nonnull align 4 dereferenceable(12) %10, ptr noundef nonnull align 4 dereferenceable(12) %7)
  %12 = load i32, ptr %3, align 4, !tbaa !5
  %13 = zext i32 %12 to i64
  %14 = getelementptr inbounds [384 x %"struct.geometry::types::minkowskiDiffVertex_t"], ptr %8, i64 0, i64 %13
  %15 = load <2 x i32>, ptr %1, align 4, !tbaa !11
  store <2 x i32> %15, ptr %14, align 4, !tbaa !11
  %16 = getelementptr inbounds i8, ptr %1, i64 20
  %17 = getelementptr inbounds [384 x %"struct.geometry::types::minkowskiDiffVertex_t"], ptr %8, i64 0, i64 %13, i32 3
  %18 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZN7Vector3aSERKS_(ptr noundef nonnull align 4 dereferenceable(12) %17, ptr noundef nonnull align 4 dereferenceable(12) %16)
  %19 = getelementptr inbounds i8, ptr %1, i64 32
  %20 = load i32, ptr %3, align 4, !tbaa !5
  %21 = zext i32 %20 to i64
  %22 = getelementptr inbounds [384 x %"struct.geometry::types::minkowskiDiffVertex_t"], ptr %8, i64 0, i64 %21, i32 4
  %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) %19)
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = add i32 %24, 1
  store i32 %25, ptr %3, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %2, %6
  %.0 = phi i32 [ %24, %6 ], [ -2, %2 ]
  ret i32 %.0
}

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

!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 = !{!8, !8, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass