; LLVM IR from Discngine/fpocket :: src/qhull/src/libqhullcpp/Coordinates.ll (ZNK8orgQhull11Coordinates7indexOfERKdi)

; 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::Coordinates::const_iterator" = type { %"class.__gnu_cxx::__normal_iterator" }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK8orgQhull11Coordinates5beginEv(ptr dead_on_unwind noalias writable sret(%"class.orgQhull::Coordinates::const_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK8orgQhull11Coordinates14const_iteratorplEi(ptr dead_on_unwind noalias writable sret(%"class.orgQhull::Coordinates::const_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #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
define dso_local noundef i32 @_ZNK8orgQhull11Coordinates7indexOfERKdi(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(8) %1, i32 noundef %2) #1 align 2 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca %"class.orgQhull::Coordinates::const_iterator", align 8
  %9 = alloca %"class.orgQhull::Coordinates::const_iterator", align 8
  %10 = alloca %"class.orgQhull::Coordinates::const_iterator", align 8
  %11 = alloca %"class.orgQhull::Coordinates::const_iterator", align 8
  %12 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  %13 = load ptr, ptr %5, align 8
  %14 = load i32, ptr %7, align 4, !tbaa !9
  %15 = icmp slt i32 %14, 0
  br i1 %15, label %16, label %24

16:                                               ; preds = %3
  %17 = call noundef i32 @_ZNK8orgQhull11Coordinates5countEv(ptr noundef nonnull align 8 dereferenceable(24) %13)
  %18 = load i32, ptr %7, align 4, !tbaa !9
  %19 = add nsw i32 %18, %17
  store i32 %19, ptr %7, align 4, !tbaa !9
  %20 = load i32, ptr %7, align 4, !tbaa !9
  %21 = icmp slt i32 %20, 0
  br i1 %21, label %22, label %23

22:                                               ; preds = %16
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %23

23:                                               ; preds = %22, %16
  br label %24

24:                                               ; preds = %23, %3
  %25 = load i32, ptr %7, align 4, !tbaa !9
  %26 = call noundef i32 @_ZNK8orgQhull11Coordinates5countEv(ptr noundef nonnull align 8 dereferenceable(24) %13)
  %27 = icmp slt i32 %25, %26
  br i1 %27, label %28, label %47

28:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @_ZNK8orgQhull11Coordinates5beginEv(ptr dead_on_unwind writable sret(%"class.orgQhull::Coordinates::const_iterator") align 8 %9, ptr noundef nonnull align 8 dereferenceable(24) %13)
  %29 = load i32, ptr %7, align 4, !tbaa !9
  call void @_ZNK8orgQhull11Coordinates14const_iteratorplEi(ptr dead_on_unwind writable sret(%"class.orgQhull::Coordinates::const_iterator") align 8 %8, ptr noundef nonnull align 8 dereferenceable(8) %9, i32 noundef %29)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %30

30:                                               ; preds = %41, %28
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  call void @_ZNK8orgQhull11Coordinates8constEndEv(ptr dead_on_unwind writable sret(%"class.orgQhull::Coordinates::const_iterator") align 8 %10, ptr noundef nonnull align 8 dereferenceable(24) %13)
  %31 = call noundef zeroext i1 @_ZNK8orgQhull11Coordinates14const_iteratorneERKS1_(ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef nonnull align 8 dereferenceable(8) %10)
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br i1 %31, label %32, label %43

32:                                               ; preds = %30
  %33 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK8orgQhull11Coordinates14const_iteratordeEv(ptr noundef nonnull align 8 dereferenceable(8) %8)
  %34 = load double, ptr %33, align 8, !tbaa !11
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = load double, ptr %35, align 8, !tbaa !11
  %37 = fcmp oeq double %34, %36
  br i1 %37, label %38, label %41

38:                                               ; preds = %32
  call void @_ZNK8orgQhull11Coordinates5beginEv(ptr dead_on_unwind writable sret(%"class.orgQhull::Coordinates::const_iterator") align 8 %11, ptr noundef nonnull align 8 dereferenceable(24) %13)
  %39 = call noundef i64 @_ZNK8orgQhull11Coordinates14const_iteratormiES1_(ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef %11)
  %40 = trunc i64 %39 to i32
  store i32 %40, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %44

41:                                               ; preds = %32
  %42 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN8orgQhull11Coordinates14const_iteratorppEv(ptr noundef nonnull align 8 dereferenceable(8) %8)
  br label %30, !llvm.loop !13

43:                                               ; preds = %30
  store i32 0, ptr %12, align 4
  br label %44

44:                                               ; preds = %43, %38
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %45 = load i32, ptr %12, align 4
  switch i32 %45, label %50 [
    i32 0, label %46
    i32 1, label %48
  ]

46:                                               ; preds = %44
  br label %47

47:                                               ; preds = %46, %24
  store i32 -1, ptr %4, align 4
  br label %48

48:                                               ; preds = %47, %44
  %49 = load i32, ptr %4, align 4
  ret i32 %49

50:                                               ; preds = %44
  unreachable
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK8orgQhull11Coordinates8constEndEv(ptr dead_on_unwind noalias writable sret(%"class.orgQhull::Coordinates::const_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZN8orgQhull11Coordinates14const_iteratorppEv(ptr noundef nonnull align 8 dereferenceable(8)) #2 align 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 = { 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 = { 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, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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::Coordinates::const_iterator" = type { %"class.__gnu_cxx::__normal_iterator" }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }

; 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 uwtable
declare dso_local noundef i32 @_ZNK8orgQhull11Coordinates5countEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK8orgQhull11Coordinates5beginEv(ptr dead_on_unwind noalias writable sret(%"class.orgQhull::Coordinates::const_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK8orgQhull11Coordinates14const_iteratorplEi(ptr dead_on_unwind noalias writable sret(%"class.orgQhull::Coordinates::const_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) 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
define dso_local noundef i32 @_ZNK8orgQhull11Coordinates7indexOfERKdi(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(8) %1, i32 noundef %2) local_unnamed_addr #1 align 2 {
  %4 = alloca %"class.orgQhull::Coordinates::const_iterator", align 8
  %5 = alloca %"class.orgQhull::Coordinates::const_iterator", align 8
  %6 = alloca %"class.orgQhull::Coordinates::const_iterator", align 8
  %7 = alloca %"class.orgQhull::Coordinates::const_iterator", align 8
  %8 = icmp slt i32 %2, 0
  br i1 %8, label %9, label %12

9:                                                ; preds = %3
  %10 = tail call noundef i32 @_ZNK8orgQhull11Coordinates5countEv(ptr noundef nonnull align 8 dereferenceable(24) %0)
  %11 = add nsw i32 %10, %2
  %spec.store.select = tail call i32 @llvm.smax.i32(i32 %11, i32 0)
  br label %12

12:                                               ; preds = %9, %3
  %.08 = phi i32 [ %spec.store.select, %9 ], [ %2, %3 ]
  %13 = tail call noundef i32 @_ZNK8orgQhull11Coordinates5countEv(ptr noundef nonnull align 8 dereferenceable(24) %0)
  %14 = icmp slt i32 %.08, %13
  br i1 %14, label %15, label %27

15:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  call void @_ZNK8orgQhull11Coordinates5beginEv(ptr dead_on_unwind nonnull writable sret(%"class.orgQhull::Coordinates::const_iterator") align 8 %5, ptr noundef nonnull align 8 dereferenceable(24) %0)
  call void @_ZNK8orgQhull11Coordinates14const_iteratorplEi(ptr dead_on_unwind nonnull writable sret(%"class.orgQhull::Coordinates::const_iterator") align 8 %4, ptr noundef nonnull align 8 dereferenceable(8) %5, i32 noundef %.08)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #4
  call void @_ZNK8orgQhull11Coordinates8constEndEv(ptr dead_on_unwind nonnull writable sret(%"class.orgQhull::Coordinates::const_iterator") align 8 %6, ptr noundef nonnull align 8 dereferenceable(24) %0)
  %16 = call noundef zeroext i1 @_ZNK8orgQhull11Coordinates14const_iteratorneERKS1_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %6)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #4
  br i1 %16, label %.lr.ph, label %.thread

.thread:                                          ; preds = %21, %15
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  br label %27

.lr.ph:                                           ; preds = %15, %21
  %17 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK8orgQhull11Coordinates14const_iteratordeEv(ptr noundef nonnull align 8 dereferenceable(8) %4)
  %18 = load double, ptr %17, align 8, !tbaa !5
  %19 = load double, ptr %1, align 8, !tbaa !5
  %20 = fcmp oeq double %18, %19
  br i1 %20, label %24, label %21

21:                                               ; preds = %.lr.ph
  %22 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN8orgQhull11Coordinates14const_iteratorppEv(ptr noundef nonnull align 8 dereferenceable(8) %4)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #4
  call void @_ZNK8orgQhull11Coordinates8constEndEv(ptr dead_on_unwind nonnull writable sret(%"class.orgQhull::Coordinates::const_iterator") align 8 %6, ptr noundef nonnull align 8 dereferenceable(24) %0)
  %23 = call noundef zeroext i1 @_ZNK8orgQhull11Coordinates14const_iteratorneERKS1_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %6)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #4
  br i1 %23, label %.lr.ph, label %.thread, !llvm.loop !9

24:                                               ; preds = %.lr.ph
  call void @_ZNK8orgQhull11Coordinates5beginEv(ptr dead_on_unwind nonnull writable sret(%"class.orgQhull::Coordinates::const_iterator") align 8 %7, ptr noundef nonnull align 8 dereferenceable(24) %0)
  %25 = call noundef i64 @_ZNK8orgQhull11Coordinates14const_iteratormiES1_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull %7)
  %26 = trunc i64 %25 to i32
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  br label %27

27:                                               ; preds = %12, %.thread, %24
  %.1 = phi i32 [ %26, %24 ], [ -1, %.thread ], [ -1, %12 ]
  ret i32 %.1
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK8orgQhull11Coordinates8constEndEv(ptr dead_on_unwind noalias writable sret(%"class.orgQhull::Coordinates::const_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

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

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #3

attributes #0 = { mustprogress 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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass