; LLVM IR from jrouwe/JoltPhysics :: Jolt/Geometry/ConvexHullBuilder.ll (ZN3JPH17ConvexHullBuilder11sUnlinkFaceEPNS0_4FaceE)

; 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.JPH::AssertLastParam" = type { i8 }
%"class.JPH::ConvexHullBuilder::Face" = type <{ %"class.JPH::Vec3", %"class.JPH::Vec3", %"class.JPH::Array", ptr, float, i8, [11 x i8] }>
%"class.JPH::Vec3" = type { %union.anon }
%union.anon = type { <4 x float> }
%"class.JPH::Array" = type { i64, i64, ptr }
%"class.JPH::ConvexHullBuilder::Edge" = type <{ ptr, ptr, ptr, i32, [4 x i8] }>

@.str.1 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [39 x i8], align 1

; 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: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef, ptr noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH17ConvexHullBuilder11sUnlinkFaceEPNS0_4FaceE(ptr noundef %0) #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca %"struct.JPH::AssertLastParam", align 1
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds %"class.JPH::ConvexHullBuilder::Face", ptr %5, i32 0, i32 3
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  store ptr %7, ptr %3, align 8, !tbaa !5
  br label %8

8:                                                ; preds = %38, %1
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %"class.JPH::ConvexHullBuilder::Edge", ptr %9, i32 0, i32 2
  %11 = load ptr, ptr %10, align 8, !tbaa !16
  %12 = icmp ne ptr %11, null
  br i1 %12, label %13, label %34

13:                                               ; preds = %8
  br label %14

14:                                               ; preds = %13
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %"class.JPH::ConvexHullBuilder::Edge", ptr %15, i32 0, i32 2
  %17 = load ptr, ptr %16, align 8, !tbaa !16
  %18 = getelementptr inbounds %"class.JPH::ConvexHullBuilder::Edge", ptr %17, i32 0, i32 2
  %19 = load ptr, ptr %18, align 8, !tbaa !16
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = icmp eq ptr %19, %20
  br i1 %21, label %25, label %22

22:                                               ; preds = %14
  %23 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.18, ptr noundef @.str.1, i32 noundef 763)
  br i1 %23, label %24, label %25

24:                                               ; preds = %22
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #3, !srcloc !19
  br label %25

25:                                               ; preds = %24, %22, %14
  br label %26

26:                                               ; preds = %25
  br label %27

27:                                               ; preds = %26
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %"class.JPH::ConvexHullBuilder::Edge", ptr %28, i32 0, i32 2
  %30 = load ptr, ptr %29, align 8, !tbaa !16
  %31 = getelementptr inbounds %"class.JPH::ConvexHullBuilder::Edge", ptr %30, i32 0, i32 2
  store ptr null, ptr %31, align 8, !tbaa !16
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds %"class.JPH::ConvexHullBuilder::Edge", ptr %32, i32 0, i32 2
  store ptr null, ptr %33, align 8, !tbaa !16
  br label %34

34:                                               ; preds = %27, %8
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %"class.JPH::ConvexHullBuilder::Edge", ptr %35, i32 0, i32 1
  %37 = load ptr, ptr %36, align 8, !tbaa !20
  store ptr %37, ptr %3, align 8, !tbaa !5
  br label %38

38:                                               ; preds = %34
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = getelementptr inbounds %"class.JPH::ConvexHullBuilder::Face", ptr %40, i32 0, i32 3
  %42 = load ptr, ptr %41, align 8, !tbaa !9
  %43 = icmp ne ptr %39, %42
  br i1 %43, label %8, label %44, !llvm.loop !21

44:                                               ; preds = %38
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 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, !6, i64 56}
!10 = !{!"_ZTSN3JPH17ConvexHullBuilder4FaceE", !11, i64 0, !11, i64 16, !12, i64 32, !6, i64 56, !14, i64 64, !15, i64 68}
!11 = !{!"_ZTSN3JPH4Vec3E", !7, i64 0}
!12 = !{!"_ZTSN3JPH5ArrayIiNS_12STLAllocatorIiEEEE", !13, i64 0, !13, i64 8, !6, i64 16}
!13 = !{!"long", !7, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = !{!"bool", !7, i64 0}
!16 = !{!17, !6, i64 16}
!17 = !{!"_ZTSN3JPH17ConvexHullBuilder4EdgeE", !6, i64 0, !6, i64 8, !6, i64 16, !18, i64 24}
!18 = !{!"int", !7, i64 0}
!19 = !{i64 2157048613}
!20 = !{!17, !6, i64 8}
!21 = distinct !{!21, !22}
!22 = !{!"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"

@.str.1 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [39 x i8], align 1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH17ConvexHullBuilder11sUnlinkFaceEPNS0_4FaceE(ptr nocapture noundef readonly %0) local_unnamed_addr #1 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 56
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  br label %4

4:                                                ; preds = %18, %1
  %5 = phi ptr [ %3, %1 ], [ %19, %18 ]
  %.0 = phi ptr [ %3, %1 ], [ %21, %18 ]
  %6 = getelementptr inbounds i8, ptr %.0, i64 16
  %7 = load ptr, ptr %6, align 8, !tbaa !15
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %18, label %8

8:                                                ; preds = %4
  %9 = getelementptr inbounds i8, ptr %7, i64 16
  %10 = load ptr, ptr %9, align 8, !tbaa !15
  %11 = icmp eq ptr %10, %.0
  br i1 %11, label %15, label %12

12:                                               ; preds = %8
  %13 = tail call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.18, ptr noundef nonnull @.str.1, i32 noundef 763)
  br i1 %13, label %14, label %15

14:                                               ; preds = %12
  tail call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #2, !srcloc !18
  br label %15

15:                                               ; preds = %14, %12, %8
  %16 = load ptr, ptr %6, align 8, !tbaa !15
  %17 = getelementptr inbounds i8, ptr %16, i64 16
  store ptr null, ptr %17, align 8, !tbaa !15
  store ptr null, ptr %6, align 8, !tbaa !15
  %.pre = load ptr, ptr %2, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %15, %4
  %19 = phi ptr [ %.pre, %15 ], [ %5, %4 ]
  %20 = getelementptr inbounds i8, ptr %.0, i64 8
  %21 = load ptr, ptr %20, align 8, !tbaa !19
  %.not11 = icmp eq ptr %21, %19
  br i1 %.not11, label %22, label %4, !llvm.loop !20

22:                                               ; preds = %18
  ret void
}

attributes #0 = { inlinehint 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 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 = { 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, !12, i64 56}
!6 = !{!"_ZTSN3JPH17ConvexHullBuilder4FaceE", !7, i64 0, !7, i64 16, !10, i64 32, !12, i64 56, !13, i64 64, !14, i64 68}
!7 = !{!"_ZTSN3JPH4Vec3E", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN3JPH5ArrayIiNS_12STLAllocatorIiEEEE", !11, i64 0, !11, i64 8, !12, i64 16}
!11 = !{!"long", !8, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!"float", !8, i64 0}
!14 = !{!"bool", !8, i64 0}
!15 = !{!16, !12, i64 16}
!16 = !{!"_ZTSN3JPH17ConvexHullBuilder4EdgeE", !12, i64 0, !12, i64 8, !12, i64 16, !17, i64 24}
!17 = !{!"int", !8, i64 0}
!18 = !{i64 2157048613}
!19 = !{!16, !12, i64 8}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass