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

; 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::OutPt" = type { i32, %"struct.ClipperLib::IntPoint", 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: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN10ClipperLib15FirstIsBottomPtEPKNS_5OutPtES2_(ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN10ClipperLib11GetBottomPtEPNS_5OutPtE(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  store ptr null, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds %"struct.ClipperLib::OutPt", ptr %5, i32 0, i32 2
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  store ptr %7, ptr %4, align 8, !tbaa !5
  br label %8

8:                                                ; preds = %73, %1
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = icmp ne ptr %9, %10
  br i1 %11, label %12, label %77

12:                                               ; preds = %8
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %"struct.ClipperLib::OutPt", ptr %13, i32 0, i32 1
  %15 = getelementptr inbounds %"struct.ClipperLib::IntPoint", ptr %14, i32 0, i32 1
  %16 = load i64, ptr %15, align 8, !tbaa !14
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %"struct.ClipperLib::OutPt", ptr %17, i32 0, i32 1
  %19 = getelementptr inbounds %"struct.ClipperLib::IntPoint", ptr %18, i32 0, i32 1
  %20 = load i64, ptr %19, align 8, !tbaa !14
  %21 = icmp sgt i64 %16, %20
  br i1 %21, label %22, label %24

22:                                               ; preds = %12
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %23, ptr %2, align 8, !tbaa !5
  store ptr null, ptr %3, align 8, !tbaa !5
  br label %73

24:                                               ; preds = %12
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %"struct.ClipperLib::OutPt", ptr %25, i32 0, i32 1
  %27 = getelementptr inbounds %"struct.ClipperLib::IntPoint", ptr %26, i32 0, i32 1
  %28 = load i64, ptr %27, align 8, !tbaa !14
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = getelementptr inbounds %"struct.ClipperLib::OutPt", ptr %29, i32 0, i32 1
  %31 = getelementptr inbounds %"struct.ClipperLib::IntPoint", ptr %30, i32 0, i32 1
  %32 = load i64, ptr %31, align 8, !tbaa !14
  %33 = icmp eq i64 %28, %32
  br i1 %33, label %34, label %72

34:                                               ; preds = %24
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %"struct.ClipperLib::OutPt", ptr %35, i32 0, i32 1
  %37 = getelementptr inbounds %"struct.ClipperLib::IntPoint", ptr %36, i32 0, i32 0
  %38 = load i64, ptr %37, align 8, !tbaa !15
  %39 = load ptr, ptr %2, align 8, !tbaa !5
  %40 = getelementptr inbounds %"struct.ClipperLib::OutPt", ptr %39, i32 0, i32 1
  %41 = getelementptr inbounds %"struct.ClipperLib::IntPoint", ptr %40, i32 0, i32 0
  %42 = load i64, ptr %41, align 8, !tbaa !15
  %43 = icmp sle i64 %38, %42
  br i1 %43, label %44, label %72

44:                                               ; preds = %34
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %"struct.ClipperLib::OutPt", ptr %45, i32 0, i32 1
  %47 = getelementptr inbounds %"struct.ClipperLib::IntPoint", ptr %46, i32 0, i32 0
  %48 = load i64, ptr %47, align 8, !tbaa !15
  %49 = load ptr, ptr %2, align 8, !tbaa !5
  %50 = getelementptr inbounds %"struct.ClipperLib::OutPt", ptr %49, i32 0, i32 1
  %51 = getelementptr inbounds %"struct.ClipperLib::IntPoint", ptr %50, i32 0, i32 0
  %52 = load i64, ptr %51, align 8, !tbaa !15
  %53 = icmp slt i64 %48, %52
  br i1 %53, label %54, label %56

54:                                               ; preds = %44
  store ptr null, ptr %3, align 8, !tbaa !5
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %55, ptr %2, align 8, !tbaa !5
  br label %71

56:                                               ; preds = %44
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = getelementptr inbounds %"struct.ClipperLib::OutPt", ptr %57, i32 0, i32 2
  %59 = load ptr, ptr %58, align 8, !tbaa !9
  %60 = load ptr, ptr %2, align 8, !tbaa !5
  %61 = icmp ne ptr %59, %60
  br i1 %61, label %62, label %70

62:                                               ; preds = %56
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds %"struct.ClipperLib::OutPt", ptr %63, i32 0, i32 3
  %65 = load ptr, ptr %64, align 8, !tbaa !16
  %66 = load ptr, ptr %2, align 8, !tbaa !5
  %67 = icmp ne ptr %65, %66
  br i1 %67, label %68, label %70

68:                                               ; preds = %62
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %69, ptr %3, align 8, !tbaa !5
  br label %70

70:                                               ; preds = %68, %62, %56
  br label %71

71:                                               ; preds = %70, %54
  br label %72

72:                                               ; preds = %71, %34, %24
  br label %73

73:                                               ; preds = %72, %22
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = getelementptr inbounds %"struct.ClipperLib::OutPt", ptr %74, i32 0, i32 2
  %76 = load ptr, ptr %75, align 8, !tbaa !9
  store ptr %76, ptr %4, align 8, !tbaa !5
  br label %8, !llvm.loop !17

77:                                               ; preds = %8
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  %79 = icmp ne ptr %78, null
  br i1 %79, label %80, label %107

80:                                               ; preds = %77
  br label %81

81:                                               ; preds = %105, %80
  %82 = load ptr, ptr %3, align 8, !tbaa !5
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  %84 = icmp ne ptr %82, %83
  br i1 %84, label %85, label %106

85:                                               ; preds = %81
  %86 = load ptr, ptr %4, align 8, !tbaa !5
  %87 = load ptr, ptr %3, align 8, !tbaa !5
  %88 = call noundef zeroext i1 @_ZN10ClipperLib15FirstIsBottomPtEPKNS_5OutPtES2_(ptr noundef %86, ptr noundef %87)
  br i1 %88, label %91, label %89

89:                                               ; preds = %85
  %90 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %90, ptr %2, align 8, !tbaa !5
  br label %91

91:                                               ; preds = %89, %85
  %92 = load ptr, ptr %3, align 8, !tbaa !5
  %93 = getelementptr inbounds %"struct.ClipperLib::OutPt", ptr %92, i32 0, i32 2
  %94 = load ptr, ptr %93, align 8, !tbaa !9
  store ptr %94, ptr %3, align 8, !tbaa !5
  br label %95

95:                                               ; preds = %101, %91
  %96 = load ptr, ptr %3, align 8, !tbaa !5
  %97 = getelementptr inbounds %"struct.ClipperLib::OutPt", ptr %96, i32 0, i32 1
  %98 = load ptr, ptr %2, align 8, !tbaa !5
  %99 = getelementptr inbounds %"struct.ClipperLib::OutPt", ptr %98, i32 0, i32 1
  %100 = call noundef zeroext i1 @_ZN10ClipperLibneERKNS_8IntPointES2_(ptr noundef nonnull align 8 dereferenceable(16) %97, ptr noundef nonnull align 8 dereferenceable(16) %99)
  br i1 %100, label %101, label %105

101:                                              ; preds = %95
  %102 = load ptr, ptr %3, align 8, !tbaa !5
  %103 = getelementptr inbounds %"struct.ClipperLib::OutPt", ptr %102, i32 0, i32 2
  %104 = load ptr, ptr %103, align 8, !tbaa !9
  store ptr %104, ptr %3, align 8, !tbaa !5
  br label %95, !llvm.loop !19

105:                                              ; preds = %95
  br label %81, !llvm.loop !20

106:                                              ; preds = %81
  br label %107

107:                                              ; preds = %106, %77
  %108 = load ptr, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret ptr %108
}

; 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)) #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 = { 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 #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 24}
!10 = !{!"_ZTSN10ClipperLib5OutPtE", !11, i64 0, !12, i64 8, !6, i64 24, !6, i64 32}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_ZTSN10ClipperLib8IntPointE", !13, i64 0, !13, i64 8}
!13 = !{!"long long", !7, i64 0}
!14 = !{!10, !13, i64 16}
!15 = !{!10, !13, i64 8}
!16 = !{!10, !6, i64 32}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}
!20 = distinct !{!20, !18}


; 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 uwtable
declare dso_local noundef zeroext i1 @_ZN10ClipperLib15FirstIsBottomPtEPKNS_5OutPtES2_(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN10ClipperLib11GetBottomPtEPNS_5OutPtE(ptr noundef %0) local_unnamed_addr #0 {
  %.0.in46 = getelementptr inbounds i8, ptr %0, i64 24
  %.047 = load ptr, ptr %.0.in46, align 8, !tbaa !5
  %.not48 = icmp eq ptr %.047, %0
  br i1 %.not48, label %.loopexit45, label %.lr.ph

.lr.ph:                                           ; preds = %1, %22
  %.051 = phi ptr [ %.0, %22 ], [ %.047, %1 ]
  %.03050 = phi ptr [ %.1, %22 ], [ null, %1 ]
  %.03149 = phi ptr [ %.132, %22 ], [ %0, %1 ]
  %2 = getelementptr inbounds i8, ptr %.051, i64 8
  %3 = getelementptr inbounds i8, ptr %.051, i64 16
  %4 = load i64, ptr %3, align 8, !tbaa !13
  %5 = getelementptr inbounds i8, ptr %.03149, i64 8
  %6 = getelementptr inbounds i8, ptr %.03149, i64 16
  %7 = load i64, ptr %6, align 8, !tbaa !13
  %8 = icmp sgt i64 %4, %7
  br i1 %8, label %22, label %9

9:                                                ; preds = %.lr.ph
  %10 = icmp eq i64 %4, %7
  br i1 %10, label %11, label %22

11:                                               ; preds = %9
  %12 = load i64, ptr %2, align 8, !tbaa !14
  %13 = load i64, ptr %5, align 8, !tbaa !14
  %.not41 = icmp sgt i64 %12, %13
  br i1 %.not41, label %22, label %14

14:                                               ; preds = %11
  %15 = icmp slt i64 %12, %13
  br i1 %15, label %22, label %16

16:                                               ; preds = %14
  %17 = getelementptr inbounds i8, ptr %.051, i64 24
  %18 = load ptr, ptr %17, align 8, !tbaa !5
  %.not42 = icmp eq ptr %18, %.03149
  br i1 %.not42, label %22, label %19

19:                                               ; preds = %16
  %20 = getelementptr inbounds i8, ptr %.051, i64 32
  %21 = load ptr, ptr %20, align 8, !tbaa !15
  %.not43 = icmp eq ptr %21, %.03149
  %spec.select = select i1 %.not43, ptr %.03050, ptr %.051
  br label %22

22:                                               ; preds = %19, %14, %.lr.ph, %9, %11, %16
  %.132 = phi ptr [ %.03149, %16 ], [ %.03149, %11 ], [ %.03149, %9 ], [ %.051, %.lr.ph ], [ %.051, %14 ], [ %.03149, %19 ]
  %.1 = phi ptr [ %.03050, %16 ], [ %.03050, %11 ], [ %.03050, %9 ], [ null, %.lr.ph ], [ null, %14 ], [ %spec.select, %19 ]
  %.0.in = getelementptr inbounds i8, ptr %.051, i64 24
  %.0 = load ptr, ptr %.0.in, align 8, !tbaa !5
  %.not = icmp eq ptr %.0, %.132
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !16

._crit_edge:                                      ; preds = %22
  %.not39 = icmp eq ptr %.1, null
  %.not4054 = icmp eq ptr %.1, %.0
  %or.cond = or i1 %.not39, %.not4054
  br i1 %or.cond, label %.loopexit45, label %.lr.ph57

.loopexit:                                        ; preds = %25
  %.not40 = icmp eq ptr %.3, %.0
  br i1 %.not40, label %.loopexit45, label %.lr.ph57, !llvm.loop !18

.lr.ph57:                                         ; preds = %._crit_edge, %.loopexit
  %.256 = phi ptr [ %.3, %.loopexit ], [ %.1, %._crit_edge ]
  %.23355 = phi ptr [ %spec.select44, %.loopexit ], [ %.132, %._crit_edge ]
  %23 = tail call noundef zeroext i1 @_ZN10ClipperLib15FirstIsBottomPtEPKNS_5OutPtES2_(ptr noundef %.0, ptr noundef %.256)
  %spec.select44 = select i1 %23, ptr %.23355, ptr %.256
  %24 = getelementptr inbounds i8, ptr %spec.select44, i64 8
  br label %25

25:                                               ; preds = %25, %.lr.ph57
  %.2.pn = phi ptr [ %.256, %.lr.ph57 ], [ %.3, %25 ]
  %.3.in = getelementptr inbounds i8, ptr %.2.pn, i64 24
  %.3 = load ptr, ptr %.3.in, align 8, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %.3, i64 8
  %27 = tail call noundef zeroext i1 @_ZN10ClipperLibneERKNS_8IntPointES2_(ptr noundef nonnull align 8 dereferenceable(16) %26, ptr noundef nonnull align 8 dereferenceable(16) %24)
  br i1 %27, label %25, label %.loopexit, !llvm.loop !19

.loopexit45:                                      ; preds = %.loopexit, %1, %._crit_edge
  %.4 = phi ptr [ %.132, %._crit_edge ], [ %0, %1 ], [ %spec.select44, %.loopexit ]
  ret ptr %.4
}

; 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 #1

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

!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, !12, i64 24}
!6 = !{!"_ZTSN10ClipperLib5OutPtE", !7, i64 0, !10, i64 8, !12, i64 24, !12, i64 32}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN10ClipperLib8IntPointE", !11, i64 0, !11, i64 8}
!11 = !{!"long long", !8, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!6, !11, i64 16}
!14 = !{!6, !11, i64 8}
!15 = !{!6, !12, i64 32}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}
!19 = distinct !{!19, !17}


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