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

; 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.24 = external hidden unnamed_addr constant [18 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
declare dso_local void @_ZN3JPH17ConvexHullBuilder13sMarkAffectedEPNS0_4FaceERNS_5ArrayIS2_NS_12STLAllocatorIS2_EEEE(ptr noundef, ptr noundef nonnull align 8 dereferenceable(24)) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK3JPH17ConvexHullBuilder17RemoveTwoEdgeFaceEPNS0_4FaceERNS_5ArrayIS2_NS_12STLAllocatorIS2_EEEE(ptr noundef nonnull align 8 dereferenceable(56) %0, ptr noundef %1, ptr noundef nonnull align 8 dereferenceable(24) %2) #2 align 2 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca %"struct.JPH::AssertLastParam", align 1
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %16 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = getelementptr inbounds %"class.JPH::ConvexHullBuilder::Face", ptr %17, i32 0, i32 3
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  store ptr %19, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = getelementptr inbounds %"class.JPH::ConvexHullBuilder::Edge", ptr %20, i32 0, i32 1
  %22 = load ptr, ptr %21, align 8, !tbaa !16
  store ptr %22, ptr %9, align 8, !tbaa !5
  br label %23

23:                                               ; preds = %3
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  %25 = load ptr, ptr %9, align 8, !tbaa !5
  %26 = icmp ne ptr %24, %25
  br i1 %26, label %30, label %27

27:                                               ; preds = %23
  %28 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.24, ptr noundef @.str.1, i32 noundef 1139)
  br i1 %28, label %29, label %30

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

30:                                               ; preds = %29, %27, %23
  br label %31

31:                                               ; preds = %30
  br label %32

32:                                               ; preds = %31
  %33 = load ptr, ptr %9, align 8, !tbaa !5
  %34 = getelementptr inbounds %"class.JPH::ConvexHullBuilder::Edge", ptr %33, i32 0, i32 1
  %35 = load ptr, ptr %34, align 8, !tbaa !16
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = icmp eq ptr %35, %36
  br i1 %37, label %38, label %67

38:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = getelementptr inbounds %"class.JPH::ConvexHullBuilder::Edge", ptr %39, i32 0, i32 2
  %41 = load ptr, ptr %40, align 8, !tbaa !20
  store ptr %41, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %42 = load ptr, ptr %11, align 8, !tbaa !5
  %43 = getelementptr inbounds %"class.JPH::ConvexHullBuilder::Edge", ptr %42, i32 0, i32 0
  %44 = load ptr, ptr %43, align 8, !tbaa !21
  store ptr %44, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  %46 = getelementptr inbounds %"class.JPH::ConvexHullBuilder::Edge", ptr %45, i32 0, i32 2
  %47 = load ptr, ptr %46, align 8, !tbaa !20
  store ptr %47, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %48 = load ptr, ptr %13, align 8, !tbaa !5
  %49 = getelementptr inbounds %"class.JPH::ConvexHullBuilder::Edge", ptr %48, i32 0, i32 0
  %50 = load ptr, ptr %49, align 8, !tbaa !21
  store ptr %50, ptr %14, align 8, !tbaa !5
  %51 = load ptr, ptr %12, align 8, !tbaa !5
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  call void @_ZN3JPH17ConvexHullBuilder13sMarkAffectedEPNS0_4FaceERNS_5ArrayIS2_NS_12STLAllocatorIS2_EEEE(ptr noundef %51, ptr noundef nonnull align 8 dereferenceable(24) %52)
  %53 = load ptr, ptr %14, align 8, !tbaa !5
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  call void @_ZN3JPH17ConvexHullBuilder13sMarkAffectedEPNS0_4FaceERNS_5ArrayIS2_NS_12STLAllocatorIS2_EEEE(ptr noundef %53, ptr noundef nonnull align 8 dereferenceable(24) %54)
  %55 = load ptr, ptr %13, align 8, !tbaa !5
  %56 = load ptr, ptr %11, align 8, !tbaa !5
  %57 = getelementptr inbounds %"class.JPH::ConvexHullBuilder::Edge", ptr %56, i32 0, i32 2
  store ptr %55, ptr %57, align 8, !tbaa !20
  %58 = load ptr, ptr %11, align 8, !tbaa !5
  %59 = load ptr, ptr %13, align 8, !tbaa !5
  %60 = getelementptr inbounds %"class.JPH::ConvexHullBuilder::Edge", ptr %59, i32 0, i32 2
  store ptr %58, ptr %60, align 8, !tbaa !20
  %61 = load ptr, ptr %8, align 8, !tbaa !5
  %62 = getelementptr inbounds %"class.JPH::ConvexHullBuilder::Edge", ptr %61, i32 0, i32 2
  store ptr null, ptr %62, align 8, !tbaa !20
  %63 = load ptr, ptr %9, align 8, !tbaa !5
  %64 = getelementptr inbounds %"class.JPH::ConvexHullBuilder::Edge", ptr %63, i32 0, i32 2
  store ptr null, ptr %64, align 8, !tbaa !20
  %65 = load ptr, ptr %6, align 8, !tbaa !5
  %66 = getelementptr inbounds %"class.JPH::ConvexHullBuilder::Face", ptr %65, i32 0, i32 5
  store i8 1, ptr %66, align 4, !tbaa !22
  store i1 true, ptr %4, align 1
  store i32 1, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  br label %68

67:                                               ; preds = %32
  store i1 false, ptr %4, align 1
  store i32 1, ptr %15, align 4
  br label %68

68:                                               ; preds = %67, %38
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %69 = load i1, ptr %4, align 1
  ret i1 %69
}

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 8}
!17 = !{!"_ZTSN3JPH17ConvexHullBuilder4EdgeE", !6, i64 0, !6, i64 8, !6, i64 16, !18, i64 24}
!18 = !{!"int", !7, i64 0}
!19 = !{i64 2157050752}
!20 = !{!17, !6, i64 16}
!21 = !{!17, !6, i64 0}
!22 = !{!10, !15, i64 68}


; 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.24 = external hidden unnamed_addr constant [18 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
declare dso_local void @_ZN3JPH17ConvexHullBuilder13sMarkAffectedEPNS0_4FaceERNS_5ArrayIS2_NS_12STLAllocatorIS2_EEEE(ptr noundef, ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK3JPH17ConvexHullBuilder17RemoveTwoEdgeFaceEPNS0_4FaceERNS_5ArrayIS2_NS_12STLAllocatorIS2_EEEE(ptr nocapture noundef nonnull readnone align 8 dereferenceable(56) %0, ptr nocapture noundef %1, ptr noundef nonnull align 8 dereferenceable(24) %2) local_unnamed_addr #1 align 2 {
  %4 = getelementptr inbounds i8, ptr %1, i64 56
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %5, i64 8
  %7 = load ptr, ptr %6, align 8, !tbaa !15
  %.not = icmp eq ptr %5, %7
  br i1 %.not, label %8, label %11

8:                                                ; preds = %3
  %9 = tail call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.24, ptr noundef nonnull @.str.1, i32 noundef 1139)
  br i1 %9, label %10, label %11

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

11:                                               ; preds = %10, %8, %3
  %12 = getelementptr inbounds i8, ptr %7, i64 8
  %13 = load ptr, ptr %12, align 8, !tbaa !15
  %14 = icmp eq ptr %13, %5
  br i1 %14, label %15, label %25

15:                                               ; preds = %11
  %16 = getelementptr inbounds i8, ptr %5, i64 16
  %17 = load ptr, ptr %16, align 8, !tbaa !19
  %18 = load ptr, ptr %17, align 8, !tbaa !20
  %19 = getelementptr inbounds i8, ptr %7, i64 16
  %20 = load ptr, ptr %19, align 8, !tbaa !19
  %21 = load ptr, ptr %20, align 8, !tbaa !20
  tail call void @_ZN3JPH17ConvexHullBuilder13sMarkAffectedEPNS0_4FaceERNS_5ArrayIS2_NS_12STLAllocatorIS2_EEEE(ptr noundef %18, ptr noundef nonnull align 8 dereferenceable(24) %2)
  tail call void @_ZN3JPH17ConvexHullBuilder13sMarkAffectedEPNS0_4FaceERNS_5ArrayIS2_NS_12STLAllocatorIS2_EEEE(ptr noundef %21, ptr noundef nonnull align 8 dereferenceable(24) %2)
  %22 = getelementptr inbounds i8, ptr %17, i64 16
  store ptr %20, ptr %22, align 8, !tbaa !19
  %23 = getelementptr inbounds i8, ptr %20, i64 16
  store ptr %17, ptr %23, align 8, !tbaa !19
  store ptr null, ptr %16, align 8, !tbaa !19
  store ptr null, ptr %19, align 8, !tbaa !19
  %24 = getelementptr inbounds i8, ptr %1, i64 68
  store i8 1, ptr %24, align 4, !tbaa !21
  br label %25

25:                                               ; preds = %11, %15
  ret i1 %14
}

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 8}
!16 = !{!"_ZTSN3JPH17ConvexHullBuilder4EdgeE", !12, i64 0, !12, i64 8, !12, i64 16, !17, i64 24}
!17 = !{!"int", !8, i64 0}
!18 = !{i64 2157050752}
!19 = !{!16, !12, i64 16}
!20 = !{!16, !12, i64 0}
!21 = !{!6, !14, i64 68}


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