; LLVM IR from Discngine/fpocket :: src/qhull/src/libqhullcpp/QhullFacetList.ll (ZNK8orgQhull14QhullFacetList5countEv)

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK8orgQhull14QhullFacetList11isSelectAllEv(ptr noundef nonnull align 8 dereferenceable(33)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK8orgQhull10QhullFacet6isGoodEv(ptr noundef nonnull align 8 dereferenceable(16)) #1 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
declare dso_local void @_ZNK8orgQhull15QhullLinkedListINS_10QhullFacetEE5beginEv(ptr dead_on_unwind noalias writable sret(%"class.orgQhull::QhullLinkedList<orgQhull::QhullFacet>::const_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(32)) #2 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK8orgQhull15QhullLinkedListINS_10QhullFacetEE3endEv(ptr dead_on_unwind noalias writable sret(%"class.orgQhull::QhullLinkedList<orgQhull::QhullFacet>::const_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(32)) #2 align 2

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK8orgQhull14QhullFacetList5countEv(ptr noundef nonnull align 8 dereferenceable(33) %0) #2 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca %"class.orgQhull::QhullLinkedList<orgQhull::QhullFacet>::const_iterator", align 8
  %6 = alloca %"class.orgQhull::QhullLinkedList<orgQhull::QhullFacet>::const_iterator", align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %9 = load ptr, ptr %3, align 8
  %10 = call noundef zeroext i1 @_ZNK8orgQhull14QhullFacetList11isSelectAllEv(ptr noundef nonnull align 8 dereferenceable(33) %9)
  br i1 %10, label %11, label %13

11:                                               ; preds = %1
  %12 = call noundef i32 @_ZNK8orgQhull15QhullLinkedListINS_10QhullFacetEE5countEv(ptr noundef nonnull align 8 dereferenceable(32) %9)
  store i32 %12, ptr %2, align 4
  br label %47

13:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #4
  call void @_ZNK8orgQhull15QhullLinkedListINS_10QhullFacetEE5beginEv(ptr dead_on_unwind writable sret(%"class.orgQhull::QhullLinkedList<orgQhull::QhullFacet>::const_iterator") align 8 %5, ptr noundef nonnull align 8 dereferenceable(32) %9)
  br label %14

14:                                               ; preds = %43, %13
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #4
  invoke void @_ZNK8orgQhull15QhullLinkedListINS_10QhullFacetEE3endEv(ptr dead_on_unwind writable sret(%"class.orgQhull::QhullLinkedList<orgQhull::QhullFacet>::const_iterator") align 8 %6, ptr noundef nonnull align 8 dereferenceable(32) %9)
          to label %15 unwind label %19

15:                                               ; preds = %14
  %16 = invoke noundef zeroext i1 @_ZNK8orgQhull15QhullLinkedListINS_10QhullFacetEE14const_iteratorneERKS3_(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 8 dereferenceable(16) %6)
          to label %17 unwind label %23

17:                                               ; preds = %15
  call void @_ZN8orgQhull15QhullLinkedListINS_10QhullFacetEE14const_iteratorD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %6) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #4
  br i1 %16, label %28, label %18

18:                                               ; preds = %17
  call void @_ZN8orgQhull15QhullLinkedListINS_10QhullFacetEE14const_iteratorD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %5) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #4
  br label %45

19:                                               ; preds = %14
  %20 = landingpad { ptr, i32 }
          cleanup
  %21 = extractvalue { ptr, i32 } %20, 0
  store ptr %21, ptr %7, align 8
  %22 = extractvalue { ptr, i32 } %20, 1
  store i32 %22, ptr %8, align 4
  br label %27

23:                                               ; preds = %15
  %24 = landingpad { ptr, i32 }
          cleanup
  %25 = extractvalue { ptr, i32 } %24, 0
  store ptr %25, ptr %7, align 8
  %26 = extractvalue { ptr, i32 } %24, 1
  store i32 %26, ptr %8, align 4
  call void @_ZN8orgQhull15QhullLinkedListINS_10QhullFacetEE14const_iteratorD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %6) #4
  br label %27

27:                                               ; preds = %23, %19
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #4
  br label %44

28:                                               ; preds = %17
  %29 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNK8orgQhull15QhullLinkedListINS_10QhullFacetEE14const_iteratordeEv(ptr noundef nonnull align 8 dereferenceable(16) %5)
          to label %30 unwind label %36

30:                                               ; preds = %28
  %31 = invoke noundef zeroext i1 @_ZNK8orgQhull10QhullFacet6isGoodEv(ptr noundef nonnull align 8 dereferenceable(16) %29)
          to label %32 unwind label %36

32:                                               ; preds = %30
  br i1 %31, label %33, label %40

33:                                               ; preds = %32
  %34 = load i32, ptr %4, align 4, !tbaa !9
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %4, align 4, !tbaa !9
  br label %40

36:                                               ; preds = %41, %30, %28
  %37 = landingpad { ptr, i32 }
          cleanup
  %38 = extractvalue { ptr, i32 } %37, 0
  store ptr %38, ptr %7, align 8
  %39 = extractvalue { ptr, i32 } %37, 1
  store i32 %39, ptr %8, align 4
  br label %44

40:                                               ; preds = %33, %32
  br label %41

41:                                               ; preds = %40
  %42 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZN8orgQhull15QhullLinkedListINS_10QhullFacetEE14const_iteratorppEv(ptr noundef nonnull align 8 dereferenceable(16) %5)
          to label %43 unwind label %36

43:                                               ; preds = %41
  br label %14, !llvm.loop !11

44:                                               ; preds = %36, %27
  call void @_ZN8orgQhull15QhullLinkedListINS_10QhullFacetEE14const_iteratorD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %5) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %49

45:                                               ; preds = %18
  %46 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %46, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %47

47:                                               ; preds = %45, %11
  %48 = load i32, ptr %2, align 4
  ret i32 %48

49:                                               ; preds = %44
  %50 = load ptr, ptr %7, align 8
  %51 = load i32, ptr %8, align 4
  %52 = insertvalue { ptr, i32 } poison, ptr %50, 0
  %53 = insertvalue { ptr, i32 } %52, i32 %51, 1
  resume { ptr, i32 } %53
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 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, !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 = distinct !{!11, !12}
!12 = !{!"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"

%"class.orgQhull::QhullLinkedList<orgQhull::QhullFacet>::const_iterator" = type { %"class.orgQhull::QhullFacet" }
%"class.orgQhull::QhullFacet" = type { ptr, ptr }

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK8orgQhull14QhullFacetList11isSelectAllEv(ptr noundef nonnull align 8 dereferenceable(33)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK8orgQhull10QhullFacet6isGoodEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1 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
declare dso_local void @_ZNK8orgQhull15QhullLinkedListINS_10QhullFacetEE5beginEv(ptr dead_on_unwind noalias writable sret(%"class.orgQhull::QhullLinkedList<orgQhull::QhullFacet>::const_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK8orgQhull15QhullLinkedListINS_10QhullFacetEE3endEv(ptr dead_on_unwind noalias writable sret(%"class.orgQhull::QhullLinkedList<orgQhull::QhullFacet>::const_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2 align 2

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK8orgQhull14QhullFacetList5countEv(ptr noundef nonnull align 8 dereferenceable(33) %0) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca %"class.orgQhull::QhullLinkedList<orgQhull::QhullFacet>::const_iterator", align 8
  %3 = alloca %"class.orgQhull::QhullLinkedList<orgQhull::QhullFacet>::const_iterator", align 8
  %4 = tail call noundef zeroext i1 @_ZNK8orgQhull14QhullFacetList11isSelectAllEv(ptr noundef nonnull align 8 dereferenceable(33) %0)
  br i1 %4, label %5, label %7

5:                                                ; preds = %1
  %6 = tail call noundef i32 @_ZNK8orgQhull15QhullLinkedListINS_10QhullFacetEE5countEv(ptr noundef nonnull align 8 dereferenceable(32) %0)
  br label %22

7:                                                ; preds = %1
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #4
  call void @_ZNK8orgQhull15QhullLinkedListINS_10QhullFacetEE5beginEv(ptr dead_on_unwind nonnull writable sret(%"class.orgQhull::QhullLinkedList<orgQhull::QhullFacet>::const_iterator") align 8 %2, ptr noundef nonnull align 8 dereferenceable(32) %0)
  br label %8

8:                                                ; preds = %14, %7
  %.06 = phi i32 [ 0, %7 ], [ %spec.select, %14 ]
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #4
  invoke void @_ZNK8orgQhull15QhullLinkedListINS_10QhullFacetEE3endEv(ptr dead_on_unwind nonnull writable sret(%"class.orgQhull::QhullLinkedList<orgQhull::QhullFacet>::const_iterator") align 8 %3, ptr noundef nonnull align 8 dereferenceable(32) %0)
          to label %9 unwind label %12

9:                                                ; preds = %8
  %10 = call noundef zeroext i1 @_ZNK8orgQhull15QhullLinkedListINS_10QhullFacetEE14const_iteratorneERKS3_(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 8 dereferenceable(16) %3)
  call void @_ZN8orgQhull15QhullLinkedListINS_10QhullFacetEE14const_iteratorD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %3) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #4
  br i1 %10, label %14, label %11

11:                                               ; preds = %9
  call void @_ZN8orgQhull15QhullLinkedListINS_10QhullFacetEE14const_iteratorD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %2) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #4
  br label %22

12:                                               ; preds = %8
  %13 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #4
  br label %21

14:                                               ; preds = %9
  %15 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK8orgQhull15QhullLinkedListINS_10QhullFacetEE14const_iteratordeEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
  %16 = call noundef zeroext i1 @_ZNK8orgQhull10QhullFacet6isGoodEv(ptr noundef nonnull align 8 dereferenceable(16) %15)
  %17 = zext i1 %16 to i32
  %spec.select = add nuw nsw i32 %.06, %17
  %18 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZN8orgQhull15QhullLinkedListINS_10QhullFacetEE14const_iteratorppEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
          to label %8 unwind label %19, !llvm.loop !5

19:                                               ; preds = %14
  %20 = landingpad { ptr, i32 }
          cleanup
  br label %21

21:                                               ; preds = %19, %12
  %.pn = phi { ptr, i32 } [ %20, %19 ], [ %13, %12 ]
  call void @_ZN8orgQhull15QhullLinkedListINS_10QhullFacetEE14const_iteratorD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %2) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #4
  resume { ptr, i32 } %.pn

22:                                               ; preds = %11, %5
  %.07 = phi i32 [ %6, %5 ], [ %.06, %11 ]
  ret i32 %.07
}

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


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