; LLVM IR from lzyrapx/Competitive-Programming :: 51Nod/1298（计算几何）（线段与圆的交点）.ll (Z20intersect_seg_circle5pointdS_S_)

; 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.point = type { double, double }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_Z5xmult5pointS_S_(double, double, double, double, double, double) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_Z8distance5pointS_(double, double, double, double) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_Z10disptoline5pointS_S_(double, double, double, double, double, double) #0

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_Z20intersect_seg_circle5pointdS_S_(double %0, double %1, double noundef %2, double %3, double %4, double %5, double %6) #0 {
  %8 = alloca i32, align 4
  %9 = alloca %struct.point, align 8
  %10 = alloca %struct.point, align 8
  %11 = alloca %struct.point, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca %struct.point, align 8
  %15 = alloca %struct.point, align 8
  %16 = alloca double, align 8
  %17 = alloca %struct.point, align 8
  %18 = alloca %struct.point, align 8
  %19 = alloca %struct.point, align 8
  %20 = alloca i32, align 4
  %21 = alloca %struct.point, align 8
  %22 = alloca %struct.point, align 8
  %23 = alloca %struct.point, align 8
  %24 = alloca %struct.point, align 8
  %25 = alloca %struct.point, align 8
  %26 = alloca %struct.point, align 8
  %27 = alloca %struct.point, align 8
  %28 = alloca %struct.point, align 8
  %29 = alloca %struct.point, align 8
  %30 = getelementptr inbounds { double, double }, ptr %9, i32 0, i32 0
  store double %0, ptr %30, align 8
  %31 = getelementptr inbounds { double, double }, ptr %9, i32 0, i32 1
  store double %1, ptr %31, align 8
  %32 = getelementptr inbounds { double, double }, ptr %10, i32 0, i32 0
  store double %3, ptr %32, align 8
  %33 = getelementptr inbounds { double, double }, ptr %10, i32 0, i32 1
  store double %4, ptr %33, align 8
  %34 = getelementptr inbounds { double, double }, ptr %11, i32 0, i32 0
  store double %5, ptr %34, align 8
  %35 = getelementptr inbounds { double, double }, ptr %11, i32 0, i32 1
  store double %6, ptr %35, align 8
  store double %2, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %14, ptr align 8 %9, i64 16, i1 false), !tbaa.struct !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %15, ptr align 8 %10, i64 16, i1 false), !tbaa.struct !9
  %36 = getelementptr inbounds { double, double }, ptr %14, i32 0, i32 0
  %37 = load double, ptr %36, align 8
  %38 = getelementptr inbounds { double, double }, ptr %14, i32 0, i32 1
  %39 = load double, ptr %38, align 8
  %40 = getelementptr inbounds { double, double }, ptr %15, i32 0, i32 0
  %41 = load double, ptr %40, align 8
  %42 = getelementptr inbounds { double, double }, ptr %15, i32 0, i32 1
  %43 = load double, ptr %42, align 8
  %44 = call noundef double @_Z8distance5pointS_(double %37, double %39, double %41, double %43)
  %45 = load double, ptr %12, align 8, !tbaa !5
  %46 = fsub double %44, %45
  store double %46, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %17, ptr align 8 %9, i64 16, i1 false), !tbaa.struct !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %18, ptr align 8 %11, i64 16, i1 false), !tbaa.struct !9
  %47 = getelementptr inbounds { double, double }, ptr %17, i32 0, i32 0
  %48 = load double, ptr %47, align 8
  %49 = getelementptr inbounds { double, double }, ptr %17, i32 0, i32 1
  %50 = load double, ptr %49, align 8
  %51 = getelementptr inbounds { double, double }, ptr %18, i32 0, i32 0
  %52 = load double, ptr %51, align 8
  %53 = getelementptr inbounds { double, double }, ptr %18, i32 0, i32 1
  %54 = load double, ptr %53, align 8
  %55 = call noundef double @_Z8distance5pointS_(double %48, double %50, double %52, double %54)
  %56 = load double, ptr %12, align 8, !tbaa !5
  %57 = fsub double %55, %56
  store double %57, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %19) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %19, ptr align 8 %9, i64 16, i1 false), !tbaa.struct !9
  %58 = load double, ptr %13, align 8, !tbaa !5
  %59 = fcmp olt double %58, 1.000000e-08
  br i1 %59, label %63, label %60

60:                                               ; preds = %7
  %61 = load double, ptr %16, align 8, !tbaa !5
  %62 = fcmp olt double %61, 1.000000e-08
  br i1 %62, label %63, label %72

63:                                               ; preds = %60, %7
  %64 = load double, ptr %13, align 8, !tbaa !5
  %65 = fcmp ogt double %64, -1.000000e-08
  br i1 %65, label %69, label %66

66:                                               ; preds = %63
  %67 = load double, ptr %16, align 8, !tbaa !5
  %68 = fcmp ogt double %67, -1.000000e-08
  br label %69

69:                                               ; preds = %66, %63
  %70 = phi i1 [ true, %63 ], [ %68, %66 ]
  %71 = zext i1 %70 to i32
  store i32 %71, ptr %8, align 4
  store i32 1, ptr %20, align 4
  br label %137

72:                                               ; preds = %60
  %73 = getelementptr inbounds %struct.point, ptr %10, i32 0, i32 1
  %74 = load double, ptr %73, align 8, !tbaa !10
  %75 = getelementptr inbounds %struct.point, ptr %11, i32 0, i32 1
  %76 = load double, ptr %75, align 8, !tbaa !10
  %77 = fsub double %74, %76
  %78 = getelementptr inbounds %struct.point, ptr %19, i32 0, i32 0
  %79 = load double, ptr %78, align 8, !tbaa !12
  %80 = fadd double %79, %77
  store double %80, ptr %78, align 8, !tbaa !12
  %81 = getelementptr inbounds %struct.point, ptr %11, i32 0, i32 0
  %82 = load double, ptr %81, align 8, !tbaa !12
  %83 = getelementptr inbounds %struct.point, ptr %10, i32 0, i32 0
  %84 = load double, ptr %83, align 8, !tbaa !12
  %85 = fsub double %82, %84
  %86 = getelementptr inbounds %struct.point, ptr %19, i32 0, i32 1
  %87 = load double, ptr %86, align 8, !tbaa !10
  %88 = fadd double %87, %85
  store double %88, ptr %86, align 8, !tbaa !10
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %21, ptr align 8 %10, i64 16, i1 false), !tbaa.struct !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %22, ptr align 8 %9, i64 16, i1 false), !tbaa.struct !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %23, ptr align 8 %19, i64 16, i1 false), !tbaa.struct !9
  %89 = getelementptr inbounds { double, double }, ptr %21, i32 0, i32 0
  %90 = load double, ptr %89, align 8
  %91 = getelementptr inbounds { double, double }, ptr %21, i32 0, i32 1
  %92 = load double, ptr %91, align 8
  %93 = getelementptr inbounds { double, double }, ptr %22, i32 0, i32 0
  %94 = load double, ptr %93, align 8
  %95 = getelementptr inbounds { double, double }, ptr %22, i32 0, i32 1
  %96 = load double, ptr %95, align 8
  %97 = getelementptr inbounds { double, double }, ptr %23, i32 0, i32 0
  %98 = load double, ptr %97, align 8
  %99 = getelementptr inbounds { double, double }, ptr %23, i32 0, i32 1
  %100 = load double, ptr %99, align 8
  %101 = call noundef double @_Z5xmult5pointS_S_(double %90, double %92, double %94, double %96, double %98, double %100)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %24, ptr align 8 %11, i64 16, i1 false), !tbaa.struct !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %25, ptr align 8 %9, i64 16, i1 false), !tbaa.struct !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %26, ptr align 8 %19, i64 16, i1 false), !tbaa.struct !9
  %102 = getelementptr inbounds { double, double }, ptr %24, i32 0, i32 0
  %103 = load double, ptr %102, align 8
  %104 = getelementptr inbounds { double, double }, ptr %24, i32 0, i32 1
  %105 = load double, ptr %104, align 8
  %106 = getelementptr inbounds { double, double }, ptr %25, i32 0, i32 0
  %107 = load double, ptr %106, align 8
  %108 = getelementptr inbounds { double, double }, ptr %25, i32 0, i32 1
  %109 = load double, ptr %108, align 8
  %110 = getelementptr inbounds { double, double }, ptr %26, i32 0, i32 0
  %111 = load double, ptr %110, align 8
  %112 = getelementptr inbounds { double, double }, ptr %26, i32 0, i32 1
  %113 = load double, ptr %112, align 8
  %114 = call noundef double @_Z5xmult5pointS_S_(double %103, double %105, double %107, double %109, double %111, double %113)
  %115 = fmul double %101, %114
  %116 = fcmp olt double %115, 1.000000e-08
  br i1 %116, label %117, label %134

117:                                              ; preds = %72
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %27, ptr align 8 %9, i64 16, i1 false), !tbaa.struct !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %28, ptr align 8 %10, i64 16, i1 false), !tbaa.struct !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %29, ptr align 8 %11, i64 16, i1 false), !tbaa.struct !9
  %118 = getelementptr inbounds { double, double }, ptr %27, i32 0, i32 0
  %119 = load double, ptr %118, align 8
  %120 = getelementptr inbounds { double, double }, ptr %27, i32 0, i32 1
  %121 = load double, ptr %120, align 8
  %122 = getelementptr inbounds { double, double }, ptr %28, i32 0, i32 0
  %123 = load double, ptr %122, align 8
  %124 = getelementptr inbounds { double, double }, ptr %28, i32 0, i32 1
  %125 = load double, ptr %124, align 8
  %126 = getelementptr inbounds { double, double }, ptr %29, i32 0, i32 0
  %127 = load double, ptr %126, align 8
  %128 = getelementptr inbounds { double, double }, ptr %29, i32 0, i32 1
  %129 = load double, ptr %128, align 8
  %130 = call noundef double @_Z10disptoline5pointS_S_(double %119, double %121, double %123, double %125, double %127, double %129)
  %131 = load double, ptr %12, align 8, !tbaa !5
  %132 = fsub double %130, %131
  %133 = fcmp olt double %132, 1.000000e-08
  br label %134

134:                                              ; preds = %117, %72
  %135 = phi i1 [ false, %72 ], [ %133, %117 ]
  %136 = zext i1 %135 to i32
  store i32 %136, ptr %8, align 4
  store i32 1, ptr %20, align 4
  br label %137

137:                                              ; preds = %134, %69
  call void @llvm.lifetime.end.p0(i64 16, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  %138 = load i32, ptr %8, align 4
  ret i32 %138
}

attributes #0 = { 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 #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i64 0, i64 8, !5, i64 8, i64 8, !5}
!10 = !{!11, !6, i64 8}
!11 = !{!"_ZTS5point", !6, i64 0, !6, i64 8}
!12 = !{!11, !6, 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 nounwind uwtable
declare dso_local noundef double @_Z5xmult5pointS_S_(double, double, double, double, double, double) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_Z8distance5pointS_(double, double, double, double) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_Z10disptoline5pointS_S_(double, double, double, double, double, double) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef range(i32 0, 2) i32 @_Z20intersect_seg_circle5pointdS_S_(double %0, double %1, double noundef %2, double %3, double %4, double %5, double %6) local_unnamed_addr #0 {
  %8 = tail call noundef double @_Z8distance5pointS_(double %0, double %1, double %3, double %4)
  %9 = fsub double %8, %2
  %10 = tail call noundef double @_Z8distance5pointS_(double %0, double %1, double %5, double %6)
  %11 = fsub double %10, %2
  %12 = fcmp olt double %9, 1.000000e-08
  %13 = fcmp olt double %11, 1.000000e-08
  %or.cond = or i1 %12, %13
  br i1 %or.cond, label %14, label %18

14:                                               ; preds = %7
  %15 = fcmp ogt double %9, -1.000000e-08
  %16 = fcmp ogt double %11, -1.000000e-08
  %17 = or i1 %15, %16
  br label %31

18:                                               ; preds = %7
  %19 = fsub double %4, %6
  %20 = fadd double %19, %0
  %21 = fsub double %5, %3
  %22 = fadd double %21, %1
  %23 = tail call noundef double @_Z5xmult5pointS_S_(double %3, double %4, double %0, double %1, double %20, double %22)
  %24 = tail call noundef double @_Z5xmult5pointS_S_(double %5, double %6, double %0, double %1, double %20, double %22)
  %25 = fmul double %23, %24
  %26 = fcmp olt double %25, 1.000000e-08
  br i1 %26, label %27, label %31

27:                                               ; preds = %18
  %28 = tail call noundef double @_Z10disptoline5pointS_S_(double %0, double %1, double %3, double %4, double %5, double %6)
  %29 = fsub double %28, %2
  %30 = fcmp olt double %29, 1.000000e-08
  br label %31

31:                                               ; preds = %18, %27, %14
  %.0.shrunk = phi i1 [ %17, %14 ], [ false, %18 ], [ %30, %27 ]
  %.0 = zext i1 %.0.shrunk to i32
  ret i32 %.0
}

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


; Effective O3 passes: GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass