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

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

; 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN10ClipperLibeqERKNS_8IntPointES2_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN10ClipperLib12IsHorizontalERNS_5TEdgeE(ptr noundef nonnull align 8 dereferenceable(136)) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN10ClipperLibneERKNS_8IntPointES2_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN10ClipperLib14FindNextLocMinEPNS_5TEdgeE(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  br label %5

5:                                                ; preds = %82, %1
  br label %6

6:                                                ; preds = %22, %5
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = getelementptr inbounds %"struct.ClipperLib::TEdge", ptr %7, i32 0, i32 0
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %"struct.ClipperLib::TEdge", ptr %9, i32 0, i32 11
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  %12 = getelementptr inbounds %"struct.ClipperLib::TEdge", ptr %11, i32 0, i32 0
  %13 = call noundef zeroext i1 @_ZN10ClipperLibneERKNS_8IntPointES2_(ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef nonnull align 8 dereferenceable(16) %12)
  br i1 %13, label %20, label %14

14:                                               ; preds = %6
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds %"struct.ClipperLib::TEdge", ptr %15, i32 0, i32 1
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %"struct.ClipperLib::TEdge", ptr %17, i32 0, i32 2
  %19 = call noundef zeroext i1 @_ZN10ClipperLibeqERKNS_8IntPointES2_(ptr noundef nonnull align 8 dereferenceable(16) %16, ptr noundef nonnull align 8 dereferenceable(16) %18)
  br label %20

20:                                               ; preds = %14, %6
  %21 = phi i1 [ true, %6 ], [ %19, %14 ]
  br i1 %21, label %22, label %26

22:                                               ; preds = %20
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = getelementptr inbounds %"struct.ClipperLib::TEdge", ptr %23, i32 0, i32 10
  %25 = load ptr, ptr %24, align 8, !tbaa !17
  store ptr %25, ptr %2, align 8, !tbaa !5
  br label %6, !llvm.loop !18

26:                                               ; preds = %20
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = call noundef zeroext i1 @_ZN10ClipperLib12IsHorizontalERNS_5TEdgeE(ptr noundef nonnull align 8 dereferenceable(136) %27)
  br i1 %28, label %35, label %29

29:                                               ; preds = %26
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  %31 = getelementptr inbounds %"struct.ClipperLib::TEdge", ptr %30, i32 0, i32 11
  %32 = load ptr, ptr %31, align 8, !tbaa !9
  %33 = call noundef zeroext i1 @_ZN10ClipperLib12IsHorizontalERNS_5TEdgeE(ptr noundef nonnull align 8 dereferenceable(136) %32)
  br i1 %33, label %35, label %34

34:                                               ; preds = %29
  br label %84

35:                                               ; preds = %29, %26
  br label %36

36:                                               ; preds = %41, %35
  %37 = load ptr, ptr %2, align 8, !tbaa !5
  %38 = getelementptr inbounds %"struct.ClipperLib::TEdge", ptr %37, i32 0, i32 11
  %39 = load ptr, ptr %38, align 8, !tbaa !9
  %40 = call noundef zeroext i1 @_ZN10ClipperLib12IsHorizontalERNS_5TEdgeE(ptr noundef nonnull align 8 dereferenceable(136) %39)
  br i1 %40, label %41, label %45

41:                                               ; preds = %36
  %42 = load ptr, ptr %2, align 8, !tbaa !5
  %43 = getelementptr inbounds %"struct.ClipperLib::TEdge", ptr %42, i32 0, i32 11
  %44 = load ptr, ptr %43, align 8, !tbaa !9
  store ptr %44, ptr %2, align 8, !tbaa !5
  br label %36, !llvm.loop !20

45:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %46 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %46, ptr %3, align 8, !tbaa !5
  br label %47

47:                                               ; preds = %50, %45
  %48 = load ptr, ptr %2, align 8, !tbaa !5
  %49 = call noundef zeroext i1 @_ZN10ClipperLib12IsHorizontalERNS_5TEdgeE(ptr noundef nonnull align 8 dereferenceable(136) %48)
  br i1 %49, label %50, label %54

50:                                               ; preds = %47
  %51 = load ptr, ptr %2, align 8, !tbaa !5
  %52 = getelementptr inbounds %"struct.ClipperLib::TEdge", ptr %51, i32 0, i32 10
  %53 = load ptr, ptr %52, align 8, !tbaa !17
  store ptr %53, ptr %2, align 8, !tbaa !5
  br label %47, !llvm.loop !21

54:                                               ; preds = %47
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = getelementptr inbounds %"struct.ClipperLib::TEdge", ptr %55, i32 0, i32 2
  %57 = getelementptr inbounds %"struct.ClipperLib::IntPoint", ptr %56, i32 0, i32 1
  %58 = load i64, ptr %57, align 8, !tbaa !22
  %59 = load ptr, ptr %2, align 8, !tbaa !5
  %60 = getelementptr inbounds %"struct.ClipperLib::TEdge", ptr %59, i32 0, i32 11
  %61 = load ptr, ptr %60, align 8, !tbaa !9
  %62 = getelementptr inbounds %"struct.ClipperLib::TEdge", ptr %61, i32 0, i32 0
  %63 = getelementptr inbounds %"struct.ClipperLib::IntPoint", ptr %62, i32 0, i32 1
  %64 = load i64, ptr %63, align 8, !tbaa !23
  %65 = icmp eq i64 %58, %64
  br i1 %65, label %66, label %67

66:                                               ; preds = %54
  store i32 3, ptr %4, align 4
  br label %82, !llvm.loop !24

67:                                               ; preds = %54
  %68 = load ptr, ptr %3, align 8, !tbaa !5
  %69 = getelementptr inbounds %"struct.ClipperLib::TEdge", ptr %68, i32 0, i32 11
  %70 = load ptr, ptr %69, align 8, !tbaa !9
  %71 = getelementptr inbounds %"struct.ClipperLib::TEdge", ptr %70, i32 0, i32 0
  %72 = getelementptr inbounds %"struct.ClipperLib::IntPoint", ptr %71, i32 0, i32 0
  %73 = load i64, ptr %72, align 8, !tbaa !25
  %74 = load ptr, ptr %2, align 8, !tbaa !5
  %75 = getelementptr inbounds %"struct.ClipperLib::TEdge", ptr %74, i32 0, i32 0
  %76 = getelementptr inbounds %"struct.ClipperLib::IntPoint", ptr %75, i32 0, i32 0
  %77 = load i64, ptr %76, align 8, !tbaa !25
  %78 = icmp slt i64 %73, %77
  br i1 %78, label %79, label %81

79:                                               ; preds = %67
  %80 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %80, ptr %2, align 8, !tbaa !5
  br label %81

81:                                               ; preds = %79, %67
  store i32 2, ptr %4, align 4
  br label %82

82:                                               ; preds = %81, %66
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  %83 = load i32, ptr %4, align 4
  switch i32 %83, label %86 [
    i32 3, label %5
    i32 2, label %84
  ]

84:                                               ; preds = %82, %34
  %85 = load ptr, ptr %2, align 8, !tbaa !5
  ret ptr %85

86:                                               ; preds = %82
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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, !6, i64 88}
!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, !6, i64 80}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}
!21 = distinct !{!21, !19}
!22 = !{!10, !12, i64 40}
!23 = !{!10, !12, i64 8}
!24 = distinct !{!24, !19}
!25 = !{!10, !12, 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN10ClipperLibeqERKNS_8IntPointES2_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN10ClipperLib12IsHorizontalERNS_5TEdgeE(ptr noundef nonnull align 8 dereferenceable(136)) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN10ClipperLibneERKNS_8IntPointES2_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef ptr @_ZN10ClipperLib14FindNextLocMinEPNS_5TEdgeE(ptr noundef %0) local_unnamed_addr #1 {
  br label %2

2:                                                ; preds = %.backedge, %1
  %.1 = phi ptr [ %0, %1 ], [ %.1.be, %.backedge ]
  %3 = getelementptr inbounds i8, ptr %.1, i64 88
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = tail call noundef zeroext i1 @_ZN10ClipperLibneERKNS_8IntPointES2_(ptr noundef nonnull align 8 dereferenceable(16) %.1, ptr noundef nonnull align 8 dereferenceable(16) %4)
  br i1 %5, label %.critedge, label %6

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %.1, i64 16
  %8 = getelementptr inbounds i8, ptr %.1, i64 32
  %9 = tail call noundef zeroext i1 @_ZN10ClipperLibeqERKNS_8IntPointES2_(ptr noundef nonnull align 8 dereferenceable(16) %7, ptr noundef nonnull align 8 dereferenceable(16) %8)
  br i1 %9, label %.critedge, label %12

.critedge:                                        ; preds = %2, %6
  %10 = getelementptr inbounds i8, ptr %.1, i64 80
  %11 = load ptr, ptr %10, align 8, !tbaa !16
  br label %.backedge

.backedge:                                        ; preds = %.critedge, %._crit_edge
  %.1.be = phi ptr [ %11, %.critedge ], [ %.3.lcssa, %._crit_edge ]
  br label %2, !llvm.loop !17

12:                                               ; preds = %6
  %13 = getelementptr inbounds i8, ptr %.1, i64 88
  %14 = tail call noundef zeroext i1 @_ZN10ClipperLib12IsHorizontalERNS_5TEdgeE(ptr noundef nonnull align 8 dereferenceable(136) %.1)
  br i1 %14, label %18, label %15

15:                                               ; preds = %12
  %16 = load ptr, ptr %13, align 8, !tbaa !5
  %17 = tail call noundef zeroext i1 @_ZN10ClipperLib12IsHorizontalERNS_5TEdgeE(ptr noundef nonnull align 8 dereferenceable(136) %16)
  br i1 %17, label %18, label %.loopexit

18:                                               ; preds = %15, %12
  %19 = load ptr, ptr %13, align 8, !tbaa !5
  %20 = tail call noundef zeroext i1 @_ZN10ClipperLib12IsHorizontalERNS_5TEdgeE(ptr noundef nonnull align 8 dereferenceable(136) %19)
  br i1 %20, label %.lr.ph, label %.preheader

.preheader:                                       ; preds = %.lr.ph, %18
  %.2.lcssa = phi ptr [ %.1, %18 ], [ %23, %.lr.ph ]
  %.lcssa24 = phi ptr [ %13, %18 ], [ %24, %.lr.ph ]
  %21 = tail call noundef zeroext i1 @_ZN10ClipperLib12IsHorizontalERNS_5TEdgeE(ptr noundef nonnull align 8 dereferenceable(136) %.2.lcssa)
  br i1 %21, label %.lr.ph28, label %._crit_edge

.lr.ph:                                           ; preds = %18, %.lr.ph
  %22 = phi ptr [ %24, %.lr.ph ], [ %13, %18 ]
  %23 = load ptr, ptr %22, align 8, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %23, i64 88
  %25 = load ptr, ptr %24, align 8, !tbaa !5
  %26 = tail call noundef zeroext i1 @_ZN10ClipperLib12IsHorizontalERNS_5TEdgeE(ptr noundef nonnull align 8 dereferenceable(136) %25)
  br i1 %26, label %.lr.ph, label %.preheader, !llvm.loop !19

.lr.ph28:                                         ; preds = %.preheader, %.lr.ph28
  %.327 = phi ptr [ %28, %.lr.ph28 ], [ %.2.lcssa, %.preheader ]
  %27 = getelementptr inbounds i8, ptr %.327, i64 80
  %28 = load ptr, ptr %27, align 8, !tbaa !16
  %29 = tail call noundef zeroext i1 @_ZN10ClipperLib12IsHorizontalERNS_5TEdgeE(ptr noundef nonnull align 8 dereferenceable(136) %28)
  br i1 %29, label %.lr.ph28, label %._crit_edge, !llvm.loop !20

._crit_edge:                                      ; preds = %.lr.ph28, %.preheader
  %.3.lcssa = phi ptr [ %.2.lcssa, %.preheader ], [ %28, %.lr.ph28 ]
  %30 = getelementptr inbounds i8, ptr %.3.lcssa, i64 40
  %31 = load i64, ptr %30, align 8, !tbaa !21
  %32 = getelementptr inbounds i8, ptr %.3.lcssa, i64 88
  %33 = load ptr, ptr %32, align 8, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %33, i64 8
  %35 = load i64, ptr %34, align 8, !tbaa !22
  %36 = icmp eq i64 %31, %35
  br i1 %36, label %.backedge, label %.thread

.thread:                                          ; preds = %._crit_edge
  %37 = load ptr, ptr %.lcssa24, align 8, !tbaa !5
  %38 = load i64, ptr %37, align 8, !tbaa !23
  %39 = load i64, ptr %.3.lcssa, align 8, !tbaa !23
  %40 = icmp slt i64 %38, %39
  %spec.select = select i1 %40, ptr %.2.lcssa, ptr %.3.lcssa
  br label %.loopexit

.loopexit:                                        ; preds = %15, %.thread
  %.6 = phi ptr [ %spec.select, %.thread ], [ %.1, %15 ]
  ret ptr %.6
}

attributes #0 = { inlinehint 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 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" }

!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 88}
!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, !15, i64 80}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}
!20 = distinct !{!20, !18}
!21 = !{!6, !8, i64 40}
!22 = !{!6, !8, i64 8}
!23 = !{!6, !8, i64 0}


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