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

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

%"struct.ClipperLib::TEdge" = type { %"struct.ClipperLib::IntPoint", %"struct.ClipperLib::IntPoint", %"struct.ClipperLib::IntPoint", double, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%"struct.ClipperLib::IntPoint" = type { i64, i64 }
%"struct.ClipperLib::OutRec" = type { i32, i8, i8, ptr, ptr, ptr, ptr }
%"class.ClipperLib::ClipperBase" = type { ptr, %"class.__gnu_cxx::__normal_iterator", %"class.std::vector.5", i8, %"class.std::vector.10", i8, i8, %"class.std::vector.15", ptr, %"class.std::priority_queue" }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }
%"class.std::vector.5" = type { %"struct.std::_Vector_base.6" }
%"struct.std::_Vector_base.6" = type { %"struct.std::_Vector_base<ClipperLib::LocalMinimum, std::allocator<ClipperLib::LocalMinimum>>::_Vector_impl" }
%"struct.std::_Vector_base<ClipperLib::LocalMinimum, std::allocator<ClipperLib::LocalMinimum>>::_Vector_impl" = type { %"struct.std::_Vector_base<ClipperLib::LocalMinimum, std::allocator<ClipperLib::LocalMinimum>>::_Vector_impl_data" }
%"struct.std::_Vector_base<ClipperLib::LocalMinimum, std::allocator<ClipperLib::LocalMinimum>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.10" = type { %"struct.std::_Vector_base.11" }
%"struct.std::_Vector_base.11" = type { %"struct.std::_Vector_base<ClipperLib::TEdge *, std::allocator<ClipperLib::TEdge *>>::_Vector_impl" }
%"struct.std::_Vector_base<ClipperLib::TEdge *, std::allocator<ClipperLib::TEdge *>>::_Vector_impl" = type { %"struct.std::_Vector_base<ClipperLib::TEdge *, std::allocator<ClipperLib::TEdge *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<ClipperLib::TEdge *, std::allocator<ClipperLib::TEdge *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.15" = type { %"struct.std::_Vector_base.16" }
%"struct.std::_Vector_base.16" = type { %"struct.std::_Vector_base<ClipperLib::OutRec *, std::allocator<ClipperLib::OutRec *>>::_Vector_impl" }
%"struct.std::_Vector_base<ClipperLib::OutRec *, std::allocator<ClipperLib::OutRec *>>::_Vector_impl" = type { %"struct.std::_Vector_base<ClipperLib::OutRec *, std::allocator<ClipperLib::OutRec *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<ClipperLib::OutRec *, std::allocator<ClipperLib::OutRec *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::priority_queue" = type <{ %"class.std::vector.20", [8 x i8] }>
%"class.std::vector.20" = type { %"struct.std::_Vector_base.21" }
%"struct.std::_Vector_base.21" = type { %"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl" }
%"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl" = type { %"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl_data" }
%"struct.std::_Vector_base<long long, std::allocator<long long>>::_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: 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 nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN10ClipperLib6OutRecESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN10ClipperLib7Clipper12SetHoleStateEPNS_5TEdgeEPNS_6OutRecE(ptr noundef nonnull align 8 dereferenceable(135) %0, ptr noundef %1, ptr noundef %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = getelementptr inbounds %"struct.ClipperLib::TEdge", ptr %10, i32 0, i32 14
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  store ptr %12, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  store ptr null, ptr %8, align 8, !tbaa !5
  br label %13

13:                                               ; preds = %42, %3
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %46

16:                                               ; preds = %13
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = getelementptr inbounds %"struct.ClipperLib::TEdge", ptr %17, i32 0, i32 9
  %19 = load i32, ptr %18, align 4, !tbaa !17
  %20 = icmp sge i32 %19, 0
  br i1 %20, label %21, label %42

21:                                               ; preds = %16
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = getelementptr inbounds %"struct.ClipperLib::TEdge", ptr %22, i32 0, i32 6
  %24 = load i32, ptr %23, align 8, !tbaa !18
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %26, label %42

26:                                               ; preds = %21
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = icmp ne ptr %27, null
  br i1 %28, label %31, label %29

29:                                               ; preds = %26
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %30, ptr %8, align 8, !tbaa !5
  br label %41

31:                                               ; preds = %26
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = getelementptr inbounds %"struct.ClipperLib::TEdge", ptr %32, i32 0, i32 9
  %34 = load i32, ptr %33, align 4, !tbaa !17
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = getelementptr inbounds %"struct.ClipperLib::TEdge", ptr %35, i32 0, i32 9
  %37 = load i32, ptr %36, align 4, !tbaa !17
  %38 = icmp eq i32 %34, %37
  br i1 %38, label %39, label %40

39:                                               ; preds = %31
  store ptr null, ptr %8, align 8, !tbaa !5
  br label %40

40:                                               ; preds = %39, %31
  br label %41

41:                                               ; preds = %40, %29
  br label %42

42:                                               ; preds = %41, %21, %16
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = getelementptr inbounds %"struct.ClipperLib::TEdge", ptr %43, i32 0, i32 14
  %45 = load ptr, ptr %44, align 8, !tbaa !9
  store ptr %45, ptr %7, align 8, !tbaa !5
  br label %13, !llvm.loop !19

46:                                               ; preds = %13
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = icmp ne ptr %47, null
  br i1 %48, label %54, label %49

49:                                               ; preds = %46
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = getelementptr inbounds %"struct.ClipperLib::OutRec", ptr %50, i32 0, i32 3
  store ptr null, ptr %51, align 8, !tbaa !21
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = getelementptr inbounds %"struct.ClipperLib::OutRec", ptr %52, i32 0, i32 1
  store i8 0, ptr %53, align 4, !tbaa !24
  br label %78

54:                                               ; preds = %46
  %55 = load ptr, ptr %9, align 8, !tbaa !25
  %56 = getelementptr i8, ptr %55, i64 -24
  %57 = load i64, ptr %56, align 8
  %58 = getelementptr inbounds i8, ptr %9, i64 %57
  %59 = getelementptr inbounds %"class.ClipperLib::ClipperBase", ptr %58, i32 0, i32 7
  %60 = load ptr, ptr %8, align 8, !tbaa !5
  %61 = getelementptr inbounds %"struct.ClipperLib::TEdge", ptr %60, i32 0, i32 9
  %62 = load i32, ptr %61, align 4, !tbaa !17
  %63 = sext i32 %62 to i64
  %64 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN10ClipperLib6OutRecESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %59, i64 noundef %63) #2
  %65 = load ptr, ptr %64, align 8, !tbaa !5
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = getelementptr inbounds %"struct.ClipperLib::OutRec", ptr %66, i32 0, i32 3
  store ptr %65, ptr %67, align 8, !tbaa !21
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = getelementptr inbounds %"struct.ClipperLib::OutRec", ptr %68, i32 0, i32 3
  %70 = load ptr, ptr %69, align 8, !tbaa !21
  %71 = getelementptr inbounds %"struct.ClipperLib::OutRec", ptr %70, i32 0, i32 1
  %72 = load i8, ptr %71, align 4, !tbaa !24, !range !27, !noundef !28
  %73 = trunc i8 %72 to i1
  %74 = xor i1 %73, true
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = getelementptr inbounds %"struct.ClipperLib::OutRec", ptr %75, i32 0, i32 1
  %77 = zext i1 %74 to i8
  store i8 %77, ptr %76, align 4, !tbaa !24
  br label %78

78:                                               ; preds = %54, %49
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  ret void
}

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, !6, i64 112}
!10 = !{!"_ZTSN10ClipperLib5TEdgeE", !11, i64 0, !11, i64 16, !11, i64 32, !13, i64 48, !14, i64 56, !15, i64 60, !16, i64 64, !16, i64 68, !16, i64 72, !16, i64 76, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128}
!11 = !{!"_ZTSN10ClipperLib8IntPointE", !12, i64 0, !12, i64 8}
!12 = !{!"long long", !7, i64 0}
!13 = !{!"double", !7, i64 0}
!14 = !{!"_ZTSN10ClipperLib8PolyTypeE", !7, i64 0}
!15 = !{!"_ZTSN10ClipperLib8EdgeSideE", !7, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = !{!10, !16, i64 76}
!18 = !{!10, !16, i64 64}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!22, !6, i64 8}
!22 = !{!"_ZTSN10ClipperLib6OutRecE", !16, i64 0, !23, i64 4, !23, i64 5, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!23 = !{!"bool", !7, i64 0}
!24 = !{!22, !23, i64 4}
!25 = !{!26, !26, i64 0}
!26 = !{!"vtable pointer", !8, i64 0}
!27 = !{i8 0, i8 2}
!28 = !{}


; 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 @_ZNSt6vectorIPN10ClipperLib6OutRecESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN10ClipperLib7Clipper12SetHoleStateEPNS_5TEdgeEPNS_6OutRecE(ptr noundef nonnull align 8 dereferenceable(135) %0, ptr nocapture noundef readonly %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #0 align 2 {
  %.017.in22 = getelementptr inbounds i8, ptr %1, i64 112
  %.01723 = load ptr, ptr %.017.in22, align 8, !tbaa !5
  %.not24 = icmp eq ptr %.01723, null
  br i1 %.not24, label %._crit_edge.thread, label %.lr.ph

.lr.ph:                                           ; preds = %3, %15
  %.01726 = phi ptr [ %.017, %15 ], [ %.01723, %3 ]
  %.025 = phi ptr [ %.1, %15 ], [ null, %3 ]
  %4 = getelementptr inbounds i8, ptr %.01726, i64 76
  %5 = load i32, ptr %4, align 4, !tbaa !16
  %6 = icmp sgt i32 %5, -1
  br i1 %6, label %7, label %15

7:                                                ; preds = %.lr.ph
  %8 = getelementptr inbounds i8, ptr %.01726, i64 64
  %9 = load i32, ptr %8, align 8, !tbaa !17
  %.not20 = icmp eq i32 %9, 0
  br i1 %.not20, label %15, label %10

10:                                               ; preds = %7
  %.not21 = icmp eq ptr %.025, null
  br i1 %.not21, label %15, label %11

11:                                               ; preds = %10
  %12 = getelementptr inbounds i8, ptr %.025, i64 76
  %13 = load i32, ptr %12, align 4, !tbaa !16
  %14 = icmp eq i32 %13, %5
  %spec.store.select = select i1 %14, ptr null, ptr %.025
  br label %15

15:                                               ; preds = %10, %11, %7, %.lr.ph
  %.1 = phi ptr [ %spec.store.select, %11 ], [ %.025, %7 ], [ %.025, %.lr.ph ], [ %.01726, %10 ]
  %.017.in = getelementptr inbounds i8, ptr %.01726, i64 112
  %.017 = load ptr, ptr %.017.in, align 8, !tbaa !5
  %.not = icmp eq ptr %.017, null
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !18

._crit_edge:                                      ; preds = %15
  %.not19 = icmp eq ptr %.1, null
  br i1 %.not19, label %._crit_edge.thread, label %16

16:                                               ; preds = %._crit_edge
  %17 = load ptr, ptr %0, align 8, !tbaa !20
  %18 = getelementptr i8, ptr %17, i64 -24
  %19 = load i64, ptr %18, align 8
  %20 = getelementptr inbounds i8, ptr %0, i64 %19
  %21 = getelementptr inbounds i8, ptr %20, i64 80
  %22 = getelementptr inbounds i8, ptr %.1, i64 76
  %23 = load i32, ptr %22, align 4, !tbaa !16
  %24 = sext i32 %23 to i64
  %25 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN10ClipperLib6OutRecESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %21, i64 noundef %24) #1
  %26 = load ptr, ptr %25, align 8, !tbaa !22
  %27 = getelementptr inbounds i8, ptr %26, i64 4
  %28 = load i8, ptr %27, align 4, !tbaa !23, !range !26, !noundef !27
  %29 = xor i8 %28, 1
  br label %._crit_edge.thread

._crit_edge.thread:                               ; preds = %3, %._crit_edge, %16
  %.sink27 = phi ptr [ %26, %16 ], [ null, %._crit_edge ], [ null, %3 ]
  %.sink = phi i8 [ %29, %16 ], [ 0, %._crit_edge ], [ 0, %3 ]
  %30 = getelementptr inbounds i8, ptr %2, i64 8
  store ptr %.sink27, ptr %30, align 8
  %31 = getelementptr inbounds i8, ptr %2, i64 4
  store i8 %.sink, ptr %31, align 4
  ret void
}

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, !15, i64 112}
!6 = !{!"_ZTSN10ClipperLib5TEdgeE", !7, i64 0, !7, i64 16, !7, i64 32, !11, i64 48, !12, i64 56, !13, i64 60, !14, i64 64, !14, i64 68, !14, i64 72, !14, i64 76, !15, i64 80, !15, i64 88, !15, i64 96, !15, i64 104, !15, i64 112, !15, i64 120, !15, i64 128}
!7 = !{!"_ZTSN10ClipperLib8IntPointE", !8, i64 0, !8, i64 8}
!8 = !{!"long long", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"double", !9, i64 0}
!12 = !{!"_ZTSN10ClipperLib8PolyTypeE", !9, i64 0}
!13 = !{!"_ZTSN10ClipperLib8EdgeSideE", !9, i64 0}
!14 = !{!"int", !9, i64 0}
!15 = !{!"any pointer", !9, i64 0}
!16 = !{!6, !14, i64 76}
!17 = !{!6, !14, i64 64}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!21, !21, i64 0}
!21 = !{!"vtable pointer", !10, i64 0}
!22 = !{!15, !15, i64 0}
!23 = !{!24, !25, i64 4}
!24 = !{!"_ZTSN10ClipperLib6OutRecE", !14, i64 0, !25, i64 4, !25, i64 5, !15, i64 8, !15, i64 16, !15, i64 24, !15, i64 32}
!25 = !{!"bool", !9, i64 0}
!26 = !{i8 0, i8 2}
!27 = !{}


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