; LLVM IR from PaddlePaddle/Serving :: core/predictor/tools/ocrtools/clipper.ll (ZNK10ClipperLib8PolyNode16GetNextSiblingUpEv)

; 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.ClipperLib::PolyNode" = type { ptr, %"class.std::vector", %"class.std::vector.0", ptr, i32, i8, i32, i32 }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<ClipperLib::IntPoint, std::allocator<ClipperLib::IntPoint>>::_Vector_impl" }
%"struct.std::_Vector_base<ClipperLib::IntPoint, std::allocator<ClipperLib::IntPoint>>::_Vector_impl" = type { %"struct.std::_Vector_base<ClipperLib::IntPoint, std::allocator<ClipperLib::IntPoint>>::_Vector_impl_data" }
%"struct.std::_Vector_base<ClipperLib::IntPoint, std::allocator<ClipperLib::IntPoint>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<ClipperLib::PolyNode *, std::allocator<ClipperLib::PolyNode *>>::_Vector_impl" }
%"struct.std::_Vector_base<ClipperLib::PolyNode *, std::allocator<ClipperLib::PolyNode *>>::_Vector_impl" = type { %"struct.std::_Vector_base<ClipperLib::PolyNode *, std::allocator<ClipperLib::PolyNode *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<ClipperLib::PolyNode *, std::allocator<ClipperLib::PolyNode *>>::_Vector_impl_data" = type { ptr, ptr, ptr }

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZNK10ClipperLib8PolyNode16GetNextSiblingUpEv(ptr noundef nonnull align 8 dereferenceable(80) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %4 = load ptr, ptr %3, align 8
  %5 = getelementptr inbounds %"class.ClipperLib::PolyNode", ptr %4, i32 0, i32 3
  %6 = load ptr, ptr %5, align 8, !tbaa !9
  %7 = icmp ne ptr %6, null
  br i1 %7, label %9, label %8

8:                                                ; preds = %1
  store ptr null, ptr %2, align 8
  br label %33

9:                                                ; preds = %1
  %10 = getelementptr inbounds %"class.ClipperLib::PolyNode", ptr %4, i32 0, i32 4
  %11 = load i32, ptr %10, align 8, !tbaa !23
  %12 = zext i32 %11 to i64
  %13 = getelementptr inbounds %"class.ClipperLib::PolyNode", ptr %4, i32 0, i32 3
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  %15 = getelementptr inbounds %"class.ClipperLib::PolyNode", ptr %14, i32 0, i32 2
  %16 = call noundef i64 @_ZNKSt6vectorIPN10ClipperLib8PolyNodeESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %15) #2
  %17 = sub i64 %16, 1
  %18 = icmp eq i64 %12, %17
  br i1 %18, label %19, label %23

19:                                               ; preds = %9
  %20 = getelementptr inbounds %"class.ClipperLib::PolyNode", ptr %4, i32 0, i32 3
  %21 = load ptr, ptr %20, align 8, !tbaa !9
  %22 = call noundef ptr @_ZNK10ClipperLib8PolyNode16GetNextSiblingUpEv(ptr noundef nonnull align 8 dereferenceable(80) %21)
  store ptr %22, ptr %2, align 8
  br label %33

23:                                               ; preds = %9
  %24 = getelementptr inbounds %"class.ClipperLib::PolyNode", ptr %4, i32 0, i32 3
  %25 = load ptr, ptr %24, align 8, !tbaa !9
  %26 = getelementptr inbounds %"class.ClipperLib::PolyNode", ptr %25, i32 0, i32 2
  %27 = getelementptr inbounds %"class.ClipperLib::PolyNode", ptr %4, i32 0, i32 4
  %28 = load i32, ptr %27, align 8, !tbaa !23
  %29 = add i32 %28, 1
  %30 = zext i32 %29 to i64
  %31 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN10ClipperLib8PolyNodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %26, i64 noundef %30) #2
  %32 = load ptr, ptr %31, align 8, !tbaa !5
  store ptr %32, ptr %2, align 8
  br label %33

33:                                               ; preds = %23, %19, %8
  %34 = load ptr, ptr %2, align 8
  ret ptr %34
}

attributes #0 = { 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 #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 = { 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 56}
!10 = !{!"_ZTSN10ClipperLib8PolyNodeE", !11, i64 8, !15, i64 32, !6, i64 56, !19, i64 64, !20, i64 68, !21, i64 72, !22, i64 76}
!11 = !{!"_ZTSSt6vectorIN10ClipperLib8IntPointESaIS1_EE", !12, i64 0}
!12 = !{!"_ZTSSt12_Vector_baseIN10ClipperLib8IntPointESaIS1_EE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIN10ClipperLib8IntPointESaIS1_EE12_Vector_implE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseIN10ClipperLib8IntPointESaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!15 = !{!"_ZTSSt6vectorIPN10ClipperLib8PolyNodeESaIS2_EE", !16, i64 0}
!16 = !{!"_ZTSSt12_Vector_baseIPN10ClipperLib8PolyNodeESaIS2_EE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIPN10ClipperLib8PolyNodeESaIS2_EE12_Vector_implE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIPN10ClipperLib8PolyNodeESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!19 = !{!"int", !7, i64 0}
!20 = !{!"bool", !7, i64 0}
!21 = !{!"_ZTSN10ClipperLib8JoinTypeE", !7, i64 0}
!22 = !{!"_ZTSN10ClipperLib7EndTypeE", !7, i64 0}
!23 = !{!10, !19, i64 64}


; 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"

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef ptr @_ZNK10ClipperLib8PolyNode16GetNextSiblingUpEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(80) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 56
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %.not5 = icmp eq ptr %3, null
  br i1 %.not5, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %1, %tailrecurse
  %4 = phi ptr [ %15, %tailrecurse ], [ %3, %1 ]
  %5 = phi ptr [ %14, %tailrecurse ], [ %2, %1 ]
  %.tr6 = phi ptr [ %13, %tailrecurse ], [ %0, %1 ]
  %6 = getelementptr inbounds i8, ptr %.tr6, i64 64
  %7 = load i32, ptr %6, align 8, !tbaa !22
  %8 = zext i32 %7 to i64
  %9 = getelementptr inbounds i8, ptr %4, i64 32
  %10 = tail call noundef i64 @_ZNKSt6vectorIPN10ClipperLib8PolyNodeESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %9) #1
  %11 = add i64 %10, -1
  %12 = icmp eq i64 %11, %8
  br i1 %12, label %tailrecurse, label %16

tailrecurse:                                      ; preds = %.lr.ph
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %13, i64 56
  %15 = load ptr, ptr %14, align 8, !tbaa !5
  %.not = icmp eq ptr %15, null
  br i1 %.not, label %.loopexit, label %.lr.ph

16:                                               ; preds = %.lr.ph
  %17 = getelementptr inbounds i8, ptr %.tr6, i64 64
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %18, i64 32
  %20 = load i32, ptr %17, align 8, !tbaa !22
  %21 = add i32 %20, 1
  %22 = zext i32 %21 to i64
  %23 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN10ClipperLib8PolyNodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %19, i64 noundef %22) #1
  %24 = load ptr, ptr %23, align 8, !tbaa !23
  br label %.loopexit

.loopexit:                                        ; preds = %tailrecurse, %1, %16
  %.0 = phi ptr [ %24, %16 ], [ null, %1 ], [ null, %tailrecurse ]
  ret ptr %.0
}

attributes #0 = { 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 #1 = { 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, !11, i64 56}
!6 = !{!"_ZTSN10ClipperLib8PolyNodeE", !7, i64 8, !14, i64 32, !11, i64 56, !18, i64 64, !19, i64 68, !20, i64 72, !21, i64 76}
!7 = !{!"_ZTSSt6vectorIN10ClipperLib8IntPointESaIS1_EE", !8, i64 0}
!8 = !{!"_ZTSSt12_Vector_baseIN10ClipperLib8IntPointESaIS1_EE", !9, i64 0}
!9 = !{!"_ZTSNSt12_Vector_baseIN10ClipperLib8IntPointESaIS1_EE12_Vector_implE", !10, i64 0}
!10 = !{!"_ZTSNSt12_Vector_baseIN10ClipperLib8IntPointESaIS1_EE17_Vector_impl_dataE", !11, i64 0, !11, i64 8, !11, i64 16}
!11 = !{!"any pointer", !12, i64 0}
!12 = !{!"omnipotent char", !13, i64 0}
!13 = !{!"Simple C++ TBAA"}
!14 = !{!"_ZTSSt6vectorIPN10ClipperLib8PolyNodeESaIS2_EE", !15, i64 0}
!15 = !{!"_ZTSSt12_Vector_baseIPN10ClipperLib8PolyNodeESaIS2_EE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIPN10ClipperLib8PolyNodeESaIS2_EE12_Vector_implE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIPN10ClipperLib8PolyNodeESaIS2_EE17_Vector_impl_dataE", !11, i64 0, !11, i64 8, !11, i64 16}
!18 = !{!"int", !12, i64 0}
!19 = !{!"bool", !12, i64 0}
!20 = !{!"_ZTSN10ClipperLib8JoinTypeE", !12, i64 0}
!21 = !{!"_ZTSN10ClipperLib7EndTypeE", !12, i64 0}
!22 = !{!6, !18, i64 64}
!23 = !{!11, !11, i64 0}


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