; LLVM IR from jrouwe/JoltPhysics :: TestFramework/Renderer (DebugRendererImp)

; 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.JPH::AABox" = type { %"class.JPH::Vec3", %"class.JPH::Vec3" }
%"class.JPH::Vec3" = type { %union.anon }
%union.anon = type { <4 x float> }
%"class.JPH::DebugRenderer::Vertex" = type { %"class.JPH::Float3", %"class.JPH::Float3", %"class.JPH::Float2", %"class.JPH::Color" }
%"class.JPH::Float3" = type { float, float, float }
%"class.JPH::Float2" = type { float, float }
%"class.JPH::Color" = type { %union.anon.0 }
%union.anon.0 = type { i32 }

; 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: alwaysinline mustprogress uwtable
declare dso_local void @_ZN3JPH4Vec3C2ERKNS_6Float3E(ptr noundef nonnull align 16 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH13DebugRenderer16sCalculateBoundsEPKNS0_6VertexEi(ptr dead_on_unwind noalias writable sret(%"class.JPH::AABox") align 16 %0, ptr noundef %1, i32 noundef %2) #2 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca %"class.JPH::Vec3", align 16
  store ptr %1, ptr %4, align 8, !tbaa !5
  store i32 %2, ptr %5, align 4, !tbaa !9
  call void @_ZN3JPH5AABoxC2Ev(ptr noundef nonnull align 16 dereferenceable(32) %0)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %9, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = load i32, ptr %5, align 4, !tbaa !9
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds %"class.JPH::DebugRenderer::Vertex", ptr %10, i64 %12
  store ptr %13, ptr %7, align 8, !tbaa !5
  br label %14

14:                                               ; preds = %26, %3
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = icmp ult ptr %15, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %29

19:                                               ; preds = %14
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = getelementptr inbounds %"class.JPH::DebugRenderer::Vertex", ptr %20, i32 0, i32 0
  call void @_ZN3JPH4Vec3C2ERKNS_6Float3E(ptr noundef nonnull align 16 dereferenceable(16) %8, ptr noundef nonnull align 4 dereferenceable(12) %21)
  %22 = getelementptr inbounds { double, double }, ptr %8, i32 0, i32 0
  %23 = load double, ptr %22, align 16
  %24 = getelementptr inbounds { double, double }, ptr %8, i32 0, i32 1
  %25 = load double, ptr %24, align 8
  call void @_ZN3JPH5AABox11EncapsulateENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(32) %0, double %23, double %25)
  br label %26

26:                                               ; preds = %19
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = getelementptr inbounds %"class.JPH::DebugRenderer::Vertex", ptr %27, i32 1
  store ptr %28, ptr %6, align 8, !tbaa !5
  br label %14, !llvm.loop !11

29:                                               ; preds = %18
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3JPH5AABoxC2Ev(ptr noundef nonnull align 16 dereferenceable(32)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3JPH5AABox11EncapsulateENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(32), double, double) #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { alwaysinline mustprogress uwtable "min-legal-vector-width"="128" "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 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 = distinct !{!11, !12}
!12 = !{!"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.JPH::AABox" = type { %"class.JPH::Vec3", %"class.JPH::Vec3" }
%"class.JPH::Vec3" = type { %union.anon }
%union.anon = type { <4 x float> }
%"class.JPH::DebugRenderer::Vertex" = type { %"class.JPH::Float3", %"class.JPH::Float3", %"class.JPH::Float2", %"class.JPH::Color" }
%"class.JPH::Float3" = type { float, float, float }
%"class.JPH::Float2" = type { float, float }
%"class.JPH::Color" = type { %union.anon.0 }
%union.anon.0 = type { i32 }

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH13DebugRenderer16sCalculateBoundsEPKNS0_6VertexEi(ptr dead_on_unwind noalias nonnull writable sret(%"class.JPH::AABox") align 16 %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #1 align 2 {
  %4 = alloca %"class.JPH::Vec3", align 16
  tail call void @_ZN3JPH5AABoxC2Ev(ptr noundef nonnull align 16 dereferenceable(32) %0)
  %5 = sext i32 %2 to i64
  %6 = getelementptr inbounds %"class.JPH::DebugRenderer::Vertex", ptr %1, i64 %5
  %7 = icmp sgt i32 %2, 0
  br i1 %7, label %.lr.ph, label %._crit_edge

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

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

9:                                                ; preds = %.lr.ph, %9
  %.06 = phi ptr [ %1, %.lr.ph ], [ %12, %9 ]
  call void @_ZN3JPH4Vec3C2ERKNS_6Float3E(ptr noundef nonnull align 16 dereferenceable(16) %4, ptr noundef nonnull align 4 dereferenceable(12) %.06)
  %10 = load double, ptr %4, align 16
  %11 = load double, ptr %8, align 8
  call void @_ZN3JPH5AABox11EncapsulateENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(32) %0, double %10, double %11)
  %12 = getelementptr inbounds i8, ptr %.06, i64 36
  %13 = icmp ult ptr %12, %6
  br i1 %13, label %9, label %._crit_edge, !llvm.loop !5
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3JPH5AABoxC2Ev(ptr noundef nonnull align 16 dereferenceable(32)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3JPH5AABox11EncapsulateENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(32), double, double) local_unnamed_addr #1 align 2

attributes #0 = { alwaysinline mustprogress uwtable "min-legal-vector-width"="128" "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 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass