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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8geometry14supportMappingERK7Vector3RKNS_5types18convexPolyhedron_tE(ptr dead_on_unwind noalias writable sret(%"struct.geometry::types::labeledVertex_t") align 4 %0, ptr noundef nonnull align 4 dereferenceable(12) %1, ptr noundef nonnull align 4 dereferenceable(6016) %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca float, align 4
  %8 = alloca %class.Vector3, align 4
  %9 = alloca i32, align 4
  %10 = alloca float, align 4
  %11 = alloca %class.Vector3, align 4
  store ptr %0, ptr %4, align 8
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 12, ptr %8) #2
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = getelementptr inbounds %"struct.geometry::types::convexPolyhedron_t", ptr %12, i32 0, i32 1
  %14 = getelementptr inbounds [500 x %class.Vector3], ptr %13, i64 0, i64 0
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = getelementptr inbounds %"struct.geometry::types::convexPolyhedron_t", ptr %15, 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) %14, ptr noundef nonnull align 4 dereferenceable(12) %16)
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = call noundef float @_ZNK7Vector33dotERKS_(ptr noundef nonnull align 4 dereferenceable(12) %8, ptr noundef nonnull align 4 dereferenceable(12) %17)
  call void @llvm.lifetime.end.p0(i64 12, ptr %8) #2
  store float %18, ptr %7, align 4, !tbaa !9
  %19 = getelementptr inbounds %"struct.geometry::types::labeledVertex_t", ptr %0, i32 0, i32 0
  store i32 0, ptr %19, align 4, !tbaa !11
  %20 = getelementptr inbounds %"struct.geometry::types::labeledVertex_t", ptr %0, i32 0, i32 1
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = getelementptr inbounds %"struct.geometry::types::convexPolyhedron_t", ptr %21, i32 0, i32 1
  %23 = getelementptr inbounds [500 x %class.Vector3], ptr %22, i64 0, i64 0
  call void @_ZN7Vector3C2ERKS_(ptr noundef nonnull align 4 dereferenceable(12) %20, ptr noundef nonnull align 4 dereferenceable(12) %23)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  store i32 1, ptr %9, align 4, !tbaa !15
  br label %24

24:                                               ; preds = %56, %3
  %25 = load i32, ptr %9, align 4, !tbaa !15
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = getelementptr inbounds %"struct.geometry::types::convexPolyhedron_t", ptr %26, i32 0, i32 0
  %28 = load i32, ptr %27, align 4, !tbaa !16
  %29 = icmp ult i32 %25, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  br label %59

31:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.start.p0(i64 12, ptr %11) #2
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = getelementptr inbounds %"struct.geometry::types::convexPolyhedron_t", ptr %32, i32 0, i32 1
  %34 = load i32, ptr %9, align 4, !tbaa !15
  %35 = zext i32 %34 to i64
  %36 = getelementptr inbounds [500 x %class.Vector3], ptr %33, i64 0, i64 %35
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = getelementptr inbounds %"struct.geometry::types::convexPolyhedron_t", ptr %37, i32 0, i32 2
  call void @_ZNK7Vector3miERKS_(ptr dead_on_unwind writable sret(%class.Vector3) align 4 %11, ptr noundef nonnull align 4 dereferenceable(12) %36, ptr noundef nonnull align 4 dereferenceable(12) %38)
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = call noundef float @_ZNK7Vector33dotERKS_(ptr noundef nonnull align 4 dereferenceable(12) %11, ptr noundef nonnull align 4 dereferenceable(12) %39)
  call void @llvm.lifetime.end.p0(i64 12, ptr %11) #2
  store float %40, ptr %10, align 4, !tbaa !9
  %41 = load float, ptr %10, align 4, !tbaa !9
  %42 = load float, ptr %7, align 4, !tbaa !9
  %43 = fcmp ogt float %41, %42
  br i1 %43, label %44, label %55

44:                                               ; preds = %31
  %45 = load float, ptr %10, align 4, !tbaa !9
  store float %45, ptr %7, align 4, !tbaa !9
  %46 = load i32, ptr %9, align 4, !tbaa !15
  %47 = getelementptr inbounds %"struct.geometry::types::labeledVertex_t", ptr %0, i32 0, i32 0
  store i32 %46, ptr %47, align 4, !tbaa !11
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = getelementptr inbounds %"struct.geometry::types::convexPolyhedron_t", ptr %48, i32 0, i32 1
  %50 = load i32, ptr %9, align 4, !tbaa !15
  %51 = zext i32 %50 to i64
  %52 = getelementptr inbounds [500 x %class.Vector3], ptr %49, i64 0, i64 %51
  %53 = getelementptr inbounds %"struct.geometry::types::labeledVertex_t", ptr %0, i32 0, i32 1
  %54 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZN7Vector3aSERKS_(ptr noundef nonnull align 4 dereferenceable(12) %53, ptr noundef nonnull align 4 dereferenceable(12) %52)
  br label %55

55:                                               ; preds = %44, %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  br label %56

56:                                               ; preds = %55
  %57 = load i32, ptr %9, align 4, !tbaa !15
  %58 = add i32 %57, 1
  store i32 %58, ptr %9, align 4, !tbaa !15
  br label %24, !llvm.loop !18

59:                                               ; preds = %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  ret void
}

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

; 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)) #0 align 2

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

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

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

; 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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = !{!"float", !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"_ZTSN8geometry5types15labeledVertex_tE", !13, i64 0, !14, i64 4}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTS7Vector3", !7, i64 0}
!15 = !{!13, !13, i64 0}
!16 = !{!17, !13, i64 0}
!17 = !{!"_ZTSN8geometry5types18convexPolyhedron_tE", !13, i64 0, !7, i64 4, !14, i64 6004}
!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::labeledVertex_t" = type { i32, %class.Vector3 }
%class.Vector3 = type { [3 x float] }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8geometry14supportMappingERK7Vector3RKNS_5types18convexPolyhedron_tE(ptr dead_on_unwind noalias writable sret(%"struct.geometry::types::labeledVertex_t") align 4 %0, ptr noundef nonnull align 4 dereferenceable(12) %1, ptr noundef nonnull align 4 dereferenceable(6016) %2) local_unnamed_addr #0 {
  %4 = alloca %class.Vector3, align 4
  %5 = alloca %class.Vector3, align 4
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %4) #2
  %6 = getelementptr inbounds i8, ptr %2, i64 4
  %7 = getelementptr inbounds i8, ptr %2, i64 6004
  call void @_ZNK7Vector3miERKS_(ptr dead_on_unwind nonnull writable sret(%class.Vector3) align 4 %4, ptr noundef nonnull align 4 dereferenceable(12) %6, ptr noundef nonnull align 4 dereferenceable(12) %7)
  %8 = call noundef float @_ZNK7Vector33dotERKS_(ptr noundef nonnull align 4 dereferenceable(12) %4, ptr noundef nonnull align 4 dereferenceable(12) %1)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %4) #2
  store i32 0, ptr %0, align 4, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 4
  call void @_ZN7Vector3C2ERKS_(ptr noundef nonnull align 4 dereferenceable(12) %9, ptr noundef nonnull align 4 dereferenceable(12) %6)
  %10 = load i32, ptr %2, align 4, !tbaa !11
  %11 = icmp ugt i32 %10, 1
  br i1 %11, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %18, %3
  ret void

.lr.ph:                                           ; preds = %3, %18
  %indvars.iv = phi i64 [ %indvars.iv.next, %18 ], [ 1, %3 ]
  %.019 = phi float [ %.1, %18 ], [ %8, %3 ]
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %5) #2
  %12 = getelementptr inbounds [500 x %class.Vector3], ptr %6, i64 0, i64 %indvars.iv
  call void @_ZNK7Vector3miERKS_(ptr dead_on_unwind nonnull writable sret(%class.Vector3) align 4 %5, ptr noundef nonnull align 4 dereferenceable(12) %12, ptr noundef nonnull align 4 dereferenceable(12) %7)
  %13 = call noundef float @_ZNK7Vector33dotERKS_(ptr noundef nonnull align 4 dereferenceable(12) %5, ptr noundef nonnull align 4 dereferenceable(12) %1)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %5) #2
  %14 = fcmp ogt float %13, %.019
  br i1 %14, label %15, label %18

15:                                               ; preds = %.lr.ph
  %16 = trunc nuw i64 %indvars.iv to i32
  store i32 %16, ptr %0, align 4, !tbaa !5
  %17 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZN7Vector3aSERKS_(ptr noundef nonnull align 4 dereferenceable(12) %9, ptr noundef nonnull align 4 dereferenceable(12) %12)
  br label %18

18:                                               ; preds = %15, %.lr.ph
  %.1 = phi float [ %13, %15 ], [ %.019, %.lr.ph ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %19 = load i32, ptr %2, align 4, !tbaa !11
  %20 = zext i32 %19 to i64
  %21 = icmp ult i64 %indvars.iv.next, %20
  br i1 %21, label %.lr.ph, label %._crit_edge, !llvm.loop !13
}

; 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 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 #0 align 2

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

; 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 uwtable
declare dso_local void @_ZN7Vector3C2ERKS_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #0 align 2

; 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

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = !{!"_ZTSN8geometry5types15labeledVertex_tE", !7, i64 0, !10, i64 4}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTS7Vector3", !8, i64 0}
!11 = !{!12, !7, i64 0}
!12 = !{!"_ZTSN8geometry5types18convexPolyhedron_tE", !7, i64 0, !8, i64 4, !10, i64 6004}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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