; LLVM IR from jrouwe/JoltPhysics :: Jolt/Geometry/ConvexHullBuilder2D.ll (ZNK3JPH19ConvexHullBuilder2D13ValidateEdgesEv)

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

@.str = external hidden unnamed_addr constant [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [90 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [19 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: mustprogress uwtable
define dso_local void @_ZNK3JPH19ConvexHullBuilder2D13ValidateEdgesEv(ptr noundef nonnull align 8 dereferenceable(20) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca %"struct.JPH::AssertLastParam", align 1
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca %"struct.JPH::AssertLastParam", align 1
  %7 = alloca %"struct.JPH::AssertLastParam", align 1
  %8 = alloca %"struct.JPH::AssertLastParam", align 1
  store ptr %0, ptr %2, align 8, !tbaa !5
  %9 = load ptr, ptr %2, align 8
  %10 = getelementptr inbounds %"class.JPH::ConvexHullBuilder2D", ptr %9, i32 0, i32 1
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %23

13:                                               ; preds = %1
  br label %14

14:                                               ; preds = %13
  %15 = getelementptr inbounds %"class.JPH::ConvexHullBuilder2D", ptr %9, i32 0, i32 2
  %16 = load i32, ptr %15, align 8, !tbaa !12
  %17 = icmp eq i32 %16, 0
  br i1 %17, label %21, label %18

18:                                               ; preds = %14
  %19 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 87)
  br i1 %19, label %20, label %21

20:                                               ; preds = %18
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #3, !srcloc !13
  br label %21

21:                                               ; preds = %20, %18, %14
  br label %22

22:                                               ; preds = %21
  br label %77

23:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %24 = getelementptr inbounds %"class.JPH::ConvexHullBuilder2D", ptr %9, i32 0, i32 1
  %25 = load ptr, ptr %24, align 8, !tbaa !9
  store ptr %25, ptr %5, align 8, !tbaa !5
  br label %26

26:                                               ; preds = %60, %23
  br label %27

27:                                               ; preds = %26
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = getelementptr inbounds %"class.JPH::ConvexHullBuilder2D::Edge", ptr %28, i32 0, i32 4
  %30 = load ptr, ptr %29, align 16, !tbaa !15
  %31 = getelementptr inbounds %"class.JPH::ConvexHullBuilder2D::Edge", ptr %30, i32 0, i32 3
  %32 = load ptr, ptr %31, align 8, !tbaa !21
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = icmp eq ptr %32, %33
  br i1 %34, label %38, label %35

35:                                               ; preds = %27
  %36 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 97)
  br i1 %36, label %37, label %38

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

38:                                               ; preds = %37, %35, %27
  br label %39

39:                                               ; preds = %38
  br label %40

40:                                               ; preds = %39
  br label %41

41:                                               ; preds = %40
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %"class.JPH::ConvexHullBuilder2D::Edge", ptr %42, i32 0, i32 3
  %44 = load ptr, ptr %43, align 8, !tbaa !21
  %45 = getelementptr inbounds %"class.JPH::ConvexHullBuilder2D::Edge", ptr %44, i32 0, i32 4
  %46 = load ptr, ptr %45, align 16, !tbaa !15
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = icmp eq ptr %46, %47
  br i1 %48, label %52, label %49

49:                                               ; preds = %41
  %50 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 98)
  br i1 %50, label %51, label %52

51:                                               ; preds = %49
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #3, !srcloc !23
  br label %52

52:                                               ; preds = %51, %49, %41
  br label %53

53:                                               ; preds = %52
  br label %54

54:                                               ; preds = %53
  %55 = load i32, ptr %4, align 4, !tbaa !14
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %4, align 4, !tbaa !14
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = getelementptr inbounds %"class.JPH::ConvexHullBuilder2D::Edge", ptr %57, i32 0, i32 4
  %59 = load ptr, ptr %58, align 16, !tbaa !15
  store ptr %59, ptr %5, align 8, !tbaa !5
  br label %60

60:                                               ; preds = %54
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = getelementptr inbounds %"class.JPH::ConvexHullBuilder2D", ptr %9, i32 0, i32 1
  %63 = load ptr, ptr %62, align 8, !tbaa !9
  %64 = icmp ne ptr %61, %63
  br i1 %64, label %26, label %65, !llvm.loop !24

65:                                               ; preds = %60
  br label %66

66:                                               ; preds = %65
  %67 = load i32, ptr %4, align 4, !tbaa !14
  %68 = getelementptr inbounds %"class.JPH::ConvexHullBuilder2D", ptr %9, i32 0, i32 2
  %69 = load i32, ptr %68, align 8, !tbaa !12
  %70 = icmp eq i32 %67, %69
  br i1 %70, label %74, label %71

71:                                               ; preds = %66
  %72 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 105)
  br i1 %72, label %73, label %74

73:                                               ; preds = %71
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #3, !srcloc !26
  br label %74

74:                                               ; preds = %73, %71, %66
  br label %75

75:                                               ; preds = %74
  br label %76

76:                                               ; preds = %75
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %77

77:                                               ; preds = %76, %22
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef, ptr noundef, i32 noundef) #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 = { 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 #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 8}
!10 = !{!"_ZTSN3JPH19ConvexHullBuilder2DE", !6, i64 0, !6, i64 8, !11, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 16}
!13 = !{i64 2156837868}
!14 = !{!11, !11, i64 0}
!15 = !{!16, !6, i64 64}
!16 = !{!"_ZTSN3JPH19ConvexHullBuilder2D4EdgeE", !17, i64 0, !17, i64 16, !18, i64 32, !6, i64 56, !6, i64 64, !11, i64 72, !20, i64 76}
!17 = !{!"_ZTSN3JPH4Vec3E", !7, i64 0}
!18 = !{!"_ZTSN3JPH5ArrayIiNS_12STLAllocatorIiEEEE", !19, i64 0, !19, i64 8, !6, i64 16}
!19 = !{!"long", !7, i64 0}
!20 = !{!"float", !7, i64 0}
!21 = !{!16, !6, i64 56}
!22 = !{i64 2156838233}
!23 = !{i64 2156838598}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{i64 2156838932}


; 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 [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [90 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [19 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3JPH19ConvexHullBuilder2D13ValidateEdgesEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(20) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = icmp eq ptr %3, null
  br i1 %4, label %5, label %.preheader

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = load i32, ptr %6, align 8, !tbaa !11
  %8 = icmp eq i32 %7, 0
  br i1 %8, label %40, 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 87)
  br i1 %10, label %11, label %40

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

.preheader:                                       ; preds = %1, %29
  %.08 = phi i32 [ %30, %29 ], [ 0, %1 ]
  %.0 = phi ptr [ %31, %29 ], [ %3, %1 ]
  %12 = getelementptr inbounds i8, ptr %.0, i64 64
  %13 = load ptr, ptr %12, align 16, !tbaa !13
  %14 = getelementptr inbounds i8, ptr %13, i64 56
  %15 = load ptr, ptr %14, align 8, !tbaa !19
  %16 = icmp eq ptr %15, %.0
  br i1 %16, label %20, label %17

17:                                               ; preds = %.preheader
  %18 = tail call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 97)
  br i1 %18, label %19, label %20

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

20:                                               ; preds = %.preheader, %17, %19
  %21 = getelementptr inbounds i8, ptr %.0, i64 56
  %22 = load ptr, ptr %21, align 8, !tbaa !19
  %23 = getelementptr inbounds i8, ptr %22, i64 64
  %24 = load ptr, ptr %23, align 16, !tbaa !13
  %25 = icmp eq ptr %24, %.0
  br i1 %25, label %29, label %26

26:                                               ; preds = %20
  %27 = tail call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 98)
  br i1 %27, label %28, label %29

28:                                               ; preds = %26
  tail call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #2, !srcloc !21
  br label %29

29:                                               ; preds = %28, %26, %20
  %30 = add nuw nsw i32 %.08, 1
  %31 = load ptr, ptr %12, align 16, !tbaa !13
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %.not = icmp eq ptr %31, %32
  br i1 %.not, label %33, label %.preheader, !llvm.loop !22

33:                                               ; preds = %29
  %34 = getelementptr inbounds i8, ptr %0, i64 16
  %35 = load i32, ptr %34, align 8, !tbaa !11
  %36 = icmp eq i32 %30, %35
  br i1 %36, label %40, label %37

37:                                               ; preds = %33
  %38 = tail call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 105)
  br i1 %38, label %39, label %40

39:                                               ; preds = %37
  tail call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #2, !srcloc !24
  br label %40

40:                                               ; preds = %33, %37, %39, %11, %9, %5
  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

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 = { 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 8}
!6 = !{!"_ZTSN3JPH19ConvexHullBuilder2DE", !7, i64 0, !7, i64 8, !10, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !10, i64 16}
!12 = !{i64 2156837868}
!13 = !{!14, !7, i64 64}
!14 = !{!"_ZTSN3JPH19ConvexHullBuilder2D4EdgeE", !15, i64 0, !15, i64 16, !16, i64 32, !7, i64 56, !7, i64 64, !10, i64 72, !18, i64 76}
!15 = !{!"_ZTSN3JPH4Vec3E", !8, i64 0}
!16 = !{!"_ZTSN3JPH5ArrayIiNS_12STLAllocatorIiEEEE", !17, i64 0, !17, i64 8, !7, i64 16}
!17 = !{!"long", !8, i64 0}
!18 = !{!"float", !8, i64 0}
!19 = !{!14, !7, i64 56}
!20 = !{i64 2156838233}
!21 = !{i64 2156838598}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = !{i64 2156838932}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass