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

; 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::IntPoint" = type { i64, i64 }

@.str = external hidden unnamed_addr constant [33 x i8], align 1
@_ZTIN10ClipperLib16clipperExceptionE = external dso_local constant { ptr, ptr, ptr }, align 8

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10ClipperLib9RangeTestERKNS_8IntPointERb(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 1 dereferenceable(1) %1) #0 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = load i8, ptr %7, align 1, !tbaa !9, !range !11, !noundef !12
  %9 = trunc i8 %8 to i1
  br i1 %9, label %10, label %40

10:                                               ; preds = %2
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %"struct.ClipperLib::IntPoint", ptr %11, i32 0, i32 0
  %13 = load i64, ptr %12, align 8, !tbaa !13
  %14 = icmp sgt i64 %13, 4611686018427387903
  br i1 %14, label %32, label %15

15:                                               ; preds = %10
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %"struct.ClipperLib::IntPoint", ptr %16, i32 0, i32 1
  %18 = load i64, ptr %17, align 8, !tbaa !16
  %19 = icmp sgt i64 %18, 4611686018427387903
  br i1 %19, label %32, label %20

20:                                               ; preds = %15
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %"struct.ClipperLib::IntPoint", ptr %21, i32 0, i32 0
  %23 = load i64, ptr %22, align 8, !tbaa !13
  %24 = sub nsw i64 0, %23
  %25 = icmp sgt i64 %24, 4611686018427387903
  br i1 %25, label %32, label %26

26:                                               ; preds = %20
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %"struct.ClipperLib::IntPoint", ptr %27, i32 0, i32 1
  %29 = load i64, ptr %28, align 8, !tbaa !16
  %30 = sub nsw i64 0, %29
  %31 = icmp sgt i64 %30, 4611686018427387903
  br i1 %31, label %32, label %39

32:                                               ; preds = %26, %20, %15, %10
  %33 = call ptr @__cxa_allocate_exception(i64 40) #2
  invoke void @_ZN10ClipperLib16clipperExceptionC2EPKc(ptr noundef nonnull align 8 dereferenceable(40) %33, ptr noundef @.str)
          to label %34 unwind label %35

34:                                               ; preds = %32
  call void @__cxa_throw(ptr %33, ptr @_ZTIN10ClipperLib16clipperExceptionE, ptr @_ZN10ClipperLib16clipperExceptionD2Ev) #3
  unreachable

35:                                               ; preds = %32
  %36 = landingpad { ptr, i32 }
          cleanup
  %37 = extractvalue { ptr, i32 } %36, 0
  store ptr %37, ptr %5, align 8
  %38 = extractvalue { ptr, i32 } %36, 1
  store i32 %38, ptr %6, align 4
  call void @__cxa_free_exception(ptr %33) #2
  br label %68

39:                                               ; preds = %26
  br label %67

40:                                               ; preds = %2
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %"struct.ClipperLib::IntPoint", ptr %41, i32 0, i32 0
  %43 = load i64, ptr %42, align 8, !tbaa !13
  %44 = icmp sgt i64 %43, 1073741823
  br i1 %44, label %62, label %45

45:                                               ; preds = %40
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = getelementptr inbounds %"struct.ClipperLib::IntPoint", ptr %46, i32 0, i32 1
  %48 = load i64, ptr %47, align 8, !tbaa !16
  %49 = icmp sgt i64 %48, 1073741823
  br i1 %49, label %62, label %50

50:                                               ; preds = %45
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = getelementptr inbounds %"struct.ClipperLib::IntPoint", ptr %51, i32 0, i32 0
  %53 = load i64, ptr %52, align 8, !tbaa !13
  %54 = sub nsw i64 0, %53
  %55 = icmp sgt i64 %54, 1073741823
  br i1 %55, label %62, label %56

56:                                               ; preds = %50
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %"struct.ClipperLib::IntPoint", ptr %57, i32 0, i32 1
  %59 = load i64, ptr %58, align 8, !tbaa !16
  %60 = sub nsw i64 0, %59
  %61 = icmp sgt i64 %60, 1073741823
  br i1 %61, label %62, label %66

62:                                               ; preds = %56, %50, %45, %40
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  store i8 1, ptr %63, align 1, !tbaa !9
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN10ClipperLib9RangeTestERKNS_8IntPointERb(ptr noundef nonnull align 8 dereferenceable(16) %64, ptr noundef nonnull align 1 dereferenceable(1) %65)
  br label %66

66:                                               ; preds = %62, %56
  br label %67

67:                                               ; preds = %66, %39
  ret void

68:                                               ; preds = %35
  %69 = load ptr, ptr %5, align 8
  %70 = load i32, ptr %6, align 4
  %71 = insertvalue { ptr, i32 } poison, ptr %69, 0
  %72 = insertvalue { ptr, i32 } %71, i32 %70, 1
  resume { ptr, i32 } %72
}

declare ptr @__cxa_allocate_exception(i64)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10ClipperLib16clipperExceptionC2EPKc(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef) unnamed_addr #0 align 2

declare void @__cxa_free_exception(ptr)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN10ClipperLib16clipperExceptionD2Ev(ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #1 align 2

declare void @__cxa_throw(ptr, ptr, ptr)

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 = { 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 }
attributes #3 = { noreturn }

!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 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !15, i64 0}
!14 = !{!"_ZTSN10ClipperLib8IntPointE", !15, i64 0, !15, i64 8}
!15 = !{!"long long", !7, i64 0}
!16 = !{!14, !15, i64 8}


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

@.str = external hidden unnamed_addr constant [33 x i8], align 1
@_ZTIN10ClipperLib16clipperExceptionE = external dso_local constant { ptr, ptr, ptr }, align 8

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10ClipperLib9RangeTestERKNS_8IntPointERb(ptr nocapture noundef nonnull readonly align 8 dereferenceable(16) %0, ptr nocapture noundef nonnull align 1 dereferenceable(1) %1) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %.promoted = load i8, ptr %1, align 1, !tbaa !5
  %3 = trunc nuw i8 %.promoted to i1
  %.pre = load i64, ptr %0, align 8, !tbaa !9
  br i1 %3, label %tailrecurse._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %4 = icmp sgt i64 %.pre, 1073741823
  br i1 %4, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph
  store i8 1, ptr %1, align 1, !tbaa !5
  br label %tailrecurse._crit_edge

.lr.ph.split:                                     ; preds = %.lr.ph
  %5 = icmp slt i64 %.pre, -1073741823
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  %7 = load i64, ptr %6, align 8
  %8 = add i64 %7, -1073741824
  %9 = icmp ult i64 %8, -2147483647
  %or.cond18 = or i1 %5, %9
  br i1 %or.cond18, label %tailrecurse._crit_edge.thread, label %.loopexit

tailrecurse._crit_edge.thread:                    ; preds = %.lr.ph.split
  store i8 1, ptr %1, align 1, !tbaa !5
  br label %11

tailrecurse._crit_edge:                           ; preds = %.lr.ph.split.us, %2
  %10 = icmp sgt i64 %.pre, 4611686018427387903
  br i1 %10, label %17, label %11

11:                                               ; preds = %tailrecurse._crit_edge.thread, %tailrecurse._crit_edge
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  %13 = load i64, ptr %12, align 8, !tbaa !12
  %14 = icmp slt i64 %.pre, -4611686018427387903
  %15 = add i64 %13, -4611686018427387904
  %16 = icmp ult i64 %15, -9223372036854775807
  %or.cond16 = or i1 %14, %16
  br i1 %or.cond16, label %17, label %.loopexit

17:                                               ; preds = %11, %tailrecurse._crit_edge
  %18 = tail call ptr @__cxa_allocate_exception(i64 40) #2
  invoke void @_ZN10ClipperLib16clipperExceptionC2EPKc(ptr noundef nonnull align 8 dereferenceable(40) %18, ptr noundef nonnull @.str)
          to label %19 unwind label %20

19:                                               ; preds = %17
  tail call void @__cxa_throw(ptr nonnull %18, ptr nonnull @_ZTIN10ClipperLib16clipperExceptionE, ptr nonnull @_ZN10ClipperLib16clipperExceptionD2Ev) #3
  unreachable

20:                                               ; preds = %17
  %21 = landingpad { ptr, i32 }
          cleanup
  tail call void @__cxa_free_exception(ptr %18) #2
  resume { ptr, i32 } %21

.loopexit:                                        ; preds = %.lr.ph.split, %11
  ret void
}

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10ClipperLib16clipperExceptionC2EPKc(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef) unnamed_addr #0 align 2

declare void @__cxa_free_exception(ptr) local_unnamed_addr

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN10ClipperLib16clipperExceptionD2Ev(ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #1 align 2

declare void @__cxa_throw(ptr, ptr, ptr) local_unnamed_addr

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 = { 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 }
attributes #3 = { noreturn }

!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 = !{!"bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_ZTSN10ClipperLib8IntPointE", !11, i64 0, !11, i64 8}
!11 = !{!"long long", !7, i64 0}
!12 = !{!10, !11, i64 8}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass