; LLVM IR from Discngine/fpocket :: src/qhull/src/libqhullcpp (QhullRidge)

; 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.orgQhull::QhullRidge" = type { ptr, ptr }
%"class.orgQhull::QhullVertex" = type { ptr, ptr }

@.str = external hidden unnamed_addr constant [95 x i8], align 1
@_ZTIN8orgQhull10QhullErrorE = external dso_local constant { ptr, ptr, ptr }, align 8

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare ptr @qh_nextridge3d(ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK8orgQhull10QhullRidge9getRidgeTEv(ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK8orgQhull10QhullFacet9getFacetTEv(ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

; 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 @_ZNK8orgQhull10QhullRidge11nextRidge3dERKNS_10QhullFacetEPNS_11QhullVertexE(ptr dead_on_unwind noalias writable sret(%"class.orgQhull::QhullRidge") align 8 %0, ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef %3) #3 align 2 personality ptr @__gxx_personality_v0 {
  %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 ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca %"class.orgQhull::QhullVertex", align 8
  store ptr %0, ptr %5, align 8
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  %14 = load ptr, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  store ptr null, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  store ptr null, ptr %10, align 8, !tbaa !5
  %15 = getelementptr inbounds %"class.orgQhull::QhullRidge", ptr %14, i32 0, i32 1
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %38

18:                                               ; preds = %4
  %19 = call noundef ptr @_ZNK8orgQhull10QhullRidge9getRidgeTEv(ptr noundef nonnull align 8 dereferenceable(16) %14)
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = call noundef ptr @_ZNK8orgQhull10QhullFacet9getFacetTEv(ptr noundef nonnull align 8 dereferenceable(16) %20)
  %22 = call ptr @qh_nextridge3d(ptr noundef %19, ptr noundef %21, ptr noundef %9)
  store ptr %22, ptr %10, align 8, !tbaa !5
  %23 = load ptr, ptr %10, align 8, !tbaa !5
  %24 = icmp ne ptr %23, null
  br i1 %24, label %37, label %25

25:                                               ; preds = %18
  %26 = call ptr @__cxa_allocate_exception(i64 80) #4
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = invoke noundef i32 @_ZNK8orgQhull10QhullFacet2idEv(ptr noundef nonnull align 8 dereferenceable(16) %27)
          to label %29 unwind label %33

29:                                               ; preds = %25
  %30 = invoke noundef i32 @_ZNK8orgQhull10QhullRidge2idEv(ptr noundef nonnull align 8 dereferenceable(16) %14)
          to label %31 unwind label %33

31:                                               ; preds = %29
  invoke void @_ZN8orgQhull10QhullErrorC2EiPKcii(ptr noundef nonnull align 8 dereferenceable(80) %26, i32 noundef 10030, ptr noundef @.str, i32 noundef %28, i32 noundef %30)
          to label %32 unwind label %33

32:                                               ; preds = %31
  call void @__cxa_throw(ptr %26, ptr @_ZTIN8orgQhull10QhullErrorE, ptr @_ZN8orgQhull9RoadErrorD2Ev) #5
  unreachable

33:                                               ; preds = %31, %29, %25
  %34 = landingpad { ptr, i32 }
          cleanup
  %35 = extractvalue { ptr, i32 } %34, 0
  store ptr %35, ptr %11, align 8
  %36 = extractvalue { ptr, i32 } %34, 1
  store i32 %36, ptr %12, align 4
  call void @__cxa_free_exception(ptr %26) #4
  br label %56

37:                                               ; preds = %18
  br label %38

38:                                               ; preds = %37, %4
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = icmp ne ptr %39, null
  br i1 %40, label %41, label %52

41:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #4
  %42 = getelementptr inbounds %"class.orgQhull::QhullRidge", ptr %14, i32 0, i32 1
  %43 = load ptr, ptr %42, align 8, !tbaa !9
  %44 = load ptr, ptr %9, align 8, !tbaa !5
  call void @_ZN8orgQhull11QhullVertexC2EPNS_7QhullQhEP7vertexT(ptr noundef nonnull align 8 dereferenceable(16) %13, ptr noundef %43, ptr noundef %44)
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  %46 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZN8orgQhull11QhullVertexaSERKS0_(ptr noundef nonnull align 8 dereferenceable(16) %45, ptr noundef nonnull align 8 dereferenceable(16) %13)
          to label %47 unwind label %48

47:                                               ; preds = %41
  call void @_ZN8orgQhull11QhullVertexD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %13) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #4
  br label %52

48:                                               ; preds = %41
  %49 = landingpad { ptr, i32 }
          cleanup
  %50 = extractvalue { ptr, i32 } %49, 0
  store ptr %50, ptr %11, align 8
  %51 = extractvalue { ptr, i32 } %49, 1
  store i32 %51, ptr %12, align 4
  call void @_ZN8orgQhull11QhullVertexD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %13) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #4
  br label %56

52:                                               ; preds = %47, %38
  %53 = getelementptr inbounds %"class.orgQhull::QhullRidge", ptr %14, i32 0, i32 1
  %54 = load ptr, ptr %53, align 8, !tbaa !9
  %55 = load ptr, ptr %10, align 8, !tbaa !5
  call void @_ZN8orgQhull10QhullRidgeC2EPNS_7QhullQhEP6ridgeT(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %54, ptr noundef %55)
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  ret void

56:                                               ; preds = %48, %33
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  br label %57

57:                                               ; preds = %56
  %58 = load ptr, ptr %11, align 8
  %59 = load i32, ptr %12, align 4
  %60 = insertvalue { ptr, i32 } poison, ptr %58, 0
  %61 = insertvalue { ptr, i32 } %60, i32 %59, 1
  resume { ptr, i32 } %61
}

declare ptr @__cxa_allocate_exception(i64)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK8orgQhull10QhullFacet2idEv(ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK8orgQhull10QhullRidge2idEv(ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8orgQhull10QhullErrorC2EiPKcii(ptr noundef nonnull align 8 dereferenceable(80), i32 noundef, ptr noundef, i32 noundef, i32 noundef) unnamed_addr #3 align 2

declare void @__cxa_free_exception(ptr)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN8orgQhull9RoadErrorD2Ev(ptr noundef nonnull align 8 dereferenceable(80)) unnamed_addr #2 align 2

declare void @__cxa_throw(ptr, ptr, ptr)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN8orgQhull11QhullVertexC2EPNS_7QhullQhEP7vertexT(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, ptr noundef) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZN8orgQhull11QhullVertexaSERKS0_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN8orgQhull10QhullRidgeC2EPNS_7QhullQhEP6ridgeT(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, ptr noundef) unnamed_addr #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 #3 = { 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 = { nounwind }
attributes #5 = { noreturn }

!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 = !{!"_ZTSN8orgQhull10QhullRidgeE", !6, i64 0, !6, i64 8}


; 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.orgQhull::QhullRidge" = type { ptr, ptr }
%"class.orgQhull::QhullVertex" = type { ptr, ptr }

@.str = external hidden unnamed_addr constant [95 x i8], align 1
@_ZTIN8orgQhull10QhullErrorE = external dso_local constant { ptr, ptr, ptr }, align 8

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare ptr @qh_nextridge3d(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK8orgQhull10QhullRidge9getRidgeTEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK8orgQhull10QhullFacet9getFacetTEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress 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 @_ZNK8orgQhull10QhullRidge11nextRidge3dERKNS_10QhullFacetEPNS_11QhullVertexE(ptr dead_on_unwind noalias writable sret(%"class.orgQhull::QhullRidge") align 8 %0, ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef %3) local_unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca ptr, align 8
  %6 = alloca %"class.orgQhull::QhullVertex", align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  store ptr null, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %1, i64 8
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %20, label %9

9:                                                ; preds = %4
  %10 = tail call noundef ptr @_ZNK8orgQhull10QhullRidge9getRidgeTEv(ptr noundef nonnull align 8 dereferenceable(16) %1)
  %11 = tail call noundef ptr @_ZNK8orgQhull10QhullFacet9getFacetTEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
  %12 = call ptr @qh_nextridge3d(ptr noundef %10, ptr noundef %11, ptr noundef nonnull %5)
  %.not10 = icmp eq ptr %12, null
  br i1 %.not10, label %13, label %._crit_edge

._crit_edge:                                      ; preds = %9
  %.pre12.pre = load ptr, ptr %7, align 8, !tbaa !9
  br label %20

13:                                               ; preds = %9
  %14 = call ptr @__cxa_allocate_exception(i64 80) #4
  %15 = call noundef i32 @_ZNK8orgQhull10QhullFacet2idEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
  %16 = call noundef i32 @_ZNK8orgQhull10QhullRidge2idEv(ptr noundef nonnull align 8 dereferenceable(16) %1)
  invoke void @_ZN8orgQhull10QhullErrorC2EiPKcii(ptr noundef nonnull align 8 dereferenceable(80) %14, i32 noundef 10030, ptr noundef nonnull @.str, i32 noundef %15, i32 noundef %16)
          to label %17 unwind label %18

17:                                               ; preds = %13
  call void @__cxa_throw(ptr nonnull %14, ptr nonnull @_ZTIN8orgQhull10QhullErrorE, ptr nonnull @_ZN8orgQhull9RoadErrorD2Ev) #5
  unreachable

18:                                               ; preds = %13
  %19 = landingpad { ptr, i32 }
          cleanup
  call void @__cxa_free_exception(ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  resume { ptr, i32 } %19

20:                                               ; preds = %._crit_edge, %4
  %.pre12 = phi ptr [ %.pre12.pre, %._crit_edge ], [ null, %4 ]
  %.0 = phi ptr [ %12, %._crit_edge ], [ null, %4 ]
  %.not11 = icmp eq ptr %3, null
  br i1 %.not11, label %24, label %21

21:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #4
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN8orgQhull11QhullVertexC2EPNS_7QhullQhEP7vertexT(ptr noundef nonnull align 8 dereferenceable(16) %6, ptr noundef %.pre12, ptr noundef %22)
  %23 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN8orgQhull11QhullVertexaSERKS0_(ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull align 8 dereferenceable(16) %6)
  call void @_ZN8orgQhull11QhullVertexD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %6) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #4
  %.pre = load ptr, ptr %7, align 8, !tbaa !9
  br label %24

24:                                               ; preds = %21, %20
  %25 = phi ptr [ %.pre, %21 ], [ %.pre12, %20 ]
  call void @_ZN8orgQhull10QhullRidgeC2EPNS_7QhullQhEP6ridgeT(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %25, ptr noundef %.0)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  ret void
}

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK8orgQhull10QhullFacet2idEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK8orgQhull10QhullRidge2idEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8orgQhull10QhullErrorC2EiPKcii(ptr noundef nonnull align 8 dereferenceable(80), i32 noundef, ptr noundef, i32 noundef, i32 noundef) unnamed_addr #3 align 2

declare void @__cxa_free_exception(ptr) local_unnamed_addr

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN8orgQhull9RoadErrorD2Ev(ptr noundef nonnull align 8 dereferenceable(80)) unnamed_addr #2 align 2

declare void @__cxa_throw(ptr, ptr, ptr) local_unnamed_addr

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN8orgQhull11QhullVertexC2EPNS_7QhullQhEP7vertexT(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, ptr noundef) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZN8orgQhull11QhullVertexaSERKS0_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN8orgQhull10QhullRidgeC2EPNS_7QhullQhEP6ridgeT(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, ptr noundef) unnamed_addr #2 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 #3 = { 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 = { nounwind }
attributes #5 = { noreturn }

!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 = !{!"_ZTSN8orgQhull10QhullRidgeE", !6, i64 0, !6, i64 8}


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