; 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 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [57 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

declare i32 @__gxx_personality_v0(...)

; 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 nounwind uwtable
declare dso_local void @_ZN3JPH17ConvexHullBuilder4EdgedlEPv(ptr noundef) #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH17ConvexHullBuilder4Face10InitializeEiiiPKNS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(69) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4) #2 align 2 personality ptr @__gxx_personality_v0 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca %"struct.JPH::AssertLastParam", align 1
  %12 = alloca %"struct.JPH::AssertLastParam", align 1
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !9
  store ptr %4, ptr %10, align 8, !tbaa !5
  %18 = load ptr, ptr %6, align 8
  br label %19

19:                                               ; preds = %5
  %20 = getelementptr inbounds %"class.JPH::ConvexHullBuilder::Face", ptr %18, i32 0, i32 3
  %21 = load ptr, ptr %20, align 8, !tbaa !11
  %22 = icmp eq ptr %21, null
  br i1 %22, label %26, label %23

23:                                               ; preds = %19
  %24 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 94)
  br i1 %24, label %25, label %26

25:                                               ; preds = %23
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #6, !srcloc !18
  br label %26

26:                                               ; preds = %25, %23, %19
  br label %27

27:                                               ; preds = %26
  br label %28

28:                                               ; preds = %27
  %29 = load i32, ptr %7, align 4, !tbaa !9
  %30 = load i32, ptr %8, align 4, !tbaa !9
  %31 = icmp ne i32 %29, %30
  br i1 %31, label %32, label %40

32:                                               ; preds = %28
  %33 = load i32, ptr %7, align 4, !tbaa !9
  %34 = load i32, ptr %9, align 4, !tbaa !9
  %35 = icmp ne i32 %33, %34
  br i1 %35, label %36, label %40

36:                                               ; preds = %32
  %37 = load i32, ptr %8, align 4, !tbaa !9
  %38 = load i32, ptr %9, align 4, !tbaa !9
  %39 = icmp ne i32 %37, %38
  br i1 %39, label %43, label %40

40:                                               ; preds = %36, %32, %28
  %41 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 95)
  br i1 %41, label %42, label %43

42:                                               ; preds = %40
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #6, !srcloc !19
  br label %43

43:                                               ; preds = %42, %40, %36
  br label %44

44:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %45 = call noundef ptr @_ZN3JPH17ConvexHullBuilder4EdgenwEm(i64 noundef 32)
  %46 = load i32, ptr %7, align 4, !tbaa !9
  invoke void @_ZN3JPH17ConvexHullBuilder4EdgeC2EPNS0_4FaceEi(ptr noundef nonnull align 8 dereferenceable(28) %45, ptr noundef %18, i32 noundef %46)
          to label %47 unwind label %66

47:                                               ; preds = %44
  store ptr %45, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  %48 = call noundef ptr @_ZN3JPH17ConvexHullBuilder4EdgenwEm(i64 noundef 32)
  %49 = load i32, ptr %8, align 4, !tbaa !9
  invoke void @_ZN3JPH17ConvexHullBuilder4EdgeC2EPNS0_4FaceEi(ptr noundef nonnull align 8 dereferenceable(28) %48, ptr noundef %18, i32 noundef %49)
          to label %50 unwind label %70

50:                                               ; preds = %47
  store ptr %48, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #6
  %51 = call noundef ptr @_ZN3JPH17ConvexHullBuilder4EdgenwEm(i64 noundef 32)
  %52 = load i32, ptr %9, align 4, !tbaa !9
  invoke void @_ZN3JPH17ConvexHullBuilder4EdgeC2EPNS0_4FaceEi(ptr noundef nonnull align 8 dereferenceable(28) %51, ptr noundef %18, i32 noundef %52)
          to label %53 unwind label %74

53:                                               ; preds = %50
  store ptr %51, ptr %17, align 8, !tbaa !5
  %54 = load ptr, ptr %16, align 8, !tbaa !5
  %55 = load ptr, ptr %13, align 8, !tbaa !5
  %56 = getelementptr inbounds %"class.JPH::ConvexHullBuilder::Edge", ptr %55, i32 0, i32 1
  store ptr %54, ptr %56, align 8, !tbaa !20
  %57 = load ptr, ptr %17, align 8, !tbaa !5
  %58 = load ptr, ptr %16, align 8, !tbaa !5
  %59 = getelementptr inbounds %"class.JPH::ConvexHullBuilder::Edge", ptr %58, i32 0, i32 1
  store ptr %57, ptr %59, align 8, !tbaa !20
  %60 = load ptr, ptr %13, align 8, !tbaa !5
  %61 = load ptr, ptr %17, align 8, !tbaa !5
  %62 = getelementptr inbounds %"class.JPH::ConvexHullBuilder::Edge", ptr %61, i32 0, i32 1
  store ptr %60, ptr %62, align 8, !tbaa !20
  %63 = load ptr, ptr %13, align 8, !tbaa !5
  %64 = getelementptr inbounds %"class.JPH::ConvexHullBuilder::Face", ptr %18, i32 0, i32 3
  store ptr %63, ptr %64, align 8, !tbaa !11
  %65 = load ptr, ptr %10, align 8, !tbaa !5
  call void @_ZN3JPH17ConvexHullBuilder4Face26CalculateNormalAndCentroidEPKNS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(69) %18, ptr noundef %65)
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  ret void

66:                                               ; preds = %44
  %67 = landingpad { ptr, i32 }
          cleanup
  %68 = extractvalue { ptr, i32 } %67, 0
  store ptr %68, ptr %14, align 8
  %69 = extractvalue { ptr, i32 } %67, 1
  store i32 %69, ptr %15, align 4
  call void @_ZN3JPH17ConvexHullBuilder4EdgedlEPv(ptr noundef %45) #6
  br label %79

70:                                               ; preds = %47
  %71 = landingpad { ptr, i32 }
          cleanup
  %72 = extractvalue { ptr, i32 } %71, 0
  store ptr %72, ptr %14, align 8
  %73 = extractvalue { ptr, i32 } %71, 1
  store i32 %73, ptr %15, align 4
  call void @_ZN3JPH17ConvexHullBuilder4EdgedlEPv(ptr noundef %48) #6
  br label %78

74:                                               ; preds = %50
  %75 = landingpad { ptr, i32 }
          cleanup
  %76 = extractvalue { ptr, i32 } %75, 0
  store ptr %76, ptr %14, align 8
  %77 = extractvalue { ptr, i32 } %75, 1
  store i32 %77, ptr %15, align 4
  call void @_ZN3JPH17ConvexHullBuilder4EdgedlEPv(ptr noundef %51) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #6
  br label %78

78:                                               ; preds = %74, %70
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  br label %79

79:                                               ; preds = %78, %66
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  br label %80

80:                                               ; preds = %79
  %81 = load ptr, ptr %14, align 8
  %82 = load i32, ptr %15, align 4
  %83 = insertvalue { ptr, i32 } poison, ptr %81, 0
  %84 = insertvalue { ptr, i32 } %83, i32 %82, 1
  resume { ptr, i32 } %84
}

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

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local noundef ptr @_ZN3JPH17ConvexHullBuilder4EdgenwEm(i64 noundef) #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH17ConvexHullBuilder4EdgeC2EPNS0_4FaceEi(ptr noundef nonnull align 8 dereferenceable(28), ptr noundef, i32 noundef) unnamed_addr #5 align 2

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


; 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 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [57 x i8], align 1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3JPH17ConvexHullBuilder4Face26CalculateNormalAndCentroidEPKNS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(69), ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH17ConvexHullBuilder4Face10InitializeEiiiPKNS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(69) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4) local_unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %6 = getelementptr inbounds i8, ptr %0, i64 56
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = icmp eq ptr %7, null
  br i1 %8, label %12, label %9

9:                                                ; preds = %5
  %10 = tail call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 94)
  br i1 %10, label %11, label %12

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

12:                                               ; preds = %11, %9, %5
  %.not = icmp eq i32 %1, %2
  %.not19 = icmp eq i32 %1, %3
  %or.cond = or i1 %.not, %.not19
  %.not20 = icmp eq i32 %2, %3
  %or.cond21 = or i1 %.not20, %or.cond
  br i1 %or.cond21, label %13, label %16

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

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

16:                                               ; preds = %12, %13, %15
  %17 = tail call noundef ptr @_ZN3JPH17ConvexHullBuilder4EdgenwEm(i64 noundef 32)
  tail call void @_ZN3JPH17ConvexHullBuilder4EdgeC2EPNS0_4FaceEi(ptr noundef nonnull align 8 dereferenceable(28) %17, ptr noundef nonnull %0, i32 noundef %1)
  %18 = tail call noundef ptr @_ZN3JPH17ConvexHullBuilder4EdgenwEm(i64 noundef 32)
  tail call void @_ZN3JPH17ConvexHullBuilder4EdgeC2EPNS0_4FaceEi(ptr noundef nonnull align 8 dereferenceable(28) %18, ptr noundef nonnull %0, i32 noundef %2)
  %19 = tail call noundef ptr @_ZN3JPH17ConvexHullBuilder4EdgenwEm(i64 noundef 32)
  tail call void @_ZN3JPH17ConvexHullBuilder4EdgeC2EPNS0_4FaceEi(ptr noundef nonnull align 8 dereferenceable(28) %19, ptr noundef nonnull %0, i32 noundef %3)
  %20 = getelementptr inbounds i8, ptr %17, i64 8
  store ptr %18, ptr %20, align 8, !tbaa !17
  %21 = getelementptr inbounds i8, ptr %18, i64 8
  store ptr %19, ptr %21, align 8, !tbaa !17
  %22 = getelementptr inbounds i8, ptr %19, i64 8
  store ptr %17, ptr %22, align 8, !tbaa !17
  store ptr %17, ptr %6, align 8, !tbaa !5
  tail call void @_ZN3JPH17ConvexHullBuilder4Face26CalculateNormalAndCentroidEPKNS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(69) %0, ptr noundef %4)
  ret void
}

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

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local noundef ptr @_ZN3JPH17ConvexHullBuilder4EdgenwEm(i64 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH17ConvexHullBuilder4EdgeC2EPNS0_4FaceEi(ptr noundef nonnull align 8 dereferenceable(28), ptr noundef, i32 noundef) unnamed_addr #3 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 = { 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 = { alwaysinline 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 = { 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 #4 = { 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 = !{i64 2157043595}
!16 = !{i64 2157044002}
!17 = !{!18, !12, i64 8}
!18 = !{!"_ZTSN3JPH17ConvexHullBuilder4EdgeE", !12, i64 0, !12, i64 8, !12, i64 16, !19, i64 24}
!19 = !{!"int", !8, i64 0}


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