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

; 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::ClipperOffset" = type { double, double, %"class.std::vector.28", %"class.std::vector", %"class.std::vector", %"class.std::vector.49", double, double, double, double, double, double, %"struct.ClipperLib::IntPoint", %"class.ClipperLib::PolyNode" }
%"class.std::vector.28" = type { %"struct.std::_Vector_base.29" }
%"struct.std::_Vector_base.29" = type { %"struct.std::_Vector_base<std::vector<ClipperLib::IntPoint>, std::allocator<std::vector<ClipperLib::IntPoint>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::vector<ClipperLib::IntPoint>, std::allocator<std::vector<ClipperLib::IntPoint>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::vector<ClipperLib::IntPoint>, std::allocator<std::vector<ClipperLib::IntPoint>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::vector<ClipperLib::IntPoint>, std::allocator<std::vector<ClipperLib::IntPoint>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"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.49" = type { %"struct.std::_Vector_base.50" }
%"struct.std::_Vector_base.50" = type { %"struct.std::_Vector_base<ClipperLib::DoublePoint, std::allocator<ClipperLib::DoublePoint>>::_Vector_impl" }
%"struct.std::_Vector_base<ClipperLib::DoublePoint, std::allocator<ClipperLib::DoublePoint>>::_Vector_impl" = type { %"struct.std::_Vector_base<ClipperLib::DoublePoint, std::allocator<ClipperLib::DoublePoint>>::_Vector_impl_data" }
%"struct.std::_Vector_base<ClipperLib::DoublePoint, std::allocator<ClipperLib::DoublePoint>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.ClipperLib::IntPoint" = type { i64, i64 }
%"class.ClipperLib::PolyNode" = type { ptr, %"class.std::vector", %"class.std::vector.0", ptr, i32, i8, i32, i32 }
%"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: 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 nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN10ClipperLib8PolyNodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 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 nounwind uwtable
declare dso_local noundef i32 @_ZNK10ClipperLib8PolyNode10ChildCountEv(ptr noundef nonnull align 8 dereferenceable(80)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN10ClipperLib13ClipperOffset5ClearEv(ptr noundef nonnull align 8 dereferenceable(256) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %5

5:                                                ; preds = %24, %1
  %6 = load i32, ptr %3, align 4, !tbaa !9
  %7 = getelementptr inbounds %"class.ClipperLib::ClipperOffset", ptr %4, i32 0, i32 13
  %8 = call noundef i32 @_ZNK10ClipperLib8PolyNode10ChildCountEv(ptr noundef nonnull align 8 dereferenceable(80) %7)
  %9 = icmp slt i32 %6, %8
  br i1 %9, label %11, label %10

10:                                               ; preds = %5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  br label %27

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

19:                                               ; preds = %11
  %20 = load ptr, ptr %17, align 8, !tbaa !11
  %21 = getelementptr inbounds ptr, ptr %20, i64 1
  %22 = load ptr, ptr %21, align 8
  call void %22(ptr noundef nonnull align 8 dereferenceable(80) %17) #2
  br label %23

23:                                               ; preds = %19, %11
  br label %24

24:                                               ; preds = %23
  %25 = load i32, ptr %3, align 4, !tbaa !9
  %26 = add nsw i32 %25, 1
  store i32 %26, ptr %3, align 4, !tbaa !9
  br label %5, !llvm.loop !13

27:                                               ; preds = %10
  %28 = getelementptr inbounds %"class.ClipperLib::ClipperOffset", ptr %4, i32 0, i32 13
  %29 = getelementptr inbounds %"class.ClipperLib::PolyNode", ptr %28, i32 0, i32 2
  call void @_ZNSt6vectorIPN10ClipperLib8PolyNodeESaIS2_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %29) #2
  %30 = getelementptr inbounds %"class.ClipperLib::ClipperOffset", ptr %4, i32 0, i32 12
  %31 = getelementptr inbounds %"struct.ClipperLib::IntPoint", ptr %30, i32 0, i32 0
  store i64 -1, ptr %31, align 8, !tbaa !15
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIPN10ClipperLib8PolyNodeESaIS2_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 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 = { 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 = !{!"vtable pointer", !8, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !31, i64 160}
!16 = !{!"_ZTSN10ClipperLib13ClipperOffsetE", !17, i64 0, !17, i64 8, !18, i64 16, !22, i64 40, !22, i64 64, !26, i64 88, !17, i64 112, !17, i64 120, !17, i64 128, !17, i64 136, !17, i64 144, !17, i64 152, !30, i64 160, !32, i64 176}
!17 = !{!"double", !7, i64 0}
!18 = !{!"_ZTSSt6vectorIS_IN10ClipperLib8IntPointESaIS1_EESaIS3_EE", !19, i64 0}
!19 = !{!"_ZTSSt12_Vector_baseISt6vectorIN10ClipperLib8IntPointESaIS2_EESaIS4_EE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseISt6vectorIN10ClipperLib8IntPointESaIS2_EESaIS4_EE12_Vector_implE", !21, i64 0}
!21 = !{!"_ZTSNSt12_Vector_baseISt6vectorIN10ClipperLib8IntPointESaIS2_EESaIS4_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!22 = !{!"_ZTSSt6vectorIN10ClipperLib8IntPointESaIS1_EE", !23, i64 0}
!23 = !{!"_ZTSSt12_Vector_baseIN10ClipperLib8IntPointESaIS1_EE", !24, i64 0}
!24 = !{!"_ZTSNSt12_Vector_baseIN10ClipperLib8IntPointESaIS1_EE12_Vector_implE", !25, i64 0}
!25 = !{!"_ZTSNSt12_Vector_baseIN10ClipperLib8IntPointESaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!26 = !{!"_ZTSSt6vectorIN10ClipperLib11DoublePointESaIS1_EE", !27, i64 0}
!27 = !{!"_ZTSSt12_Vector_baseIN10ClipperLib11DoublePointESaIS1_EE", !28, i64 0}
!28 = !{!"_ZTSNSt12_Vector_baseIN10ClipperLib11DoublePointESaIS1_EE12_Vector_implE", !29, i64 0}
!29 = !{!"_ZTSNSt12_Vector_baseIN10ClipperLib11DoublePointESaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!30 = !{!"_ZTSN10ClipperLib8IntPointE", !31, i64 0, !31, i64 8}
!31 = !{!"long long", !7, i64 0}
!32 = !{!"_ZTSN10ClipperLib8PolyNodeE", !22, i64 8, !33, i64 32, !6, i64 56, !10, i64 64, !37, i64 68, !38, i64 72, !39, i64 76}
!33 = !{!"_ZTSSt6vectorIPN10ClipperLib8PolyNodeESaIS2_EE", !34, i64 0}
!34 = !{!"_ZTSSt12_Vector_baseIPN10ClipperLib8PolyNodeESaIS2_EE", !35, i64 0}
!35 = !{!"_ZTSNSt12_Vector_baseIPN10ClipperLib8PolyNodeESaIS2_EE12_Vector_implE", !36, i64 0}
!36 = !{!"_ZTSNSt12_Vector_baseIPN10ClipperLib8PolyNodeESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!37 = !{!"bool", !7, i64 0}
!38 = !{!"_ZTSN10ClipperLib8JoinTypeE", !7, i64 0}
!39 = !{!"_ZTSN10ClipperLib7EndTypeE", !7, i64 0}


; 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 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
declare dso_local noundef i32 @_ZNK10ClipperLib8PolyNode10ChildCountEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN10ClipperLib13ClipperOffset5ClearEv(ptr noundef nonnull align 8 dereferenceable(256) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 176
  %3 = tail call noundef i32 @_ZNK10ClipperLib8PolyNode10ChildCountEv(ptr noundef nonnull align 8 dereferenceable(80) %2)
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 208
  br label %8

._crit_edge:                                      ; preds = %16, %1
  %6 = getelementptr inbounds i8, ptr %0, i64 208
  tail call void @_ZNSt6vectorIPN10ClipperLib8PolyNodeESaIS2_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %6) #1
  %7 = getelementptr inbounds i8, ptr %0, i64 160
  store i64 -1, ptr %7, align 8, !tbaa !5
  ret void

8:                                                ; preds = %.lr.ph, %16
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %16 ]
  %9 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN10ClipperLib8PolyNodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %indvars.iv) #1
  %10 = load ptr, ptr %9, align 8, !tbaa !34
  %11 = icmp eq ptr %10, null
  br i1 %11, label %16, label %12

12:                                               ; preds = %8
  %13 = load ptr, ptr %10, align 8, !tbaa !35
  %14 = getelementptr inbounds i8, ptr %13, i64 8
  %15 = load ptr, ptr %14, align 8
  tail call void %15(ptr noundef nonnull align 8 dereferenceable(80) %10) #1
  br label %16

16:                                               ; preds = %8, %12
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %17 = tail call noundef i32 @_ZNK10ClipperLib8PolyNode10ChildCountEv(ptr noundef nonnull align 8 dereferenceable(80) %2)
  %18 = sext i32 %17 to i64
  %19 = icmp slt i64 %indvars.iv.next, %18
  br i1 %19, label %8, label %._crit_edge, !llvm.loop !37
}

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

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, !24, i64 160}
!6 = !{!"_ZTSN10ClipperLib13ClipperOffsetE", !7, i64 0, !7, i64 8, !10, i64 16, !15, i64 40, !15, i64 64, !19, i64 88, !7, i64 112, !7, i64 120, !7, i64 128, !7, i64 136, !7, i64 144, !7, i64 152, !23, i64 160, !25, i64 176}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSSt6vectorIS_IN10ClipperLib8IntPointESaIS1_EESaIS3_EE", !11, i64 0}
!11 = !{!"_ZTSSt12_Vector_baseISt6vectorIN10ClipperLib8IntPointESaIS2_EESaIS4_EE", !12, i64 0}
!12 = !{!"_ZTSNSt12_Vector_baseISt6vectorIN10ClipperLib8IntPointESaIS2_EESaIS4_EE12_Vector_implE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseISt6vectorIN10ClipperLib8IntPointESaIS2_EESaIS4_EE17_Vector_impl_dataE", !14, i64 0, !14, i64 8, !14, i64 16}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!"_ZTSSt6vectorIN10ClipperLib8IntPointESaIS1_EE", !16, i64 0}
!16 = !{!"_ZTSSt12_Vector_baseIN10ClipperLib8IntPointESaIS1_EE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIN10ClipperLib8IntPointESaIS1_EE12_Vector_implE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIN10ClipperLib8IntPointESaIS1_EE17_Vector_impl_dataE", !14, i64 0, !14, i64 8, !14, i64 16}
!19 = !{!"_ZTSSt6vectorIN10ClipperLib11DoublePointESaIS1_EE", !20, i64 0}
!20 = !{!"_ZTSSt12_Vector_baseIN10ClipperLib11DoublePointESaIS1_EE", !21, i64 0}
!21 = !{!"_ZTSNSt12_Vector_baseIN10ClipperLib11DoublePointESaIS1_EE12_Vector_implE", !22, i64 0}
!22 = !{!"_ZTSNSt12_Vector_baseIN10ClipperLib11DoublePointESaIS1_EE17_Vector_impl_dataE", !14, i64 0, !14, i64 8, !14, i64 16}
!23 = !{!"_ZTSN10ClipperLib8IntPointE", !24, i64 0, !24, i64 8}
!24 = !{!"long long", !8, i64 0}
!25 = !{!"_ZTSN10ClipperLib8PolyNodeE", !15, i64 8, !26, i64 32, !14, i64 56, !30, i64 64, !31, i64 68, !32, i64 72, !33, i64 76}
!26 = !{!"_ZTSSt6vectorIPN10ClipperLib8PolyNodeESaIS2_EE", !27, i64 0}
!27 = !{!"_ZTSSt12_Vector_baseIPN10ClipperLib8PolyNodeESaIS2_EE", !28, i64 0}
!28 = !{!"_ZTSNSt12_Vector_baseIPN10ClipperLib8PolyNodeESaIS2_EE12_Vector_implE", !29, i64 0}
!29 = !{!"_ZTSNSt12_Vector_baseIPN10ClipperLib8PolyNodeESaIS2_EE17_Vector_impl_dataE", !14, i64 0, !14, i64 8, !14, i64 16}
!30 = !{!"int", !8, i64 0}
!31 = !{!"bool", !8, i64 0}
!32 = !{!"_ZTSN10ClipperLib8JoinTypeE", !8, i64 0}
!33 = !{!"_ZTSN10ClipperLib7EndTypeE", !8, i64 0}
!34 = !{!14, !14, i64 0}
!35 = !{!36, !36, i64 0}
!36 = !{!"vtable pointer", !9, i64 0}
!37 = distinct !{!37, !38}
!38 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass