; 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::OutRec" = type { i32, i8, i8, ptr, 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
define dso_local void @_ZN10ClipperLib7Clipper14FixHoleLinkageERNS_6OutRecE(ptr noundef nonnull align 8 dereferenceable(135) %0, ptr noundef nonnull align 8 dereferenceable(40) %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = getelementptr inbounds %"struct.ClipperLib::OutRec", ptr %7, i32 0, i32 3
  %9 = load ptr, ptr %8, align 8, !tbaa !9
  %10 = icmp ne ptr %9, null
  br i1 %10, label %11, label %32

11:                                               ; preds = %2
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %"struct.ClipperLib::OutRec", ptr %12, i32 0, i32 1
  %14 = load i8, ptr %13, align 4, !tbaa !13, !range !14, !noundef !15
  %15 = trunc i8 %14 to i1
  %16 = zext i1 %15 to i32
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %"struct.ClipperLib::OutRec", ptr %17, i32 0, i32 3
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  %20 = getelementptr inbounds %"struct.ClipperLib::OutRec", ptr %19, i32 0, i32 1
  %21 = load i8, ptr %20, align 4, !tbaa !13, !range !14, !noundef !15
  %22 = trunc i8 %21 to i1
  %23 = zext i1 %22 to i32
  %24 = icmp ne i32 %16, %23
  br i1 %24, label %25, label %33

25:                                               ; preds = %11
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %"struct.ClipperLib::OutRec", ptr %26, i32 0, i32 3
  %28 = load ptr, ptr %27, align 8, !tbaa !9
  %29 = getelementptr inbounds %"struct.ClipperLib::OutRec", ptr %28, i32 0, i32 5
  %30 = load ptr, ptr %29, align 8, !tbaa !16
  %31 = icmp ne ptr %30, null
  br i1 %31, label %32, label %33

32:                                               ; preds = %25, %2
  br label %70

33:                                               ; preds = %25, %11
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %"struct.ClipperLib::OutRec", ptr %34, i32 0, i32 3
  %36 = load ptr, ptr %35, align 8, !tbaa !9
  store ptr %36, ptr %5, align 8, !tbaa !5
  br label %37

37:                                               ; preds = %62, %33
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = icmp ne ptr %38, null
  br i1 %39, label %40, label %60

40:                                               ; preds = %37
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %"struct.ClipperLib::OutRec", ptr %41, i32 0, i32 1
  %43 = load i8, ptr %42, align 4, !tbaa !13, !range !14, !noundef !15
  %44 = trunc i8 %43 to i1
  %45 = zext i1 %44 to i32
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %"struct.ClipperLib::OutRec", ptr %46, i32 0, i32 1
  %48 = load i8, ptr %47, align 4, !tbaa !13, !range !14, !noundef !15
  %49 = trunc i8 %48 to i1
  %50 = zext i1 %49 to i32
  %51 = icmp eq i32 %45, %50
  br i1 %51, label %58, label %52

52:                                               ; preds = %40
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %"struct.ClipperLib::OutRec", ptr %53, i32 0, i32 5
  %55 = load ptr, ptr %54, align 8, !tbaa !16
  %56 = icmp ne ptr %55, null
  %57 = xor i1 %56, true
  br label %58

58:                                               ; preds = %52, %40
  %59 = phi i1 [ true, %40 ], [ %57, %52 ]
  br label %60

60:                                               ; preds = %58, %37
  %61 = phi i1 [ false, %37 ], [ %59, %58 ]
  br i1 %61, label %62, label %66

62:                                               ; preds = %60
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = getelementptr inbounds %"struct.ClipperLib::OutRec", ptr %63, i32 0, i32 3
  %65 = load ptr, ptr %64, align 8, !tbaa !9
  store ptr %65, ptr %5, align 8, !tbaa !5
  br label %37, !llvm.loop !17

66:                                               ; preds = %60
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = getelementptr inbounds %"struct.ClipperLib::OutRec", ptr %68, i32 0, i32 3
  store ptr %67, ptr %69, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  br label %70

70:                                               ; preds = %66, %32
  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 8}
!10 = !{!"_ZTSN10ClipperLib6OutRecE", !11, i64 0, !12, i64 4, !12, i64 5, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!11 = !{!"int", !7, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!10, !12, i64 4}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = !{!10, !6, i64 24}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


; 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 nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @_ZN10ClipperLib7Clipper14FixHoleLinkageERNS_6OutRecE(ptr nocapture noundef nonnull readnone align 8 dereferenceable(135) %0, ptr nocapture noundef nonnull align 8 dereferenceable(40) %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %1, i64 8
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %20, label %5

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %1, i64 4
  %7 = load i8, ptr %6, align 4, !tbaa !12, !range !13, !noundef !14
  %8 = getelementptr inbounds i8, ptr %4, i64 4
  %9 = load i8, ptr %8, align 4, !tbaa !12, !range !13, !noundef !14
  %.not16 = icmp eq i8 %7, %9
  br i1 %.not16, label %.lr.ph.preheader, label %10

10:                                               ; preds = %5
  %11 = getelementptr inbounds i8, ptr %4, i64 24
  %12 = load ptr, ptr %11, align 8, !tbaa !15
  %.not17 = icmp eq ptr %12, null
  br i1 %.not17, label %.lr.ph.preheader, label %20

.lr.ph.preheader:                                 ; preds = %5, %10
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.critedge2
  %.022 = phi ptr [ %.0, %.critedge2 ], [ %4, %.lr.ph.preheader ]
  %13 = getelementptr inbounds i8, ptr %.022, i64 4
  %14 = load i8, ptr %13, align 4, !tbaa !12, !range !13, !noundef !14
  %15 = icmp eq i8 %14, %7
  br i1 %15, label %.critedge2, label %16

16:                                               ; preds = %.lr.ph
  %17 = getelementptr inbounds i8, ptr %.022, i64 24
  %18 = load ptr, ptr %17, align 8, !tbaa !15
  %.not19 = icmp eq ptr %18, null
  br i1 %.not19, label %.critedge2, label %.critedge

.critedge2:                                       ; preds = %.lr.ph, %16
  %19 = getelementptr inbounds i8, ptr %.022, i64 8
  %.0 = load ptr, ptr %19, align 8, !tbaa !5
  %.not18 = icmp eq ptr %.0, null
  br i1 %.not18, label %.critedge, label %.lr.ph, !llvm.loop !16

.critedge:                                        ; preds = %16, %.critedge2
  %.0.lcssa.ph = phi ptr [ %.022, %16 ], [ null, %.critedge2 ]
  store ptr %.0.lcssa.ph, ptr %3, align 8, !tbaa !5
  br label %20

20:                                               ; preds = %2, %10, %.critedge
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) 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, !11, i64 8}
!6 = !{!"_ZTSN10ClipperLib6OutRecE", !7, i64 0, !10, i64 4, !10, i64 5, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!6, !10, i64 4}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!6, !11, i64 24}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


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