; LLVM IR from Discngine/fpocket :: src/qhull/src/libqhullcpp/QhullFacetSet.ll (ZNK8orgQhull13QhullFacetSet5countEv)

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

; 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: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK8orgQhull13QhullFacetSet11isSelectAllEv(ptr noundef nonnull align 8 dereferenceable(17)) #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: mustprogress nounwind uwtable
declare dso_local void @_ZN8orgQhull10QhullFacetD2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #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 @_ZNK8orgQhull8QhullSetINS_10QhullFacetEE5beginEv(ptr dead_on_unwind noalias writable sret(%"class.orgQhull::QhullSet<orgQhull::QhullFacet>::const_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK8orgQhull8QhullSetINS_10QhullFacetEE14const_iteratordeEv(ptr dead_on_unwind noalias writable sret(%"class.orgQhull::QhullFacet") align 8, ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK8orgQhull13QhullFacetSet5countEv(ptr noundef nonnull align 8 dereferenceable(17) %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::QhullSet<orgQhull::QhullFacet>::const_iterator", align 8
  %6 = alloca %"class.orgQhull::QhullSet<orgQhull::QhullFacet>::const_iterator", align 8
  %7 = alloca %"class.orgQhull::QhullFacet", align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %10 = load ptr, ptr %3, align 8
  %11 = call noundef zeroext i1 @_ZNK8orgQhull13QhullFacetSet11isSelectAllEv(ptr noundef nonnull align 8 dereferenceable(17) %10)
  br i1 %11, label %12, label %14

12:                                               ; preds = %1
  %13 = call noundef i32 @_ZNK8orgQhull12QhullSetBase5countEv(ptr noundef nonnull align 8 dereferenceable(16) %10)
  store i32 %13, ptr %2, align 4
  br label %33

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

15:                                               ; preds = %29, %14
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #3
  call void @_ZNK8orgQhull8QhullSetINS_10QhullFacetEE3endEv(ptr dead_on_unwind writable sret(%"class.orgQhull::QhullSet<orgQhull::QhullFacet>::const_iterator") align 8 %6, ptr noundef nonnull align 8 dereferenceable(16) %10)
  %16 = call noundef zeroext i1 @_ZNK8orgQhull8QhullSetINS_10QhullFacetEE14const_iteratorneERKS3_(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 8 dereferenceable(16) %6)
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #3
  br i1 %16, label %18, label %17

17:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #3
  br label %31

18:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #3
  call void @_ZNK8orgQhull8QhullSetINS_10QhullFacetEE14const_iteratordeEv(ptr dead_on_unwind writable sret(%"class.orgQhull::QhullFacet") align 8 %7, ptr noundef nonnull align 8 dereferenceable(16) %5)
  %19 = invoke noundef zeroext i1 @_ZNK8orgQhull10QhullFacet6isGoodEv(ptr noundef nonnull align 8 dereferenceable(16) %7)
          to label %20 unwind label %24

20:                                               ; preds = %18
  br i1 %19, label %21, label %28

21:                                               ; preds = %20
  %22 = load i32, ptr %4, align 4, !tbaa !9
  %23 = add nsw i32 %22, 1
  store i32 %23, ptr %4, align 4, !tbaa !9
  br label %28

24:                                               ; preds = %18
  %25 = landingpad { ptr, i32 }
          cleanup
  %26 = extractvalue { ptr, i32 } %25, 0
  store ptr %26, ptr %8, align 8
  %27 = extractvalue { ptr, i32 } %25, 1
  store i32 %27, ptr %9, align 4
  call void @_ZN8orgQhull10QhullFacetD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %7) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %35

28:                                               ; preds = %21, %20
  call void @_ZN8orgQhull10QhullFacetD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %7) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #3
  br label %29

29:                                               ; preds = %28
  %30 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN8orgQhull8QhullSetINS_10QhullFacetEE14const_iteratorppEv(ptr noundef nonnull align 8 dereferenceable(16) %5)
  br label %15, !llvm.loop !11

31:                                               ; preds = %17
  %32 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %32, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %33

33:                                               ; preds = %31, %12
  %34 = load i32, ptr %2, align 4
  ret i32 %34

35:                                               ; preds = %24
  %36 = load ptr, ptr %8, align 8
  %37 = load i32, ptr %9, align 4
  %38 = insertvalue { ptr, i32 } poison, ptr %36, 0
  %39 = insertvalue { ptr, i32 } %38, i32 %37, 1
  resume { ptr, i32 } %39
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK8orgQhull12QhullSetBase5countEv(ptr noundef nonnull align 8 dereferenceable(16)) #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 = { 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::QhullSet<orgQhull::QhullFacet>::const_iterator" = type { ptr, ptr }
%"class.orgQhull::QhullFacet" = type { ptr, ptr }

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

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

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

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

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

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

6:                                                ; preds = %1
  %7 = tail call noundef i32 @_ZNK8orgQhull12QhullSetBase5countEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
  br label %14

8:                                                ; preds = %1
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #3
  call void @_ZNK8orgQhull8QhullSetINS_10QhullFacetEE5beginEv(ptr dead_on_unwind nonnull writable sret(%"class.orgQhull::QhullSet<orgQhull::QhullFacet>::const_iterator") align 8 %2, ptr noundef nonnull align 8 dereferenceable(16) %0)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #3
  call void @_ZNK8orgQhull8QhullSetINS_10QhullFacetEE3endEv(ptr dead_on_unwind nonnull writable sret(%"class.orgQhull::QhullSet<orgQhull::QhullFacet>::const_iterator") align 8 %3, ptr noundef nonnull align 8 dereferenceable(16) %0)
  %9 = call noundef zeroext i1 @_ZNK8orgQhull8QhullSetINS_10QhullFacetEE14const_iteratorneERKS3_(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 8 dereferenceable(16) %3)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #3
  br i1 %9, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %8
  %.0.lcssa = phi i32 [ 0, %8 ], [ %spec.select, %.lr.ph ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #3
  br label %14

.lr.ph:                                           ; preds = %8, %.lr.ph
  %.04 = phi i32 [ %spec.select, %.lr.ph ], [ 0, %8 ]
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #3
  call void @_ZNK8orgQhull8QhullSetINS_10QhullFacetEE14const_iteratordeEv(ptr dead_on_unwind nonnull writable sret(%"class.orgQhull::QhullFacet") align 8 %4, ptr noundef nonnull align 8 dereferenceable(16) %2)
  %10 = call noundef zeroext i1 @_ZNK8orgQhull10QhullFacet6isGoodEv(ptr noundef nonnull align 8 dereferenceable(16) %4)
  %11 = zext i1 %10 to i32
  %spec.select = add nuw nsw i32 %.04, %11
  call void @_ZN8orgQhull10QhullFacetD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %4) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #3
  %12 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN8orgQhull8QhullSetINS_10QhullFacetEE14const_iteratorppEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #3
  call void @_ZNK8orgQhull8QhullSetINS_10QhullFacetEE3endEv(ptr dead_on_unwind nonnull writable sret(%"class.orgQhull::QhullSet<orgQhull::QhullFacet>::const_iterator") align 8 %3, ptr noundef nonnull align 8 dereferenceable(16) %0)
  %13 = call noundef zeroext i1 @_ZNK8orgQhull8QhullSetINS_10QhullFacetEE14const_iteratorneERKS3_(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 8 dereferenceable(16) %3)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #3
  br i1 %13, label %.lr.ph, label %._crit_edge, !llvm.loop !5

14:                                               ; preds = %._crit_edge, %6
  %.03 = phi i32 [ %7, %6 ], [ %.0.lcssa, %._crit_edge ]
  ret i32 %.03
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK8orgQhull12QhullSetBase5countEv(ptr noundef nonnull align 8 dereferenceable(16)) 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 = { 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,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass