; LLVM IR from Slingshot-Physics/slingshot-community :: tests/test_utils (transform_utils)

; 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::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 }
%"struct.geometry::types::convexPolyhedron_t" = type { i32, [500 x %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 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: mustprogress uwtable
define dso_local void @_ZN10test_utils40convert_triangleMesh_to_convexPolyhedronERKN8geometry5types14triangleMesh_tERNS1_18convexPolyhedron_tE(ptr noundef nonnull align 4 dereferenceable(30008) %0, ptr noundef nonnull align 4 dereferenceable(6016) %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca %class.Vector3, align 4
  %7 = alloca i32, align 4
  %8 = alloca float, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %9

9:                                                ; preds = %28, %2
  %10 = load i32, ptr %5, align 4, !tbaa !9
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %"struct.geometry::types::triangleMesh_t", ptr %11, i32 0, i32 1
  %13 = load i32, ptr %12, align 4, !tbaa !11
  %14 = icmp ult i32 %10, %13
  br i1 %14, label %16, label %15

15:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %31

16:                                               ; preds = %9
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %"struct.geometry::types::triangleMesh_t", ptr %17, i32 0, i32 3
  %19 = load i32, ptr %5, align 4, !tbaa !9
  %20 = zext i32 %19 to i64
  %21 = getelementptr inbounds [500 x %class.Vector3], ptr %18, i64 0, i64 %20
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %"struct.geometry::types::convexPolyhedron_t", ptr %22, i32 0, i32 1
  %24 = load i32, ptr %5, align 4, !tbaa !9
  %25 = zext i32 %24 to i64
  %26 = getelementptr inbounds [500 x %class.Vector3], ptr %23, i64 0, i64 %25
  %27 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZN7Vector3aSERKS_(ptr noundef nonnull align 4 dereferenceable(12) %26, ptr noundef nonnull align 4 dereferenceable(12) %21)
  br label %28

28:                                               ; preds = %16
  %29 = load i32, ptr %5, align 4, !tbaa !9
  %30 = add i32 %29, 1
  store i32 %30, ptr %5, align 4, !tbaa !9
  br label %9, !llvm.loop !13

31:                                               ; preds = %15
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds %"struct.geometry::types::triangleMesh_t", ptr %32, i32 0, i32 1
  %34 = load i32, ptr %33, align 4, !tbaa !11
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %"struct.geometry::types::convexPolyhedron_t", ptr %35, i32 0, i32 0
  store i32 %34, ptr %36, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 12, ptr %6) #3
  call void @_ZN7Vector3C2Efff(ptr noundef nonnull align 4 dereferenceable(12) %6, float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 0.000000e+00)
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %"struct.geometry::types::convexPolyhedron_t", ptr %37, i32 0, i32 2
  %39 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZN7Vector3aSERKS_(ptr noundef nonnull align 4 dereferenceable(12) %38, ptr noundef nonnull align 4 dereferenceable(12) %6)
  call void @llvm.lifetime.end.p0(i64 12, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %40

40:                                               ; preds = %56, %31
  %41 = load i32, ptr %7, align 4, !tbaa !9
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %"struct.geometry::types::convexPolyhedron_t", ptr %42, i32 0, i32 0
  %44 = load i32, ptr %43, align 4, !tbaa !15
  %45 = icmp ult i32 %41, %44
  br i1 %45, label %47, label %46

46:                                               ; preds = %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %59

47:                                               ; preds = %40
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %"struct.geometry::types::triangleMesh_t", ptr %48, i32 0, i32 3
  %50 = load i32, ptr %7, align 4, !tbaa !9
  %51 = zext i32 %50 to i64
  %52 = getelementptr inbounds [500 x %class.Vector3], ptr %49, i64 0, i64 %51
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = getelementptr inbounds %"struct.geometry::types::convexPolyhedron_t", ptr %53, i32 0, i32 2
  %55 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZN7Vector3pLERKS_(ptr noundef nonnull align 4 dereferenceable(12) %54, ptr noundef nonnull align 4 dereferenceable(12) %52)
  br label %56

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

59:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = getelementptr inbounds %"struct.geometry::types::convexPolyhedron_t", ptr %60, i32 0, i32 0
  %62 = load i32, ptr %61, align 4, !tbaa !15
  %63 = uitofp i32 %62 to float
  store float %63, ptr %8, align 4, !tbaa !19
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds %"struct.geometry::types::convexPolyhedron_t", ptr %64, i32 0, i32 2
  %66 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZN7Vector3dVERKf(ptr noundef nonnull align 4 dereferenceable(12) %65, ptr noundef nonnull align 4 dereferenceable(4) %8)
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  ret void
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZN7Vector3dVERKf(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(4)) #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 4}
!12 = !{!"_ZTSN8geometry5types14triangleMesh_tE", !10, i64 0, !10, i64 4, !7, i64 8, !7, i64 24008}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !10, i64 0}
!16 = !{!"_ZTSN8geometry5types18convexPolyhedron_tE", !10, i64 0, !7, i64 4, !17, i64 6004}
!17 = !{!"_ZTS7Vector3", !7, i64 0}
!18 = distinct !{!18, !14}
!19 = !{!20, !20, i64 0}
!20 = !{!"float", !7, i64 0}


; 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] }

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10test_utils40convert_triangleMesh_to_convexPolyhedronERKN8geometry5types14triangleMesh_tERNS1_18convexPolyhedron_tE(ptr noundef nonnull align 4 dereferenceable(30008) %0, ptr noundef nonnull align 4 dereferenceable(6016) %1) local_unnamed_addr #1 {
  %3 = alloca %class.Vector3, align 4
  %4 = alloca float, align 4
  %5 = getelementptr inbounds i8, ptr %0, i64 4
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

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

._crit_edge:                                      ; preds = %13, %2
  %.lcssa19 = phi i32 [ 0, %2 ], [ %17, %13 ]
  store i32 %.lcssa19, ptr %1, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %3) #3
  call void @_ZN7Vector3C2Efff(ptr noundef nonnull align 4 dereferenceable(12) %3, float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 0.000000e+00)
  %9 = getelementptr inbounds i8, ptr %1, i64 6004
  %10 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZN7Vector3aSERKS_(ptr noundef nonnull align 4 dereferenceable(12) %9, ptr noundef nonnull align 4 dereferenceable(12) %3)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %3) #3
  %11 = load i32, ptr %1, align 4, !tbaa !10
  %.not26 = icmp eq i32 %11, 0
  br i1 %.not26, label %._crit_edge24, label %.lr.ph23

.lr.ph23:                                         ; preds = %._crit_edge
  %12 = getelementptr inbounds i8, ptr %0, i64 24008
  br label %22

13:                                               ; preds = %.lr.ph, %13
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %13 ]
  %14 = getelementptr inbounds [500 x %class.Vector3], ptr %7, i64 0, i64 %indvars.iv
  %15 = getelementptr inbounds [500 x %class.Vector3], ptr %8, i64 0, i64 %indvars.iv
  %16 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZN7Vector3aSERKS_(ptr noundef nonnull align 4 dereferenceable(12) %15, ptr noundef nonnull align 4 dereferenceable(12) %14)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %17 = load i32, ptr %5, align 4, !tbaa !5
  %18 = zext i32 %17 to i64
  %19 = icmp ult i64 %indvars.iv.next, %18
  br i1 %19, label %13, label %._crit_edge, !llvm.loop !13

._crit_edge24.loopexit:                           ; preds = %22
  %20 = uitofp i32 %25 to float
  br label %._crit_edge24

._crit_edge24:                                    ; preds = %._crit_edge24.loopexit, %._crit_edge
  %.lcssa = phi float [ 0.000000e+00, %._crit_edge ], [ %20, %._crit_edge24.loopexit ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #3
  store float %.lcssa, ptr %4, align 4, !tbaa !15
  %21 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZN7Vector3dVERKf(ptr noundef nonnull align 4 dereferenceable(12) %9, ptr noundef nonnull align 4 dereferenceable(4) %4)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #3
  ret void

22:                                               ; preds = %.lr.ph23, %22
  %indvars.iv30 = phi i64 [ 0, %.lr.ph23 ], [ %indvars.iv.next31, %22 ]
  %23 = getelementptr inbounds [500 x %class.Vector3], ptr %12, i64 0, i64 %indvars.iv30
  %24 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZN7Vector3pLERKS_(ptr noundef nonnull align 4 dereferenceable(12) %9, ptr noundef nonnull align 4 dereferenceable(12) %23)
  %indvars.iv.next31 = add nuw nsw i64 %indvars.iv30, 1
  %25 = load i32, ptr %1, align 4, !tbaa !10
  %26 = zext i32 %25 to i64
  %27 = icmp ult i64 %indvars.iv.next31, %26
  br i1 %27, label %22, label %._crit_edge24.loopexit, !llvm.loop !17
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZN7Vector3dVERKf(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(4)) 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, !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 = !{!11, !7, i64 0}
!11 = !{!"_ZTSN8geometry5types18convexPolyhedron_tE", !7, i64 0, !8, i64 4, !12, i64 6004}
!12 = !{!"_ZTS7Vector3", !8, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !16, i64 0}
!16 = !{!"float", !8, i64 0}
!17 = distinct !{!17, !14}


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