; LLVM IR from PaddlePaddle/Serving :: core/predictor/tools/ocrtools/clipper.ll (ZN10ClipperLib4AreaEPKNS_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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZN10ClipperLib4AreaEPKNS_5OutPtE(ptr noundef %0) #2 {
  %2 = alloca double, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca double, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %7, ptr %4, align 8, !tbaa !5
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = icmp ne ptr %8, null
  br i1 %9, label %11, label %10

10:                                               ; preds = %1
  store double 0.000000e+00, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %49

11:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store double 0.000000e+00, ptr %6, align 8, !tbaa !9
  br label %12

12:                                               ; preds = %42, %11
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %"struct.ClipperLib::OutPt", ptr %13, i32 0, i32 3
  %15 = load ptr, ptr %14, align 8, !tbaa !11
  %16 = getelementptr inbounds %"struct.ClipperLib::OutPt", ptr %15, i32 0, i32 1
  %17 = getelementptr inbounds %"struct.ClipperLib::IntPoint", ptr %16, i32 0, i32 0
  %18 = load i64, ptr %17, align 8, !tbaa !16
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %"struct.ClipperLib::OutPt", ptr %19, i32 0, i32 1
  %21 = getelementptr inbounds %"struct.ClipperLib::IntPoint", ptr %20, i32 0, i32 0
  %22 = load i64, ptr %21, align 8, !tbaa !16
  %23 = add nsw i64 %18, %22
  %24 = sitofp i64 %23 to double
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %"struct.ClipperLib::OutPt", ptr %25, i32 0, i32 3
  %27 = load ptr, ptr %26, align 8, !tbaa !11
  %28 = getelementptr inbounds %"struct.ClipperLib::OutPt", ptr %27, i32 0, i32 1
  %29 = getelementptr inbounds %"struct.ClipperLib::IntPoint", ptr %28, i32 0, i32 1
  %30 = load i64, ptr %29, align 8, !tbaa !17
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %"struct.ClipperLib::OutPt", ptr %31, i32 0, i32 1
  %33 = getelementptr inbounds %"struct.ClipperLib::IntPoint", ptr %32, i32 0, i32 1
  %34 = load i64, ptr %33, align 8, !tbaa !17
  %35 = sub nsw i64 %30, %34
  %36 = sitofp i64 %35 to double
  %37 = load double, ptr %6, align 8, !tbaa !9
  %38 = call double @llvm.fmuladd.f64(double %24, double %36, double %37)
  store double %38, ptr %6, align 8, !tbaa !9
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds %"struct.ClipperLib::OutPt", ptr %39, i32 0, i32 2
  %41 = load ptr, ptr %40, align 8, !tbaa !18
  store ptr %41, ptr %3, align 8, !tbaa !5
  br label %42

42:                                               ; preds = %12
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = icmp ne ptr %43, %44
  br i1 %45, label %12, label %46, !llvm.loop !19

46:                                               ; preds = %42
  %47 = load double, ptr %6, align 8, !tbaa !9
  %48 = fmul double %47, 5.000000e-01
  store double %48, ptr %2, align 8
  store i32 1, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %49

49:                                               ; preds = %46, %10
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %50 = load double, ptr %2, align 8
  ret double %50
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !6, i64 32}
!12 = !{!"_ZTSN10ClipperLib5OutPtE", !13, i64 0, !14, i64 8, !6, i64 24, !6, i64 32}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTSN10ClipperLib8IntPointE", !15, i64 0, !15, i64 8}
!15 = !{!"long long", !7, i64 0}
!16 = !{!12, !15, i64 8}
!17 = !{!12, !15, i64 16}
!18 = !{!12, !6, i64 24}
!19 = distinct !{!19, !20}
!20 = !{!"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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) uwtable
define dso_local noundef double @_ZN10ClipperLib4AreaEPKNS_5OutPtE(ptr noundef readonly %0) local_unnamed_addr #1 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %21, label %.preheader

.preheader:                                       ; preds = %1, %.preheader
  %.013 = phi ptr [ %18, %.preheader ], [ %0, %1 ]
  %.0 = phi double [ %16, %.preheader ], [ 0.000000e+00, %1 ]
  %2 = getelementptr inbounds i8, ptr %.013, i64 32
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %3, i64 8
  %5 = load i64, ptr %4, align 8, !tbaa !13
  %6 = getelementptr inbounds i8, ptr %.013, i64 8
  %7 = load i64, ptr %6, align 8, !tbaa !13
  %8 = add nsw i64 %7, %5
  %9 = sitofp i64 %8 to double
  %10 = getelementptr inbounds i8, ptr %3, i64 16
  %11 = load i64, ptr %10, align 8, !tbaa !14
  %12 = getelementptr inbounds i8, ptr %.013, i64 16
  %13 = load i64, ptr %12, align 8, !tbaa !14
  %14 = sub nsw i64 %11, %13
  %15 = sitofp i64 %14 to double
  %16 = tail call double @llvm.fmuladd.f64(double %9, double %15, double %.0)
  %17 = getelementptr inbounds i8, ptr %.013, i64 24
  %18 = load ptr, ptr %17, align 8, !tbaa !15
  %.not15 = icmp eq ptr %18, %0
  br i1 %.not15, label %19, label %.preheader, !llvm.loop !16

19:                                               ; preds = %.preheader
  %20 = fmul double %16, 5.000000e-01
  br label %21

21:                                               ; preds = %1, %19
  %.012 = phi double [ %20, %19 ], [ 0.000000e+00, %1 ]
  ret double %.012
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, 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, !12, i64 32}
!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 8}
!14 = !{!6, !11, i64 16}
!15 = !{!6, !12, i64 24}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass