; 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::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 @_ZN10ClipperLib20DistanceFromLineSqrdERKNS_8IntPointES2_S2_(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(16) %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = getelementptr inbounds %"struct.ClipperLib::IntPoint", ptr %10, i32 0, i32 1
  %12 = load i64, ptr %11, align 8, !tbaa !9
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = getelementptr inbounds %"struct.ClipperLib::IntPoint", ptr %13, i32 0, i32 1
  %15 = load i64, ptr %14, align 8, !tbaa !9
  %16 = sub nsw i64 %12, %15
  %17 = sitofp i64 %16 to double
  store double %17, ptr %7, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = getelementptr inbounds %"struct.ClipperLib::IntPoint", ptr %18, i32 0, i32 0
  %20 = load i64, ptr %19, align 8, !tbaa !14
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %"struct.ClipperLib::IntPoint", ptr %21, i32 0, i32 0
  %23 = load i64, ptr %22, align 8, !tbaa !14
  %24 = sub nsw i64 %20, %23
  %25 = sitofp i64 %24 to double
  store double %25, ptr %8, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %26 = load double, ptr %7, align 8, !tbaa !12
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %"struct.ClipperLib::IntPoint", ptr %27, i32 0, i32 0
  %29 = load i64, ptr %28, align 8, !tbaa !14
  %30 = sitofp i64 %29 to double
  %31 = load double, ptr %8, align 8, !tbaa !12
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %"struct.ClipperLib::IntPoint", ptr %32, i32 0, i32 1
  %34 = load i64, ptr %33, align 8, !tbaa !9
  %35 = sitofp i64 %34 to double
  %36 = fmul double %31, %35
  %37 = call double @llvm.fmuladd.f64(double %26, double %30, double %36)
  store double %37, ptr %9, align 8, !tbaa !12
  %38 = load double, ptr %7, align 8, !tbaa !12
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %"struct.ClipperLib::IntPoint", ptr %39, i32 0, i32 0
  %41 = load i64, ptr %40, align 8, !tbaa !14
  %42 = sitofp i64 %41 to double
  %43 = load double, ptr %8, align 8, !tbaa !12
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %"struct.ClipperLib::IntPoint", ptr %44, i32 0, i32 1
  %46 = load i64, ptr %45, align 8, !tbaa !9
  %47 = sitofp i64 %46 to double
  %48 = fmul double %43, %47
  %49 = call double @llvm.fmuladd.f64(double %38, double %42, double %48)
  %50 = load double, ptr %9, align 8, !tbaa !12
  %51 = fsub double %49, %50
  store double %51, ptr %9, align 8, !tbaa !12
  %52 = load double, ptr %9, align 8, !tbaa !12
  %53 = load double, ptr %9, align 8, !tbaa !12
  %54 = fmul double %52, %53
  %55 = load double, ptr %7, align 8, !tbaa !12
  %56 = load double, ptr %7, align 8, !tbaa !12
  %57 = load double, ptr %8, align 8, !tbaa !12
  %58 = load double, ptr %8, align 8, !tbaa !12
  %59 = fmul double %57, %58
  %60 = call double @llvm.fmuladd.f64(double %55, double %56, double %59)
  %61 = fdiv double %54, %60
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret double %61
}

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, !11, i64 8}
!10 = !{!"_ZTSN10ClipperLib8IntPointE", !11, i64 0, !11, i64 8}
!11 = !{!"long long", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"double", !7, i64 0}
!14 = !{!10, !11, 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: 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(argmem: read) uwtable
define dso_local noundef double @_ZN10ClipperLib20DistanceFromLineSqrdERKNS_8IntPointES2_S2_(ptr nocapture noundef nonnull readonly align 8 dereferenceable(16) %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(16) %1, ptr nocapture noundef nonnull readonly align 8 dereferenceable(16) %2) local_unnamed_addr #1 {
  %4 = getelementptr inbounds i8, ptr %1, i64 8
  %5 = load i64, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %2, i64 8
  %7 = load i64, ptr %6, align 8, !tbaa !5
  %8 = sub nsw i64 %5, %7
  %9 = sitofp i64 %8 to double
  %10 = load i64, ptr %2, align 8, !tbaa !10
  %11 = load i64, ptr %1, align 8, !tbaa !10
  %12 = sub nsw i64 %10, %11
  %13 = sitofp i64 %12 to double
  %14 = sitofp i64 %11 to double
  %15 = sitofp i64 %5 to double
  %16 = fmul double %15, %13
  %17 = tail call double @llvm.fmuladd.f64(double %9, double %14, double %16)
  %18 = load i64, ptr %0, align 8, !tbaa !10
  %19 = sitofp i64 %18 to double
  %20 = getelementptr inbounds i8, ptr %0, i64 8
  %21 = load i64, ptr %20, align 8, !tbaa !5
  %22 = sitofp i64 %21 to double
  %23 = fmul double %13, %22
  %24 = tail call double @llvm.fmuladd.f64(double %9, double %19, double %23)
  %25 = fsub double %24, %17
  %26 = fmul double %25, %25
  %27 = fmul double %13, %13
  %28 = tail call double @llvm.fmuladd.f64(double %9, double %9, double %27)
  %29 = fdiv double %26, %28
  ret double %29
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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, !7, i64 8}
!6 = !{!"_ZTSN10ClipperLib8IntPointE", !7, i64 0, !7, i64 8}
!7 = !{!"long long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,TailCallElimPass